]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.db.tests/src/org/simantics/db/tests/api/write/claimLiteral/WriteUntypedCustomLiteral.java
Added missing org.simantics.db.{tests,testing} plug-ins.
[simantics/platform.git] / tests / org.simantics.db.tests / src / org / simantics / db / tests / api / write / claimLiteral / WriteUntypedCustomLiteral.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.write.claimLiteral;
13
14 import org.junit.Test;
15 import org.simantics.databoard.Bindings;
16 import org.simantics.db.ReadGraph;
17 import org.simantics.db.Resource;
18 import org.simantics.db.Session;
19 import org.simantics.db.WriteGraph;
20 import org.simantics.db.common.request.ReadRequest;
21 import org.simantics.db.common.request.WriteResultRequest;
22 import org.simantics.db.exception.DatabaseException;
23 import org.simantics.db.testing.annotation.Fails;
24 import org.simantics.db.testing.base.ExistingDatabaseTest;
25 import org.simantics.layer0.Layer0;
26
27
28 public class WriteUntypedCustomLiteral extends ExistingDatabaseTest {
29         
30         @Test
31         @Fails
32         public void test() throws Exception {
33                 
34                 Session session = getSession();
35
36                 final Resource literal = session.syncRequest(new WriteResultRequest<Resource>() {
37
38                         @Override
39                         public Resource perform(WriteGraph graph) throws DatabaseException {
40                                 
41                                 TestLiteral value = new TestLiteral();
42                                 value.setA(1091);
43                                 Resource literal = graph.newResource();
44                                 Layer0 b = Layer0.getInstance(graph);
45                                 graph.claimLiteral(literal, b.HasProperty, value);
46                                 return literal;
47                                 
48                         }
49                         
50                 });
51                 
52                 session.syncRequest(new ReadRequest() {
53                         
54                         @Override
55                         public void run(ReadGraph graph) throws DatabaseException {
56                             Layer0 b = Layer0.getInstance(graph);
57                                 TestLiteral l1 = graph.getRelatedValue(literal, b.HasProperty, Bindings.getBindingUnchecked(TestLiteral.class));
58                                 assert(l1 != null);
59                                 assert(l1.toString().equals("TestLiteral 1091 [1.0, 2.0]"));
60                                 
61                         }
62                         
63                 });
64                 
65         }
66
67 }