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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations