From f1cc5796cfab20e603931a8de976a131f6255518 Mon Sep 17 00:00:00 2001 From: Paurikova2 Date: Wed, 23 Oct 2024 09:30:09 +0200 Subject: [PATCH] registration cleanup modification --- .../builder/ClarinUserRegistrationBuilder.java | 14 ++++++++++++++ .../rest/ClarinUserMetadataImportControllerIT.java | 9 --------- .../rest/ClarinUserMetadataRestControllerIT.java | 11 ----------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/dspace-api/src/test/java/org/dspace/builder/ClarinUserRegistrationBuilder.java b/dspace-api/src/test/java/org/dspace/builder/ClarinUserRegistrationBuilder.java index d9e57addf4ea..d1595cd46cb9 100644 --- a/dspace-api/src/test/java/org/dspace/builder/ClarinUserRegistrationBuilder.java +++ b/dspace-api/src/test/java/org/dspace/builder/ClarinUserRegistrationBuilder.java @@ -13,6 +13,8 @@ import java.util.UUID; import org.dspace.authorize.AuthorizeException; +import org.dspace.content.clarin.ClarinLicense; +import org.dspace.content.clarin.ClarinLicenseResourceUserAllowance; import org.dspace.content.clarin.ClarinUserMetadata; import org.dspace.content.clarin.ClarinUserRegistration; import org.dspace.content.service.clarin.ClarinUserRegistrationService; @@ -74,6 +76,18 @@ public void cleanup() throws Exception { clarinUserMetadata = c.reloadEntity(clarinUserMetadata); clarinUserMetadataService.delete(c, clarinUserMetadata); } + + List clarinLicenses = clarinUserRegistration.getClarinLicenses(); + for (ClarinLicense license : clarinLicenses) { + license = c.reloadEntity(license); + clarinLicenseService.delete(c, license); + } + + List licenseResourceUserAllowances = clarinUserRegistration.getLicenseResourceUserAllowances(); + for (ClarinLicenseResourceUserAllowance resourceUserAllowance : licenseResourceUserAllowances) { + resourceUserAllowance = c.reloadEntity(resourceUserAllowance); + clarinLicenseResourceUserAllowanceService.delete(c, resourceUserAllowance); + } } delete(c, clarinUserRegistration); c.complete(); diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/ClarinUserMetadataImportControllerIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/ClarinUserMetadataImportControllerIT.java index 91187884f528..224a625af387 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/ClarinUserMetadataImportControllerIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/ClarinUserMetadataImportControllerIT.java @@ -159,9 +159,6 @@ public void importUserMetadataWithEpersonTest() throws Exception { assertEquals(clarinUserMetadata.getTransaction().getCreatedOn().getTime(), getDateFromString("2012-09-19T10:30:03.741633").getTime()); assertEquals(clarinUserMetadata.getTransaction().getToken(), "111"); - - //clean all - ClarinUserMetadataBuilder.deleteClarinUserMetadata(clarinUserRegistration.getID()); } @Test @@ -206,9 +203,6 @@ public void importUserMetadataWithoutEpersonTest() throws Exception { assertEquals(clarinUserMetadata.getTransaction().getCreatedOn().getTime(), getDateFromString("2012-09-19T10:30:03.741633").getTime()); assertEquals(clarinUserMetadata.getTransaction().getToken(), "111"); - - //clean all - ClarinUserMetadataBuilder.deleteClarinUserMetadata(clarinUserRegistration.getID()); } // The user metadata shouldn't be updated, but it should be added @@ -266,9 +260,6 @@ public void importTwoTimesUserMetadataWithEpersonTest() throws Exception { assertEquals(clarinUserMetadata.getTransaction().getCreatedOn().getTime(), getDateFromString("2012-09-19T10:30:03.741633").getTime()); assertEquals(clarinUserMetadata.getTransaction().getToken(), "111"); - - //clean all - ClarinUserMetadataBuilder.deleteClarinUserMetadata(clarinUserRegistration.getID()); } /** diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/ClarinUserMetadataRestControllerIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/ClarinUserMetadataRestControllerIT.java index ed88186c33fa..a69baa74ce7a 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/ClarinUserMetadataRestControllerIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/ClarinUserMetadataRestControllerIT.java @@ -238,8 +238,6 @@ public void authorizedUserWithoutMetadata_shouldReturnToken() throws Exception { .contentType(contentType)) .andExpect(status().isOk()) .andExpect(jsonPath("$.page.totalElements", is(1))); - - ClarinUserMetadataBuilder.deleteClarinUserMetadata(clarinUserRegistration.getID()); } @Test @@ -292,8 +290,6 @@ public void authorizedUserWithoutMetadata_shouldSendEmail() throws Exception { .contentType(contentType)) .andExpect(status().isOk()) .andExpect(jsonPath("$.page.totalElements", is(1))); - - ClarinUserMetadataBuilder.deleteClarinUserMetadata(clarinUserRegistration.getID()); } @Test @@ -341,8 +337,6 @@ public void authorizedUserWithMetadata_shouldSendToken() throws Exception { .contentType(contentType)) .andExpect(status().isOk()) .andExpect(jsonPath("$.page.totalElements", is(1))); - - ClarinUserMetadataBuilder.deleteClarinUserMetadata(clarinUserRegistration.getID()); } @Test @@ -399,8 +393,6 @@ public void authorizedUserWithMetadata_shouldSendEmail() throws Exception { .contentType(contentType)) .andExpect(status().isOk()) .andExpect(jsonPath("$.page.totalElements", is(1))); - - ClarinUserMetadataBuilder.deleteClarinUserMetadata(clarinUserRegistration.getID()); } // Confirmation = 1 @@ -561,9 +553,6 @@ public void shouldNotCreateDuplicateUserMetadataBasedOnHistory() throws Exceptio .contentType(contentType)) .andExpect(status().isOk()) .andExpect(jsonPath("$.page.totalElements", is(2))); - - // Delete all created user metadata - clean test environment - ClarinUserMetadataBuilder.deleteClarinUserMetadata(clarinUserRegistration.getID()); } private WorkspaceItem createWorkspaceItemWithFile(boolean secondBitstream) {