Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryQualifyActionHB.java')
-rwxr-xr-xtests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryQualifyActionHB.java102
1 files changed, 102 insertions, 0 deletions
diff --git a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryQualifyActionHB.java b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryQualifyActionHB.java
new file mode 100755
index 000000000..b1673ad65
--- /dev/null
+++ b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryQualifyActionHB.java
@@ -0,0 +1,102 @@
+/**
+ * <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: LibraryQualifyActionHB.java,v 1.7 2008/02/28 07:08:14 mtaal Exp $
+ */
+
+package org.eclipse.emf.teneo.test.emf.sample;
+
+import org.eclipse.emf.teneo.extension.ExtensionManager;
+import org.eclipse.emf.teneo.mapping.strategy.EntityNameStrategy;
+import org.eclipse.emf.teneo.mapping.strategy.impl.QualifyingEntityNameStrategy;
+import org.eclipse.emf.teneo.samples.emf.sample.library.Book;
+import org.eclipse.emf.teneo.samples.emf.sample.library.BookCategory;
+import org.eclipse.emf.teneo.samples.emf.sample.library.Library;
+import org.eclipse.emf.teneo.samples.emf.sample.library.LibraryFactory;
+import org.eclipse.emf.teneo.samples.emf.sample.library.LibraryPackage;
+import org.eclipse.emf.teneo.samples.emf.sample.library.Writer;
+import org.eclipse.emf.teneo.test.AbstractTestAction;
+import org.eclipse.emf.teneo.test.stores.TestStore;
+
+/**
+ * Tests setting of qualified enames
+ *
+ * @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
+ * @version $Revision: 1.7 $
+ */
+public class LibraryQualifyActionHB extends AbstractTestAction {
+ /**
+ * Constructor for ClassHierarchyParsing.
+ *
+ * @param arg0
+ */
+ public LibraryQualifyActionHB() {
+ super(LibraryPackage.eINSTANCE);
+
+ }
+
+ /** Add extensions if you want */
+ @Override
+ public void setExtensions(ExtensionManager extensionManager) {
+ extensionManager.registerExtension(EntityNameStrategy.class.getName(), QualifyingEntityNameStrategy.class
+ .getName());
+ }
+
+ /** Creates an item, an address and links them to a po. */
+ @Override
+ @SuppressWarnings("unchecked")
+ public void doAction(TestStore store) {
+ final LibraryFactory factory = LibraryFactory.eINSTANCE;
+ // create a book, writer and library
+ {
+ store.beginTransaction();
+
+ final Writer writer = factory.createWriter();
+ writer.setName("JRR Tolkien");
+
+ final Book book = factory.createBook();
+ book.setAuthor(writer);
+ book.setPages(5);
+ book.setTitle("The Hobbit");
+ book.setCategory(BookCategory.SCIENCE_FICTION_LITERAL);
+
+ final Book book2 = factory.createBook();
+ book2.setAuthor(writer);
+ book2.setPages(5);
+ book2.setTitle("The fellowship of the ring");
+ book2.setCategory(BookCategory.SCIENCE_FICTION_LITERAL);
+
+ final Library library = factory.createLibrary();
+ library.getBooks().add(book);
+ library.setName("Science Fiction Library");
+ library.getBooks().add(book2);
+ library.getWriters().add(writer);
+ store.store(library);
+
+ store.commitTransaction();
+ assertEquals(2, writer.getBooks().size());
+ }
+
+ // now test some qualified queries
+ {
+ store.beginTransaction();
+ Library lib = (Library) store.query("select l from " + LibraryPackage.eNS_PREFIX + ".Library l").get(0);
+ assertTrue(lib != null);
+ Writer writ = (Writer) store.query("select w from " + LibraryPackage.eNS_PREFIX + ".Writer w").get(0);
+ assertTrue(writ != null);
+ Book bk = (Book) store.query("select b from " + LibraryPackage.eNS_PREFIX + ".Book b").get(0);
+ assertTrue(bk != null);
+ store.commitTransaction();
+ }
+ }
+} \ No newline at end of file

Back to the top