use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class WorkflowTest method testRejectModelInReviewState.
@Test
public void testRejectModelInReviewState() throws Exception {
ModelInfo model = importModel("Color.type");
IUserContext user = createUserContext("alex", PLAYGROUND);
workflow.start(model.getId(), user);
when(userRepository.findByUsername(createUserContext(getCallerId(), PLAYGROUND).getUsername())).thenReturn(new UserBuilder().withName(getCallerId()).withAuthenticationProviderID(GITHUB).build());
model = workflow.doAction(model.getId(), createUserContext(getCallerId(), PLAYGROUND), SimpleWorkflowModel.ACTION_RELEASE.getName());
assertEquals(SimpleWorkflowModel.STATE_IN_REVIEW.getName(), model.getState());
when(userRepository.findByUsername(createUserContext(ADMIN, PLAYGROUND).getUsername())).thenReturn(new UserBuilder().withName(ADMIN).withAuthenticationProviderID(GITHUB).build());
model = workflow.doAction(model.getId(), createUserContext(ADMIN, PLAYGROUND), SimpleWorkflowModel.ACTION_REJECT.getName());
assertEquals(0, workflow.getModelsByState(SimpleWorkflowModel.STATE_RELEASED.getName(), user).size());
assertEquals(0, workflow.getModelsByState(SimpleWorkflowModel.STATE_IN_REVIEW.getName(), user).size());
assertEquals(1, workflow.getModelsByState(SimpleWorkflowModel.STATE_DRAFT.getName(), user).size());
assertEquals(1, workflow.getPossibleActions(model.getId(), createUserContext(getCallerId(), PLAYGROUND)).size());
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class WorkflowTest method testApproveWithNonApprovedDependencies.
@Test
public void testApproveWithNonApprovedDependencies() 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());
workflow.doAction(fbModel.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 testStartReleaseModelWithReviewedDependencies.
@Test
public void testStartReleaseModelWithReviewedDependencies() 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(typeModel.getId(), createUserContext(getCallerId(), PLAYGROUND), SimpleWorkflowModel.ACTION_RELEASE.getName());
assertEquals("InReview", workflow.doAction(fbModel.getId(), createUserContext(getCallerId(), PLAYGROUND), SimpleWorkflowModel.ACTION_RELEASE.getName()).getState());
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class UserReferenceSearchSimpleTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
testInfrastructure = new SearchTestInfrastructure();
testInfrastructure.importModel(testInfrastructure.DATATYPE_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.");
}
// "reviewer" user updates the only imported model's visibility to public, i.e.
// "lastModifiedBy" -> reviewer
ModelId updated = testInfrastructure.getRepositoryFactory().getRepository(testInfrastructure.createUserContext("reviewer")).updateVisibility(model.get(0).getId(), "Public");
// "control group": importing another model as another user
testInfrastructure.importModel("HueLightStrips.infomodel", testInfrastructure.createUserContext("erle", "playground"));
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class VisibilitySearchSimpleTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
testInfrastructure = new SearchTestInfrastructure();
testInfrastructure.importModel(testInfrastructure.DATATYPE_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.");
}
// "alex" user updates the only imported model's visibility to public
ModelId updated = testInfrastructure.getRepositoryFactory().getRepository(testInfrastructure.createUserContext("alex")).updateVisibility(model.get(0).getId(), "Public");
// importing another model as private
testInfrastructure.importModel(testInfrastructure.INFORMATION_MODEL, testInfrastructure.createUserContext("alex", "playground"));
}
Aggregations