Search in sources :

Example 11 with Revision

use of org.finos.legend.sdlc.domain.model.revision.Revision in project legend-sdlc by finos.

the class TestWorkspaceRevisionsResource method testGetUserWorkspaceRevisions.

@Test
public void testGetUserWorkspaceRevisions() throws HttpResponseException {
    String projectId = "A";
    String workspaceOneId = "revisionw1";
    String entityOneName = "testentityone";
    String entityTwoName = "testentitytwo";
    String entityPackageName = "testpkg";
    this.backend.project(projectId).addEntities(workspaceOneId, InMemoryEntity.newEntity(entityOneName, entityPackageName), InMemoryEntity.newEntity(entityTwoName, entityPackageName));
    Response responseOne = this.clientFor("/api/projects/A/workspaces/revisionw1").request().get();
    if (responseOne.getStatus() != 200) {
        throw new HttpResponseException(responseOne.getStatus(), "Error during getting user workspace with status: " + responseOne.getStatus() + ", entity: " + responseOne.readEntity(String.class));
    }
    Workspace workspace = responseOne.readEntity(new GenericType<Workspace>() {
    });
    Assert.assertNotNull(workspace);
    Assert.assertEquals(workspaceOneId, workspace.getWorkspaceId());
    Assert.assertEquals(projectId, workspace.getProjectId());
    Response responseThree = this.clientFor("/api/projects/A/workspaces/revisionw1/revisions").request().get();
    if (responseThree.getStatus() != 200) {
        throw new HttpResponseException(responseThree.getStatus(), "Error during getting revisions in user workspace with status: " + responseThree.getStatus() + ", entity: " + responseThree.readEntity(String.class));
    }
    List<Revision> revisions = responseThree.readEntity(new GenericType<List<Revision>>() {
    });
    Assert.assertNotNull(revisions);
    Assert.assertEquals(1, revisions.size());
    Assert.assertNotNull(revisions.get(0).getId());
}
Also used : Response(javax.ws.rs.core.Response) Revision(org.finos.legend.sdlc.domain.model.revision.Revision) HttpResponseException(org.apache.http.client.HttpResponseException) List(java.util.List) Workspace(org.finos.legend.sdlc.domain.model.project.workspace.Workspace) Test(org.junit.Test)

Example 12 with Revision

use of org.finos.legend.sdlc.domain.model.revision.Revision in project legend-sdlc by finos.

the class TestWorkspaceRevisionsResource method testGetGroupWorkspaceRevisions.

@Test
public void testGetGroupWorkspaceRevisions() throws HttpResponseException {
    String projectId = "A";
    String workspaceOneId = "revisionw2";
    String entityOneName = "testentityone";
    String entityTwoName = "testentitytwo";
    String entityPackageName = "testpkg";
    this.backend.project(projectId).addEntities(workspaceOneId, WorkspaceType.GROUP, InMemoryEntity.newEntity(entityOneName, entityPackageName), InMemoryEntity.newEntity(entityTwoName, entityPackageName));
    Response responseOne = this.clientFor("/api/projects/A/groupWorkspaces/revisionw2").request().get();
    if (responseOne.getStatus() != 200) {
        throw new HttpResponseException(responseOne.getStatus(), "Error during getting group workspace with status: " + responseOne.getStatus() + ", entity: " + responseOne.readEntity(String.class));
    }
    Workspace workspace = responseOne.readEntity(new GenericType<Workspace>() {
    });
    Assert.assertNotNull(workspace);
    Assert.assertEquals(workspaceOneId, workspace.getWorkspaceId());
    Assert.assertEquals(projectId, workspace.getProjectId());
    Response responseThree = this.clientFor("/api/projects/A/groupWorkspaces/revisionw2/revisions").request().get();
    if (responseThree.getStatus() != 200) {
        throw new HttpResponseException(responseThree.getStatus(), "Error during getting revisions in group workspace with status: " + responseThree.getStatus() + ", entity: " + responseThree.readEntity(String.class));
    }
    List<Revision> revisions = responseThree.readEntity(new GenericType<List<Revision>>() {
    });
    Assert.assertNotNull(revisions);
    Assert.assertEquals(1, revisions.size());
    Assert.assertNotNull(revisions.get(0).getId());
}
Also used : Response(javax.ws.rs.core.Response) Revision(org.finos.legend.sdlc.domain.model.revision.Revision) HttpResponseException(org.apache.http.client.HttpResponseException) List(java.util.List) Workspace(org.finos.legend.sdlc.domain.model.project.workspace.Workspace) Test(org.junit.Test)

