SimpleMergeRequestManager implements MergeRequestManager { @Override public List<MergeRequest> getMergeRequests(MergeRequestFilterParams params) { try (RepositoryConnection conn = configProvider.getRepository().getConnection()) { return getMergeRequests(params, conn); } }  @Override List<MergeRequest> getMergeRequests(MergeRequestFilterParams params); @Override List<MergeRequest> getMergeRequests(MergeRequestFilterParams params, RepositoryConnection conn); @Override MergeRequest createMergeRequest(MergeRequestConfig config, Resource localCatalog); @Override MergeRequest createMergeRequest(MergeRequestConfig config, Resource localCatalog,
                                           RepositoryConnection conn); @Override void addMergeRequest(MergeRequest request); @Override void addMergeRequest(MergeRequest request, RepositoryConnection conn); @Override Optional<MergeRequest> getMergeRequest(Resource requestId); @Override Optional<MergeRequest> getMergeRequest(Resource requestId, RepositoryConnection conn); @Override void updateMergeRequest(Resource requestId, MergeRequest request); @Override void updateMergeRequest(Resource requestId, MergeRequest request, RepositoryConnection conn); @Override void deleteMergeRequest(Resource requestId); @Override void deleteMergeRequest(Resource requestId, RepositoryConnection conn); @Override void acceptMergeRequest(Resource requestId, User user); @Override void acceptMergeRequest(Resource requestId, User user,  RepositoryConnection conn); @Override void deleteMergeRequestsWithRecordId(Resource recordId); @Override void deleteMergeRequestsWithRecordId(Resource recordId, RepositoryConnection conn); @Override void cleanMergeRequests(Resource recordId, Resource branchId); @Override void cleanMergeRequests(Resource recordId, Resource branchId, RepositoryConnection conn); @Override Comment createComment(Resource requestId, User user, String commentStr); @Override Comment createComment(Resource requestId, User user, String commentStr, Resource parentCommentId); @Override List<List<Comment>> getComments(Resource requestId); @Override Optional<Comment> getComment(Resource commentId); @Override Optional<Comment> getComment(Resource commentId, RepositoryConnection conn); @Override void updateComment(Resource commentId, Comment comment); @Override void deleteComment(Resource commentId); @Override void deleteCommentsWithRequestId(Resource requestId);  }
