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.deny;
14 import java.util.UUID;
16 import org.simantics.db.ReadGraph;
17 import org.simantics.db.Resource;
18 import org.simantics.db.VirtualGraph;
19 import org.simantics.db.WriteGraph;
20 import org.simantics.db.common.request.WriteRequest;
21 import org.simantics.db.common.request.WriteResultRequest;
22 import org.simantics.db.exception.DatabaseException;
23 import org.simantics.db.service.VirtualGraphSupport;
24 import org.simantics.db.testing.base.WriteReadTest;
26 public class DenyTest1 extends WriteReadTest {
31 protected void write(WriteGraph graph) throws DatabaseException {
33 VirtualGraphSupport support = graph.getService(VirtualGraphSupport.class);
34 VirtualGraph virt = support.getMemoryPersistent(UUID.randomUUID().toString());
36 final Resource other2 = graph.syncRequest(new WriteResultRequest<Resource>(virt) {
39 public Resource perform(WriteGraph graph) throws DatabaseException {
40 Resource other = graph.newResource();
41 graph.claim(written, L0.ConsistsOf, L0.PartOf, other);
47 Resource single = graph.getSingleObject(written, L0.ConsistsOf);
48 assertNotNull(single);
49 assertTrue(single.equals(other2));
51 other = graph.newResource();
52 graph.claim(written, L0.ConsistsOf, L0.PartOf, other);
54 graph.syncRequest(new WriteRequest() {
57 public void perform(WriteGraph graph) throws DatabaseException {
58 graph.deny(written, L0.ConsistsOf, L0.PartOf, other2);
66 protected void read(ReadGraph graph) throws DatabaseException {
68 Resource single = graph.getPossibleObject(written, L0.ConsistsOf);
69 assertNotNull(single);
70 assertTrue(single.equals(other));