Search in sources :

Example 6 with Workspace

use of org.finos.legend.sdlc.domain.model.project.workspace.Workspace 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 7 with Workspace

use of org.finos.legend.sdlc.domain.model.project.workspace.Workspace 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 8 with Workspace

use of org.finos.legend.sdlc.domain.model.project.workspace.Workspace in project legend-sdlc by finos.

the class TestWorkspacesResource method testGetMixedTypeWorkspaces.

@Test
public void testGetMixedTypeWorkspaces() throws HttpResponseException {
    String projectId = "A";
    String workspaceOneId = "w1";
    String workspaceTwoId = "w2";
    String workspaceThreeId = "w3";
    this.backend.project(projectId).addWorkspace(workspaceOneId, WorkspaceType.USER);
    this.backend.project(projectId).addWorkspace(workspaceTwoId, WorkspaceType.USER);
    this.backend.project(projectId).addWorkspace(workspaceThreeId, WorkspaceType.GROUP);
    Response responseOne = this.clientFor("/api/projects/A/workspaces").request().get();
    if (responseOne.getStatus() != 200) {
        throw new HttpResponseException(responseOne.getStatus(), "Error during getting user workspaces with status: " + responseOne.getStatus() + ", entity: " + responseOne.readEntity(String.class));
    }
    List<Workspace> allUserWorkspaces = responseOne.readEntity(new GenericType<List<Workspace>>() {
    });
    Assert.assertNotNull(allUserWorkspaces);
    Assert.assertEquals(2, allUserWorkspaces.size());
    Assert.assertEquals(workspaceOneId, findWorkspace(allUserWorkspaces, workspaceOneId).getWorkspaceId());
    Assert.assertEquals(projectId, findWorkspace(allUserWorkspaces, workspaceOneId).getProjectId());
    Assert.assertEquals(workspaceTwoId, findWorkspace(allUserWorkspaces, workspaceTwoId).getWorkspaceId());
    Assert.assertEquals(projectId, findWorkspace(allUserWorkspaces, workspaceTwoId).getProjectId());
    Response responseTwo = this.clientFor("/api/projects/A/groupWorkspaces").request().get();
    if (responseTwo.getStatus() != 200) {
        throw new HttpResponseException(responseTwo.getStatus(), "Error during getting group workspaces with status: " + responseTwo.getStatus() + " , entity: " + responseTwo.readEntity(String.class));
    }
    List<Workspace> allGroupWorkspaces = responseTwo.readEntity(new GenericType<List<Workspace>>() {
    });
    Assert.assertNotNull(allGroupWorkspaces);
    Assert.assertEquals(1, allGroupWorkspaces.size());
    Assert.assertEquals(workspaceThreeId, findWorkspace(allGroupWorkspaces, workspaceThreeId).getWorkspaceId());
    Assert.assertEquals(projectId, findWorkspace(allGroupWorkspaces, workspaceThreeId).getProjectId());
    Response responseThree = this.clientFor("/api/projects/A/groupWorkspaces").queryParam("includeUserWorkspaces", true).request().get();
    if (responseThree.getStatus() != 200) {
        throw new HttpResponseException(responseThree.getStatus(), "Error during getting all workspaces with status: " + responseThree.getStatus() + " , entity: " + responseThree.readEntity(String.class));
    }
    List<Workspace> allUserAndGroupWorkspaces = responseThree.readEntity(new GenericType<List<Workspace>>() {
    });
    Assert.assertNotNull(allUserAndGroupWorkspaces);
    Assert.assertEquals(3, allUserAndGroupWorkspaces.size());
    Assert.assertEquals(workspaceOneId, findWorkspace(allUserAndGroupWorkspaces, workspaceOneId).getWorkspaceId());
    Assert.assertEquals(projectId, findWorkspace(allUserAndGroupWorkspaces, workspaceOneId).getProjectId());
    Assert.assertEquals(workspaceTwoId, findWorkspace(allUserAndGroupWorkspaces, workspaceTwoId).getWorkspaceId());
    Assert.assertEquals(projectId, findWorkspace(allUserAndGroupWorkspaces, workspaceTwoId).getProjectId());
    Assert.assertEquals(workspaceThreeId, findWorkspace(allUserAndGroupWorkspaces, workspaceThreeId).getWorkspaceId());
    Assert.assertEquals(projectId, findWorkspace(allUserAndGroupWorkspaces, workspaceThreeId).getProjectId());
}
Also used : Response(javax.ws.rs.core.Response) 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 9 with Workspace

use of org.finos.legend.sdlc.domain.model.project.workspace.Workspace in project legend-sdlc by finos.

the class TestWorkspacesResource method testGetAndDeleteUserWorkspace.

