Search in sources :

Example 11 with MonolingualTextValue

use of org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue in project OpenRefine by OpenRefine.

the class TermedStatementEntityEditTest method testMergeLabelsIfNew.

@Test
public void testMergeLabelsIfNew() {
    MonolingualTextValue label1 = Datamodel.makeMonolingualTextValue("first label", "en");
    MonolingualTextValue label2 = Datamodel.makeMonolingualTextValue("second label", "en");
    TermedStatementEntityEdit edit1 = new TermedStatementEntityEditBuilder(existingSubject).addLabel(label1, false).build();
    TermedStatementEntityEdit edit2 = new TermedStatementEntityEditBuilder(existingSubject).addLabel(label2, false).build();
    TermedStatementEntityEdit merged = edit1.merge(edit2);
    assertEquals(Collections.singleton(label1), merged.getLabelsIfNew());
    assertEquals(Collections.emptySet(), merged.getLabels());
}
Also used : MonolingualTextValue(org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue) Test(org.testng.annotations.Test)

Example 12 with MonolingualTextValue

use of org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue in project OpenRefine by OpenRefine.

the class TermedStatementEntityEditTest method testMergeDescriptionsIfNewOverriding2.

@Test
public void testMergeDescriptionsIfNewOverriding2() {
    MonolingualTextValue description1 = Datamodel.makeMonolingualTextValue("first description", "en");
    MonolingualTextValue description2 = Datamodel.makeMonolingualTextValue("second description", "en");
    TermedStatementEntityEdit update1 = new TermedStatementEntityEditBuilder(existingSubject).addDescription(description1, false).build();
    TermedStatementEntityEdit update2 = new TermedStatementEntityEditBuilder(existingSubject).addDescription(description2, true).build();
    TermedStatementEntityEdit merged = update1.merge(update2);
    assertEquals(Collections.singleton(description2), merged.getDescriptions());
    assertEquals(Collections.emptySet(), merged.getDescriptionsIfNew());
}
Also used : MonolingualTextValue(org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue) Test(org.testng.annotations.Test)

Example 13 with MonolingualTextValue

use of org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue in project OpenRefine by OpenRefine.

the class TermedStatementEntityEditTest method testMergeDescriptionsIfNewOverriding.

@Test
public void testMergeDescriptionsIfNewOverriding() {
    MonolingualTextValue description1 = Datamodel.makeMonolingualTextValue("first description", "en");
    MonolingualTextValue description2 = Datamodel.makeMonolingualTextValue("second description", "en");
    TermedStatementEntityEdit edit1 = new TermedStatementEntityEditBuilder(existingSubject).addDescription(description1, true).build();
    TermedStatementEntityEdit edit2 = new TermedStatementEntityEditBuilder(existingSubject).addDescription(description2, false).build();
    TermedStatementEntityEdit merged = edit1.merge(edit2);
    assertEquals(Collections.singleton(description1), merged.getDescriptions());
    assertEquals(Collections.emptySet(), merged.getDescriptionsIfNew());
}
Also used : MonolingualTextValue(org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue) Test(org.testng.annotations.Test)

Example 14 with MonolingualTextValue

use of org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue in project OpenRefine by OpenRefine.

the class TermedStatementEntityEditTest method testConstructOverridingLabels.

@Test
public void testConstructOverridingLabels() {
    MonolingualTextValue label1 = Datamodel.makeMonolingualTextValue("first label", "en");
    MonolingualTextValue label2 = Datamodel.makeMonolingualTextValue("second label", "en");
    TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(existingSubject).addLabel(label1, false).addLabel(label2, true).build();
    assertEquals(Collections.singleton(label2), update.getLabels());
    assertEquals(Collections.emptySet(), update.getLabelsIfNew());
}
Also used : MonolingualTextValue(org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue) Test(org.testng.annotations.Test)

Example 15 with MonolingualTextValue

use of org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue in project OpenRefine by OpenRefine.

the class TermedStatementEntityEditTest method testMergeLabels.

@Test
public void testMergeLabels() {
    MonolingualTextValue label1 = Datamodel.makeMonolingualTextValue("first label", "en");
    MonolingualTextValue label2 = Datamodel.makeMonolingualTextValue("second label", "en");
    TermedStatementEntityEdit edit1 = new TermedStatementEntityEditBuilder(existingSubject).addLabel(label1, true).build();
    TermedStatementEntityEdit edit2 = new TermedStatementEntityEditBuilder(existingSubject).addLabel(label2, true).build();
    TermedStatementEntityEdit merged = edit1.merge(edit2);
    assertEquals(Collections.singleton(label2), merged.getLabels());
}
Also used : MonolingualTextValue(org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue) Test(org.testng.annotations.Test)

Aggregations

MonolingualTextValue (org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue)23 Test (org.testng.annotations.Test)13 ArrayList (java.util.ArrayList)6 List (java.util.List)6 HashMap (java.util.HashMap)4 Collectors (java.util.stream.Collectors)4 TermedStatementEntityEdit (org.openrefine.wikidata.updates.TermedStatementEntityEdit)4 Datamodel (org.wikidata.wdtk.datamodel.helpers.Datamodel)4 ItemDocument (org.wikidata.wdtk.datamodel.interfaces.ItemDocument)4 ItemIdValue (org.wikidata.wdtk.datamodel.interfaces.ItemIdValue)4 MediaInfoIdValue (org.wikidata.wdtk.datamodel.interfaces.MediaInfoIdValue)4 StatementUpdate (org.wikidata.wdtk.datamodel.interfaces.StatementUpdate)4 Collections (java.util.Collections)3 LinkedList (java.util.LinkedList)3 Map (java.util.Map)3 WikidataRefineTest (org.openrefine.wikidata.testing.WikidataRefineTest)3 TermedStatementEntityEditBuilder (org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder)3 EntityDocument (org.wikidata.wdtk.datamodel.interfaces.EntityDocument)3 EntityIdValue (org.wikidata.wdtk.datamodel.interfaces.EntityIdValue)3 MediaInfoDocument (org.wikidata.wdtk.datamodel.interfaces.MediaInfoDocument)3