Search in sources :

Example 61 with ModelInfo

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);
}
Also used : IModelRepository(org.eclipse.vorto.repository.core.IModelRepository) IUserContext(org.eclipse.vorto.repository.core.IUserContext) ModelInfo(org.eclipse.vorto.repository.core.ModelInfo) BeforeClass(org.junit.BeforeClass)

Example 62 with ModelInfo

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());
}
Also used : ModelInfo(org.eclipse.vorto.repository.core.ModelInfo) Test(org.junit.Test)

Example 63 with ModelInfo

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;
}
Also used : ModelInfo(org.eclipse.vorto.repository.core.ModelInfo) ModelId(org.eclipse.vorto.model.ModelId)

Example 64 with ModelInfo

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());
}
Also used : ModelInfo(org.eclipse.vorto.repository.core.ModelInfo)

Example 65 with ModelInfo

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());
}
Also used : IUserContext(org.eclipse.vorto.repository.core.IUserContext) ModelInfo(org.eclipse.vorto.repository.core.ModelInfo) Test(org.junit.Test)

Aggregations

ModelInfo (org.eclipse.vorto.repository.core.ModelInfo)89 Test (org.junit.Test)33 IUserContext (org.eclipse.vorto.repository.core.IUserContext)32 ModelId (org.eclipse.vorto.model.ModelId)28 IModelRepository (org.eclipse.vorto.repository.core.IModelRepository)21 FileContent (org.eclipse.vorto.repository.core.FileContent)11 ClassPathResource (org.springframework.core.io.ClassPathResource)11 IOException (java.io.IOException)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 ModelNotFoundException (org.eclipse.vorto.repository.core.ModelNotFoundException)8 WorkflowException (org.eclipse.vorto.repository.workflow.WorkflowException)8 BeforeClass (org.junit.BeforeClass)7 ResponseEntity (org.springframework.http.ResponseEntity)7 List (java.util.List)6 Optional (java.util.Optional)6 ModelAlreadyExistsException (org.eclipse.vorto.repository.core.ModelAlreadyExistsException)6 NotAuthorizedException (org.eclipse.vorto.repository.web.core.exceptions.NotAuthorizedException)6 DependencyManager (org.eclipse.vorto.repository.core.impl.utils.DependencyManager)5