]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.db.tests/src/org/simantics/db/tests/api/readGraph/getPredicates/PredicatePropertiesTest.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 / getPredicates / PredicatePropertiesTest.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.getPredicates;
13
14 import org.simantics.db.ReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.db.exception.DatabaseException;
17 import org.simantics.db.testing.base.WriteReadTest;
18
19 public class PredicatePropertiesTest extends WriteReadTest {
20     
21     
22     @Override
23     protected void read(ReadGraph graph) throws DatabaseException {
24         Resource[] predicates = {L0.Asserts, L0.ConsistsOf, L0.DependsOn, L0.HasDataType,
25                         L0.HasLabel, L0.HasName, L0.HasPredicate, L0.HasValueType, L0.Inherits,
26                         L0.InstanceOf, L0.IsRelatedTo, L0.IsWeaklyRelatedTo, L0.SubrelationOf};
27         if (DEBUG)
28             System.out.println("Is Functional:");
29         for (int i=0; i<predicates.length; i++) {
30                 Resource predicate = predicates[i];
31                 boolean isFunctional = graph.isInstanceOf(predicate, L0.FunctionalRelation);
32                 if (DEBUG)
33                     System.out.println(i + " " + isFunctional);
34         }
35         if (DEBUG)
36             System.out.println("SubRelationOf:");
37         for (int i=0; i<predicates.length; i++) {
38                 Resource predicate1 = predicates[i];
39                 for (int j=0; j<predicates.length; j++) {
40                         Resource predicate2 = predicates[j];
41                         boolean isSubRelationOf = graph.isSubrelationOf(predicate1, predicate2);
42                         if (DEBUG)
43                             System.out.println(i + "," + j + " : " + isSubRelationOf);
44                 }
45         }
46     }
47 }