use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class VersionSearchSimpleTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
testInfrastructure = new SearchTestInfrastructure();
// Color type with version 1.0.0 - will update to 1.0.1
testInfrastructure.importModel(testInfrastructure.DATATYPE_MODEL);
// Switcher fb with version 1.0.0 - will update to 2.1.0
testInfrastructure.importModel(testInfrastructure.FUNCTIONBLOCK_MODEL);
List<ModelInfo> model = testInfrastructure.getRepositoryFactory().getRepository(testInfrastructure.createUserContext("alex")).search("*");
// this is arguably over-cautious, as the next statement would fail all tests anyway
if (model.isEmpty()) {
fail("Model is empty after importing.");
}
IUserContext alex = testInfrastructure.createUserContext("alex");
IModelRepository repo = testInfrastructure.getRepositoryFactory().getRepository(alex);
ModelInfo type = model.stream().filter(m -> m.getFileName().equals(testInfrastructure.DATATYPE_MODEL)).findFirst().orElseGet(() -> {
fail("Model not found");
return null;
});
ModelInfo functionBlock = model.stream().filter(m -> m.getFileName().equals(testInfrastructure.FUNCTIONBLOCK_MODEL)).findFirst().orElseGet(() -> {
fail("Model not found");
return null;
});
// updating infomodel to 1.0.1 and removing previous
repo.createVersion(type.getId(), "1.0.1", alex);
repo.removeModel(type.getId());
// updating functionblock to 2.1.0 and removing previous
repo.createVersion(functionBlock.getId(), "2.1.0", alex);
repo.removeModel(functionBlock.getId());
// finally, importing mapping as-is (1.0.0)
testInfrastructure.importModel(testInfrastructure.MAPPING_MODEL);
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class DependencyManagerTest method testDependentDatatypes.
@Test
public void testDependentDatatypes() {
ModelInfo subunit = create("Subunit", ModelType.Datatype);
ModelInfo unit = create("Unit", ModelType.Datatype, subunit);
ModelInfo temp = create("Temperature", ModelType.Datatype, unit);
dm.addResource(subunit);
dm.addResource(unit);
dm.addResource(temp);
assertEquals(subunit.getId(), dm.getSorted().get(0).getId());
assertEquals(unit.getId(), dm.getSorted().get(1).getId());
assertEquals(temp.getId(), dm.getSorted().get(2).getId());
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class DependencyManagerTest method create.
protected ModelInfo create(String name, ModelType type, ModelInfo... references) {
final ModelId id = new ModelId(name, "org.eclipse.vorto", "1.0.0");
ModelInfo resource = new ModelInfo(id, type);
resource.setReferences(Arrays.asList(references).stream().map(reference -> reference.getId()).collect(Collectors.toList()));
Arrays.asList(references).stream().forEach(it -> it.addReferencedBy(id));
return resource;
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class BulkOperationServiceTest method checkCorrectness.
private void checkCorrectness(String modelId, String visibility, String state) {
ModelInfo modelInfo = getModelRepository(createUserContext("creator")).getById(ModelId.fromPrettyFormat(modelId));
assertEquals(visibility, modelInfo.getVisibility());
assertEquals(state, modelInfo.getState());
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class WorkflowTest method testSearchByTypeAndState.
@Test
public void testSearchByTypeAndState() throws Exception {
IUserContext user = createUserContext("alex", PLAYGROUND);
ModelInfo model = importModel("Color.type");
workflow.start(model.getId(), user);
model = importModel("Colorlight.fbmodel");
workflow.start(model.getId(), user);
assertEquals(0, repositoryFactory.getRepository(user).search("Functionblock state:Released").size());
}
Aggregations