X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=tests%2Forg.simantics.db.tests%2Fsrc%2Forg%2Fsimantics%2Fdb%2Ftests%2Fapi%2FreadGraph%2FgetInverse%2FGetInverseTest3.java;fp=tests%2Forg.simantics.db.tests%2Fsrc%2Forg%2Fsimantics%2Fdb%2Ftests%2Fapi%2FreadGraph%2FgetInverse%2FGetInverseTest3.java;h=fd9f1451c0ba5d71404197bfef5c870f634d9511;hb=67fd62f9c742337ec80eef658192db198a0efaac;hp=0000000000000000000000000000000000000000;hpb=cde82ba81327d5515fdca362f7f4c70f5103ae80;p=simantics%2Fplatform.git diff --git a/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/readGraph/getInverse/GetInverseTest3.java b/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/readGraph/getInverse/GetInverseTest3.java new file mode 100644 index 000000000..fd9f1451c --- /dev/null +++ b/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/readGraph/getInverse/GetInverseTest3.java @@ -0,0 +1,49 @@ +package org.simantics.db.tests.api.readGraph.getInverse; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.exception.ManyObjectsForFunctionalRelationException; +import org.simantics.db.exception.NoInverseException; +import org.simantics.db.exception.NoSingleResultException; +import org.simantics.db.testing.base.WriteReadTest; + +/* + * When a resource does not specify L0.InverseOf, getInverse shall throw NoInverseException. + */ +public class GetInverseTest3 extends WriteReadTest { + private Resource relation1; + private Resource relation2; + private Resource relation3; + + @Override + protected void write(WriteGraph graph) throws DatabaseException { + + //Create first resource and give it a name + relation1 = graph.newResource(); + graph.claim(relation1, L0.Inherits, L0.Relation); + relation2 = graph.newResource(); + graph.claim(relation2, L0.Inherits, L0.Relation); + graph.claim(relation2, L0.InverseOf, relation1); + + relation3 = graph.newResource(); + graph.claim(relation3, L0.Inherits, L0.Relation); + graph.claim(relation3, L0.InverseOf, relation1); + + } + + @Override + protected void read(ReadGraph graph) throws DatabaseException { + try { + assertNotNull("Null not allowed", graph.getInverse(relation1)); + } catch (NoInverseException e) { + return; + } catch(Throwable t) { + fail("Wrong exception was thrown " + t); + } + + fail("No exception was thrown!"); + } + +}