88196: WIP: Test place of metadata in new version (implementation needs fix)

This commit is contained in:
Bruno Roemers
2022-03-11 15:10:26 +01:00
parent 938f1bab52
commit d31f6834c8
2 changed files with 60 additions and 21 deletions

View File

@@ -62,9 +62,18 @@ public abstract class AbstractVersionProvider {
continue; continue;
} }
itemService itemService.addMetadata(
.addMetadata(context, itemNew, metadataField, aMd.getLanguage(), aMd.getValue(), aMd.getAuthority(), context,
aMd.getConfidence()); itemNew,
metadataField.getMetadataSchema().getName(),
metadataField.getElement(),
metadataField.getQualifier(),
aMd.getLanguage(),
aMd.getValue(),
aMd.getAuthority(),
aMd.getConfidence(),
aMd.getPlace()
);
} }
} }

View File

@@ -1081,37 +1081,67 @@ public class VersioningWithRelationshipsTest extends AbstractIntegrationTestWith
RelationshipBuilder.createRelationshipBuilder(context, originalPublication, author6, isAuthorOfPublication) RelationshipBuilder.createRelationshipBuilder(context, originalPublication, author6, isAuthorOfPublication)
.build(); .build();
itemService.update(context, originalPublication); ////////////////////////////////
// test dc.contributor.author //
////////////////////////////////
List<MetadataValue> oldMdvs = itemService.getMetadata(
originalPublication, "dc", "contributor", "author", Item.ANY
);
assertFalse(oldMdvs.get(0) instanceof RelationshipMetadataValue);
assertEquals("author 1 (plain)", oldMdvs.get(0).getValue());
assertTrue(oldMdvs.get(1) instanceof RelationshipMetadataValue);
assertEquals("author, 2 (item)", oldMdvs.get(1).getValue());
assertFalse(oldMdvs.get(2) instanceof RelationshipMetadataValue);
assertEquals("author 3 (plain)", oldMdvs.get(2).getValue());
assertTrue(oldMdvs.get(3) instanceof RelationshipMetadataValue);
assertEquals("author, 4 (item)", oldMdvs.get(3).getValue());
assertFalse(oldMdvs.get(4) instanceof RelationshipMetadataValue);
assertEquals("author 5 (plain)", oldMdvs.get(4).getValue());
assertTrue(oldMdvs.get(5) instanceof RelationshipMetadataValue);
assertEquals("author, 6 (item)", oldMdvs.get(5).getValue());
///////////////////////////////////////
// create new version of publication //
///////////////////////////////////////
Version newVersion = versioningService.createNewVersion(context, originalPublication);
Item newPublication = newVersion.getItem();
assertNotSame(originalPublication, newPublication);
//////////////////////////////// ////////////////////////////////
// test dc.contributor.author // // test dc.contributor.author //
//////////////////////////////// ////////////////////////////////
List<MetadataValue> mdvs = itemService.getMetadata( List<MetadataValue> newMdvs = itemService.getMetadata(
originalPublication, "dc", "contributor", "author", Item.ANY newPublication, "dc", "contributor", "author", Item.ANY
); );
// TODO make sure test setup respects following order assertFalse(newMdvs.get(0) instanceof RelationshipMetadataValue);
assertEquals("author 1 (plain)", newMdvs.get(0).getValue());
assertFalse(mdvs.get(0) instanceof RelationshipMetadataValue); assertTrue(newMdvs.get(1) instanceof RelationshipMetadataValue);
assertEquals("author 1 (plain)", mdvs.get(0).getValue()); assertEquals("author, 2 (item)", newMdvs.get(1).getValue());
assertTrue(mdvs.get(1) instanceof RelationshipMetadataValue); assertFalse(newMdvs.get(2) instanceof RelationshipMetadataValue);
assertEquals("author, 2 (item)", mdvs.get(1).getValue()); assertEquals("author 3 (plain)", newMdvs.get(2).getValue());
assertFalse(mdvs.get(2) instanceof RelationshipMetadataValue); assertTrue(newMdvs.get(3) instanceof RelationshipMetadataValue);
assertEquals("author 3 (plain)", mdvs.get(2).getValue()); assertEquals("author, 4 (item)", newMdvs.get(3).getValue());
assertTrue(mdvs.get(3) instanceof RelationshipMetadataValue); assertFalse(newMdvs.get(4) instanceof RelationshipMetadataValue);
assertEquals("author, 4 (item)", mdvs.get(3).getValue()); assertEquals("author 5 (plain)", newMdvs.get(4).getValue());
assertFalse(mdvs.get(4) instanceof RelationshipMetadataValue); assertTrue(newMdvs.get(5) instanceof RelationshipMetadataValue);
assertEquals("author 5 (plain)", mdvs.get(4).getValue()); assertEquals("author, 6 (item)", newMdvs.get(5).getValue());
assertTrue(mdvs.get(5) instanceof RelationshipMetadataValue); // TODO also test place after removing/adding relationships and metadata
assertEquals("author, 6 (item)", mdvs.get(5).getValue());
// TODO finish rest of test
} }
} }