use of org.terasology.gestalt.module.ModuleRegistry in project Terasology by MovingBlocks.
the class ModuleDownloadListGeneratorTest method testSingleModuleNoUpdate.
@Test
public void testSingleModuleNoUpdate() throws DependencyResolutionFailedException {
ModuleRegistry localRegistry = buildRegistry("1.0.0", buildSimpleModule("myModule", "1.0.0"));
DependencyResolver resolver = mockResolver(true, buildSimpleModule("myModule", "1.0.0"), buildEngineModule("1.0.0"));
ModuleDownloadListGenerator listGenerator = new ModuleDownloadListGenerator(localRegistry, resolver);
assertEquals(Collections.emptySet(), buildList(listGenerator));
}
use of org.terasology.gestalt.module.ModuleRegistry in project Terasology by MovingBlocks.
the class BindsSubsystemTest method setUpMockModuleEnvironment.
private void setUpMockModuleEnvironment() {
ModuleManager moduleManager = mock(ModuleManager.class);
ModuleRegistry moduleRegistry = new TableModuleRegistry();
Module module = mock(Module.class);
when(module.getId()).thenReturn(new Name(TEST_MODULE));
when(module.getVersion()).thenReturn(new Version(0, 0, 1, true));
when(module.getMetadata()).thenReturn(new ModuleMetadata());
moduleRegistry.add(module);
when(moduleManager.getRegistry()).thenReturn(moduleRegistry);
ModuleEnvironment environment = mock(ModuleEnvironment.class);
when(moduleManager.loadEnvironment(any(), anyBoolean())).thenReturn(environment);
when(moduleManager.getEnvironment()).thenReturn(environment);
registerBindButtonClasses = new ArrayList<>();
when(environment.getTypesAnnotatedWith(eq(RegisterBindButton.class))).thenReturn(registerBindButtonClasses);
when(environment.getTypesAnnotatedWith(eq(RegisterBindButton.class), any())).thenReturn(registerBindButtonClasses);
registerRealBindAxisClasses = new ArrayList<>();
when(environment.getTypesAnnotatedWith(eq(RegisterBindAxis.class))).thenReturn(registerRealBindAxisClasses);
when(environment.getTypesAnnotatedWith(eq(RegisterBindAxis.class), any())).thenReturn(registerRealBindAxisClasses);
when(environment.getModuleProviding(any())).thenReturn(new Name(TEST_MODULE));
context.put(ModuleManager.class, moduleManager);
}
use of org.terasology.gestalt.module.ModuleRegistry in project Terasology by MovingBlocks.
the class JoinGameScreen method getModulesText.
private String getModulesText(Future<ServerInfoMessage> info) {
try {
ServerInfoMessage serverInfoMessage = info.get();
if (serverInfoMessage == null) {
return FontColor.getColored(translationSystem.translate("${engine:menu#connection-failed}"), Color.RED);
}
List<String> codedModInfo = new ArrayList<>();
ModuleRegistry reg = moduleManager.getRegistry();
for (NameVersion entry : serverInfoMessage.getModuleList()) {
boolean isInstalled = reg.getModule(entry.getName(), entry.getVersion()) != null;
Color color = isInstalled ? Color.GREEN : Color.RED;
codedModInfo.add(FontColor.getColored(entry.toString(), color));
}
Collections.sort(codedModInfo, String.CASE_INSENSITIVE_ORDER);
return Joiner.on('\n').join(codedModInfo);
} catch (ExecutionException | InterruptedException e) {
return FontColor.getColored(translationSystem.translate("${engine:menu#connection-failed}"), Color.RED);
}
}
use of org.terasology.gestalt.module.ModuleRegistry in project Terasology by MovingBlocks.
the class ModuleDownloadListGeneratorTest method testResolverFailed.
@Test
public void testResolverFailed() throws DependencyResolutionFailedException {
ModuleRegistry localRegistry = buildRegistry("1.0.0", buildSimpleModule("myModule", "1.0.0"));
DependencyResolver resolver = mockResolver(false);
ModuleDownloadListGenerator listGenerator = new ModuleDownloadListGenerator(localRegistry, resolver);
Assertions.assertThrows(DependencyResolutionFailedException.class, () -> buildList(listGenerator));
}
use of org.terasology.gestalt.module.ModuleRegistry in project Terasology by MovingBlocks.
the class ModuleDownloadListGeneratorTest method testMultipleModulesPartialUpdate.
@Test
public void testMultipleModulesPartialUpdate() throws DependencyResolutionFailedException {
Module moduleAV1 = buildSimpleModule("myModuleA", "1.0.0");
Module moduleBV1 = buildSimpleModule("myModuleB", "1.0.0");
Module moduleBV2 = buildSimpleModule("myModuleB", "2.0.0");
ModuleRegistry localRegistry = buildRegistry("1.0.0", moduleAV1, moduleBV1);
DependencyResolver resolver = mockResolver(true, moduleBV1, moduleBV2, buildEngineModule("1.0.0"));
ModuleDownloadListGenerator listGenerator = new ModuleDownloadListGenerator(localRegistry, resolver);
assertEquals(Collections.singleton(moduleBV2), buildList(listGenerator));
}
Aggregations