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.readGraph.adapt;
14 import org.simantics.db.AsyncReadGraph;
15 import org.simantics.db.ReadGraph;
16 import org.simantics.db.WriteGraph;
17 import org.simantics.db.common.request.ResourceAsyncRead;
18 import org.simantics.db.exception.AdaptionException;
19 import org.simantics.db.exception.DatabaseException;
20 import org.simantics.db.procedure.AsyncProcedure;
21 import org.simantics.db.testing.base.WriteReadTest;
22 import org.simantics.db.tests.api.readGraph.common.Ontologies;
25 * Checks that {@link ReadGraph#adapt(org.simantics.db.Resource, Class)},
26 * {@link ReadGraph#adaptUnique(org.simantics.db.Resource, Class)},
27 * <code>AsyncReadGraph.forAdapted</code> fail as expected.
30 * Regression test for https://www.simulationsite.net/trac/simantics/ticket/617
32 * @author Tuukka Lehtonen
34 public class AdaptTest4 extends WriteReadTest {
37 protected void write(WriteGraph graph) throws DatabaseException {
38 written = Ontologies.relatedTypelessResource(L0, graph);
42 protected void read(ReadGraph graph) throws DatabaseException {
46 .syncRequest(new ResourceAsyncRead<String>(written) {
48 public void perform(AsyncReadGraph graph,
49 AsyncProcedure<String> procedure) {
50 graph.forAdapted(resource, String.class, procedure);
53 assertTrue("adapt must never return null", s != null);
54 } catch (AdaptionException e) {
56 } catch (Exception e) {
57 fail("Wrong exception: " + e.getClass().getCanonicalName());