Add support for symmetric constraint

This commit is contained in:
Antonin Delpeuch 2018-06-09 12:31:55 +01:00
parent 9cb4a46277
commit 3c181c9070
2 changed files with 12 additions and 0 deletions

View File

@ -59,6 +59,9 @@ public class InverseConstraintScrutinizer extends StatementScrutinizer {
return _inverse.get(pid);
} else {
PropertyIdValue inversePid = _fetcher.getInversePid(pid);
if (inversePid == null && _fetcher.isSymmetric(pid)) {
inversePid = pid;
}
_inverse.put(pid, inversePid);
_statements.put(pid, new HashMap<EntityIdValue, Set<EntityIdValue>>());

View File

@ -37,6 +37,7 @@ public class InverseConstaintScrutinizerTest extends StatementScrutinizerTest {
private ItemIdValue idB = TestingData.newIdB;
private PropertyIdValue pidWithInverse = MockConstraintFetcher.pidWithInverse;
private PropertyIdValue inversePid = MockConstraintFetcher.inversePid;
private PropertyIdValue symmetricPid = MockConstraintFetcher.symmetricPid;
@Override
public EditScrutinizer getScrutinizer() {
@ -50,6 +51,14 @@ public class InverseConstaintScrutinizerTest extends StatementScrutinizerTest {
scrutinize(update);
assertWarningsRaised(InverseConstraintScrutinizer.type);
}
@Test
public void testSymmetric() {
ItemUpdate update = new ItemUpdateBuilder(idA)
.addStatement(TestingData.generateStatement(idA, symmetricPid, idB)).build();
scrutinize(update);
assertWarningsRaised(InverseConstraintScrutinizer.type);
}
@Test
public void testNoSymmetricClosure() {