]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.db.tests/src/org/simantics/db/tests/api/readGraph/isSubrelationOf/IsSubrelationOfTest1.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 / isSubrelationOf / IsSubrelationOfTest1.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.tests.api.readGraph.isSubrelationOf;
13
14 import org.junit.Test;
15 import org.simantics.db.ReadGraph;
16 import org.simantics.db.common.request.ReadRequest;
17 import org.simantics.db.exception.DatabaseException;
18 import org.simantics.db.testing.base.SimpleBase;
19 import org.simantics.layer0.Layer0;
20
21 public class IsSubrelationOfTest1 extends SimpleBase {
22         @Test
23     public void testSubrelationOf() throws DatabaseException {
24         getSession().syncRequest(new ReadRequest() {
25             @Override
26             public void run(ReadGraph g) throws DatabaseException {
27                 Layer0 l0 = Layer0.getInstance(g);
28                 /*
29                  * Null arguments are not allowed but are not checked. The
30                  * behavior in this case is unspecified and can't be tested.
31                  */
32 //                assertFalse(g.isSubrelationOf(null, null));
33 //                assertFalse(g.isSubrelationOf(rl, null));
34                 // Current implementation doesn't check if argument is relation.
35                 assertTrue(g.isSubrelationOf(rl, rl));
36                 // By definition returns true if the two resources are equal.
37                 assertTrue(g.isSubrelationOf(l0.Relation, l0.Relation));
38                 assertFalse(g.isSubrelationOf(rl, l0.Relation));
39                 assertFalse(g.isSubrelationOf(rl, l0.Entity));
40                 assertFalse(g.isSubrelationOf(rl, l0.Library));
41                 assertFalse(g.isSubrelationOf(l0.IsRelatedTo, l0.Relation));
42                 assertFalse(g.isSubrelationOf(l0.FunctionalRelation, l0.Relation));
43                 assertTrue(g.isSubrelationOf(l0.InverseOf, l0.DependsOn));
44                 assertTrue(g.isSubrelationOf(l0.InverseOf, l0.IsRelatedTo));
45                 assertTrue(g.isSubrelationOf(l0.InverseOf, l0.IsWeaklyRelatedTo));
46                 assertFalse(g.isSubrelationOf(l0.InverseOf, l0.Relation));
47                 assertFalse(g.isSubrelationOf(l0.InverseOf, l0.FunctionalRelation));
48                 assertFalse(g.isSubrelationOf(l0.InverseOf, l0.Relation));
49                 assertTrue(g.isSubrelationOf(l0.SubrelationOf, l0.DependsOn));
50             }
51         });
52     }
53 }