+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!");
+ }
+
+}