@Test public void getOpenMergeRequestsSortByNotSet() { try (RepositoryConnection conn = repo.getConnection()) { MergeRequestFilterParams.Builder builder = new MergeRequestFilterParams.Builder(); List<MergeRequest> result = manager.getMergeRequests(builder.build(), conn); assertEquals(2, result.size()); Iterator<MergeRequest> it = result.iterator(); assertEquals(request2.getResource(), it.next().getResource()); assertEquals(request1.getResource(), it.next().getResource()); verify(utilsService).getExpectedObject(eq(request1.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); verify(utilsService).getExpectedObject(eq(request2.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); } }
@Test public void getOpenMergeRequestsSortByTitleTest() { try (RepositoryConnection conn = repo.getConnection()) { MergeRequestFilterParams.Builder builder = new MergeRequestFilterParams.Builder().setSortBy(VALUE_FACTORY.createIRI(_Thing.title_IRI)); List<MergeRequest> result = manager.getMergeRequests(builder.build(), conn); assertEquals(2, result.size()); Iterator<MergeRequest> it = result.iterator(); assertEquals(request2.getResource(), it.next().getResource()); assertEquals(request1.getResource(), it.next().getResource()); verify(utilsService).getExpectedObject(eq(request1.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); verify(utilsService).getExpectedObject(eq(request2.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); builder.setAscending(true); result = manager.getMergeRequests(builder.build(), conn); assertEquals(2, result.size()); it = result.iterator(); assertEquals(request1.getResource(), it.next().getResource()); assertEquals(request2.getResource(), it.next().getResource()); } }
@Test public void getOpenMergeRequestsSortByIssuedTest() { try (RepositoryConnection conn = repo.getConnection()) { MergeRequestFilterParams.Builder builder = new MergeRequestFilterParams.Builder().setSortBy(VALUE_FACTORY.createIRI(_Thing.issued_IRI)); List<MergeRequest> result = manager.getMergeRequests(builder.build(), conn); assertEquals(2, result.size()); Iterator<MergeRequest> it = result.iterator(); assertEquals(request2.getResource(), it.next().getResource()); assertEquals(request1.getResource(), it.next().getResource()); verify(utilsService).getExpectedObject(eq(request1.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); verify(utilsService).getExpectedObject(eq(request2.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); builder.setAscending(true); result = manager.getMergeRequests(builder.build(), conn); assertEquals(2, result.size()); it = result.iterator(); assertEquals(request1.getResource(), it.next().getResource()); assertEquals(request2.getResource(), it.next().getResource()); } }
@Test public void getOpenMergeRequestsAssignee() { try (RepositoryConnection conn = repo.getConnection()) { MergeRequestFilterParams.Builder builder = new MergeRequestFilterParams.Builder().setSortBy(VALUE_FACTORY.createIRI(_Thing.title_IRI)); builder.setAssignee(user1.getResource()); List<MergeRequest> result = manager.getMergeRequests(builder.build(), conn); assertEquals(1, result.size()); assertEquals(request1.getResource(), result.get(0).getResource()); verify(utilsService).getExpectedObject(eq(request1.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); builder.setAssignee(user2.getResource()); result = manager.getMergeRequests(builder.build(), conn); assertEquals(1, result.size()); assertEquals(request2.getResource(), result.get(0).getResource()); verify(utilsService).getExpectedObject(eq(request2.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); } }
@Test public void getOpenMergeRequestsOnRecord() { try (RepositoryConnection conn = repo.getConnection()) { MergeRequestFilterParams.Builder builder = new MergeRequestFilterParams.Builder().setSortBy(VALUE_FACTORY.createIRI(_Thing.title_IRI)); builder.setOnRecord(RECORD_1_IRI); List<MergeRequest> result = manager.getMergeRequests(builder.build(), conn); assertEquals(1, result.size()); assertEquals(request1.getResource(), result.get(0).getResource()); verify(utilsService).getExpectedObject(eq(request1.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); builder.setOnRecord(RECORD_2_IRI); result = manager.getMergeRequests(builder.build(), conn); assertEquals(1, result.size()); assertEquals(request2.getResource(), result.get(0).getResource()); verify(utilsService).getExpectedObject(eq(request2.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); } }
@Test public void getOpenMergeRequestsSourceBranch() { try (RepositoryConnection conn = repo.getConnection()) { MergeRequestFilterParams.Builder builder = new MergeRequestFilterParams.Builder().setSortBy(VALUE_FACTORY.createIRI(_Thing.title_IRI)); builder.setSourceBranch(SOURCE_BRANCH_1_IRI); List<MergeRequest> result = manager.getMergeRequests(builder.build(), conn); assertEquals(1, result.size()); assertEquals(request1.getResource(), result.get(0).getResource()); verify(utilsService).getExpectedObject(eq(request1.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); builder.setSourceBranch(SOURCE_BRANCH_2_IRI); result = manager.getMergeRequests(builder.build(), conn); assertEquals(1, result.size()); assertEquals(request2.getResource(), result.get(0).getResource()); verify(utilsService).getExpectedObject(eq(request2.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); } }
@Test public void getOpenMergeRequestsTargetBranch() { try (RepositoryConnection conn = repo.getConnection()) { MergeRequestFilterParams.Builder builder = new MergeRequestFilterParams.Builder().setSortBy(VALUE_FACTORY.createIRI(_Thing.title_IRI)); builder.setTargetBranch(TARGET_BRANCH_1_IRI); List<MergeRequest> result = manager.getMergeRequests(builder.build(), conn); assertEquals(1, result.size()); assertEquals(request1.getResource(), result.get(0).getResource()); verify(utilsService).getExpectedObject(eq(request1.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); builder.setTargetBranch(TARGET_BRANCH_2_IRI); result = manager.getMergeRequests(builder.build(), conn); assertEquals(1, result.size()); assertEquals(request2.getResource(), result.get(0).getResource()); verify(utilsService).getExpectedObject(eq(request2.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); } }
@Test public void getOpenMergeRequestsRemoveSource() { try (RepositoryConnection conn = repo.getConnection()) { MergeRequestFilterParams.Builder builder = new MergeRequestFilterParams.Builder().setSortBy(VALUE_FACTORY.createIRI(_Thing.title_IRI)); builder.setRemoveSource(true); List<MergeRequest> result = manager.getMergeRequests(builder.build(), conn); assertEquals(1, result.size()); assertEquals(request1.getResource(), result.get(0).getResource()); verify(utilsService).getExpectedObject(eq(request1.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); builder.setRemoveSource(false); result = manager.getMergeRequests(builder.build(), conn); assertEquals(1, result.size()); assertEquals(request2.getResource(), result.get(0).getResource()); verify(utilsService).getExpectedObject(eq(request2.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); } }
@Test public void getAcceptedMergeRequestsTest() { try (RepositoryConnection conn = repo.getConnection()) { MergeRequestFilterParams.Builder builder = new MergeRequestFilterParams.Builder(); builder.setSortBy(VALUE_FACTORY.createIRI(_Thing.title_IRI)).setAccepted(true); List<MergeRequest> result = manager.getMergeRequests(builder.build(), conn); assertEquals(2, result.size()); Iterator<MergeRequest> it = result.iterator(); assertEquals(request5.getResource(), it.next().getResource()); assertEquals(request4.getResource(), it.next().getResource()); verify(utilsService).getExpectedObject(eq(request4.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); } }
@Test public void getAcceptedMergeRequestsSourceCommit() { try (RepositoryConnection conn = repo.getConnection()) { MergeRequestFilterParams.Builder builder = new MergeRequestFilterParams.Builder().setSortBy(VALUE_FACTORY.createIRI(_Thing.title_IRI)); builder.setAccepted(true).setSourceCommit(sourceCommit1.getResource()); List<MergeRequest> result = manager.getMergeRequests(builder.build(), conn); assertEquals(1, result.size()); assertEquals(request4.getResource(), result.get(0).getResource()); verify(utilsService).getExpectedObject(eq(request4.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); builder.setSourceCommit(sourceCommit2.getResource()); result = manager.getMergeRequests(builder.build(), conn); assertEquals(1, result.size()); assertEquals(request5.getResource(), result.get(0).getResource()); verify(utilsService).getExpectedObject(eq(request5.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); } }
@Test public void getAcceptedMergeRequestsTargetCommit() { try (RepositoryConnection conn = repo.getConnection()) { MergeRequestFilterParams.Builder builder = new MergeRequestFilterParams.Builder().setSortBy(VALUE_FACTORY.createIRI(_Thing.title_IRI)); builder.setAccepted(true).setTargetCommit(targetCommit1.getResource()); List<MergeRequest> result = manager.getMergeRequests(builder.build(), conn); assertEquals(1, result.size()); assertEquals(request4.getResource(), result.get(0).getResource()); verify(utilsService).getExpectedObject(eq(request4.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); builder.setTargetCommit(targetCommit2.getResource()); result = manager.getMergeRequests(builder.build(), conn); assertEquals(1, result.size()); assertEquals(request5.getResource(), result.get(0).getResource()); verify(utilsService).getExpectedObject(eq(request5.getResource()), eq(mergeRequestFactory), any(RepositoryConnection.class)); } }