Skip to content

Commit

Permalink
registration cleanup modification
Browse files Browse the repository at this point in the history
  • Loading branch information
Paurikova2 committed Oct 23, 2024
1 parent eeeb108 commit f1cc579
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,6 +76,18 @@ public void cleanup() throws Exception {
clarinUserMetadata = c.reloadEntity(clarinUserMetadata);
clarinUserMetadataService.delete(c, clarinUserMetadata);
}

List<ClarinLicense> clarinLicenses = clarinUserRegistration.getClarinLicenses();
for (ClarinLicense license : clarinLicenses) {
license = c.reloadEntity(license);
clarinLicenseService.delete(c, license);
}

List<ClarinLicenseResourceUserAllowance> licenseResourceUserAllowances = clarinUserRegistration.getLicenseResourceUserAllowances();
for (ClarinLicenseResourceUserAllowance resourceUserAllowance : licenseResourceUserAllowances) {
resourceUserAllowance = c.reloadEntity(resourceUserAllowance);
clarinLicenseResourceUserAllowanceService.delete(c, resourceUserAllowance);
}
}
delete(c, clarinUserRegistration);
c.complete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f1cc579

Please sign in to comment.