diff --git a/dspace-api/src/test/java/org/dspace/content/DuplicateDetectionTest.java b/dspace-api/src/test/java/org/dspace/content/DuplicateDetectionTest.java index 35b0b35d3d..128936edc8 100644 --- a/dspace-api/src/test/java/org/dspace/content/DuplicateDetectionTest.java +++ b/dspace-api/src/test/java/org/dspace/content/DuplicateDetectionTest.java @@ -7,6 +7,11 @@ */ package org.dspace.content; +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertNull; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.fail; + import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -29,11 +34,6 @@ import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem; import org.junit.Before; import org.junit.Test; -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertNull; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.fail; - /** * * Integration tests for the duplicate detection service @@ -41,7 +41,8 @@ import static org.junit.Assert.fail; * @author Kim Shepherd */ public class DuplicateDetectionTest extends AbstractIntegrationTestWithDatabase { - private DuplicateDetectionService duplicateDetectionService = ContentServiceFactory.getInstance().getDuplicateDetectionService(); + private DuplicateDetectionService duplicateDetectionService = ContentServiceFactory.getInstance() + .getDuplicateDetectionService(); private ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService(); private Collection col; private Collection workflowCol; @@ -224,7 +225,8 @@ public class DuplicateDetectionTest extends AbstractIntegrationTestWithDatabase try { potentialDuplicates = duplicateDetectionService.getPotentialDuplicates(context, item4); } catch (SearchServiceException e) { - fail("Duplicate search with special characters should NOT result in search exception (" + e.getMessage() + ")"); + fail("Duplicate search with special characters should NOT result in search exception (" + + e.getMessage() + ")"); } // Make sure result list is size 1 @@ -256,7 +258,8 @@ public class DuplicateDetectionTest extends AbstractIntegrationTestWithDatabase //indexingService.commit(); context.restoreAuthSystemState(); context.setCurrentUser(admin); - List potentialDuplicates = duplicateDetectionService.getPotentialDuplicates(context, workflowItem1.getItem()); + List potentialDuplicates = + duplicateDetectionService.getPotentialDuplicates(context, workflowItem1.getItem()); // Make sure result list is size 1 int size = 1; diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/DuplicateDetectionRestIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/DuplicateDetectionRestIT.java index 645c0e258f..2de08c87c2 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/DuplicateDetectionRestIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/DuplicateDetectionRestIT.java @@ -7,11 +7,17 @@ */ package org.dspace.app.rest; -import javax.ws.rs.core.MediaType; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.MediaType; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -45,12 +51,6 @@ import org.hamcrest.Matchers; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - /** * Test item link and section data REST endpoints for duplicate detection. * @see DuplicateDetectionTest (dspace-api) for lower level integration tests. @@ -408,13 +408,15 @@ public class DuplicateDetectionRestIT extends AbstractControllerIntegrationTest String reviewerToken = getAuthToken(admin.getEmail(), password); // The reviewer should be able to see the workflow item as a potential duplicate of the test item - getClient(reviewerToken).perform(get("/api/core/items/" + workflowItem1.getItem().getID() + "/duplicates")) + getClient(reviewerToken).perform(get("/api/core/items/" + workflowItem1.getItem().getID() + + "/duplicates")) .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) // Valid duplicates array .andExpect(jsonPath("$._embedded.duplicates", Matchers.hasSize(1))) // UUID of only array member matches the new workflow item ID - .andExpect(jsonPath("$._embedded.duplicates[0].uuid").value(workflowItem2.getItem().getID().toString())); + .andExpect(jsonPath("$._embedded.duplicates[0].uuid") + .value(workflowItem2.getItem().getID().toString())); // Another random user will NOT see this getClient(getAuthToken(anotherEPerson.getEmail(), password))