Search in sources :

Example 1 with Version

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.
}
Also used : ExampleClass(org.terasology.unittest.ExampleClass) Version(org.terasology.gestalt.naming.Version) ModuleMetadata(org.terasology.gestalt.module.ModuleMetadata) Module(org.terasology.gestalt.module.Module) File(java.io.File) Name(org.terasology.gestalt.naming.Name) Test(org.junit.jupiter.api.Test)

Example 2 with Version

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);
}
Also used : TableModuleRegistry(org.terasology.gestalt.module.TableModuleRegistry) Version(org.terasology.gestalt.naming.Version) ModuleEnvironment(org.terasology.gestalt.module.ModuleEnvironment) RegisterBindButton(org.terasology.engine.input.RegisterBindButton) RegisterBindAxis(org.terasology.engine.input.RegisterBindAxis) ModuleRegistry(org.terasology.gestalt.module.ModuleRegistry) TableModuleRegistry(org.terasology.gestalt.module.TableModuleRegistry) ModuleMetadata(org.terasology.gestalt.module.ModuleMetadata) ModuleManager(org.terasology.engine.core.module.ModuleManager) Module(org.terasology.gestalt.module.Module) Name(org.terasology.gestalt.naming.Name)

Example 3 with Version

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);
}
Also used : Version(org.terasology.gestalt.naming.Version) ResolutionResult(org.terasology.gestalt.module.dependencyresolution.ResolutionResult)

Example 4 with Version

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);
}
Also used : Version(org.terasology.gestalt.naming.Version) ModuleMetadata(org.terasology.gestalt.module.ModuleMetadata) EmptyFileSource(org.terasology.gestalt.module.resources.EmptyFileSource) Module(org.terasology.gestalt.module.Module) Name(org.terasology.gestalt.naming.Name) Reflections(org.reflections.Reflections)

Example 5 with Version

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;
}
Also used : NameVersion(org.terasology.gestalt.naming.NameVersion) NetData(org.terasology.protobuf.NetData) Version(org.terasology.gestalt.naming.Version) NameVersion(org.terasology.gestalt.naming.NameVersion) Name(org.terasology.gestalt.naming.Name)

Aggregations

Version (org.terasology.gestalt.naming.Version)6 Name (org.terasology.gestalt.naming.Name)5 Module (org.terasology.gestalt.module.Module)4 ModuleMetadata (org.terasology.gestalt.module.ModuleMetadata)4 ModuleManager (org.terasology.engine.core.module.ModuleManager)2 File (java.io.File)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 StringUtils (org.codehaus.plexus.util.StringUtils)1 Vector2i (org.joml.Vector2i)1