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.NoInverseException;
8 import org.simantics.db.testing.base.WriteReadTest;
11 * When a resource does not specify L0.InverseOf, getInverse shall throw NoInverseException.
13 public class GetInverseTest4 extends WriteReadTest {
14 private Resource relation1;
15 private Resource relation2;
16 private Resource relation3;
19 protected void write(WriteGraph graph) throws DatabaseException {
21 //Create first resource and give it a name
22 relation1 = graph.newResource();
23 graph.claim(relation1, L0.Inherits, L0.Relation);
24 relation2 = graph.newResource();
25 graph.claim(relation2, L0.Inherits, L0.Relation);
26 graph.claim(relation1, L0.InverseOf, relation2);
28 relation3 = graph.newResource();
29 graph.claim(relation3, L0.Inherits, L0.Relation);
30 graph.claim(relation1, L0.InverseOf, relation3);
35 protected void read(ReadGraph graph) throws DatabaseException {
37 assertNotNull("Null not allowed", graph.getInverse(relation1));
38 } catch (NoInverseException e) {
40 } catch(Throwable t) {
41 fail("Wrong exception was thrown " + t);
43 fail("No exception was thrown!");