]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.db.tests/src/org/simantics/db/tests/api/readGraph/getInverse/GetInverseTest4.java
Added missing org.simantics.db.{tests,testing} plug-ins.
[simantics/platform.git] / tests / org.simantics.db.tests / src / org / simantics / db / tests / api / readGraph / getInverse / GetInverseTest4.java
1 package org.simantics.db.tests.api.readGraph.getInverse;
2
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;
9
10 /*
11  * When a resource does not specify L0.InverseOf, getInverse shall throw NoInverseException.
12  */
13 public class GetInverseTest4 extends WriteReadTest {
14         private Resource relation1;
15         private Resource relation2;
16         private Resource relation3;
17
18         @Override
19         protected void write(WriteGraph graph) throws DatabaseException {
20
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);
27
28         relation3 = graph.newResource();
29         graph.claim(relation3, L0.Inherits, L0.Relation);
30         graph.claim(relation1, L0.InverseOf, relation3);
31
32         }
33
34         @Override
35         protected void read(ReadGraph graph) throws DatabaseException {
36         try {
37                 assertNotNull("Null not allowed", graph.getInverse(relation1));
38         } catch (NoInverseException e) {
39             return;
40         } catch(Throwable t) {
41             fail("Wrong exception was thrown " + t);
42         }
43         fail("No exception was thrown!");
44         }
45 }