@Test
public void testGetAndDeleteUserWorkspace() throws HttpResponseException {
    String projectId = "A";
    String workspaceId = "userw1";
    this.backend.project(projectId).addWorkspace(workspaceId, WorkspaceType.USER);
    Response response = this.clientFor("/api/projects/A/workspaces/userw1").request().get();
    if (response.getStatus() != 200) {
        throw new HttpResponseException(response.getStatus(), "Error during getting user workspace with status: " + response.getStatus() + ", entity: " + response.readEntity(String.class));
    }
    Workspace workspace = response.readEntity(new GenericType<Workspace>() {
    });
    Assert.assertNotNull(workspace);
    Assert.assertEquals(workspaceId, workspace.getWorkspaceId());
    Assert.assertEquals(projectId, workspace.getProjectId());
    Response deletionResponse = this.clientFor("/api/projects/A/workspaces/userw1").request().delete();
    Assert.assertEquals("Error during deleting user workspace with status: " + deletionResponse.getStatus() + ", entity: " + deletionResponse.readEntity(String.class), 204, deletionResponse.getStatus());
    Response finalGetResponse = this.clientFor("/api/projects/A/workspaces/userw1").request().get();
    Assert.assertEquals("Error during getting deleted user workspace with status: " + finalGetResponse.getStatus() + ", entity: " + finalGetResponse.readEntity(String.class), 204, finalGetResponse.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) HttpResponseException(org.apache.http.client.HttpResponseException) Workspace(org.finos.legend.sdlc.domain.model.project.workspace.Workspace) Test(org.junit.Test)

Example 10 with Workspace

use of org.finos.legend.sdlc.domain.model.project.workspace.Workspace in project legend-sdlc by finos.

the class TestWorkspacesResource method testGetAndDeleteGroupWorkspace.

@Test
public void testGetAndDeleteGroupWorkspace() throws HttpResponseException {
    String projectId = "A";
    String workspaceId = "groupw1";
    this.backend.project(projectId).addWorkspace(workspaceId, WorkspaceType.GROUP);
    Response response = this.clientFor("/api/projects/A/groupWorkspaces/groupw1").request().get();
    if (response.getStatus() != 200) {
        throw new HttpResponseException(response.getStatus(), "Error during getting group workspace with status: " + response.getStatus() + ", entity: " + response.readEntity(String.class));
    }
    Workspace workspace = response.readEntity(new GenericType<Workspace>() {
    });
    Assert.assertNotNull(workspace);
    Assert.assertEquals(workspaceId, workspace.getWorkspaceId());
    Assert.assertEquals(projectId, workspace.getProjectId());
    Response deletionResponse = this.clientFor("/api/projects/A/groupWorkspaces/groupw1").request().delete();
    Assert.assertEquals("Error during deleting group workspace with status: " + deletionResponse.getStatus() + ", entity: " + deletionResponse.readEntity(String.class), 204, deletionResponse.getStatus());
    Response finalGetResponse = this.clientFor("/api/projects/A/groupWorkspaces/groupw1").request().get();
    Assert.assertEquals("Error during getting deleted group workspace with status: " + finalGetResponse.getStatus() + ", entity: " + finalGetResponse.readEntity(String.class), 204, finalGetResponse.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) HttpResponseException(org.apache.http.client.HttpResponseException) Workspace(org.finos.legend.sdlc.domain.model.project.workspace.Workspace) Test(org.junit.Test)

Aggregations

Workspace (org.finos.legend.sdlc.domain.model.project.workspace.Workspace)23 List (java.util.List)12 Entity (org.finos.legend.sdlc.domain.model.entity.Entity)12 Revision (org.finos.legend.sdlc.domain.model.revision.Revision)11 Project (org.finos.legend.sdlc.domain.model.project.Project)10 ProjectType (org.finos.legend.sdlc.domain.model.project.ProjectType)10 Response (javax.ws.rs.core.Response)9 HttpResponseException (org.apache.http.client.HttpResponseException)9 Test (org.junit.Test)9 GitLabProjectId (org.finos.legend.sdlc.server.gitlab.GitLabProjectId)7 GitLabApiException (org.gitlab4j.api.GitLabApiException)6 MergeRequestApi (org.gitlab4j.api.MergeRequestApi)6 RepositoryApi (org.gitlab4j.api.RepositoryApi)6 MergeRequest (org.gitlab4j.api.models.MergeRequest)6 Review (org.finos.legend.sdlc.domain.model.review.Review)4 InMemoryEntity (org.finos.legend.sdlc.server.inmemory.domain.api.InMemoryEntity)4 Collectors (java.util.stream.Collectors)3 Inject (javax.inject.Inject)3 Status (javax.ws.rs.core.Response.Status)3 Lists (org.eclipse.collections.api.factory.Lists)3