### Question:
CheckModuleAdapter extends ModuleVisitor { @Override public void visitUse(final String service) { checkVisitEndNotCalled(); CheckMethodAdapter.checkInternalName(Opcodes.V9, service, "service"); usedServices.checkNameNotAlreadyDeclared(service); super.visitUse(service); } CheckModuleAdapter(final ModuleVisitor moduleVisitor, final boolean isOpen); protected  CheckModuleAdapter(
      final int api, final ModuleVisitor moduleVisitor, final boolean isOpen); @Override void visitMainClass(final String mainClass); @Override void visitPackage(final String packaze); @Override void visitRequire(final String module, final int access, final String version); @Override void visitExport(final String packaze, final int access, final String... modules); @Override void visitOpen(final String packaze, final int access, final String... modules); @Override void visitUse(final String service); @Override void visitProvide(final String service, final String... providers); @Override void visitEnd();  }### Answer:
@Test public void testVisitUse_nameAlreadyDeclared() { CheckModuleAdapter checkModuleAdapter = new CheckModuleAdapter(null, false); checkModuleAdapter.visitUse("service"); Executable visitUse = () -> checkModuleAdapter.visitUse("service"); Exception exception = assertThrows(IllegalArgumentException.class, visitUse); assertEquals("Module uses 'service' already declared", exception.getMessage()); }