Search in sources :

Example 16 with Project

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

use of org.finos.legend.sdlc.domain.model.project.Project 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)

Example 18 with Project

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

the class GitLabWorkspaceApiTestResource method runUpdateGroupWorkspaceWithRebaseNoConflictTest.

public void runUpdateGroupWorkspaceWithRebaseNoConflictTest() throws GitLabApiException {
    // Create new workspace from previous HEAD
    String projectName = "WorkspaceTestProjectThree";
    String description = "A test project.";
    ProjectType projectType = ProjectType.PRODUCTION;
    String groupId = "org.finos.sdlc.test";
    String artifactId = "testworkprojthree";
    List<String> tags = Lists.mutable.with("doe", "moffitt", AbstractGitLabServerApiTest.INTEGRATION_TEST_PROJECT_TAG);
    String workspaceName = "workspaceone";
    Project createdProject = gitLabProjectApi.createProject(projectName, description, projectType, groupId, artifactId, tags);
    String projectId = createdProject.getProjectId();
    Workspace createdWorkspace = gitLabWorkspaceApi.newGroupWorkspace(projectId, workspaceName);
    String workspaceId = createdWorkspace.getWorkspaceId();
    List<Entity> initialWorkspaceEntities = gitLabEntityApi.getGroupWorkspaceEntityAccessContext(projectId, workspaceId).getEntities(null, null, null);
    List<Entity> initialProjectEntities = gitLabEntityApi.getProjectEntityAccessContext(projectId).getEntities(null, null, null);
    Assert.assertEquals(Collections.emptyList(), initialWorkspaceEntities);
    Assert.assertEquals(Collections.emptyList(), initialProjectEntities);
    // Create another workspace, commit, review, merge to move project HEAD forward -- use workspace two
    String workspaceTwoName = "workspacetwo";
    Workspace createdWorkspaceTwo = gitLabWorkspaceApi.newGroupWorkspace(projectId, workspaceTwoName);
    String workspaceTwoId = createdWorkspaceTwo.getWorkspaceId();
    List<Entity> initialWorkspaceTwoEntities = gitLabEntityApi.getGroupWorkspaceEntityAccessContext(projectId, workspaceTwoId).getEntities(null, null, null);
    Assert.assertEquals(Collections.emptyList(), initialWorkspaceTwoEntities);
    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, workspaceTwoId).createEntity(entityPath, classifierPath, entityContentMap, "initial entity");
    List<Entity> modifiedWorkspaceEntities = gitLabEntityApi.getGroupWorkspaceEntityAccessContext(projectId, workspaceTwoId).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<String> labels = Collections.singletonList("default");
    Review testReview = gitLabCommitterReviewApi.createReview(projectId, workspaceTwoId, WorkspaceType.GROUP, "Add Courses.", "add two math courses", labels);
    String reviewId = testReview.getId();
    Review approvedReview = gitLabApproverReviewApi.approveReview(projectId, reviewId);
    Assert.assertNotNull(approvedReview);
    Assert.assertEquals(reviewId, approvedReview.getId());
    Assert.assertEquals(ReviewState.OPEN, approvedReview.getState());
    GitLabProjectId sdlcGitLabProjectId = GitLabProjectId.parseProjectId(projectId);
    MergeRequestApi mergeRequestApi = gitLabMemberUserContext.getGitLabAPI(sdlcGitLabProjectId.getGitLabMode()).getMergeRequestApi();
    Integer parsedMergeRequestId = Integer.parseInt(reviewId);
    Integer gitlabProjectId = sdlcGitLabProjectId.getGitLabId();
    String requiredStatus = "can_be_merged";
    CallUntil<MergeRequest, GitLabApiException> callUntil = CallUntil.callUntil(() -> mergeRequestApi.getMergeRequest(gitlabProjectId, parsedMergeRequestId), mr -> requiredStatus.equals(mr.getMergeStatus()), 20, 1000);
    if (!callUntil.succeeded()) {
        throw new RuntimeException("Merge request " + approvedReview.getId() + " still does not have status \"" + requiredStatus + "\" after " + callUntil.getTryCount() + " tries");
    }
    LOGGER.info("Waited {} times for merge to have status \"{}\"", callUntil.getTryCount(), requiredStatus);
    gitLabCommitterReviewApi.commitReview(projectId, reviewId, "add two math courses");
    String requiredMergedStatus = "merged";
    CallUntil<MergeRequest, GitLabApiException> callUntilMerged = CallUntil.callUntil(() -> mergeRequestApi.getMergeRequest(gitlabProjectId, parsedMergeRequestId), mr -> requiredMergedStatus.equals(mr.getState()), 10, 500);
    if (!callUntilMerged.succeeded()) {
        throw new RuntimeException("Merge request " + reviewId + " still does not have state \"" + requiredMergedStatus + "\" after " + callUntilMerged.getTryCount() + " tries");
    }
    LOGGER.info("Waited {} times for merge request to have state \"{}\"", callUntilMerged.getTryCount(), requiredMergedStatus);
    RepositoryApi repositoryApi = gitLabMemberUserContext.getGitLabAPI(sdlcGitLabProjectId.getGitLabMode()).getRepositoryApi();
    CallUntil<List<Branch>, GitLabApiException> callUntilBranchDeleted = CallUntil.callUntil(() -> repositoryApi.getBranches(sdlcGitLabProjectId.getGitLabId()), branches -> GitLabApiTestSetupUtil.hasOnlyBranchesWithNames(branches, Lists.mutable.of(workspaceName, "master")), 15, 1000);
    if (!callUntilBranchDeleted.succeeded()) {
        // Warn instead of throwing exception since we cannot manage time expectation on GitLab to reflect branch deletion.
        LOGGER.warn("Branch {} is still not deleted post merge after {} tries", workspaceTwoName, callUntilBranchDeleted.getTryCount());
    }
    LOGGER.info("Waited {} times for branch {} to be deleted post merge", callUntilBranchDeleted.getTryCount(), workspaceTwoName);
    List<Entity> postCommitProjectEntities = gitLabEntityApi.getProjectEntityAccessContext(projectId).getEntities(null, null, null);
    Assert.assertNotNull(postCommitProjectEntities);
    Assert.assertEquals(1, postCommitProjectEntities.size());
    Entity projectEntity = postCommitProjectEntities.get(0);
    Assert.assertEquals(projectEntity.getPath(), entityPath);
    Assert.assertEquals(projectEntity.getClassifierPath(), classifierPath);
    Assert.assertEquals(projectEntity.getContent(), entityContentMap);
    // Create changes and make change in workspace branch -- use workspace
    Map<String, String> currentEntityContentMap = Maps.mutable.with("package", "test", "name", "entity", "math-113", "abstract-algebra", "math-185", "complex-analysis");
    gitLabEntityApi.getGroupWorkspaceEntityModificationContext(projectId, workspaceId).createEntity(entityPath, classifierPath, currentEntityContentMap, "initial entity");
    List<Entity> modifiedWorkspaceEntitiesNew = gitLabEntityApi.getGroupWorkspaceEntityAccessContext(projectId, workspaceId).getEntities(null, null, null);
    Assert.assertNotNull(modifiedWorkspaceEntitiesNew);
    Assert.assertEquals(1, modifiedWorkspaceEntities.size());
    Entity initalEntityNew = modifiedWorkspaceEntitiesNew.get(0);
    Assert.assertEquals(initalEntityNew.getPath(), entityPath);
    Assert.assertEquals(initalEntityNew.getClassifierPath(), classifierPath);
    Assert.assertEquals(initalEntityNew.getContent(), currentEntityContentMap);
    // Update workspace branch and trigger rebase
    gitLabWorkspaceApi.updateGroupWorkspace(projectId, workspaceId);
    List<Entity> updatedWorkspaceEntities = gitLabEntityApi.getGroupWorkspaceEntityAccessContext(projectId, workspaceId).getEntities(null, null, null);
    Assert.assertNotNull(updatedWorkspaceEntities);
    Assert.assertEquals(1, updatedWorkspaceEntities.size());
    Entity updatedEntity = updatedWorkspaceEntities.get(0);
    Assert.assertEquals(updatedEntity.getPath(), entityPath);
    Assert.assertEquals(updatedEntity.getClassifierPath(), classifierPath);
    Assert.assertEquals(updatedEntity.getContent(), currentEntityContentMap);
}
Also used : Entity(org.finos.legend.sdlc.domain.model.entity.Entity) GitLabApiException(org.gitlab4j.api.GitLabApiException) Review(org.finos.legend.sdlc.domain.model.review.Review) Project(org.finos.legend.sdlc.domain.model.project.Project) MergeRequest(org.gitlab4j.api.models.MergeRequest) GitLabProjectId(org.finos.legend.sdlc.server.gitlab.GitLabProjectId) ProjectType(org.finos.legend.sdlc.domain.model.project.ProjectType) MergeRequestApi(org.gitlab4j.api.MergeRequestApi) RepositoryApi(org.gitlab4j.api.RepositoryApi) List(java.util.List) Workspace(org.finos.legend.sdlc.domain.model.project.workspace.Workspace)

