• R/O
  • HTTP
  • SSH
  • HTTPS

tmdmaker: Commit

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


Commit MetaInfo

Revisiond932da1cd49252b12c7638ec235c5d2266fc6d3f (tree)
Time2018-09-20 21:39:31
Authornakag <nakag@user...>
Commiternakag

Log Message

Add api tests.

Change Summary

Incremental Difference

--- a/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/multivalue/MultivalueOr.java
+++ b/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/multivalue/MultivalueOr.java
@@ -42,7 +42,7 @@ public class MultivalueOr {
4242
4343 public List<MultivalueOrEntity> all() {
4444 List<MultivalueOrRelationship> relationships = this.source
45- .findRelationshipFromTargetConnections(MultivalueOrRelationship.class);
45+ .findRelationshipFromSourceConnections(MultivalueOrRelationship.class);
4646 List<MultivalueOrEntity> results = new ArrayList<MultivalueOrEntity>();
4747 for (AbstractConnectionModel r : relationships) {
4848 results.add((MultivalueOrEntity) r.getTarget());
--- a/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/subset/SubsetBuilder.java
+++ b/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/subset/SubsetBuilder.java
@@ -221,4 +221,5 @@ public class SubsetBuilder {
221221 r.connect();
222222 }
223223 }
224+
224225 }
--- a/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/virtual/VirtualSubsetBuilder.java
+++ b/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/virtual/VirtualSubsetBuilder.java
@@ -59,7 +59,7 @@ public class VirtualSubsetBuilder {
5959 }
6060 return;
6161 }
62-
62+
6363 if (addSubsetList != null && !addSubsetList.isEmpty()) {
6464 this.relationship.reconnect(addSubsetList);
6565 } else {
@@ -69,7 +69,9 @@ public class VirtualSubsetBuilder {
6969
7070 public void rollback() {
7171 if (this.creation) {
72- this.relationship.disconnect();
72+ if (this.relationship != null) {
73+ this.relationship.disconnect();
74+ }
7375 } else {
7476 this.relationship.setSubset2typeRelationshipList(this.oldSubsetRelationshipList);
7577 this.relationship.connect();
--- a/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/virtual/VirtualSubsets.java
+++ b/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/virtual/VirtualSubsets.java
@@ -15,7 +15,12 @@
1515 */
1616 package jp.sourceforge.tmdmaker.model.virtual;
1717
18+import java.util.Collections;
19+import java.util.List;
20+
21+import jp.sourceforge.tmdmaker.model.AbstractEntityModel;
1822 import jp.sourceforge.tmdmaker.model.VirtualSuperset;
23+import jp.sourceforge.tmdmaker.model.VirtualSupersetType;
1924
2025 /**
2126 * みなしサブセットの集約クラス.
@@ -35,4 +40,12 @@ public class VirtualSubsets {
3540 public VirtualSubsetBuilder builder() {
3641 return new VirtualSubsetBuilder(this.parent);
3742 }
43+
44+ public List<AbstractEntityModel> all() {
45+ VirtualSupersetType type = this.parent.getVirtualSupersetType();
46+ if (type != null) {
47+ return type.getSubsetList();
48+ }
49+ return Collections.emptyList();
50+ }
3851 }
--- a/tests/tmdmaker.core.test/src/jp/sourceforge/tmdmaker/model/MultivalueAndTest.java
+++ b/tests/tmdmaker.core.test/src/jp/sourceforge/tmdmaker/model/MultivalueAndTest.java
@@ -16,15 +16,17 @@
1616 package jp.sourceforge.tmdmaker.model;
1717
1818 import static org.junit.Assert.assertEquals;
19+import static org.junit.Assert.assertTrue;
1920
2021 import java.util.Map;
2122
2223 import org.junit.Test;
2324
25+import jp.sourceforge.tmdmaker.model.multivalue.MultivalueAndBuilder;
2426 import jp.sourceforge.tmdmaker.model.relationship.Relationship;
2527
2628 /**
27- * MultivalueAndSupersetのテストクラス
29+ * 多値のANDのテストクラス
2830 *
2931 * @author nakag
3032 *
@@ -127,4 +129,32 @@ public class MultivalueAndTest {
127129 assertEquals("テスト1明細番号変更", dri3.getIdentifiers().get(1).getName()); // 伝播しない
128130
129131 }
132+
133+ @Test
134+ public void testBuilder() {
135+ Diagram diagram = new Diagram();
136+ Entity e1 = Entity.ofEvent(new Identifier("テスト1番号")).withDefaultAttribute();
137+ diagram.addChild(e1);
138+ Entity e2 = Entity.ofResource(new Identifier("テスト2番号")).withDefaultAttribute();
139+ diagram.addChild(e2);
140+ Entity e3 = Entity.ofEvent(new Identifier("テスト3番号")).withDefaultAttribute();
141+ diagram.addChild(e3);
142+ AbstractRelationship r = Relationship.of(e2, e1);
143+ r.connect();
144+ r.setSourceCardinality(Cardinality.MANY);
145+ r.setTargetCardinality(Cardinality.MANY);
146+
147+ MultivalueAndBuilder builder = e1.multivalueAnd().builder();
148+ builder.build();
149+ assertTrue(e1.isHeaderDetail());
150+ assertTrue(e1.multivalueAnd().aggregator() != null);
151+ assertTrue(e1.multivalueAnd().superset() != null);
152+ assertTrue(e1.multivalueAnd().detail() != null);
153+
154+ builder.rollback();
155+ assertTrue(!e1.isHeaderDetail());
156+ assertTrue(e1.multivalueAnd().aggregator() == null);
157+ assertTrue(e1.multivalueAnd().superset() == null);
158+ assertTrue(e1.multivalueAnd().detail() == null);
159+ }
130160 }
--- /dev/null
+++ b/tests/tmdmaker.core.test/src/jp/sourceforge/tmdmaker/model/MultivalueOrTest.java
@@ -0,0 +1,43 @@
1+/*
2+ * Copyright 2009-2018 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.model;
17+
18+import static org.junit.Assert.assertEquals;
19+
20+import org.junit.Test;
21+
22+import jp.sourceforge.tmdmaker.model.multivalue.MultivalueOrBuilder;
23+
24+/**
25+ * 多値のORのテストクラス
26+ *
27+ * @author nakag
28+ *
29+ */
30+public class MultivalueOrTest {
31+ @Test
32+ public void testSuperset() {
33+ Diagram diagram = new Diagram();
34+ Entity e1 = Entity.ofEvent(new Identifier("テスト1番号")).withDefaultAttribute();
35+ diagram.addChild(e1);
36+ MultivalueOrBuilder builder = e1.multivalueOr().builder();
37+ builder.typeName("テスト種別").build();
38+ assertEquals(1, e1.multivalueOr().all().size());
39+
40+ builder.rollback();
41+ assertEquals(0, e1.multivalueOr().all().size());
42+ }
43+}
--- a/tests/tmdmaker.core.test/src/jp/sourceforge/tmdmaker/model/SubsetTest.java
+++ b/tests/tmdmaker.core.test/src/jp/sourceforge/tmdmaker/model/SubsetTest.java
@@ -26,6 +26,7 @@ import org.junit.Test;
2626
2727 import jp.sourceforge.tmdmaker.model.SubsetType.SubsetTypeValue;
2828 import jp.sourceforge.tmdmaker.model.parts.ModelName;
29+import jp.sourceforge.tmdmaker.model.subset.SubsetBuilder;
2930
3031 /**
3132 * Subsetのテストクラス
@@ -144,4 +145,71 @@ public class SubsetTest {
144145 assertEquals(true, subsetType.isInitialPosition());
145146 }
146147
148+ @Test
149+ public void testBuilder1() {
150+ SubsetBuilder builder = e1.subsets().builder();
151+ ModelName subsetName = new ModelName("サブセット3");
152+ builder
153+ .add(subsetName)
154+ .notExpectNull()
155+ .build();
156+ assertEquals(3, e1.subsets().all().size());
157+ builder.rollbackAdd();
158+ assertEquals(2, e1.subsets().all().size());
159+ builder.build();
160+
161+ SubsetEntity s1 = e1.subsets().query().findByName(subsetName).get(0);
162+ builder = e1.subsets().builder();
163+ builder.remove(s1).build();
164+ assertEquals(2, e1.subsets().all().size());
165+ builder.rollbackRemove();
166+ }
167+
168+ @Test
169+ public void testBuilder2() {
170+ Entity e2 = Entity.ofEvent(new Identifier("テスト1番号")).withDefaultAttribute();
171+ diagram.addChild(e2);
172+ Attribute atr = new Attribute("アトリビュート");
173+ e2.addAttribute(atr);
174+
175+ SubsetBuilder builder = e2.subsets().builder();
176+ builder.different()
177+ .expectNull()
178+ .partition(atr)
179+ .add(new ModelName("サブセット1"))
180+ .add(new ModelName("サブセット2"))
181+ .build();
182+ builder.build();
183+ builder.rollbackAdd();
184+ assertEquals(0, e2.subsets().all().size());
185+ }
186+
187+ @Test
188+ public void testBuilder3() {
189+ Entity e2 = Entity.ofEvent(new Identifier("テスト1番号")).withDefaultAttribute();
190+ diagram.addChild(e2);
191+ Attribute atr = new Attribute("アトリビュート");
192+ e2.addAttribute(atr);
193+
194+ SubsetBuilder builder = e2.subsets().builder();
195+ builder.different()
196+ .expectNull()
197+ .partition(atr)
198+ .add(new ModelName("サブセット1"))
199+ .add(new ModelName("サブセット2"))
200+ .build();
201+ builder.build();
202+ assertEquals(2, e2.subsets().all().size());
203+
204+ builder = e2.subsets().builder();
205+ builder
206+ .remove(e2.subsets().all().get(0))
207+ .remove(e2.subsets().all().get(1))
208+ .build();
209+ assertEquals(0, e2.subsets().all().size());
210+
211+ builder.rollbackRemove();
212+ assertEquals(2, e2.subsets().all().size());
213+ }
214+
147215 }
--- /dev/null
+++ b/tests/tmdmaker.core.test/src/jp/sourceforge/tmdmaker/model/VirtualEntityTest.java
@@ -0,0 +1,51 @@
1+/*
2+ * Copyright 2009-2018 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.model;
17+
18+import static org.junit.Assert.assertEquals;
19+
20+import java.util.List;
21+
22+import org.junit.Test;
23+
24+import jp.sourceforge.tmdmaker.model.parts.ModelName;
25+import jp.sourceforge.tmdmaker.model.virtual.VirtualEntityBuilder;
26+
27+/**
28+ * みなしエンティティのテストクラス
29+ *
30+ * @author nakag
31+ *
32+ */
33+public class VirtualEntityTest {
34+ @Test
35+ public void testCreateVE() {
36+ Diagram diagram = new Diagram();
37+ Entity e1 = Entity.ofEvent(new Identifier("テスト1番号")).withDefaultAttribute();
38+ diagram.addChild(e1);
39+
40+ VirtualEntityBuilder builder = e1.virtualEntities().builder();
41+ ModelName veName = new ModelName("テストVE");
42+ builder.virtualEntityName(veName);
43+ builder.build();
44+ List<VirtualEntity> results = e1.virtualEntities().query().findByName(veName);
45+ assertEquals(1, results.size());
46+
47+ builder.rollback();
48+ results = e1.virtualEntities().query().findByName(veName);
49+ assertEquals(0, results.size());
50+ }
51+}
--- a/tests/tmdmaker.core.test/src/jp/sourceforge/tmdmaker/model/VirtualSupersetTest.java
+++ b/tests/tmdmaker.core.test/src/jp/sourceforge/tmdmaker/model/VirtualSupersetTest.java
@@ -16,7 +16,7 @@
1616 package jp.sourceforge.tmdmaker.model;
1717
1818 import static org.junit.Assert.assertEquals;
19-import static org.junit.Assert.fail;
19+import static org.junit.Assert.assertTrue;
2020
2121 import java.util.ArrayList;
2222 import java.util.List;
@@ -24,6 +24,7 @@ import java.util.List;
2424 import org.junit.Test;
2525
2626 import jp.sourceforge.tmdmaker.model.parts.ModelName;
27+import jp.sourceforge.tmdmaker.model.virtual.VirtualSubsetBuilder;
2728
2829 /**
2930 * VirtualSupersetのテストクラス
@@ -49,7 +50,9 @@ public class VirtualSupersetTest {
4950 list.add(e1);
5051 list.add(e2);
5152 VirtualSuperset vsp = VirtualSuperset.of(new ModelName("スーパーセット"));
52- vsp.virtualSubsets().builder().subsetList(list).build();
53+ VirtualSubsetBuilder builder = vsp.virtualSubsets().builder();
54+ builder.subsetList(list).build();
55+ assertTrue(vsp.hasSubset());
5356 VirtualSupersetType type1 = vsp.getVirtualSupersetType();
5457
5558 assertEquals(true, vsp.isDeletable());
@@ -58,15 +61,12 @@ public class VirtualSupersetTest {
5861 assertEquals(true, vsp.hasSubset());
5962 assertEquals(2, vsp.getVirtualSubsetRelationshipList().size());
6063
61- vsp.getCreationRelationship().disconnect();
62- assertEquals(0, vsp.getVirtualSubsetList().size());
63- assertEquals(false, vsp.hasSubset());
64+ builder.rollback();
65+ assertTrue(!vsp.hasSubset());
6466 VirtualSupersetType type2 = vsp.getVirtualSupersetType();
6567 if (!diagram.getChildren().contains(type2)) {
6668 return;
6769 }
68-
69- fail("VirtualSupersetType is not empty.");
7070 }
7171
7272 @Test
@@ -101,4 +101,91 @@ public class VirtualSupersetTest {
101101 assertEquals(true, type2.isVertical());
102102 assertEquals(type1.getSuperset(), vsp1);
103103 }
104+
105+ @Test
106+ public void testSuper3Super() {
107+ List<AbstractEntityModel> list = new ArrayList<AbstractEntityModel>();
108+ Diagram diagram = new Diagram();
109+ Entity e1 = Entity.ofEvent(new Identifier("テスト1番号")).withDefaultAttribute();
110+ diagram.addChild(e1);
111+ Entity e2 = Entity.ofEvent(new Identifier("テスト2番号")).withDefaultAttribute();
112+ diagram.addChild(e2);
113+ Entity e3 = Entity.ofEvent(new Identifier("テスト2番号")).withDefaultAttribute();
114+ diagram.addChild(e3);
115+ VirtualSuperset vsp1 = VirtualSuperset.of(new ModelName("スーパーセット3"));
116+ VirtualSubsetBuilder builder = vsp1.virtualSubsets().builder();
117+ builder.subsetList(list).build();
118+ assertTrue(!vsp1.hasSubset());
119+
120+ builder.rollback();
121+ list.add(e1);
122+ list.add(e2);
123+ list.add(e3);
124+ builder.subsetList(list).build();
125+ assertTrue(vsp1.hasSubset());
126+ assertEquals(diagram, vsp1.getDiagram());
127+ }
128+
129+ @Test
130+ public void testEditSuperSuper1() {
131+ List<AbstractEntityModel> list = new ArrayList<AbstractEntityModel>();
132+ Diagram diagram = new Diagram();
133+ Entity e1 = Entity.ofEvent(new Identifier("テスト1番号")).withDefaultAttribute();
134+ diagram.addChild(e1);
135+ Entity e2 = Entity.ofEvent(new Identifier("テスト2番号")).withDefaultAttribute();
136+ diagram.addChild(e2);
137+ Entity e3 = Entity.ofEvent(new Identifier("テスト2番号")).withDefaultAttribute();
138+ diagram.addChild(e3);
139+ VirtualSuperset vsp1 = VirtualSuperset.of(new ModelName("スーパーセット"));
140+ VirtualSubsetBuilder builder = vsp1.virtualSubsets().builder();
141+ list.add(e1);
142+ list.add(e2);
143+ list.add(e3);
144+ builder.subsetList(list).build();
145+ assertEquals(3, vsp1.virtualSubsets().all().size());
146+
147+ List<AbstractEntityModel> list2 = new ArrayList<AbstractEntityModel>();
148+ list2.add(e1);
149+ list2.add(e2);
150+ builder = vsp1.virtualSubsets().builder();
151+ builder.subsetList(list2).build();
152+ assertTrue(vsp1.hasSubset());
153+ assertEquals(vsp1.virtualSubsets().all().size(), 2);
154+
155+ builder.rollback();
156+ assertTrue(vsp1.hasSubset());
157+ assertEquals(vsp1.virtualSubsets().all().size(), 3);
158+ }
159+
160+ @Test
161+ public void testDeleteSuperSuper1() {
162+ List<AbstractEntityModel> list = new ArrayList<AbstractEntityModel>();
163+ Diagram diagram = new Diagram();
164+ Entity e1 = Entity.ofEvent(new Identifier("テスト1番号")).withDefaultAttribute();
165+ diagram.addChild(e1);
166+ Entity e2 = Entity.ofEvent(new Identifier("テスト2番号")).withDefaultAttribute();
167+ diagram.addChild(e2);
168+ Entity e3 = Entity.ofEvent(new Identifier("テスト2番号")).withDefaultAttribute();
169+ diagram.addChild(e3);
170+ VirtualSuperset vsp1 = VirtualSuperset.of(new ModelName("スーパーセット"));
171+ VirtualSubsetBuilder builder = vsp1.virtualSubsets().builder();
172+ list.add(e1);
173+ list.add(e2);
174+ list.add(e3);
175+ builder.subsetList(list).build();
176+ assertEquals(3, vsp1.virtualSubsets().all().size());
177+
178+ List<AbstractEntityModel> list2 = new ArrayList<AbstractEntityModel>();
179+ list2.add(e1);
180+ list2.add(e2);
181+ builder = vsp1.virtualSubsets().builder();
182+ builder.subsetList(null).build();
183+ assertTrue(!vsp1.hasSubset());
184+ assertEquals(vsp1.virtualSubsets().all().size(), 0);
185+
186+ builder.rollback();
187+ assertTrue(vsp1.hasSubset());
188+ assertEquals(vsp1.virtualSubsets().all().size(), 3);
189+ }
190+
104191 }
Show on old repository browser