From 93a99843f4b5d0f93df183d5f18da13c3aee8093 Mon Sep 17 00:00:00 2001 From: Nikita Krivonosov Date: Thu, 21 Mar 2024 16:24:17 +0100 Subject: [PATCH 1/2] [DSC-1586] - Validation errors are not displayed on submission fields visible only in workflow --- .../dspace/validation/MetadataValidator.java | 12 +- .../dspaceFolder/config/item-submission.xml | 12 ++ .../config/spring/api/edititem-service.xml | 13 ++ .../dspaceFolder/config/submission-forms.xml | 204 ++++++++++++++++++ .../app/rest/EditItemRestRepositoryIT.java | 119 ++++++++++ .../rest/WorkflowItemRestRepositoryIT.java | 159 ++++++++++++++ .../rest/WorkspaceItemRestRepositoryIT.java | 131 +++++++++++ 7 files changed, 646 insertions(+), 4 deletions(-) diff --git a/dspace-api/src/main/java/org/dspace/validation/MetadataValidator.java b/dspace-api/src/main/java/org/dspace/validation/MetadataValidator.java index d53b939ee44a..3be35da792c6 100644 --- a/dspace-api/src/main/java/org/dspace/validation/MetadataValidator.java +++ b/dspace-api/src/main/java/org/dspace/validation/MetadataValidator.java @@ -34,6 +34,7 @@ import org.dspace.core.exception.SQLRuntimeException; import org.dspace.services.ConfigurationService; import org.dspace.validation.model.ValidationError; +import org.dspace.workflow.WorkflowItem; /** * Execute three validation check on fields validation: - mandatory metadata @@ -100,12 +101,13 @@ public List validate(Context context, InProgressSubmission o } else { validateMetadataValues(obj.getCollection(), mdv, input, config, isAuthorityControlled, fieldKey, errors); - if (mdv.size() > 0 && input.isVisible(DCInput.SUBMISSION_SCOPE)) { + if (mdv.size() > 0 && (input.isVisible(DCInput.SUBMISSION_SCOPE) || + input.isVisible(DCInput.WORKFLOW_SCOPE))) { foundResult = true; } } } - if (input.isRequired() && ! foundResult) { + if (input.isRequired() && !foundResult) { // for this required qualdrop no value was found, add to the list of error fields addError(errors, ERROR_VALIDATION_REQUIRED, "/" + OPERATION_PATH_SECTIONS + "/" + config.getId() + "/" + @@ -139,8 +141,10 @@ public List validate(Context context, InProgressSubmission o } validateMetadataValues(obj.getCollection(), mdv, input, config, isAuthorityControlled, fieldKey, errors); - if ((input.isRequired() && mdv.size() == 0) && input.isVisible(DCInput.SUBMISSION_SCOPE) - && !valuesRemoved) { + if ((input.isRequired() && mdv.size() == 0) + && (input.isVisible(DCInput.SUBMISSION_SCOPE) + || (obj instanceof WorkflowItem && input.isVisible(DCInput.WORKFLOW_SCOPE))) + && !valuesRemoved) { // Is the input required for *this* type? In other words, are we looking at a required // input that is also allowed for this document type if (input.isAllowedFor(documentType)) { diff --git a/dspace-api/src/test/data/dspaceFolder/config/item-submission.xml b/dspace-api/src/test/data/dspaceFolder/config/item-submission.xml index d94d1145ee45..8a951d26b9e2 100644 --- a/dspace-api/src/test/data/dspaceFolder/config/item-submission.xml +++ b/dspace-api/src/test/data/dspaceFolder/config/item-submission.xml @@ -295,6 +295,11 @@ org.dspace.app.rest.submit.step.DescribeStep submission-form + + submit.progressbar.describe.funding + org.dspace.app.rest.submit.step.DescribeStep + submission-form + @@ -479,6 +484,13 @@ + + + + + + + diff --git a/dspace-api/src/test/data/dspaceFolder/config/spring/api/edititem-service.xml b/dspace-api/src/test/data/dspaceFolder/config/spring/api/edititem-service.xml index 787bb5ebdd5a..18a84e44b2fc 100644 --- a/dspace-api/src/test/data/dspaceFolder/config/spring/api/edititem-service.xml +++ b/dspace-api/src/test/data/dspaceFolder/config/spring/api/edititem-service.xml @@ -145,6 +145,19 @@ + + + + + + + ADMIN + + + + + + diff --git a/dspace-api/src/test/data/dspaceFolder/config/submission-forms.xml b/dspace-api/src/test/data/dspaceFolder/config/submission-forms.xml index 15c3574951d9..d88a7555fa4d 100644 --- a/dspace-api/src/test/data/dspaceFolder/config/submission-forms.xml +++ b/dspace-api/src/test/data/dspaceFolder/config/submission-forms.xml @@ -2360,6 +2360,79 @@ it, please enter the types and the actual numbers or codes. + +
+ + + dc + title + + onebox + false + You must enter the oganization name. + + + +
+ +
+ + + dc + title + + onebox + false + You must enter the project title + + + + + + oairecerif + funder + + inline-group + true + You must enter financing information + + + +
+ +
+ + + oairecerif + funder + + onebox + false + You must enter the funder + + + + + oairecerif + amount + + onebox + false + + + + + oairecerif + amount + currency + + dropdown + false + + + + +
@@ -2803,6 +2876,137 @@ it, please enter the types and the actual numbers or codes. + + + Swiss franc + Swiss franc + + + Euro + Euro + + + US dollar + US dollar + + + Albanian lek + Albanian lek + + + Armenian dram + Armenian dram + + + Azerbaijan manat + Azerbaijan manat + + + Belarusian ruble + Belarusian ruble + + + Bosnia and Herzegovina convertible mark + Bosnia and Herzegovina convertible mark + + + Bulgarian lev + Bulgarian lev + + + Croatian kuna + Croatian kuna + + + Czech koruna + Czech koruna + + + Danish krone + Danish krone + + + Faroese krona + Faroese krona + + + Georgian lari + Georgian lari + + + Gibraltar pound + Gibraltar pound + + + Guernsey pound + Guernsey pound + + + Hungarian forint + Hungarian forint + + + Icelandic krona + Icelandic krona + + + Manx pound + Manx pound + + + Jersey pound + Jersey pound + + + Kazakhstani tenge + Kazakhstani tenge + + + Moldovan leu + Moldovan leu + + + Macedonian denar + Macedonian denar + + + Norwegian krone + Norwegian krone + + + Polish zloty + Polish zloty + + + Romanian leu + Romanian leu + + + Russian ruble + Russian ruble + + + Serbian dinar + Serbian dinar + + + Swedish krona + Swedish krona + + + Turkish lira + Turkish lira + + + Ukrainian hryvnia + Ukrainian hryvnia + + + Pound sterling + Pound sterling + + + diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/EditItemRestRepositoryIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/EditItemRestRepositoryIT.java index 7a511f662fc3..3e8a8e18b44d 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/EditItemRestRepositoryIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/EditItemRestRepositoryIT.java @@ -1951,6 +1951,125 @@ public void testValidationWithHiddenSteps() throws Exception { .andExpect(jsonPath("$.errors[0].paths", contains("/sections/test-outside-workflow-hidden/dc.title"))); } + @Test + public void testPatchWithValidationErrors3213() throws Exception { + context.turnOffAuthorisationSystem(); + + parentCommunity = CommunityBuilder.createCommunity(context) + .withName("Parent Community") + .build(); + + Collection collection = CollectionBuilder.createCollection(context, parentCommunity) + .withEntityType("Funding") + .withSubmissionDefinition("modeA") + .withName("Collection 1") + .build(); + + Collection orgunitCollection = CollectionBuilder.createCollection(context, parentCommunity) + .withName("Collection 1") + .withEntityType("OrgUnit") + .withSubmissionDefinition("orgunit") + .build(); + + Item itemA = ItemBuilder.createItem(context, collection) + .withTitle("Title item") + .withIssueDate("2015-06-25") + .withAuthor("Wayne, Bruce") + .grantLicense() + .build(); + + Item orgUnit = ItemBuilder.createItem(context, orgunitCollection) + .withTitle("OrgUnit") + .withIssueDate("1957") + .grantLicense() + .build(); + + EditItem editItem = new EditItem(context, itemA); + + context.restoreAuthSystemState(); + + String tokenAdmin = getAuthToken(admin.getEmail(), password); + + List list = new ArrayList<>(); + List> funderValues = new ArrayList<>(); + Map funderValuesMap = new HashMap<>(); + List> currencyValues = new ArrayList<>(); + Map currencyMap = new HashMap<>(); + List> amountValues = new ArrayList<>(); + Map amountMap = new HashMap<>(); + funderValuesMap.put("value", "OrgUnit"); + funderValuesMap.put("authority", orgUnit.getID().toString()); + funderValues.add(funderValuesMap); + currencyMap.put("value", "Euro"); + currencyValues.add(currencyMap); + amountMap.put("value", "12312"); + amountValues.add(amountMap); + list.add(new AddOperation("/sections/funding/oairecerif.funder", funderValues)); + list.add(new AddOperation("/sections/funding/oairecerif.amount.currency", currencyValues)); + list.add(new AddOperation("/sections/funding/oairecerif.amount", amountValues)); + + String patchBody = getPatchContent(list); + getClient(tokenAdmin).perform(patch("/api/core/edititems/" + editItem.getID() + ":FIRST") + .content(patchBody) + .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.sections.funding['oairecerif.funder'][0].value", + is("OrgUnit"))) + .andExpect(jsonPath("$.sections.funding['oairecerif.funder'][0].authority", + is(orgUnit.getID().toString()))) + .andExpect(jsonPath("$.sections.funding['oairecerif.amount.currency'][0].value", + is("Euro"))) + .andExpect(jsonPath("$.sections.funding['oairecerif.amount'][0].value", + is("12312"))); + } + + @Test + public void testPatchWithValidationErrors32() throws Exception { + context.turnOffAuthorisationSystem(); + + parentCommunity = CommunityBuilder.createCommunity(context) + .withName("Parent Community") + .build(); + + Collection collection = CollectionBuilder.createCollection(context, parentCommunity) + .withEntityType("Funding") + .withSubmissionDefinition("modeA") + .withName("Collection 1") + .build(); + + Item itemA = ItemBuilder.createItem(context, collection) + .withIssueDate("2015-06-25") + .withAuthor("Wayne, Bruce") + .grantLicense() + .build(); + + EditItem editItem = new EditItem(context, itemA); + + context.restoreAuthSystemState(); + + String tokenAdmin = getAuthToken(admin.getEmail(), password); + + List list = new ArrayList<>(); + List> currencyValues = new ArrayList<>(); + Map currencyMap = new HashMap<>(); + List> amountValues = new ArrayList<>(); + Map amountMap = new HashMap<>(); + currencyMap.put("value", "Euro"); + currencyValues.add(currencyMap); + amountMap.put("value", "12312"); + amountValues.add(amountMap); + list.add(new AddOperation("/sections/funding/oairecerif.amount.currency", currencyValues)); + list.add(new AddOperation("/sections/funding/oairecerif.amount", amountValues)); + + String patchBody = getPatchContent(list); + getClient(tokenAdmin).perform(patch("/api/core/edititems/" + editItem.getID() + ":FIRST") + .content(patchBody) + .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) + .andExpect(status().isUnprocessableEntity()) + .andExpect(jsonPath("$.[0].message", is("error.validation.required"))) + .andExpect(jsonPath("$.[0].paths[0]", is("/sections/funding/dc.title"))); + } + private Bitstream getBitstream(Item item, String name) throws SQLException { return bitstreamService.getBitstreamByName(item, "ORIGINAL", name); } diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/WorkflowItemRestRepositoryIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/WorkflowItemRestRepositoryIT.java index 026a8d956544..ea4ed736a12f 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/WorkflowItemRestRepositoryIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/WorkflowItemRestRepositoryIT.java @@ -15,6 +15,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; @@ -2707,4 +2708,162 @@ public void testValidationWithHiddenSteps() throws Exception { .andExpect(jsonPath("$.errors[0].paths", contains("/sections/test-outside-workflow-hidden/dc.title"))); } + @Test + /** + * Test the addition of metadata + * + * @throws Exception + */ + public void patchAddMetadataToInlineGroupTypeMetadataShouldReturnErrorsTest() throws Exception { + context.turnOffAuthorisationSystem(); + + //** GIVEN ** + //1. A community with one collection. + parentCommunity = CommunityBuilder.createCommunity(context) + .withName("Parent Community") + .build(); + Collection col1 = CollectionBuilder.createCollection(context, parentCommunity) + .withName("Collection 1") + .withEntityType("Funding") + .withWorkflowGroup(1, eperson).build(); + + //2. create a normal user to use as submitter + EPerson submitter = EPersonBuilder.createEPerson(context) + .withEmail("submitter@example.com") + .withPassword("dspace") + .build(); + + context.setCurrentUser(submitter); + + //3. a claimed task with workflow item in edit step + ClaimedTask claimedTask = ClaimedTaskBuilder.createClaimedTask(context, col1, eperson) + .withIssueDate("2017-10-17") + .withSubject("ExtraEntry") + .grantLicense() + .build(); + claimedTask.setStepID("editstep"); + claimedTask.setActionID("editaction"); + XmlWorkflowItem witem = claimedTask.getWorkflowItem(); + + context.restoreAuthSystemState(); + + String authToken = getAuthToken(eperson.getEmail(), password); + + List list = new ArrayList<>(); + List> currencyValues = new ArrayList<>(); + Map currencyMap = new HashMap<>(); + List> amountValues = new ArrayList<>(); + Map amountMap = new HashMap<>(); + currencyMap.put("value", "Euro"); + currencyValues.add(currencyMap); + amountMap.put("value", "12312"); + amountValues.add(amountMap); + list.add(new AddOperation("/sections/funding/oairecerif.amount.currency", currencyValues)); + list.add(new AddOperation("/sections/funding/oairecerif.amount", amountValues)); + + String patchBody = getPatchContent(list); + getClient(authToken).perform(patch("/api/workflow/workflowitems/" + witem.getID()) + .content(patchBody) + .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.errors[?(@.message=='error.validation.required')]", + contains( + hasJsonPath("$.paths", containsInAnyOrder( + hasJsonPath("$", Matchers.is("/sections/funding/dc.title")), + hasJsonPath("$", Matchers.is("/sections/funding/oairecerif.funder")) + ))))) + .andExpect(jsonPath("$.sections.funding['oairecerif.amount.currency'][0].value", + is("Euro"))) + .andExpect(jsonPath("$.sections.funding['oairecerif.amount'][0].value", + is("12312"))); + + } + + @Test + /** + * Test the addition of metadata + * + * @throws Exception + */ + public void patchAddMetadataToInlineGroupTypeMetadataShouldCompletedWithoutErrorsTest() throws Exception { + context.turnOffAuthorisationSystem(); + + //** GIVEN ** + //1. A community with one collection. + parentCommunity = CommunityBuilder.createCommunity(context) + .withName("Parent Community") + .build(); + Collection col1 = CollectionBuilder.createCollection(context, parentCommunity) + .withName("Collection 1") + .withEntityType("Funding") + .withWorkflowGroup(1, eperson).build(); + + //2. create a normal user to use as submitter + EPerson submitter = EPersonBuilder.createEPerson(context) + .withEmail("submitter@example.com") + .withPassword("dspace") + .build(); + + Collection orgunitCollection = CollectionBuilder.createCollection(context, parentCommunity) + .withName("Collection 1") + .withEntityType("OrgUnit") + .withSubmissionDefinition("orgunit") + .build(); + + context.setCurrentUser(submitter); + + Item orgUnit = ItemBuilder.createItem(context, orgunitCollection) + .withTitle("OrgUnit") + .withIssueDate("1957") + .build(); + + //3. a claimed task with workflow item in edit step + ClaimedTask claimedTask = ClaimedTaskBuilder.createClaimedTask(context, col1, eperson) + .withTitle("Title") + .withIssueDate("2017-10-17") + .withSubject("ExtraEntry") + .grantLicense() + .build(); + claimedTask.setStepID("editstep"); + claimedTask.setActionID("editaction"); + XmlWorkflowItem witem = claimedTask.getWorkflowItem(); + + context.restoreAuthSystemState(); + + String authToken = getAuthToken(eperson.getEmail(), password); + + List list = new ArrayList<>(); + List> funderValues = new ArrayList<>(); + Map funderValuesMap = new HashMap<>(); + List> currencyValues = new ArrayList<>(); + Map currencyMap = new HashMap<>(); + List> amountValues = new ArrayList<>(); + Map amountMap = new HashMap<>(); + funderValuesMap.put("value", "OrgUnit"); + funderValuesMap.put("authority", orgUnit.getID().toString()); + funderValues.add(funderValuesMap); + currencyMap.put("value", "Euro"); + currencyValues.add(currencyMap); + amountMap.put("value", "12312"); + amountValues.add(amountMap); + list.add(new AddOperation("/sections/funding/oairecerif.funder", funderValues)); + list.add(new AddOperation("/sections/funding/oairecerif.amount.currency", currencyValues)); + list.add(new AddOperation("/sections/funding/oairecerif.amount", amountValues)); + + String patchBody = getPatchContent(list); + getClient(authToken).perform(patch("/api/workflow/workflowitems/" + witem.getID()) + .content(patchBody) + .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.errors").doesNotExist()) + .andExpect(jsonPath("$.sections.funding['oairecerif.funder'][0].value", + is("OrgUnit"))) + .andExpect(jsonPath("$.sections.funding['oairecerif.funder'][0].authority", + is(orgUnit.getID().toString()))) + .andExpect(jsonPath("$.sections.funding['oairecerif.amount.currency'][0].value", + is("Euro"))) + .andExpect(jsonPath("$.sections.funding['oairecerif.amount'][0].value", + is("12312")));; + } + } diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/WorkspaceItemRestRepositoryIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/WorkspaceItemRestRepositoryIT.java index c6b4821a950f..f895f5f3967b 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/WorkspaceItemRestRepositoryIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/WorkspaceItemRestRepositoryIT.java @@ -10155,4 +10155,135 @@ public void patchBySupervisorTest() throws Exception { "ExtraEntry") ))); } + + @Test + public void patchAddMetadataToInlineGroupTypeMetadataShouldCompletedWithoutErrorsTest() throws Exception { + context.turnOffAuthorisationSystem(); + + parentCommunity = CommunityBuilder.createCommunity(context) + .withName("Parent Community") + .build(); + Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity) + .withName("Sub Community") + .build(); + Collection col1 = CollectionBuilder.createCollection(context, child1) + .withName("Collection 1") + .withEntityType("Funding") + .withSubmissionDefinition("funding") + .build(); + + Collection orgunitCollection = CollectionBuilder.createCollection(context, child1) + .withName("Collection 1") + .withEntityType("OrgUnit") + .withSubmissionDefinition("orgunit") + .build(); + + String authToken = getAuthToken(eperson.getEmail(), password); + + Item orgUnit = ItemBuilder.createItem(context, orgunitCollection) + .withTitle("OrgUnit") + .withIssueDate("1957") + .build(); + + WorkspaceItem witem = WorkspaceItemBuilder.createWorkspaceItem(context, col1) + .withTitle("Test witem") + .withIssueDate("2017-10-17") + .withSubject("ExtraEntry") + .grantLicense() + .build(); + + //disable file upload mandatory + configurationService.setProperty("webui.submit.upload.required", false); + + context.restoreAuthSystemState(); + + List list = new ArrayList<>(); + List> funderValues = new ArrayList<>(); + Map funderValuesMap = new HashMap<>(); + List> currencyValues = new ArrayList<>(); + Map currencyMap = new HashMap<>(); + List> amountValues = new ArrayList<>(); + Map amountMap = new HashMap<>(); + funderValuesMap.put("value", "OrgUnit"); + funderValuesMap.put("authority", orgUnit.getID().toString()); + funderValues.add(funderValuesMap); + currencyMap.put("value", "Euro"); + currencyValues.add(currencyMap); + amountMap.put("value", "12312"); + amountValues.add(amountMap); + list.add(new AddOperation("/sections/funding/oairecerif.funder", funderValues)); + list.add(new AddOperation("/sections/funding/oairecerif.amount.currency", currencyValues)); + list.add(new AddOperation("/sections/funding/oairecerif.amount", amountValues)); + + String patchBody = getPatchContent(list); + getClient(authToken).perform(patch("/api/submission/workspaceitems/" + witem.getID()) + .content(patchBody) + .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.sections.funding['oairecerif.funder'][0].value", + is("OrgUnit"))) + .andExpect(jsonPath("$.sections.funding['oairecerif.funder'][0].authority", + is(orgUnit.getID().toString()))) + .andExpect(jsonPath("$.sections.funding['oairecerif.amount.currency'][0].value", + is("Euro"))) + .andExpect(jsonPath("$.sections.funding['oairecerif.amount'][0].value", + is("12312"))); + } + + @Test + public void patchAddMetadataToInlineGroupTypeMetadataShouldReturnErrorsTest() throws Exception { + context.turnOffAuthorisationSystem(); + + parentCommunity = CommunityBuilder.createCommunity(context) + .withName("Parent Community") + .build(); + Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity) + .withName("Sub Community") + .build(); + Collection col1 = CollectionBuilder.createCollection(context, child1) + .withName("Collection 1") + .withEntityType("Funding") + .withSubmissionDefinition("funding") + .build(); + + String authToken = getAuthToken(eperson.getEmail(), password); + + WorkspaceItem witem = WorkspaceItemBuilder.createWorkspaceItem(context, col1) + .withTitle("Test witem") + .withIssueDate("2017-10-17") + .withSubject("ExtraEntry") + .grantLicense() + .build(); + + //disable file upload mandatory + configurationService.setProperty("webui.submit.upload.required", false); + + context.restoreAuthSystemState(); + + List list = new ArrayList<>(); + List> currencyValues = new ArrayList<>(); + Map currencyMap = new HashMap<>(); + List> amountValues = new ArrayList<>(); + Map amountMap = new HashMap<>(); + currencyMap.put("value", "Euro"); + currencyValues.add(currencyMap); + amountMap.put("value", "12312"); + amountValues.add(amountMap); + list.add(new AddOperation("/sections/funding/oairecerif.amount.currency", currencyValues)); + list.add(new AddOperation("/sections/funding/oairecerif.amount", amountValues)); + + String patchBody = getPatchContent(list); + getClient(authToken).perform(patch("/api/submission/workspaceitems/" + witem.getID()) + .content(patchBody) + .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) + .andExpect(jsonPath("$.errors[?(@.message=='error.validation.required')]", + contains( + hasJsonPath("$.paths", contains( + hasJsonPath("$", Matchers.is("/sections/funding/oairecerif.funder")) + ))))) + .andExpect(jsonPath("$.sections.funding['oairecerif.amount.currency'][0].value", + is("Euro"))) + .andExpect(jsonPath("$.sections.funding['oairecerif.amount'][0].value", + is("12312"))); + } } From c4978bae4581c449692b91740dc72527818fd4c3 Mon Sep 17 00:00:00 2001 From: Nikita Krivonosov Date: Fri, 22 Mar 2024 13:59:11 +0100 Subject: [PATCH 2/2] [DSC-1586] - Fix it tests --- .../SubmissionDefinitionsControllerIT.java | 14 ++++----- .../app/rest/SubmissionFormsControllerIT.java | 30 +++++++++---------- .../app/rest/VocabularyRestRepositoryIT.java | 5 ++-- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionDefinitionsControllerIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionDefinitionsControllerIT.java index 269de3aefb9d..743e7def3404 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionDefinitionsControllerIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionDefinitionsControllerIT.java @@ -321,10 +321,10 @@ public void findAllPaginationTest() throws Exception { Matchers.containsString("page=1"), Matchers.containsString("size=1")))) .andExpect(jsonPath("$._links.last.href", Matchers.allOf( Matchers.containsString("/api/config/submissiondefinitions?"), - Matchers.containsString("page=18"), Matchers.containsString("size=1")))) + Matchers.containsString("page=19"), Matchers.containsString("size=1")))) .andExpect(jsonPath("$.page.size", is(1))) - .andExpect(jsonPath("$.page.totalElements", is(19))) - .andExpect(jsonPath("$.page.totalPages", is(19))) + .andExpect(jsonPath("$.page.totalElements", is(20))) + .andExpect(jsonPath("$.page.totalPages", is(20))) .andExpect(jsonPath("$.page.number", is(0))); getClient(tokenAdmin).perform(get("/api/config/submissiondefinitions") @@ -332,7 +332,7 @@ public void findAllPaginationTest() throws Exception { .param("page", "1")) .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) - .andExpect(jsonPath("$._embedded.submissiondefinitions[0].id", is("patent"))) + .andExpect(jsonPath("$._embedded.submissiondefinitions[0].id", is("funding"))) .andExpect(jsonPath("$._links.first.href", Matchers.allOf( Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("page=0"), Matchers.containsString("size=1")))) @@ -347,10 +347,10 @@ public void findAllPaginationTest() throws Exception { Matchers.containsString("page=1"), Matchers.containsString("size=1")))) .andExpect(jsonPath("$._links.last.href", Matchers.allOf( Matchers.containsString("/api/config/submissiondefinitions?"), - Matchers.containsString("page=18"), Matchers.containsString("size=1")))) + Matchers.containsString("page=19"), Matchers.containsString("size=1")))) .andExpect(jsonPath("$.page.size", is(1))) - .andExpect(jsonPath("$.page.totalElements", is(19))) - .andExpect(jsonPath("$.page.totalPages", is(19))) + .andExpect(jsonPath("$.page.totalElements", is(20))) + .andExpect(jsonPath("$.page.totalPages", is(20))) .andExpect(jsonPath("$.page.number", is(1))); } diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionFormsControllerIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionFormsControllerIT.java index d817b573ff2b..c2201f5792f4 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionFormsControllerIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionFormsControllerIT.java @@ -73,8 +73,8 @@ public void findAll() throws Exception { .andExpect(content().contentType(contentType)) //The configuration file for the test env includes PAGE_TOTAL_ELEMENTS forms .andExpect(jsonPath("$.page.size", is(20))) - .andExpect(jsonPath("$.page.totalElements", equalTo(40))) - .andExpect(jsonPath("$.page.totalPages", equalTo(2))) + .andExpect(jsonPath("$.page.totalElements", equalTo(43))) + .andExpect(jsonPath("$.page.totalPages", equalTo(3))) .andExpect(jsonPath("$.page.number", is(0))) .andExpect( jsonPath("$._links.self.href", Matchers.startsWith(REST_SERVER_URL + "config/submissionforms"))) @@ -90,8 +90,8 @@ public void findAllWithNewlyCreatedAccountTest() throws Exception { .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$.page.size", is(20))) - .andExpect(jsonPath("$.page.totalElements", equalTo(40))) - .andExpect(jsonPath("$.page.totalPages", equalTo(2))) + .andExpect(jsonPath("$.page.totalElements", equalTo(43))) + .andExpect(jsonPath("$.page.totalPages", equalTo(3))) .andExpect(jsonPath("$.page.number", is(0))) .andExpect(jsonPath("$._links.self.href", Matchers.startsWith(REST_SERVER_URL + "config/submissionforms"))) @@ -670,10 +670,10 @@ public void findAllPaginationTest() throws Exception { Matchers.containsString("page=1"), Matchers.containsString("size=2")))) .andExpect(jsonPath("$._links.last.href", Matchers.allOf( Matchers.containsString("/api/config/submissionforms?"), - Matchers.containsString("page=19"), Matchers.containsString("size=2")))) + Matchers.containsString("page=21"), Matchers.containsString("size=2")))) .andExpect(jsonPath("$.page.size", is(2))) - .andExpect(jsonPath("$.page.totalElements", equalTo(40))) - .andExpect(jsonPath("$.page.totalPages", equalTo(20))) + .andExpect(jsonPath("$.page.totalElements", equalTo(43))) + .andExpect(jsonPath("$.page.totalPages", equalTo(22))) .andExpect(jsonPath("$.page.number", is(0))); getClient(tokenAdmin).perform(get("/api/config/submissionforms") @@ -681,8 +681,8 @@ public void findAllPaginationTest() throws Exception { .param("page", "15")) .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) - .andExpect(jsonPath("$._embedded.submissionforms[0].id", is("publication-dc-contributor-author"))) - .andExpect(jsonPath("$._embedded.submissionforms[1].id", is("publication-dc-contributor-editor"))) + .andExpect(jsonPath("$._embedded.submissionforms[0].id", is("traditionalpagethree-cris-collapsed"))) + .andExpect(jsonPath("$._embedded.submissionforms[1].id", is("orange"))) .andExpect(jsonPath("$._links.first.href", Matchers.allOf( Matchers.containsString("/api/config/submissionforms?"), Matchers.containsString("page=0"), Matchers.containsString("size=2")))) @@ -697,10 +697,10 @@ public void findAllPaginationTest() throws Exception { Matchers.containsString("page=16"), Matchers.containsString("size=2")))) .andExpect(jsonPath("$._links.last.href", Matchers.allOf( Matchers.containsString("/api/config/submissionforms?"), - Matchers.containsString("page=19"), Matchers.containsString("size=2")))) + Matchers.containsString("page=21"), Matchers.containsString("size=2")))) .andExpect(jsonPath("$.page.size", is(2))) - .andExpect(jsonPath("$.page.totalElements", equalTo(40))) - .andExpect(jsonPath("$.page.totalPages", equalTo(20))) + .andExpect(jsonPath("$.page.totalElements", equalTo(43))) + .andExpect(jsonPath("$.page.totalPages", equalTo(22))) .andExpect(jsonPath("$.page.number", is(15))); } @@ -744,10 +744,10 @@ public void visibilityTest() throws Exception { Matchers.containsString("page=4"), Matchers.containsString("size=2")))) .andExpect(jsonPath("$._links.last.href", Matchers.allOf( Matchers.containsString("/api/config/submissionforms?"), - Matchers.containsString("page=19"), Matchers.containsString("size=2")))) + Matchers.containsString("page=21"), Matchers.containsString("size=2")))) .andExpect(jsonPath("$.page.size", is(2))) - .andExpect(jsonPath("$.page.totalElements", equalTo(40))) - .andExpect(jsonPath("$.page.totalPages", equalTo(20))) + .andExpect(jsonPath("$.page.totalElements", equalTo(43))) + .andExpect(jsonPath("$.page.totalPages", equalTo(22))) .andExpect(jsonPath("$.page.number", is(4))); } } diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/VocabularyRestRepositoryIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/VocabularyRestRepositoryIT.java index 1eedda87f990..59fddc0e5fbf 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/VocabularyRestRepositoryIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/VocabularyRestRepositoryIT.java @@ -164,11 +164,12 @@ public void findAllTest() throws Exception { VocabularyMatcher.matchProperties("SolrAuthorAuthority", "SolrAuthorAuthority", false, false), VocabularyMatcher.matchProperties("SRJournalTitle", "SRJournalTitle", false, false), VocabularyMatcher.matchProperties("common_types", "common_types", true, false), - VocabularyMatcher.matchProperties("publication-coar-types", "publication-coar-types", false, true) + VocabularyMatcher.matchProperties("publication-coar-types", "publication-coar-types", false, true), + VocabularyMatcher.matchProperties("currency", "currency", true, false) ))) .andExpect(jsonPath("$._links.self.href", Matchers.containsString("api/submission/vocabularies"))) - .andExpect(jsonPath("$.page.totalElements", is(10))); + .andExpect(jsonPath("$.page.totalElements", is(11))); } @Test