1 package org.simantics.db.tests.api.readGraph.getInverse;
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.WriteGraph;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;
8 import org.simantics.db.exception.NoInverseException;
9 import org.simantics.db.exception.NoSingleResultException;
10 import org.simantics.db.testing.base.WriteReadTest;
13 * When a resource does not specify L0.InverseOf, getInverse shall throw NoInverseException.
15 public class GetInverseTest3 extends WriteReadTest {
16 private Resource relation1;
17 private Resource relation2;
18 private Resource relation3;
21 protected void write(WriteGraph graph) throws DatabaseException {
23 //Create first resource and give it a name
24 relation1 = graph.newResource();
25 graph.claim(relation1, L0.Inherits, L0.Relation);
26 relation2 = graph.newResource();
27 graph.claim(relation2, L0.Inherits, L0.Relation);
28 graph.claim(relation2, L0.InverseOf, relation1);
30 relation3 = graph.newResource();
31 graph.claim(relation3, L0.Inherits, L0.Relation);
32 graph.claim(relation3, L0.InverseOf, relation1);
37 protected void read(ReadGraph graph) throws DatabaseException {
39 assertNotNull("Null not allowed", graph.getInverse(relation1));
40 } catch (NoInverseException e) {
42 } catch(Throwable t) {
43 fail("Wrong exception was thrown " + t);
46 fail("No exception was thrown!");