SimpleMergeRequestManager implements MergeRequestManager { @Override public MergeRequest createMergeRequest(MergeRequestConfig config, Resource localCatalog) { try (RepositoryConnection conn = configProvider.getRepository().getConnection()) { return createMergeRequest(config, localCatalog, 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 createMergeRequestTest() { MergeRequestConfig config = new MergeRequestConfig.Builder("title", RECORD_1_IRI, SOURCE_BRANCH_1_IRI, TARGET_BRANCH_1_IRI, user1, true) .description("description") .addAssignee(user1) .build(); try (RepositoryConnection conn = repo.getConnection()) { MergeRequest result = manager.createMergeRequest(config, LOCAL_CATALOG_IRI, conn); Optional<Value> title = result.getProperty(VALUE_FACTORY.createIRI(_Thing.title_IRI)); assertTrue(title.isPresent()); assertEquals("title", title.get().stringValue()); Optional<Value> description = result.getProperty(VALUE_FACTORY.createIRI(_Thing.description_IRI)); assertTrue(description.isPresent()); assertEquals("description", description.get().stringValue()); Optional<Resource> record = result.getOnRecord_resource(); assertTrue(record.isPresent()); assertEquals(RECORD_1_IRI, record.get()); Optional<Resource> sourceBranch = result.getSourceBranch_resource(); assertTrue(sourceBranch.isPresent()); assertEquals(SOURCE_BRANCH_1_IRI, sourceBranch.get()); Optional<Resource> targetBranch = result.getTargetBranch_resource(); assertTrue(targetBranch.isPresent()); assertEquals(TARGET_BRANCH_1_IRI, targetBranch.get()); assertTrue(result.getRemoveSource().get()); Optional<Value> creator = result.getProperty(VALUE_FACTORY.createIRI(_Thing.creator_IRI)); assertTrue(creator.isPresent()); assertEquals(user1.getResource().stringValue(), creator.get().stringValue()); assertEquals(1, result.getAssignee_resource().size()); } }
@Test(expected = IllegalArgumentException.class) public void createMergeRequestWithInvalidBranchTest() { doThrow(new IllegalArgumentException()).when(utilsService).validateBranch(eq(LOCAL_CATALOG_IRI), eq(RECORD_1_IRI), eq(SOURCE_BRANCH_1_IRI), any(RepositoryConnection.class)); MergeRequestConfig config = new MergeRequestConfig.Builder("title", RECORD_1_IRI, SOURCE_BRANCH_1_IRI, TARGET_BRANCH_1_IRI, user1, true).build(); try (RepositoryConnection conn = repo.getConnection()) { manager.createMergeRequest(config, LOCAL_CATALOG_IRI, conn); } }