From 46b3e41bb7f08b24186a2be44de533accfbce5d3 Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Wed, 10 Jan 2018 10:12:24 +0000 Subject: [PATCH] Update tests to use PropertyIdValue --- .../wikidata/qa/ConstraintFetcherTests.java | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/ConstraintFetcherTests.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/ConstraintFetcherTests.java index f46b4497f..612ee4921 100644 --- a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/ConstraintFetcherTests.java +++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/ConstraintFetcherTests.java @@ -14,46 +14,58 @@ public class ConstraintFetcherTests { private PropertyIdValue headOfGovernment; private PropertyIdValue startTime; private PropertyIdValue endTime; + private PropertyIdValue instanceOf; + private PropertyIdValue gridId; + private PropertyIdValue hasPart; + private PropertyIdValue partOf; + private PropertyIdValue referenceURL; + private PropertyIdValue reasonForDeprecation; public ConstraintFetcherTests() { fetcher = new ConstraintFetcher(); headOfGovernment = Datamodel.makeWikidataPropertyIdValue("P6"); startTime = Datamodel.makeWikidataPropertyIdValue("P580"); endTime = Datamodel.makeWikidataPropertyIdValue("P582"); + instanceOf = Datamodel.makeWikidataPropertyIdValue("P31"); + gridId = Datamodel.makeWikidataPropertyIdValue("P2427"); + hasPart = Datamodel.makeWikidataPropertyIdValue("P527"); + partOf = Datamodel.makeWikidataPropertyIdValue("P361"); + referenceURL = Datamodel.makeWikidataPropertyIdValue("P854"); + reasonForDeprecation = Datamodel.makeWikidataPropertyIdValue("P2241"); } @Test public void testGetFormatConstraint() { - String regex = fetcher.getFormatRegex("P2427"); + String regex = fetcher.getFormatRegex(gridId); Pattern pattern = Pattern.compile(regex); Assert.assertTrue(pattern.matcher("grid.470811.b").matches()); Assert.assertFalse(pattern.matcher("501100006367").matches()); - Assert.assertNull(fetcher.getFormatRegex("P31")); + Assert.assertNull(fetcher.getFormatRegex(instanceOf)); } @Test public void testGetInverseConstraint() { - Assert.assertEquals(fetcher.getInversePid("P361"), "P527"); + Assert.assertEquals(fetcher.getInversePid(partOf), hasPart); } @Test public void testOnlyReferences() { - Assert.assertTrue(fetcher.isForReferencesOnly("P854")); - Assert.assertFalse(fetcher.isForReferencesOnly("P2241")); + Assert.assertTrue(fetcher.isForReferencesOnly(referenceURL)); + Assert.assertFalse(fetcher.isForReferencesOnly(reasonForDeprecation)); } @Test public void testOnlyQualifiers() { - Assert.assertTrue(fetcher.isForQualifiersOnly("P2241")); - Assert.assertFalse(fetcher.isForQualifiersOnly("P6")); + Assert.assertTrue(fetcher.isForQualifiersOnly(reasonForDeprecation)); + Assert.assertFalse(fetcher.isForQualifiersOnly(headOfGovernment)); } @Test public void testOnlyValues() { - Assert.assertTrue(fetcher.isForValuesOnly("P6")); - Assert.assertFalse(fetcher.isForValuesOnly("P854")); + Assert.assertTrue(fetcher.isForValuesOnly(headOfGovernment)); + Assert.assertFalse(fetcher.isForValuesOnly(referenceURL)); } @Test