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.support.virtualGraphSupport;
14 import java.util.Collection;
15 import java.util.UUID;
17 import org.junit.Test;
18 import org.simantics.db.Resource;
19 import org.simantics.db.Statement;
20 import org.simantics.db.VirtualGraph;
21 import org.simantics.db.WriteGraph;
22 import org.simantics.db.common.request.WriteRequest;
23 import org.simantics.db.common.request.WriteResultRequest;
24 import org.simantics.db.exception.DatabaseException;
25 import org.simantics.db.service.VirtualGraphSupport;
26 import org.simantics.db.testing.base.ExistingDatabaseTest;
28 public class VirtualGraphSupportListStatementsTest extends ExistingDatabaseTest {
31 public void test() throws Exception{
33 // Create a new persistent resource
34 final Resource resource = getSession().syncRequest(new WriteResultRequest<Resource>() {
36 public Resource perform(WriteGraph g) throws DatabaseException {
37 return g.newResource();
41 VirtualGraphSupport vgs = getSession().getService(VirtualGraphSupport.class);
42 VirtualGraph vg = vgs.getMemoryPersistent(UUID.randomUUID().toString());
44 // Create some virtual graph
45 getSession().syncRequest(new WriteRequest(vg) {
47 public void perform(WriteGraph graph) throws DatabaseException {
48 Resource virtual = graph.newResource();
49 graph.claim(resource, L0.ConsistsOf, virtual);
50 graph.claimLiteral(virtual, L0.HasName, "Name");
57 Collection<Statement> stms = vgs.listStatements(vg);
59 assertEquals("Amount of statements.", stms.size(), 5);