mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-08 10:34:25 +00:00
taskid 77244 ItemMetadata caching bugfixes
This commit is contained in:
@@ -187,13 +187,38 @@ public class RelationshipMetadataServiceIT extends AbstractIntegrationTestWithDa
|
||||
public void testDeleteAuthorRelationshipCopyToLeftItem() throws Exception {
|
||||
initPublicationAuthor();
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
//verify the dc.contributor.author virtual metadata
|
||||
List<MetadataValue> authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
assertThat(authorList.size(), equalTo(1));
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
List<MetadataValue> plainMetadataAuthorList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getQualifier() != null &&
|
||||
metadataValue.getMetadataField().getQualifier().equals("author"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainMetadataAuthorList.size(), equalTo(0));
|
||||
|
||||
//verify there's no relation.isAuthorOfPublication actual metadata
|
||||
List<MetadataValue> plainRelationshipMetadataList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isAuthorOfPublication"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainRelationshipMetadataList.size(), equalTo(0));
|
||||
|
||||
//delete the relationship, copying the virtual metadata to actual metadata on the leftItem
|
||||
//leftItem is the publication
|
||||
relationshipService.delete(context, relationship, true, false);
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
List<MetadataValue> authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
plainMetadataAuthorList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getQualifier() != null &&
|
||||
metadataValue.getMetadataField().getQualifier().equals("author"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainMetadataAuthorList.size(), equalTo(1));
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
assertThat(authorList.size(), equalTo(1));
|
||||
assertThat(authorList.get(0).getValue(), equalTo("familyName, firstName"));
|
||||
assertThat(authorList.get(0).getMetadataField().getMetadataSchema().getName(), equalTo("dc"));
|
||||
@@ -201,10 +226,15 @@ public class RelationshipMetadataServiceIT extends AbstractIntegrationTestWithDa
|
||||
assertThat(authorList.get(0).getMetadataField().getQualifier(), equalTo("author"));
|
||||
assertNull(authorList.get(0).getAuthority());
|
||||
|
||||
//verify there's no relation.isAuthorOfPublication actual metadata
|
||||
//verify there's relation.isAuthorOfPublication actual metadata
|
||||
plainRelationshipMetadataList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isAuthorOfPublication"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainRelationshipMetadataList.size(), equalTo(1));
|
||||
//verify there's relation.isAuthorOfPublication actual metadata
|
||||
List<MetadataValue> relationshipMetadataList = itemService
|
||||
.getMetadata(leftItem, MetadataSchemaEnum.RELATION.getName(), "isAuthorOfPublication", null, Item.ANY);
|
||||
assertThat(relationshipMetadataList.size(), equalTo(0));
|
||||
assertThat(relationshipMetadataList.size(), equalTo(1));
|
||||
|
||||
//request the virtual metadata of the publication only
|
||||
List<RelationshipMetadataValue> list = relationshipMetadataService.getRelationshipMetadata(leftItem, true);
|
||||
@@ -399,13 +429,38 @@ public class RelationshipMetadataServiceIT extends AbstractIntegrationTestWithDa
|
||||
public void testDeleteAuthorRelationshipCopyToLeftItemFromDefaultInDb() throws Exception {
|
||||
initPublicationAuthorWithCopyParams(true, false);
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
//verify the dc.contributor.author virtual metadata
|
||||
List<MetadataValue> authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
assertThat(authorList.size(), equalTo(1));
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
List<MetadataValue> plainMetadataAuthorList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getQualifier() != null &&
|
||||
metadataValue.getMetadataField().getQualifier().equals("author"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainMetadataAuthorList.size(), equalTo(0));
|
||||
|
||||
//verify there's no relation.isAuthorOfPublication actual metadata
|
||||
List<MetadataValue> plainRelationshipMetadataList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isAuthorOfPublication"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainRelationshipMetadataList.size(), equalTo(0));
|
||||
|
||||
//delete the relationship, copying the virtual metadata to actual metadata on the leftItem
|
||||
//leftItem is the publication
|
||||
relationshipService.delete(context, relationship);
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
List<MetadataValue> authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
plainMetadataAuthorList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getQualifier() != null &&
|
||||
metadataValue.getMetadataField().getQualifier().equals("author"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainMetadataAuthorList.size(), equalTo(1));
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
assertThat(authorList.size(), equalTo(1));
|
||||
assertThat(authorList.get(0).getValue(), equalTo("familyName, firstName"));
|
||||
assertThat(authorList.get(0).getMetadataField().getMetadataSchema().getName(), equalTo("dc"));
|
||||
@@ -413,10 +468,15 @@ public class RelationshipMetadataServiceIT extends AbstractIntegrationTestWithDa
|
||||
assertThat(authorList.get(0).getMetadataField().getQualifier(), equalTo("author"));
|
||||
assertNull(authorList.get(0).getAuthority());
|
||||
|
||||
//verify there's no relation.isAuthorOfPublication actual metadata
|
||||
//verify there's relation.isAuthorOfPublication actual metadata
|
||||
plainRelationshipMetadataList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isAuthorOfPublication"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainRelationshipMetadataList.size(), equalTo(1));
|
||||
//verify there's relation.isAuthorOfPublication actual metadata
|
||||
List<MetadataValue> relationshipMetadataList = itemService
|
||||
.getMetadata(leftItem, MetadataSchemaEnum.RELATION.getName(), "isAuthorOfPublication", null, Item.ANY);
|
||||
assertThat(relationshipMetadataList.size(), equalTo(0));
|
||||
assertThat(relationshipMetadataList.size(), equalTo(1));
|
||||
|
||||
//request the virtual metadata of the publication only
|
||||
List<RelationshipMetadataValue> list = relationshipMetadataService.getRelationshipMetadata(leftItem, true);
|
||||
@@ -446,12 +506,36 @@ public class RelationshipMetadataServiceIT extends AbstractIntegrationTestWithDa
|
||||
public void testDeleteAuthorRelationshipCopyToBothItemsFromDefaultsInDb() throws Exception {
|
||||
initPublicationAuthorWithCopyParams(true, true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
//verify the dc.contributor.author virtual metadata
|
||||
List<MetadataValue> authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
assertThat(authorList.size(), equalTo(1));
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
List<MetadataValue> plainMetadataAuthorList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getQualifier() != null &&
|
||||
metadataValue.getMetadataField().getQualifier().equals("author"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainMetadataAuthorList.size(), equalTo(0));
|
||||
|
||||
//verify there's no relation.isAuthorOfPublication actual metadata
|
||||
List<MetadataValue> plainRelationshipMetadataList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isAuthorOfPublication"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainRelationshipMetadataList.size(), equalTo(0));
|
||||
|
||||
//delete the relationship, copying the virtual metadata to actual metadata on the both items
|
||||
relationshipService.delete(context, relationship);
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
List<MetadataValue> authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
plainMetadataAuthorList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getQualifier() != null &&
|
||||
metadataValue.getMetadataField().getQualifier().equals("author"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainMetadataAuthorList.size(), equalTo(1));
|
||||
|
||||
//verify the dc.contributor.author actual metadata
|
||||
authorList = itemService.getMetadata(leftItem, "dc", "contributor", "author", Item.ANY);
|
||||
assertThat(authorList.size(), equalTo(1));
|
||||
assertThat(authorList.get(0).getValue(), equalTo("familyName, firstName"));
|
||||
assertThat(authorList.get(0).getMetadataField().getMetadataSchema().getName(), equalTo("dc"));
|
||||
@@ -459,10 +543,15 @@ public class RelationshipMetadataServiceIT extends AbstractIntegrationTestWithDa
|
||||
assertThat(authorList.get(0).getMetadataField().getQualifier(), equalTo("author"));
|
||||
assertNull(authorList.get(0).getAuthority());
|
||||
|
||||
//verify there's no relation.isAuthorOfPublication actual metadata
|
||||
//verify there's relation.isAuthorOfPublication actual metadata
|
||||
plainRelationshipMetadataList = leftItem.getMetadata().stream()
|
||||
.filter(metadataValue -> metadataValue.getMetadataField().getElement().equals("isAuthorOfPublication"))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(plainRelationshipMetadataList.size(), equalTo(1));
|
||||
//verify there's relation.isAuthorOfPublication actual metadata
|
||||
List<MetadataValue> relationshipMetadataList = itemService
|
||||
.getMetadata(leftItem, MetadataSchemaEnum.RELATION.getName(), "isAuthorOfPublication", null, Item.ANY);
|
||||
assertThat(relationshipMetadataList.size(), equalTo(0));
|
||||
assertThat(relationshipMetadataList.size(), equalTo(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user