• R/O
  • HTTP
  • SSH
  • HTTPS

tmdmaker: Commit

TMD-Maker(T字形ER図作成ツール)のEclipse Plugin,RCP,Webサイト用


Commit MetaInfo

Revision6a861d3638eb54259cc287a76103305459961722 (tree)
Time2019-04-30 08:48:15
Authornakag <nakag@user...>
Commiternakag

Log Message

Add ddlutils tests.

Change Summary

Incremental Difference

--- a/docs/tmdmaker.doc/pom.xml
+++ b/docs/tmdmaker.doc/pom.xml
@@ -120,7 +120,6 @@
120120 <outputDirectory>${project.reporting.outputDirectory}/jacoco/report/</outputDirectory>
121121 <excludes>
122122 <exclude>**/org/eclipse/gmf/**/*.class</exclude>
123- <exclude>**/jp/sourceforge/tmdmaker/**/*Test.class</exclude>
124123 </excludes>
125124 </configuration>
126125 <goals>
--- a/tests/tmdmaker.ui.test/META-INF/MANIFEST.MF
+++ b/tests/tmdmaker.ui.test/META-INF/MANIFEST.MF
@@ -26,5 +26,6 @@ Require-Bundle: org.eclipse.swtbot.eclipse.finder,
2626 tmdmaker.core,
2727 org.eclipse.swtbot.e4.finder,
2828 tmdmaker.imagegenerator,
29- tmdmaker.sphinx
29+ tmdmaker.sphinx,
30+ tmdmaker.ddlgenerator
3031 Automatic-Module-Name: tmdmaker.ui.test
--- /dev/null
+++ b/tests/tmdmaker.ui.test/src/jp/sourceforge/tmdmaker/ui/editor/DDLGeneratorTest.java
@@ -0,0 +1,93 @@
1+/*
2+ * Copyright 2009-2019 TMD-Maker Project <https://tmdmaker.osdn.jp/>
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+package jp.sourceforge.tmdmaker.ui.editor;
17+
18+import java.io.File;
19+import java.util.Arrays;
20+import java.util.List;
21+import java.util.stream.Collectors;
22+
23+import org.eclipse.core.runtime.Platform;
24+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
25+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
26+import org.junit.Test;
27+import org.junit.runner.RunWith;
28+
29+import jp.sourceforge.tmdmaker.generate.ddl.DdlUtilsDDLGenerator;
30+import jp.sourceforge.tmdmaker.model.AbstractEntityModel;
31+import jp.sourceforge.tmdmaker.model.Entity;
32+
33+/**
34+ * TMD-MakerのDdlUtilsDDLGeneratorテスト.
35+ *
36+ * SWTBotがMessageDialogに対応していないので内部クラスを直接実行している.
37+ *
38+ * @author nakag
39+ *
40+ */
41+@RunWith(SWTBotJunit4ClassRunner.class)
42+public class DDLGeneratorTest extends AbstractUITest {
43+ DdlUtilsDDLGenerator generator;
44+
45+ @Override
46+ public void setUp() throws Exception {
47+ super.setUp();
48+ createEntity(50, 50, "顧客番号", 0);
49+ createEntity(300, 50, "商品番号", 0);
50+ // R:R 対照表
51+ botEditor.activateTool("Relationship");
52+ botEditor.click(55, 55);
53+ botEditor.click(305, 55);
54+ sleep();
55+ wait.waitFor(10);
56+ generator = new DdlUtilsDDLGenerator();
57+ }
58+
59+ @Test
60+ public void notSelectDatabase() {
61+ try {
62+ Entity e = (Entity) tmdEditor.getRootModel().getChildren().get(0);
63+ List<AbstractEntityModel> list = Arrays.asList(e);
64+ String rootDir = Platform.getInstanceLocation().getURL().getPath() + projectName();
65+ generator.execute(rootDir, list);
66+ } catch (RuntimeException e) {
67+ return;
68+ }
69+ fail();
70+ }
71+
72+ @Test
73+ public void generateTest() {
74+ botEditor.click(20, 20);
75+ botEditor.clickContextMenu("Select database");
76+ SWTBotShell shell = bot.shell("Select database");
77+ shell.activate();
78+ sleep();
79+
80+ bot.comboBox(0).setSelection(7);
81+ bot.button("OK").click();
82+ sleep();
83+
84+ List<AbstractEntityModel> list = tmdEditor.getRootModel().getChildren().stream()
85+ .filter(m -> m instanceof AbstractEntityModel).map(m -> (AbstractEntityModel) m)
86+ .collect(Collectors.toList());
87+
88+ String rootDir = Platform.getInstanceLocation().getURL().getPath() + projectName();
89+ generator.execute(rootDir, list);
90+ String docPath = rootDir + File.separator + "ddl.sql";
91+ assertEquals(true, new File(docPath).exists());
92+ }
93+}
--- a/tests/tmdmaker.ui.test/src/jp/sourceforge/tmdmaker/ui/editor/SphinxGeneratorTest.java
+++ b/tests/tmdmaker.ui.test/src/jp/sourceforge/tmdmaker/ui/editor/SphinxGeneratorTest.java
@@ -54,8 +54,7 @@ public class SphinxGeneratorTest extends AbstractUITest {
5454 List<AbstractEntityModel> list = Arrays.asList(e);
5555 String rootDir = Platform.getInstanceLocation().getURL().getPath() + projectName();
5656 generator.execute(rootDir, list);
57- String docPath = Platform.getInstanceLocation().getURL().getPath() + projectName()
58- + File.separator + "doc";
57+ String docPath = rootDir + File.separator + "doc";
5958 assertEquals(true, new File(docPath).exists());
6059 }
6160 }
Show on old repository browser