use of org.wikidata.wdtk.datamodel.interfaces.StatementUpdate in project OpenRefine by OpenRefine.
the class StatementGroupEditTest method testAddOrMergeStatementsMatching.
@Test
public void testAddOrMergeStatementsMatching() {
when(merger.match(statement1, statement)).thenReturn(true);
when(merger.match(statement2, statement)).thenReturn(false);
when(merger.merge(statement1, statement)).thenReturn(statement1);
StatementEdit statementEdit = new StatementEdit(statement, merger, StatementEditingMode.ADD_OR_MERGE);
StatementGroupEdit SUT = new StatementGroupEdit(Collections.singletonList(statementEdit));
SUT.contributeToStatementUpdate(builder, statementGroup);
StatementUpdate statementUpdate = builder.build();
assertEquals(statementUpdate.getAdded(), Collections.emptyList());
assertEquals(statementUpdate.getReplaced(), Collections.singletonMap(statementId1, statement1));
assertEquals(statementUpdate.getRemoved(), Collections.emptySet());
}
use of org.wikidata.wdtk.datamodel.interfaces.StatementUpdate in project OpenRefine by OpenRefine.
the class StatementGroupEditTest method testAddStatementsNoMatching.
@Test
public void testAddStatementsNoMatching() {
when(merger.match(statement1, statement)).thenReturn(false);
when(merger.match(statement2, statement)).thenReturn(false);
StatementEdit statementEdit = new StatementEdit(statement, merger, StatementEditingMode.ADD);
StatementGroupEdit SUT = new StatementGroupEdit(Collections.singletonList(statementEdit));
SUT.contributeToStatementUpdate(builder, statementGroup);
StatementUpdate statementUpdate = builder.build();
assertEquals(statementUpdate.getAdded(), Collections.singletonList(statement));
assertEquals(statementUpdate.getReplaced(), Collections.emptyMap());
assertEquals(statementUpdate.getRemoved(), Collections.emptySet());
}
use of org.wikidata.wdtk.datamodel.interfaces.StatementUpdate in project OpenRefine by OpenRefine.
the class StatementGroupEditTest method testDeleteStatements.
@Test
public void testDeleteStatements() {
when(merger.match(statement1, statement)).thenReturn(false);
when(merger.match(statement2, statement)).thenReturn(true);
StatementEdit statementEdit = new StatementEdit(statement, merger, StatementEditingMode.DELETE);
StatementGroupEdit SUT = new StatementGroupEdit(Collections.singletonList(statementEdit));
SUT.contributeToStatementUpdate(builder, statementGroup);
StatementUpdate statementUpdate = builder.build();
assertEquals(statementUpdate.getAdded(), Collections.emptyList());
assertEquals(statementUpdate.getReplaced(), Collections.emptyMap());
assertEquals(statementUpdate.getRemoved(), Collections.singleton(statementId2));
}
Aggregations