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