Search in sources :

Example 61 with TermedStatementEntityEditBuilder

use of org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder in project OpenRefine by OpenRefine.

the class EnglishDescriptionScrutinizerTest method testEndWithPunctuationSign.

@Test
public void testEndWithPunctuationSign() {
    String description = "description with punctuationSign.";
    TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(TestingData.newIdA).addDescription(Datamodel.makeMonolingualTextValue(description, "en"), false).build();
    scrutinize(update);
    assertWarningsRaised(EnglishDescriptionScrutinizer.descEndsByPunctuationSign);
}
Also used : TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) Test(org.testng.annotations.Test)

Example 62 with TermedStatementEntityEditBuilder

use of org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder in project OpenRefine by OpenRefine.

the class FormatScrutinizerTest method testIncompleteMatch.

@Test
public void testIncompleteMatch() {
    ItemIdValue idA = TestingData.existingId;
    ValueSnak value = Datamodel.makeValueSnak(propertyIdValue, incompleteMatchValue);
    Statement statement = new StatementImpl("P18", value, idA);
    TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(idA).addStatement(add(statement)).build();
    List<Statement> constraintDefinitions = generateFormatConstraint(regularExpression);
    ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
    when(fetcher.getConstraintsByType(propertyIdValue, FORMAT_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
    setFetcher(fetcher);
    scrutinize(updateA);
    assertWarningsRaised(FormatScrutinizer.type);
}
Also used : ItemIdValue(org.wikidata.wdtk.datamodel.interfaces.ItemIdValue) TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) ConstraintFetcher(org.openrefine.wikidata.qa.ConstraintFetcher) Statement(org.wikidata.wdtk.datamodel.interfaces.Statement) StatementImpl(org.wikidata.wdtk.datamodel.implementation.StatementImpl) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) ValueSnak(org.wikidata.wdtk.datamodel.interfaces.ValueSnak) Test(org.testng.annotations.Test)

Example 63 with TermedStatementEntityEditBuilder

use of org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder in project OpenRefine by OpenRefine.

the class FormatScrutinizerTest method testNoIssue.

@Test
public void testNoIssue() {
    ItemIdValue idA = TestingData.existingId;
    ValueSnak value = Datamodel.makeValueSnak(propertyIdValue, completeMatchValue);
    Statement statement = new StatementImpl("P18", value, idA);
    TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(idA).addStatement(add(statement)).build();
    List<Statement> constraintDefinitions = generateFormatConstraint(regularExpression);
    ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
    when(fetcher.getConstraintsByType(propertyIdValue, FORMAT_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
    setFetcher(fetcher);
    scrutinize(updateA);
    assertNoWarningRaised();
}
Also used : ItemIdValue(org.wikidata.wdtk.datamodel.interfaces.ItemIdValue) TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) ConstraintFetcher(org.openrefine.wikidata.qa.ConstraintFetcher) Statement(org.wikidata.wdtk.datamodel.interfaces.Statement) StatementImpl(org.wikidata.wdtk.datamodel.implementation.StatementImpl) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) ValueSnak(org.wikidata.wdtk.datamodel.interfaces.ValueSnak) Test(org.testng.annotations.Test)

Example 64 with TermedStatementEntityEditBuilder

use of org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder in project OpenRefine by OpenRefine.

the class FormatScrutinizerTest method testTrigger.

@Test
public void testTrigger() {
    ItemIdValue idA = TestingData.existingId;
    ValueSnak value = Datamodel.makeValueSnak(propertyIdValue, noMatchValue);
    Statement statement = new StatementImpl("P18", value, idA);
    TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(idA).addStatement(add(statement)).build();
    List<Statement> constraintDefinitions = generateFormatConstraint(regularExpression);
    ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
    when(fetcher.getConstraintsByType(propertyIdValue, FORMAT_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
    setFetcher(fetcher);
    scrutinize(updateA);
    assertWarningsRaised(FormatScrutinizer.type);
}
Also used : ItemIdValue(org.wikidata.wdtk.datamodel.interfaces.ItemIdValue) TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) ConstraintFetcher(org.openrefine.wikidata.qa.ConstraintFetcher) Statement(org.wikidata.wdtk.datamodel.interfaces.Statement) StatementImpl(org.wikidata.wdtk.datamodel.implementation.StatementImpl) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) ValueSnak(org.wikidata.wdtk.datamodel.interfaces.ValueSnak) Test(org.testng.annotations.Test)

Example 65 with TermedStatementEntityEditBuilder

use of org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder in project OpenRefine by OpenRefine.

the class FormatScrutinizerTest method testInvalidRegex.

@Test
public void testInvalidRegex() {
    ItemIdValue idA = TestingData.existingId;
    ValueSnak value = Datamodel.makeValueSnak(propertyIdValue, incompleteMatchValue);
    Statement statement = new StatementImpl("P18", value, idA);
    TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(idA).addStatement(add(statement)).build();
    List<Statement> constraintDefinitions = generateFormatConstraint(invalidRegularExpression);
    ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
    when(fetcher.getConstraintsByType(propertyIdValue, FORMAT_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
    setFetcher(fetcher);
    scrutinize(updateA);
    assertNoWarningRaised();
}
Also used : ItemIdValue(org.wikidata.wdtk.datamodel.interfaces.ItemIdValue) TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) ConstraintFetcher(org.openrefine.wikidata.qa.ConstraintFetcher) Statement(org.wikidata.wdtk.datamodel.interfaces.Statement) StatementImpl(org.wikidata.wdtk.datamodel.implementation.StatementImpl) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) ValueSnak(org.wikidata.wdtk.datamodel.interfaces.ValueSnak) Test(org.testng.annotations.Test)

Aggregations

TermedStatementEntityEditBuilder (org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder)107 TermedStatementEntityEdit (org.openrefine.wikidata.updates.TermedStatementEntityEdit)102 Test (org.testng.annotations.Test)101 ItemIdValue (org.wikidata.wdtk.datamodel.interfaces.ItemIdValue)57 Statement (org.wikidata.wdtk.datamodel.interfaces.Statement)56 ConstraintFetcher (org.openrefine.wikidata.qa.ConstraintFetcher)52 Snak (org.wikidata.wdtk.datamodel.interfaces.Snak)49 StatementImpl (org.wikidata.wdtk.datamodel.implementation.StatementImpl)44 SnakGroup (org.wikidata.wdtk.datamodel.interfaces.SnakGroup)34 ValueSnak (org.wikidata.wdtk.datamodel.interfaces.ValueSnak)18 WikidataRefineTest (org.openrefine.wikidata.testing.WikidataRefineTest)13 ArrayList (java.util.ArrayList)11 StatementEdit (org.openrefine.wikidata.updates.StatementEdit)9 JacksonSerializationTest (org.openrefine.wikidata.testing.JacksonSerializationTest)7 NoValueSnak (org.wikidata.wdtk.datamodel.interfaces.NoValueSnak)5 ReconEntityIdValue (org.openrefine.wikidata.schema.entityvalues.ReconEntityIdValue)4 Claim (org.wikidata.wdtk.datamodel.interfaces.Claim)4 EntityIdValue (org.wikidata.wdtk.datamodel.interfaces.EntityIdValue)4 ItemDocument (org.wikidata.wdtk.datamodel.interfaces.ItemDocument)3 Engine (com.google.refine.browsing.Engine)2