Example 13 with Revision

use of org.finos.legend.sdlc.domain.model.revision.Revision in project legend-sdlc by finos.

the class GitLabComparisonApiTestResource method runGroupWorkspaceComparisonTest.

public void runGroupWorkspaceComparisonTest() {
    String projectName = "ComparisonTestProjectTwo";
    String description = "A test project.";
    ProjectType projectType = ProjectType.PRODUCTION;
    String groupId = "org.finos.sdlc.test";
    String artifactId = "comptestprojtwo";
    List<String> tags = Lists.mutable.with("doe", "moffitt", AbstractGitLabServerApiTest.INTEGRATION_TEST_PROJECT_TAG);
    String workspaceOneId = "testworkspaceone";
    Project createdProject = gitLabProjectApi.createProject(projectName, description, projectType, groupId, artifactId, tags);
    Assert.assertNotNull(createdProject);
    Assert.assertEquals(projectName, createdProject.getName());
    Assert.assertEquals(description, createdProject.getDescription());
    Assert.assertEquals(projectType, createdProject.getProjectType());
    Assert.assertEquals(Sets.mutable.withAll(tags), Sets.mutable.withAll(createdProject.getTags()));
    String projectId = createdProject.getProjectId();
    Workspace createdWorkspaceOne = gitLabWorkspaceApi.newGroupWorkspace(projectId, workspaceOneId);
    Revision fromRevision = gitLabRevisionApi.getGroupWorkspaceRevisionContext(projectId, workspaceOneId).getCurrentRevision();
    Assert.assertNotNull(createdWorkspaceOne);
    Assert.assertEquals(workspaceOneId, createdWorkspaceOne.getWorkspaceId());
    Assert.assertEquals(projectId, createdWorkspaceOne.getProjectId());
    Assert.assertNull(createdWorkspaceOne.getUserId());
    String entityPath = "test::entity";
    String classifierPath = "meta::test::mathematicsDepartment";
    Map<String, String> entityContentMap = Maps.mutable.with("package", "test", "name", "entity", "math-113", "abstract-algebra", "math-185", "complex-analysis");
    gitLabEntityApi.getGroupWorkspaceEntityModificationContext(projectId, workspaceOneId).createEntity(entityPath, classifierPath, entityContentMap, "initial entity");
    List<Entity> modifiedWorkspaceEntities = gitLabEntityApi.getGroupWorkspaceEntityAccessContext(projectId, workspaceOneId).getEntities(null, null, null);
    Assert.assertNotNull(modifiedWorkspaceEntities);
    Assert.assertEquals(1, modifiedWorkspaceEntities.size());
    Entity initalEntity = modifiedWorkspaceEntities.get(0);
    Assert.assertEquals(initalEntity.getPath(), entityPath);
    Assert.assertEquals(initalEntity.getClassifierPath(), classifierPath);
    Assert.assertEquals(initalEntity.getContent(), entityContentMap);
    Revision toRevision = gitLabRevisionApi.getGroupWorkspaceRevisionContext(projectId, workspaceOneId).getCurrentRevision();
    List<EntityDiff> entityDiffs = gitLabComparisonApi.getGroupWorkspaceCreationComparison(projectId, workspaceOneId).getEntityDiffs();
    String fromRevisionId = gitLabComparisonApi.getGroupWorkspaceCreationComparison(projectId, workspaceOneId).getFromRevisionId();
    String toRevisionId = gitLabComparisonApi.getGroupWorkspaceCreationComparison(projectId, workspaceOneId).getToRevisionId();
    Assert.assertNotNull(fromRevision);
    Assert.assertNotNull(toRevision);
    Assert.assertEquals(fromRevision.getId(), fromRevisionId);
    Assert.assertEquals(toRevision.getId(), toRevisionId);
    Assert.assertNotNull(entityDiffs);
    Assert.assertEquals(1, entityDiffs.size());
    Assert.assertEquals(EntityChangeType.CREATE, entityDiffs.get(0).getEntityChangeType());
    Revision projectFromRevision = gitLabRevisionApi.getProjectRevisionContext(projectId).getCurrentRevision();
    Revision projectToRevision = gitLabRevisionApi.getGroupWorkspaceRevisionContext(projectId, workspaceOneId).getCurrentRevision();
    List<EntityDiff> projectEntityDiffs = gitLabComparisonApi.getGroupWorkspaceProjectComparison(projectId, workspaceOneId).getEntityDiffs();
    String projectFromRevisionId = gitLabComparisonApi.getGroupWorkspaceProjectComparison(projectId, workspaceOneId).getFromRevisionId();
    String projectToRevisionId = gitLabComparisonApi.getGroupWorkspaceProjectComparison(projectId, workspaceOneId).getToRevisionId();
    Assert.assertNotNull(projectFromRevision);
    Assert.assertEquals(projectFromRevision.getId(), projectFromRevisionId);
    Assert.assertEquals(projectToRevision.getId(), projectToRevisionId);
    Assert.assertNotNull(projectEntityDiffs);
    Assert.assertEquals(1, projectEntityDiffs.size());
    Assert.assertEquals(EntityChangeType.CREATE, projectEntityDiffs.get(0).getEntityChangeType());
}
Also used : Project(org.finos.legend.sdlc.domain.model.project.Project) Entity(org.finos.legend.sdlc.domain.model.entity.Entity) Revision(org.finos.legend.sdlc.domain.model.revision.Revision) ProjectType(org.finos.legend.sdlc.domain.model.project.ProjectType) EntityDiff(org.finos.legend.sdlc.domain.model.comparison.EntityDiff) Workspace(org.finos.legend.sdlc.domain.model.project.workspace.Workspace)