Example 19 with Project

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

the class GitLabWorkspaceApiTestResource method runUserAndGroupWorkspaceNormalWorkflowTest.

public void runUserAndGroupWorkspaceNormalWorkflowTest() {
    String projectName = "WorkspaceTestProjectOne";
    String description = "A test project.";
    ProjectType projectType = ProjectType.PRODUCTION;
    String groupId = "org.finos.sdlc.test";
    String artifactId = "worktestprojone";
    List<String> tags = Lists.mutable.with("doe", "moffitt", AbstractGitLabServerApiTest.INTEGRATION_TEST_PROJECT_TAG);
    String workspaceOneId = "testworkspaceone";
    String workspaceTwoId = "testworkspacetwo";
    String workspaceThreeId = "testworkspacethree";
    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());
    Workspace createdWorkspaceTwo = gitLabWorkspaceApi.newUserWorkspace(projectId, workspaceTwoId);
    Assert.assertNotNull(createdWorkspaceTwo);
    Assert.assertEquals(workspaceTwoId, createdWorkspaceTwo.getWorkspaceId());
    Assert.assertEquals(projectId, createdWorkspaceTwo.getProjectId());
    Assert.assertNotNull(createdWorkspaceTwo.getUserId());
    Workspace createdWorkspaceThree = gitLabWorkspaceApi.newGroupWorkspace(projectId, workspaceThreeId);
    Assert.assertNotNull(createdWorkspaceThree);
    Assert.assertEquals(workspaceThreeId, createdWorkspaceThree.getWorkspaceId());
    Assert.assertEquals(projectId, createdWorkspaceThree.getProjectId());
    Assert.assertNull(createdWorkspaceThree.getUserId());
    List<Workspace> allWorkspaces = gitLabWorkspaceApi.getAllWorkspaces(projectId);
    List<Workspace> allUserWorkspaces = gitLabWorkspaceApi.getAllUserWorkspaces(projectId);
    List<Workspace> allGroupWorkspaces = gitLabWorkspaceApi.getGroupWorkspaces(projectId);
    Assert.assertNotNull(allWorkspaces);
    Assert.assertNotNull(allUserWorkspaces);
    Assert.assertNotNull(allGroupWorkspaces);
    Assert.assertEquals(3, allWorkspaces.size());
    Assert.assertEquals(2, allUserWorkspaces.size());
    Assert.assertEquals(1, allGroupWorkspaces.size());
    Workspace retriedUserWorkspace = gitLabWorkspaceApi.getUserWorkspace(projectId, workspaceOneId);
    Assert.assertNotNull(retriedUserWorkspace);
    Assert.assertEquals(workspaceOneId, retriedUserWorkspace.getWorkspaceId());
    Assert.assertEquals(projectId, retriedUserWorkspace.getProjectId());
    Assert.assertNotNull(retriedUserWorkspace.getUserId());
    Workspace retriedGroupWorkspace = gitLabWorkspaceApi.getGroupWorkspace(projectId, workspaceThreeId);
    Assert.assertNotNull(retriedGroupWorkspace);
    Assert.assertEquals(workspaceThreeId, retriedGroupWorkspace.getWorkspaceId());
    Assert.assertEquals(projectId, retriedGroupWorkspace.getProjectId());
    Assert.assertNull(retriedGroupWorkspace.getUserId());
    boolean isUserWorkspaceInConflictResolution = gitLabWorkspaceApi.isUserWorkspaceInConflictResolutionMode(projectId, workspaceOneId);
    boolean isGroupWorkspaceInConflictResolution = gitLabWorkspaceApi.isGroupWorkspaceInConflictResolutionMode(projectId, workspaceThreeId);
    Assert.assertFalse(isUserWorkspaceInConflictResolution);
    Assert.assertFalse(isGroupWorkspaceInConflictResolution);
    boolean isUserWorkspaceOutdated = gitLabWorkspaceApi.isUserWorkspaceOutdated(projectId, workspaceOneId);
    boolean isGroupWorkspaceOutdated = gitLabWorkspaceApi.isGroupWorkspaceOutdated(projectId, workspaceThreeId);
    Assert.assertFalse(isUserWorkspaceOutdated);
    Assert.assertFalse(isGroupWorkspaceOutdated);
}
Also used : Project(org.finos.legend.sdlc.domain.model.project.Project) ProjectType(org.finos.legend.sdlc.domain.model.project.ProjectType) Workspace(org.finos.legend.sdlc.domain.model.project.workspace.Workspace)

