From 43d9ce2f2535e4720ff7388ba982b3ae66872d69 Mon Sep 17 00:00:00 2001 From: Nikita Krivonosov Date: Thu, 3 Oct 2024 12:31:53 +0200 Subject: [PATCH] [DSC-1935] added IT in ReferCrosswalkIT --- .../publication-virtual-place-datacite.xml | 32 +++++++++ ...tion-without-authors-and-type-datacite.xml | 31 ++++++++ .../crosswalks/ReferCrosswalkIT.java | 70 +++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 dspace-api/src/test/data/dspaceFolder/assetstore/crosswalk/publication-virtual-place-datacite.xml create mode 100644 dspace-api/src/test/data/dspaceFolder/assetstore/crosswalk/publication-without-authors-and-type-datacite.xml diff --git a/dspace-api/src/test/data/dspaceFolder/assetstore/crosswalk/publication-virtual-place-datacite.xml b/dspace-api/src/test/data/dspaceFolder/assetstore/crosswalk/publication-virtual-place-datacite.xml new file mode 100644 index 000000000000..3642b8acd8f4 --- /dev/null +++ b/dspace-api/src/test/data/dspaceFolder/assetstore/crosswalk/publication-virtual-place-datacite.xml @@ -0,0 +1,32 @@ + + + + + (:unav) + + + + Publication title + + Publisher + 2023 + + 2023 + 2023-10-20 + + it + + Unknown + + + http://localhost:4000/handle/123456789/99999 + + + + + + \ No newline at end of file diff --git a/dspace-api/src/test/data/dspaceFolder/assetstore/crosswalk/publication-without-authors-and-type-datacite.xml b/dspace-api/src/test/data/dspaceFolder/assetstore/crosswalk/publication-without-authors-and-type-datacite.xml new file mode 100644 index 000000000000..6a374a20c58e --- /dev/null +++ b/dspace-api/src/test/data/dspaceFolder/assetstore/crosswalk/publication-without-authors-and-type-datacite.xml @@ -0,0 +1,31 @@ + + + + + (:unav) + + + + Publication title + + Publisher + 2023 + + 2023 + 2023-10-20 + + + Unknown + + + http://localhost:4000/handle/123456789/99999 + + + + + + diff --git a/dspace-api/src/test/java/org/dspace/content/integration/crosswalks/ReferCrosswalkIT.java b/dspace-api/src/test/java/org/dspace/content/integration/crosswalks/ReferCrosswalkIT.java index e9f410df8bb5..9214b35f7400 100644 --- a/dspace-api/src/test/java/org/dspace/content/integration/crosswalks/ReferCrosswalkIT.java +++ b/dspace-api/src/test/java/org/dspace/content/integration/crosswalks/ReferCrosswalkIT.java @@ -2606,6 +2606,76 @@ public void testReferCrosswalkPublicationDataciteXml() throws Exception { } + @Test + public void testReferCrosswalkPublicationDataciteXmlWithoutTypeAndAuthor() throws Exception { + + ReferCrosswalk referCrosswalk = new DSpace().getServiceManager() + .getServiceByName("referCrosswalkPublicationDataciteXml", ReferCrosswalk.class); + assertThat(referCrosswalk, notNullValue()); + + Item publisher = createItem(context, collection) + .withEntityType("OrgUnit") + .withTitle("Publisher Name") + .withOrgUnitRORIdentifier("rorID2") + .build(); + Item item = createItem(context, collection) + .withEntityType("Publication") + .withTitle("Publication title") + .withPublisher("Publisher", publisher.getID().toString()) + .withIssueDate("2023") + .withDateAvailable("2023-10-20") + .withHandle("123456789/99999") + .build(); + + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + + referCrosswalk.disseminate(context, item, byteArrayOutputStream); + + System.out.println(new String(byteArrayOutputStream.toByteArray())); + + try (FileInputStream fis = getFileInputStream("publication-without-authors-and-type-datacite.xml")) { + String expectedXml = IOUtils.toString(fis, Charset.defaultCharset()); + compareEachLine(byteArrayOutputStream.toString(), expectedXml); + } + + } + + @Test + public void testReferCrosswalkPublicationDataciteXmlWithVirtualPlace() throws Exception { + + ReferCrosswalk referCrosswalk = new DSpace().getServiceManager() + .getServiceByName("referCrosswalkPublicationDataciteXml", ReferCrosswalk.class); + assertThat(referCrosswalk, notNullValue()); + + Item publisher = createItem(context, collection) + .withEntityType("OrgUnit") + .withTitle("Publisher Name") + .withOrgUnitRORIdentifier("rorID2") + .build(); + Item item = createItem(context, collection) + .withEntityType("Publication") + .withTitle("Publication title") + .withPublisher("Publisher", publisher.getID().toString()) + .withIssueDate("2023") + .withLanguage(Locale.ITALIAN.getLanguage()) + .withLanguage(Locale.ENGLISH.getLanguage()) + .withDateAvailable("2023-10-20") + .withHandle("123456789/99999") + .build(); + + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + + referCrosswalk.disseminate(context, item, byteArrayOutputStream); + + System.out.println(new String(byteArrayOutputStream.toByteArray())); + + try (FileInputStream fis = getFileInputStream("publication-virtual-place-datacite.xml")) { + String expectedXml = IOUtils.toString(fis, Charset.defaultCharset()); + compareEachLine(byteArrayOutputStream.toString(), expectedXml); + } + + } + @Test public void testExportToDataciteFormatItemWithThreeDOI() throws Exception { String prefix;