Search in sources :

Example 21 with ModelInfo

use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.

the class WorkflowTest method testGetModelByState.

@Test
public void testGetModelByState() throws Exception {
    IUserContext user = createUserContext("admin", PLAYGROUND);
    ModelInfo model = importModel("Color.type");
    workflow.start(model.getId(), user);
    assertEquals(1, workflow.getModelsByState(SimpleWorkflowModel.STATE_DRAFT.getName(), user).size());
}
Also used : IUserContext(org.eclipse.vorto.repository.core.IUserContext) ModelInfo(org.eclipse.vorto.repository.core.ModelInfo) Test(org.junit.Test)

Example 22 with ModelInfo

use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.

the class WorkflowTest method testApproveModelByModelReviewerInReviewState.

@Test
public void testApproveModelByModelReviewerInReviewState() throws Exception {
    ModelInfo model = importModel("creator", "Color.type");
    IUserContext user = createUserContext("creator", PLAYGROUND);
    IUserContext promoter = createUserContext("promoter", PLAYGROUND);
    workflow.start(model.getId(), user);
    model = workflow.doAction(model.getId(), promoter, SimpleWorkflowModel.ACTION_RELEASE.getName());
    assertEquals(SimpleWorkflowModel.STATE_IN_REVIEW.getName(), model.getState());
    assertEquals(1, workflow.getPossibleActions(model.getId(), promoter).size());
    assertEquals(2, workflow.getPossibleActions(model.getId(), createUserContext("reviewer", PLAYGROUND)).size());
    model = workflow.doAction(model.getId(), createUserContext("reviewer", PLAYGROUND), SimpleWorkflowModel.ACTION_APPROVE.getName());
    assertEquals(1, workflow.getModelsByState(SimpleWorkflowModel.STATE_RELEASED.getName(), user).size());
    assertEquals(0, workflow.getModelsByState(SimpleWorkflowModel.STATE_IN_REVIEW.getName(), user).size());
    assertEquals(0, workflow.getModelsByState(SimpleWorkflowModel.STATE_DRAFT.getName(), user).size());
    assertEquals(0, workflow.getPossibleActions(model.getId(), user).size());
}
Also used : IUserContext(org.eclipse.vorto.repository.core.IUserContext) ModelInfo(org.eclipse.vorto.repository.core.ModelInfo) Test(org.junit.Test)

Example 23 with ModelInfo

use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.

the class ModelIdToModelContentConverterTest method setupTestDataForLatestTag.

private void setupTestDataForLatestTag() throws WorkflowException {
    IUserContext user = createUserContext("alex", "playground");
    ModelInfo color = importModel("Color.type");
    ModelInfo color6 = importModel("Color6.type");
    importModel("Color7.type");
    importModel("sample.mapping");
    color.setState(ModelState.Released.getName());
    color6.setState(ModelState.Released.getName());
    this.workflow.start(color.getId(), user);
    this.workflow.start(color6.getId(), user);
    setReleaseState(color);
    setReleaseState(color6);
}
Also used : IUserContext(org.eclipse.vorto.repository.core.IUserContext) ModelInfo(org.eclipse.vorto.repository.core.ModelInfo)

Example 24 with ModelInfo

use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.

the class DependencyManagerTest method testDependentTypesWithFB.

@Test
public void testDependentTypesWithFB() {
    ModelInfo subunit = create("Subunit", ModelType.Datatype);
    ModelInfo unit = create("Unit", ModelType.Datatype, subunit);
    ModelInfo temp = create("Temperature", ModelType.Datatype, unit);
    ModelInfo fridge = create("Fridge", ModelType.Functionblock, temp);
    dm.addResource(unit);
    dm.addResource(subunit);
    dm.addResource(temp);
    dm.addResource(fridge);
    assertEquals(subunit.getId(), dm.getSorted().get(0).getId());
    assertEquals(unit.getId(), dm.getSorted().get(1).getId());
    assertEquals(temp.getId(), dm.getSorted().get(2).getId());
    assertEquals(fridge.getId(), dm.getSorted().get(3).getId());
}
Also used : ModelInfo(org.eclipse.vorto.repository.core.ModelInfo) Test(org.junit.Test)

Example 25 with ModelInfo

use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.

the class DependencyManagerTest method testDependentTypesWithFB2.

@Test
public void testDependentTypesWithFB2() {
    ModelInfo subunit = create("Subunit", ModelType.Datatype);
    ModelInfo unit = create("Unit", ModelType.Datatype, subunit);
    ModelInfo temp = create("Temperature", ModelType.Datatype, unit);
    ModelInfo superFridge = create("SuperFridge", ModelType.Functionblock, temp);
    ModelInfo fridge = create("Fridge", ModelType.Functionblock, superFridge);
    dm.addResource(unit);
    dm.addResource(subunit);
    dm.addResource(temp);
    dm.addResource(fridge);
    dm.addResource(superFridge);
    assertEquals(subunit.getId(), dm.getSorted().get(0).getId());
    assertEquals(unit.getId(), dm.getSorted().get(1).getId());
    assertEquals(temp.getId(), dm.getSorted().get(2).getId());
    assertEquals(superFridge.getId(), dm.getSorted().get(3).getId());
    assertEquals(fridge.getId(), dm.getSorted().get(4).getId());
}
Also used : 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