Example 20 with Project

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

the class AbstractGitLabServerApiTest method cleanUpTestProjects.

/**
 * Clean up all potential test projects.
 */
protected static void cleanUpTestProjects(GitLabProjectApi gitLabProjectApi) {
    List<Project> projectsToBeCleaned = gitLabProjectApi.getProjects(true, "", Lists.mutable.with(INTEGRATION_TEST_PROJECT_TAG), Lists.mutable.empty(), null);
    for (Project project : projectsToBeCleaned) {
        String projectId = project.getProjectId();
        String projectName = project.getName();
        LOGGER.info("Deleting test project id: {}, name: {}", projectId, projectName);
        try {
            gitLabProjectApi.deleteProject(projectId);
        } catch (Exception e) {
            LOGGER.warn("Failed to delete project id {}, name: {} during cleanup.", projectId, projectName, e);
        }
        LOGGER.info("Handled test project id: {}, name: {}", projectId, projectName);
    }
}
Also used : Project(org.finos.legend.sdlc.domain.model.project.Project) LegendSDLCServerException(org.finos.legend.sdlc.server.error.LegendSDLCServerException)

Aggregations

Project (org.finos.legend.sdlc.domain.model.project.Project)24 ProjectType (org.finos.legend.sdlc.domain.model.project.ProjectType)15 GitLabProjectId (org.finos.legend.sdlc.server.gitlab.GitLabProjectId)11 Workspace (org.finos.legend.sdlc.domain.model.project.workspace.Workspace)10 LegendSDLCServerException (org.finos.legend.sdlc.server.error.LegendSDLCServerException)9 Entity (org.finos.legend.sdlc.domain.model.entity.Entity)8 Revision (org.finos.legend.sdlc.domain.model.revision.Revision)8 List (java.util.List)7 RepositoryApi (org.gitlab4j.api.RepositoryApi)7 MergeRequest (org.gitlab4j.api.models.MergeRequest)7 ProjectConfiguration (org.finos.legend.sdlc.domain.model.project.configuration.ProjectConfiguration)5 Review (org.finos.legend.sdlc.domain.model.review.Review)4 ProjectStructure (org.finos.legend.sdlc.server.project.ProjectStructure)4 GitLabApi (org.gitlab4j.api.GitLabApi)4 ProjectStructureVersion (org.finos.legend.sdlc.domain.model.project.configuration.ProjectStructureVersion)3 GitLabMode (org.finos.legend.sdlc.server.gitlab.mode.GitLabMode)3 ProjectConfigurationUpdateBuilder (org.finos.legend.sdlc.server.project.ProjectConfigurationUpdateBuilder)3 ProjectFileAccessProvider (org.finos.legend.sdlc.server.project.ProjectFileAccessProvider)3 Branch (org.gitlab4j.api.models.Branch)3 Collections (java.util.Collections)2