use of org.terasology.gestalt.naming.Version in project Terasology by MovingBlocks.
the class ClasspathCompromisingModuleFactoryTest method directoryModuleContainsClass.
@Test
public void directoryModuleContainsClass() {
// This test assumes that the unittest module is under the current working directory (`engine-test/`)
File engineTestDirectory = new File(System.getProperty("user.dir", "."));
ModuleMetadata metadata = new ModuleMetadata(new Name("unittest"), new Version("1.0.0"));
Module module = factory.createDirectoryModule(metadata, engineTestDirectory);
// and that ExampleClass is inside that directory
assertTrue(module.getClassPredicate().test(ExampleClass.class));
// and that this other class (in engine, not engine-test) is outside that directory.
assertFalse(module.getClassPredicate().test(someClassOutsideTheModule));
// These assumptions could break if things get moved around enough.
}
use of org.terasology.gestalt.naming.Version 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.naming.Version in project Terasology by MovingBlocks.
the class ModuleDownloadListGenerator method getAllModulesToDownloadFor.
Set<Module> getAllModulesToDownloadFor(Name... modulesToInstall) throws DependencyResolutionFailedException {
Version currentEngineVersion = localRegistry.getLatestModuleVersion(TerasologyConstants.ENGINE_MODULE).getVersion();
ResolutionResult resolutionResult = remoteDependencyResolver.builder().requireVersion(TerasologyConstants.ENGINE_MODULE, currentEngineVersion).requireAll(modulesToInstall).build();
return processResolutionResult(resolutionResult);
}
use of org.terasology.gestalt.naming.Version in project Terasology by MovingBlocks.
the class ModuleDownloadListGeneratorTest method buildSimpleModule.
private Module buildSimpleModule(String id, String version) {
ModuleMetadata metadata = new ModuleMetadata();
metadata.setId(new Name(id));
if (version != null) {
metadata.setVersion(new Version(version));
}
return new Module(metadata, new EmptyFileSource(), Collections.emptyList(), new Reflections(), (c) -> false);
}
use of org.terasology.gestalt.naming.Version in project Terasology by MovingBlocks.
the class ServerInfoMessageImpl method getModuleList.
@Override
public List<NameVersion> getModuleList() {
List<NameVersion> result = Lists.newArrayList();
for (NetData.ModuleInfo moduleInfo : info.getModuleList()) {
if (!moduleInfo.hasModuleId() || !moduleInfo.hasModuleVersion()) {
logger.error("Received incomplete module info");
} else {
Name id = new Name(moduleInfo.getModuleId());
Version version = new Version(moduleInfo.getModuleVersion());
result.add(new NameVersion(id, version));
}
}
return result;
}
Aggregations