Example 14 with Revision

use of org.finos.legend.sdlc.domain.model.revision.Revision in project legend-sdlc by finos.

the class GitLabRevisionApiTestResource method runUserWorkspaceRevisionTest.

public void runUserWorkspaceRevisionTest() {
    String projectName = "RevisionTestProjectOne";
    String description = "A test project.";
    ProjectType projectType = ProjectType.PRODUCTION;
    String groupId = "org.finos.sdlc.test";
    String artifactId = "revisiontestprojone";
    List<String> tags = Lists.mutable.with("doe", "moffitt", AbstractGitLabServerApiTest.INTEGRATION_TEST_PROJECT_TAG);
    String workspaceOneId = "testworkspaceone";
    Project createdProject = gitLabProjectApi.createProject(projectName, description, projectType, groupId, artifactId, tags);
    Assert.assertNotNull(createdProject);
    Assert.assertEquals(projectName, createdProject.getName());
    Assert.assertEquals(description, createdProject.getDescription());
    Assert.assertEquals(projectType, createdProject.getProjectType());
    Assert.assertEquals(Sets.mutable.withAll(tags), Sets.mutable.withAll(createdProject.getTags()));
    String projectId = createdProject.getProjectId();
    Workspace createdWorkspaceOne = gitLabWorkspaceApi.newUserWorkspace(projectId, workspaceOneId);
    Assert.assertNotNull(createdWorkspaceOne);
    Assert.assertEquals(workspaceOneId, createdWorkspaceOne.getWorkspaceId());
    Assert.assertEquals(projectId, createdWorkspaceOne.getProjectId());
    Assert.assertNotNull(createdWorkspaceOne.getUserId());
    List<Revision> workspaceRevisions = gitLabRevisionApi.getUserWorkspaceRevisionContext(projectId, workspaceOneId).getRevisions();
    Assert.assertNotNull(workspaceRevisions);
    Assert.assertEquals(1, workspaceRevisions.size());
    Revision createProjectStructureRevision = workspaceRevisions.get(0);
    Assert.assertEquals("Build project structure", createProjectStructureRevision.getMessage());
    Assert.assertNotNull(createProjectStructureRevision.getId());
    Assert.assertNotNull(createProjectStructureRevision.getAuthorName());
    Assert.assertNotNull(createProjectStructureRevision.getCommitterName());
    Assert.assertNotNull(createProjectStructureRevision.getAuthoredTimestamp());
    Assert.assertNotNull(createProjectStructureRevision.getCommittedTimestamp());
    String entityPath = "test::entity";
    String entityPackagePath = "test";
    String classifierPath = "meta::test::mathematicsDepartment";
    Map<String, String> entityContentMap = Maps.mutable.with("package", "test", "name", "entity", "math-113", "abstract-algebra", "math-185", "complex-analysis");
    gitLabEntityApi.getUserWorkspaceEntityModificationContext(projectId, workspaceOneId).createEntity(entityPath, classifierPath, entityContentMap, "initial entity");
    List<Entity> modifiedWorkspaceEntities = gitLabEntityApi.getUserWorkspaceEntityAccessContext(projectId, workspaceOneId).getEntities(null, null, null);
    Assert.assertNotNull(modifiedWorkspaceEntities);
    Assert.assertEquals(1, modifiedWorkspaceEntities.size());
    Entity initalEntity = modifiedWorkspaceEntities.get(0);
    Assert.assertEquals(initalEntity.getPath(), entityPath);
    Assert.assertEquals(initalEntity.getClassifierPath(), classifierPath);
    Assert.assertEquals(initalEntity.getContent(), entityContentMap);
    List<Revision> updatedWorkspaceRevisions = gitLabRevisionApi.getUserWorkspaceRevisionContext(projectId, workspaceOneId).getRevisions();
    Revision currentRevision = gitLabRevisionApi.getUserWorkspaceRevisionContext(projectId, workspaceOneId).getCurrentRevision();
    Assert.assertNotNull(updatedWorkspaceRevisions);
    Assert.assertEquals(2, updatedWorkspaceRevisions.size());
    Assert.assertEquals("initial entity", currentRevision.getMessage());
    Assert.assertNotNull(currentRevision.getId());
    Assert.assertNotNull(currentRevision.getAuthorName());
    Assert.assertNotNull(currentRevision.getCommitterName());
    Assert.assertNotNull(currentRevision.getAuthoredTimestamp());
    Assert.assertNotNull(currentRevision.getCommittedTimestamp());
    List<Revision> entityRevisions = gitLabRevisionApi.getUserWorkspaceEntityRevisionContext(projectId, workspaceOneId, entityPath).getRevisions();
    Revision currentEntityRevision = gitLabRevisionApi.getUserWorkspaceEntityRevisionContext(projectId, workspaceOneId, entityPath).getCurrentRevision();
    Assert.assertNotNull(entityRevisions);
    Assert.assertEquals(1, entityRevisions.size());
    Assert.assertEquals("initial entity", currentEntityRevision.getMessage());
    Assert.assertNotNull(currentEntityRevision.getId());
    Assert.assertNotNull(currentEntityRevision.getAuthorName());
    Assert.assertNotNull(currentEntityRevision.getCommitterName());
    Assert.assertNotNull(currentEntityRevision.getAuthoredTimestamp());
    Assert.assertNotNull(currentEntityRevision.getCommittedTimestamp());
    List<Revision> packageRevisions = gitLabRevisionApi.getUserWorkspacePackageRevisionContext(projectId, workspaceOneId, entityPackagePath).getRevisions();
    Revision currentPackageRevision = gitLabRevisionApi.getUserWorkspacePackageRevisionContext(projectId, workspaceOneId, entityPackagePath).getCurrentRevision();
    Assert.assertNotNull(packageRevisions);
    Assert.assertEquals(1, packageRevisions.size());
    Assert.assertEquals("initial entity", currentPackageRevision.getMessage());
    Assert.assertNotNull(currentPackageRevision.getId());
    Assert.assertNotNull(currentPackageRevision.getAuthorName());
    Assert.assertNotNull(currentPackageRevision.getCommitterName());
    Assert.assertNotNull(currentPackageRevision.getAuthoredTimestamp());
    Assert.assertNotNull(currentPackageRevision.getCommittedTimestamp());
}
Also used : Project(org.finos.legend.sdlc.domain.model.project.Project) Entity(org.finos.legend.sdlc.domain.model.entity.Entity) Revision(org.finos.legend.sdlc.domain.model.revision.Revision) ProjectType(org.finos.legend.sdlc.domain.model.project.ProjectType) Workspace(org.finos.legend.sdlc.domain.model.project.workspace.Workspace)

