blob: 10caa58a647a59156bb0e548051b97b1f2423522 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/**
* <copyright>
*
* Copyright (c) 2005, 2006 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: HbIdAction.java,v 1.1 2006/08/31 22:46:12 mtaal Exp $
*/
package org.eclipse.emf.teneo.hibernate.test.emf.annotations;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.teneo.samples.emf.annotations.hb.generator.id.IdFactory;
import org.eclipse.emf.teneo.samples.emf.annotations.hb.generator.id.IdPackage;
import org.eclipse.emf.teneo.samples.emf.annotations.hb.generator.id.IdentityID;
import org.eclipse.emf.teneo.samples.emf.annotations.hb.generator.id.SimpleID;
import org.eclipse.emf.teneo.samples.emf.annotations.hb.generator.id.TableID;
import org.eclipse.emf.teneo.test.AbstractTestAction;
import org.eclipse.emf.teneo.test.stores.TestStore;
/**
* Tests GenericGenerator of hibernate
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
* @version $Revision: 1.1 $
*/
public class HbIdAction extends AbstractTestAction {
/** How many test objects are created */
private static final int NO_TEST_OBJECTS = 10;
/**
* Constructor for ClassHierarchyParsing.
*
* @param arg0
*/
public HbIdAction() {
super(IdPackage.eINSTANCE);
}
/** Creates an item, an address and links them to a po. */
public void doAction(TestStore store) {
//store.disableDrop();
final IdFactory factory = IdFactory.eINSTANCE;
{
store.beginTransaction();
for (int i = 0; i < NO_TEST_OBJECTS; i++) {
store.store(factory.createIdentityID());
store.store(factory.createTableID());
store.store(factory.createSimpleID());
}
store.commitTransaction();
}
// read back and check it
{
store.beginTransaction();
// test if we saved them all
List list = (List) store.getObjects(IdentityID.class);
HashMap testMap = new HashMap();
for (Iterator it = list.iterator(); it.hasNext();) {
IdentityID iid = (IdentityID) it.next();
testMap.put(new Long(iid.getMyid()), iid);
}
assertEquals(NO_TEST_OBJECTS, testMap.size());
list = (List) store.getObjects(TableID.class);
testMap = new HashMap();
for (Iterator it = list.iterator(); it.hasNext();) {
TableID sid = (TableID) it.next();
testMap.put(new Long(sid.getMyid()), sid);
}
assertEquals(NO_TEST_OBJECTS, testMap.size());
list = (List) store.getObjects(SimpleID.class);
testMap = new HashMap();
for (Iterator it = list.iterator(); it.hasNext();) {
SimpleID sid = (SimpleID) it.next();
testMap.put(new Long(sid.getAutoID()), sid);
}
assertEquals(NO_TEST_OBJECTS, testMap.size());
store.commitTransaction();
}
}
}
|