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.write.claimLiteral;
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;
28 public class WriteUntypedCustomLiteral extends ExistingDatabaseTest {
32 public void test() throws Exception {
34 Session session = getSession();
36 final Resource literal = session.syncRequest(new WriteResultRequest<Resource>() {
39 public Resource perform(WriteGraph graph) throws DatabaseException {
41 TestLiteral value = new TestLiteral();
43 Resource literal = graph.newResource();
44 Layer0 b = Layer0.getInstance(graph);
45 graph.claimLiteral(literal, b.HasProperty, value);
52 session.syncRequest(new ReadRequest() {
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));
59 assert(l1.toString().equals("TestLiteral 1091 [1.0, 2.0]"));