Example 15 with Revision

use of org.finos.legend.sdlc.domain.model.revision.Revision in project legend-sdlc by finos.

the class GitLabRevisionApiTestResource method runGroupWorkspaceRevisionTest.

public void runGroupWorkspaceRevisionTest() {
    String projectName = "RevisionTestProjectTwo";
    String description = "A test project.";
    ProjectType projectType = ProjectType.PRODUCTION;
    String groupId = "org.finos.sdlc.test";
    String artifactId = "revisiontestprojtwo";
    List<String> tags = Lists.mutable.with("doe", "moffitt", AbstractGitLabServerApiTest.INTEGRATION_TEST_PROJECT_TAG);
    String workspaceOneId = "testworkspaceone";
    Project createdProject = gitLabProjectApi.createProject(projectName, description, projectType, groupId, artifactId, tags);
    Assert.assertNotNull(createdProject);
    Assert.assertEquals(projectName, createdProject.getName());
    Assert.assertEquals(description, createdProject.getDescription());
    Assert.assertEquals(projectType, createdProject.getProjectType());
    Assert.assertEquals(Sets.mutable.withAll(tags), Sets.mutable.withAll(createdProject.getTags()));
    String projectId = createdProject.getProjectId();
    Workspace createdWorkspaceOne = gitLabWorkspaceApi.newGroupWorkspace(projectId, workspaceOneId);
    Assert.assertNotNull(createdWorkspaceOne);
    Assert.assertEquals(workspaceOneId, createdWorkspaceOne.getWorkspaceId());
    Assert.assertEquals(projectId, createdWorkspaceOne.getProjectId());
    Assert.assertNull(createdWorkspaceOne.getUserId());
    List<Revision> workspaceRevisions = gitLabRevisionApi.getGroupWorkspaceRevisionContext(projectId, workspaceOneId).getRevisions();
    Assert.assertNotNull(workspaceRevisions);
    Assert.assertEquals(1, workspaceRevisions.size());
    Revision createProjectStructureRevision = workspaceRevisions.get(0);
    Assert.assertEquals("Build project structure", createProjectStructureRevision.getMessage());
    Assert.assertNotNull(createProjectStructureRevision.getId());
    Assert.assertNotNull(createProjectStructureRevision.getAuthorName());
    Assert.assertNotNull(createProjectStructureRevision.getCommitterName());
    Assert.assertNotNull(createProjectStructureRevision.getAuthoredTimestamp());
    Assert.assertNotNull(createProjectStructureRevision.getCommittedTimestamp());
    String entityPath = "test::entity";
    String entityPackagePath = "test";
    String classifierPath = "meta::test::mathematicsDepartment";
    Map<String, String> entityContentMap = Maps.mutable.with("package", "test", "name", "entity", "math-113", "abstract-algebra", "math-185", "complex-analysis");
    gitLabEntityApi.getGroupWorkspaceEntityModificationContext(projectId, workspaceOneId).createEntity(entityPath, classifierPath, entityContentMap, "initial entity");
    List<Entity> modifiedWorkspaceEntities = gitLabEntityApi.getGroupWorkspaceEntityAccessContext(projectId, workspaceOneId).getEntities(null, null, null);
    Assert.assertNotNull(modifiedWorkspaceEntities);
    Assert.assertEquals(1, modifiedWorkspaceEntities.size());
    Entity initalEntity = modifiedWorkspaceEntities.get(0);
    Assert.assertEquals(initalEntity.getPath(), entityPath);
    Assert.assertEquals(initalEntity.getClassifierPath(), classifierPath);
    Assert.assertEquals(initalEntity.getContent(), entityContentMap);
    List<Revision> updatedWorkspaceRevisions = gitLabRevisionApi.getGroupWorkspaceRevisionContext(projectId, workspaceOneId).getRevisions();
    Revision currentRevision = gitLabRevisionApi.getGroupWorkspaceRevisionContext(projectId, workspaceOneId).getCurrentRevision();
    Assert.assertNotNull(updatedWorkspaceRevisions);
    Assert.assertEquals(2, updatedWorkspaceRevisions.size());
    Assert.assertEquals("initial entity", currentRevision.getMessage());
    Assert.assertNotNull(currentRevision.getId());
    Assert.assertNotNull(currentRevision.getAuthorName());
    Assert.assertNotNull(currentRevision.getCommitterName());
    Assert.assertNotNull(currentRevision.getAuthoredTimestamp());
    Assert.assertNotNull(currentRevision.getCommittedTimestamp());
    List<Revision> entityRevisions = gitLabRevisionApi.getGroupWorkspaceEntityRevisionContext(projectId, workspaceOneId, entityPath).getRevisions();
    Revision currentEntityRevision = gitLabRevisionApi.getGroupWorkspaceEntityRevisionContext(projectId, workspaceOneId, entityPath).getCurrentRevision();
    Assert.assertNotNull(entityRevisions);
    Assert.assertEquals(1, entityRevisions.size());
    Assert.assertEquals("initial entity", currentEntityRevision.getMessage());
    Assert.assertNotNull(currentEntityRevision.getId());
    Assert.assertNotNull(currentEntityRevision.getAuthorName());
    Assert.assertNotNull(currentEntityRevision.getCommitterName());
    Assert.assertNotNull(currentEntityRevision.getAuthoredTimestamp());
    Assert.assertNotNull(currentEntityRevision.getCommittedTimestamp());
    List<Revision> packageRevisions = gitLabRevisionApi.getGroupWorkspacePackageRevisionContext(projectId, workspaceOneId, entityPackagePath).getRevisions();
    Revision currentPackageRevision = gitLabRevisionApi.getGroupWorkspacePackageRevisionContext(projectId, workspaceOneId, entityPackagePath).getCurrentRevision();
    Assert.assertNotNull(packageRevisions);
    Assert.assertEquals(1, packageRevisions.size());
    Assert.assertEquals("initial entity", currentPackageRevision.getMessage());
    Assert.assertNotNull(currentPackageRevision.getId());
    Assert.assertNotNull(currentPackageRevision.getAuthorName());
    Assert.assertNotNull(currentPackageRevision.getCommitterName());
    Assert.assertNotNull(currentPackageRevision.getAuthoredTimestamp());
    Assert.assertNotNull(currentPackageRevision.getCommittedTimestamp());
}
Also used : Project(org.finos.legend.sdlc.domain.model.project.Project) Entity(org.finos.legend.sdlc.domain.model.entity.Entity) Revision(org.finos.legend.sdlc.domain.model.revision.Revision) ProjectType(org.finos.legend.sdlc.domain.model.project.ProjectType) Workspace(org.finos.legend.sdlc.domain.model.project.workspace.Workspace)

