use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class WorkflowTest method testStartReleaseModelWithReleasedDependencies.
@Test
public void testStartReleaseModelWithReleasedDependencies() throws Exception {
ModelInfo typeModel = importModel("Color.type");
workflow.start(typeModel.getId(), createUserContext("alex", PLAYGROUND));
ModelInfo fbModel = importModel("Colorlight.fbmodel");
workflow.start(fbModel.getId(), createUserContext("alex", PLAYGROUND));
setReleaseState(typeModel);
when(userRepository.findByUsername(createUserContext(getCallerId(), PLAYGROUND).getUsername())).thenReturn(new UserBuilder().withName(getCallerId()).withAuthenticationProviderID(GITHUB).build());
fbModel = workflow.doAction(fbModel.getId(), createUserContext(getCallerId(), PLAYGROUND), SimpleWorkflowModel.ACTION_RELEASE.getName());
assertEquals(SimpleWorkflowModel.STATE_IN_REVIEW.getName(), fbModel.getState());
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class WorkflowTest method testTransitionWorkflowInvalidAction.
@Test(expected = WorkflowException.class)
public void testTransitionWorkflowInvalidAction() throws Exception {
ModelInfo model = importModel("Color.type");
workflow.start(model.getId(), createUserContext("alex", PLAYGROUND));
model = workflow.doAction(model.getId(), createUserContext(getCallerId(), PLAYGROUND), SimpleWorkflowModel.ACTION_APPROVE.getName());
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class WorkflowTest method testStartReleaseModelWithNonReleasedDependencies.
@Test
public void testStartReleaseModelWithNonReleasedDependencies() throws Exception {
ModelInfo typeModel = importModel("Color.type");
workflow.start(typeModel.getId(), createUserContext("alex", PLAYGROUND));
ModelInfo fbModel = importModel("Colorlight.fbmodel");
workflow.start(fbModel.getId(), createUserContext("alex", PLAYGROUND));
when(userRepository.findByUsername(createUserContext(getCallerId(), PLAYGROUND).getUsername())).thenReturn(new UserBuilder().withName(getCallerId()).withAuthenticationProviderID(GITHUB).build());
workflow.doAction(fbModel.getId(), createUserContext(getCallerId(), PLAYGROUND), SimpleWorkflowModel.ACTION_RELEASE.getName());
assertEquals("InReview", this.repositoryFactory.getRepositoryByModel(typeModel.getId()).getById(typeModel.getId()).getState());
assertEquals("InReview", this.repositoryFactory.getRepositoryByModel(fbModel.getId()).getById(fbModel.getId()).getState());
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class WorkflowTest method testApproveModelByAdminInReviewState.
@Test
public void testApproveModelByAdminInReviewState() throws Exception {
ModelInfo model = importModel("creator", "Color.type");
IUserContext creator = createUserContext("creator", PLAYGROUND);
IUserContext promoter = createUserContext("promoter", PLAYGROUND);
IUserContext reviewer = createUserContext("reviewer", PLAYGROUND);
workflow.start(model.getId(), creator);
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(), reviewer).size());
model = workflow.doAction(model.getId(), reviewer, SimpleWorkflowModel.ACTION_APPROVE.getName());
assertEquals(1, workflow.getModelsByState(SimpleWorkflowModel.STATE_RELEASED.getName(), creator).size());
assertEquals(0, workflow.getModelsByState(SimpleWorkflowModel.STATE_IN_REVIEW.getName(), creator).size());
assertEquals(0, workflow.getModelsByState(SimpleWorkflowModel.STATE_DRAFT.getName(), creator).size());
assertEquals(0, workflow.getPossibleActions(model.getId(), creator).size());
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class WorkflowTest method testGetPossibleActionsForDraftState.
@Test
public void testGetPossibleActionsForDraftState() throws Exception {
ModelInfo model = importModel("Color.type");
workflow.start(model.getId(), createUserContext("alex", PLAYGROUND));
assertEquals(1, workflow.getPossibleActions(model.getId(), createUserContext(getCallerId(), PLAYGROUND)).size());
assertEquals(SimpleWorkflowModel.ACTION_RELEASE.getName(), workflow.getPossibleActions(model.getId(), createUserContext(getCallerId(), PLAYGROUND)).get(0));
}
Aggregations