use of org.terasology.gestalt.module.ModuleRegistry in project Terasology by MovingBlocks.
the class ModuleDownloadListGeneratorTest method buildRegistry.
private ModuleRegistry buildRegistry(String engineVersion, Module... modules) {
ModuleRegistry result = new TableModuleRegistry();
result.add(buildEngineModule(engineVersion));
result.addAll(Arrays.asList(modules));
return result;
}
use of org.terasology.gestalt.module.ModuleRegistry in project Terasology by MovingBlocks.
the class ModuleDownloadListGeneratorTest method testSingleModuleNeedsUpdate.
@Test
public void testSingleModuleNeedsUpdate() throws DependencyResolutionFailedException {
Module moduleV1 = buildSimpleModule("myModule", "1.0.0");
Module moduleV2 = buildSimpleModule("myModule", "2.0.0");
ModuleRegistry localRegistry = buildRegistry("1.0.0", moduleV1);
DependencyResolver resolver = mockResolver(true, moduleV2, buildEngineModule("1.0.0"));
ModuleDownloadListGenerator listGenerator = new ModuleDownloadListGenerator(localRegistry, resolver);
assertEquals(Collections.singleton(moduleV2), buildList(listGenerator));
}
use of org.terasology.gestalt.module.ModuleRegistry in project Terasology by MovingBlocks.
the class ModuleListDownloader method call.
@Override
public ModuleRegistry call() throws IOException {
logger.info("Downloading modules ..");
TableModuleRegistry modules = new TableModuleRegistry();
URL url = new URL("http", serverAddress, "/modules/list/latest");
try (InputStreamReader reader = new InputStreamReader(url.openStream(), TerasologyConstants.CHARSET)) {
logger.info("Parsing content ..");
JsonArray jsonArray = gson.fromJson(reader, JsonArray.class);
for (JsonElement jObject : jsonArray) {
String json = gson.toJson(jObject);
ModuleMetadata meta = metaReader.read(new StringReader(json));
logger.debug("Read module {} - {}", meta.getId(), meta.getVersion());
modules.add(new Module(meta, new EmptyFileSource(), Collections.emptyList(), new Reflections(), (c) -> false));
}
int count = modules.size();
logger.info(String.format("Retrieved %d %s", count, (count == 1) ? "entry" : "entries"));
}
return modules;
}
Aggregations