public void useModules(String... names) {
        checkNotNull(names, "names cannot be null");
        Set<String> deduplicateNames = new HashSet<>();
        for (String name : names) {
            if (!loadedModules.containsKey(name)) {
                throw new ValidationException(
                        String.format("No module with name '%s' exists", name));
            }
            if (!deduplicateNames.add(name)) {
                throw new ValidationException(
                        String.format("Module '%s' appears more than once", name));
            }
        }
        usedModules.clear();
        usedModules.addAll(Arrays.asList(names));
    }
@Test
    void testUseUnloadedModules() {
        assertThatThrownBy(() -> manager.useModules(CoreModuleFactory.IDENTIFIER, "x"))
                .isInstanceOf(ValidationException.class)
                .hasMessage("No module with name 'x' exists");
    }