Aggregations

Revision (org.finos.legend.sdlc.domain.model.revision.Revision)26 Entity (org.finos.legend.sdlc.domain.model.entity.Entity)15 ProjectConfiguration (org.finos.legend.sdlc.domain.model.project.configuration.ProjectConfiguration)10 Workspace (org.finos.legend.sdlc.domain.model.project.workspace.Workspace)9 LegendSDLCServerException (org.finos.legend.sdlc.server.error.LegendSDLCServerException)7 Project (org.finos.legend.sdlc.domain.model.project.Project)6 ProjectType (org.finos.legend.sdlc.domain.model.project.ProjectType)6 Instant (java.time.Instant)5 List (java.util.List)5 Test (org.junit.Test)5 Response (javax.ws.rs.core.Response)4 HttpResponseException (org.apache.http.client.HttpResponseException)4 Collections (java.util.Collections)3 Comparator (java.util.Comparator)3 Function (java.util.function.Function)3 Collectors (java.util.stream.Collectors)3 Lists (org.eclipse.collections.api.factory.Lists)3 Iterate (org.eclipse.collections.impl.utility.Iterate)3 ArtifactGeneration (org.finos.legend.sdlc.domain.model.project.configuration.ArtifactGeneration)3 MetamodelDependency (org.finos.legend.sdlc.domain.model.project.configuration.MetamodelDependency)3