Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: cd2b8fdba6b267539dafaf83e31d64fe2979492f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
 * <copyright> Copyright (c) 2005, 2006, 2007, 2008 Springsite BV (The Netherlands) and others All rights
 * reserved. This program and the accompanying materials are made available under the terms of the
 * Eclipse Public License v1.0 which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html Contributors: Martin Taal </copyright> $Id:
 * CompositeIdAction.java,v 1.2 2007/02/01 12:35:36 mtaal Exp $
 */

package org.eclipse.emf.teneo.test.emf.annotations;

import org.eclipse.emf.teneo.samples.emf.annotations.compositeid.Child;
import org.eclipse.emf.teneo.samples.emf.annotations.compositeid.CompositeidFactory;
import org.eclipse.emf.teneo.samples.emf.annotations.compositeid.CompositeidPackage;
import org.eclipse.emf.teneo.samples.emf.annotations.compositeid.Parent;
import org.eclipse.emf.teneo.test.AbstractTestAction;
import org.eclipse.emf.teneo.test.stores.TestStore;

/**
 * Testcase
 * 
 * @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
 * @version $Revision: 1.5 $
 */
public class CompositeIdAction extends AbstractTestAction {
	/**
	 * Constructor
	 */
	public CompositeIdAction() {
		super(CompositeidPackage.eINSTANCE);
	}

	/** Creates an item, an address and links them to a po. */
	@Override
	public void doAction(TestStore store) {
		final CompositeidFactory factory = CompositeidFactory.eINSTANCE;
		{
			store.beginTransaction();
			final Parent parent = factory.createParent();
			parent.setFirstName("John");
			parent.setLastName("Smith");
			final Child child1 = factory.createChild();
			child1.setFirstName("Johnny");
			child1.setLastName("Smith");
			parent.getChildren().add(child1);
			final Child child2 = factory.createChild();
			child2.setFirstName("Jane");
			child2.setLastName("Smith");
			parent.getChildren().add(child2);
			store.store(parent.getChildren());
			store.store(parent);
			store.commitTransaction();
		}

		// read again
		{
			store.beginTransaction();
			final Parent parent = (Parent) store.getObject(Parent.class);
			assertEquals(2, parent.getChildren().size());
			assertEquals("Johnny", parent.getChildren().get(0).getFirstName());
			assertEquals("Jane", parent.getChildren().get(1).getFirstName());
			store.commitTransaction();
		}
	}
}

Back to the top