]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.db.tests/src/org/simantics/db/tests/api/readGraph/getPredicates/GetPredicatesWithAssertionsTest6.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 / GetPredicatesWithAssertionsTest6.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 java.util.Collection;
15 import java.util.UUID;
16
17 import org.simantics.db.ReadGraph;
18 import org.simantics.db.Resource;
19 import org.simantics.db.WriteGraph;
20 import org.simantics.db.common.utils.NameUtils;
21 import org.simantics.db.exception.DatabaseException;
22 import org.simantics.db.testing.annotation.Fails;
23 import org.simantics.db.testing.base.WriteReadTest;
24 import org.simantics.db.tests.common.Writes;
25
26 @Fails
27 public class GetPredicatesWithAssertionsTest6 extends WriteReadTest {
28
29     private Resource type;
30     private Resource type2;
31     private Resource type3;
32     private Resource named1;
33     private Resource named2;
34
35         @Override
36         protected void write(WriteGraph graph) throws DatabaseException {
37
38         //type2 = graph.newResource();
39         //graph.claim(type2, L0.Inherits, L0.Entity);
40         //type3 = graph.newResource();
41         //graph.claim(type3, L0.Inherits, L0.Entity);
42         type = graph.newResource();
43         graph.claim(type, L0.Inherits, L0.Entity);
44
45         //graph.claim(type, L0.Inherits, type2);
46         //graph.claim(type, L0.Inherits, type3);
47         
48         named1 = Writes.named(graph, UUID.randomUUID().toString());
49         named2 = Writes.named(graph, UUID.randomUUID().toString());
50         
51         //graph.claim(type, L0.HasName, named1);
52         //graph.claim(type, L0.ConsistsOf, named2);
53
54
55         graph.claim(type, L0.Asserts, Writes.assertion(graph, L0.ConsistsOf, named1));
56         graph.claim(type, L0.Asserts, Writes.assertion(graph, L0.HasName, named2));
57        // graph.claim(type, L0.Asserts, Writes.assertion(graph, L0.HasName, named1));
58                 
59         }
60         @Override
61     protected void read(ReadGraph graph) throws DatabaseException {
62                 
63         Collection<Resource> result = graph.getPredicates(type);
64         assertNotNull("Null not allowed", result);
65
66         for (Resource r: result) {
67             System.out.println("Resrouce: " + NameUtils.getSafeName(graph, r, true));
68                 //System.out.println(TestingUtils.predicateName(L0, graph, r));
69         }
70         int size = result.size();
71         assertTrue("Wrong number of predicates: " + size,
72                         (size == 2));
73         System.out.println(graph.isSubrelationOf(L0.Inherits, L0.DependsOn));
74       
75         //assertTrue(Tests.contains(predicates));
76         //assertTrue(Tests.contains(predicates, L0.SupertypeOf, named2));
77     }
78         
79         /*
80         @Override
81         protected void read(ReadGraph graph) throws DatabaseException {
82                 
83         Collection<Statement> consists = graph.getAssertedStatements(type, L0.ConsistsOf);
84
85         assertTrue(Tests.contains(consists, type, L0.ConsistsOf, named1));
86         assertTrue(Tests.contains(consists, type2, L0.ConsistsOf, named1));
87         assertTrue(Tests.contains(consists, type3, L0.ConsistsOf, named1));
88         assertTrue(consists.size() == 3);
89         }
90     */
91 }