1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.tests.api.readGraph.isSubrelationOf;
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;
21 public class IsSubrelationOfTest1 extends SimpleBase {
23 public void testSubrelationOf() throws DatabaseException {
24 getSession().syncRequest(new ReadRequest() {
26 public void run(ReadGraph g) throws DatabaseException {
27 Layer0 l0 = Layer0.getInstance(g);
29 * Null arguments are not allowed but are not checked. The
30 * behavior in this case is unspecified and can't be tested.
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));