svnno****@sourc*****
svnno****@sourc*****
2009年 5月 3日 (日) 09:54:59 JST
Revision: 3345 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=3345 Author: daisuke_m Date: 2009-05-03 09:54:59 +0900 (Sun, 03 May 2009) Log Message: ----------- テストケースの移動。 Modified Paths: -------------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/generic/GenericDialect.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/RootModelImplTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/RootModelUtilTest.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/JiemamyNamespace.java Added Paths: ----------- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/attribute/ColumnModelImplTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/entity/ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/entity/AbstractEntityModelTest.java Removed Paths: ------------- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/ColumnUtilTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/EntityUtilTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/ForeignKeyUtilTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/TableUtilTest.java -------------- next part -------------- Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/generic/GenericDialect.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/generic/GenericDialect.java 2009-05-03 00:18:26 UTC (rev 3344) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/generic/GenericDialect.java 2009-05-03 00:54:59 UTC (rev 3345) @@ -49,7 +49,6 @@ static { List<BuiltinDataTypeMold> list = CollectionsUtil.newArrayList(); - // FIXME 適当 list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.INTEGER)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.SMALLINT)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.NUMERIC, PrecisionedDataTypeAdapter.class)); Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/RootModelImplTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/RootModelImplTest.java 2009-05-03 00:18:26 UTC (rev 3344) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/RootModelImplTest.java 2009-05-03 00:54:59 UTC (rev 3345) @@ -29,7 +29,14 @@ import org.jiemamy.Jiemamy; import org.jiemamy.JiemamyFactory; +import org.jiemamy.dialect.Dialect; +import org.jiemamy.internal.builder.TableBuilderImpl; +import org.jiemamy.internal.builder.ViewBuilderImpl; +import org.jiemamy.internal.test.CoreTestModelBuilder; +import org.jiemamy.internal.test.ReflectionDialectProvider; import org.jiemamy.model.RootModel; +import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.entity.ViewModel; /** * {@link RootModelImpl}のテストクラス。 @@ -38,12 +45,8 @@ */ public class RootModelImplTest { - private Jiemamy jiemamy; + private CoreTestModelBuilder mb; - private JiemamyFactory factory; - - private RootModel rootModel; - /** * テストを初期化する。 @@ -52,9 +55,8 @@ */ @Before public void setUp() throws Exception { - jiemamy = Jiemamy.newInstance(); - factory = jiemamy.getFactory(); - rootModel = factory.getRootModel(); + mb = new CoreTestModelBuilder(new ReflectionDialectProvider()); + mb.build(); } /** @@ -64,9 +66,7 @@ */ @After public void tearDown() throws Exception { - rootModel = null; - factory = null; - jiemamy = null; + mb = null; } /** @@ -76,6 +76,10 @@ */ @Test public void test01_各プロパティが正常に初期化されていること() throws Exception { + Jiemamy jiemamy = Jiemamy.newInstance(); + JiemamyFactory factory = jiemamy.getFactory(); + RootModel rootModel = factory.getRootModel(); + assertThat(rootModel.getBeginScript(), is(nullValue())); assertThat(rootModel.getEndScript(), is(nullValue())); assertThat(rootModel.getDescription(), is(nullValue())); @@ -94,4 +98,79 @@ assertThat(rootModel.getDataSets().size(), is(0)); } + /** + * rootModelから特定のエンティティを抽出するテスト。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test02_rootModelから特定のエンティティを抽出するテスト() throws Exception { + Jiemamy jiemamy = Jiemamy.newInstance(); + JiemamyFactory factory = jiemamy.getFactory(); + RootModel rootModel = factory.getRootModel(); + + rootModel.getEntities().add(new TableBuilderImpl(factory, "table1").build()); + rootModel.getEntities().add(new TableBuilderImpl(factory, "table2").build()); + rootModel.getEntities().add(new TableBuilderImpl(factory, "table3").build()); + rootModel.getEntities().add(new ViewBuilderImpl(factory, "view1").build()); + rootModel.getEntities().add(new ViewBuilderImpl(factory, "view2").build()); + + assertThat(rootModel.findEntities(TableModel.class).size(), is(3)); + assertThat(rootModel.findEntities(ViewModel.class).size(), is(2)); + } + + /** + * {@link RootModel#findDialect()}のテスト。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test03_getDialect() throws Exception { + Dialect dialect = mb.rootModel.findDialect(); + assertThat(dialect, is(notNullValue())); + assertThat(dialect.toString(), is(mb.rootModel.getDialectClassName())); + } + + /** + * {@link RootModel#normalize()}のテスト。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test03_normalize() throws Exception { + // empIdはPKである + assertThat(mb.empId.checkPrimaryKeyColumn(), is(true)); + + // PKはカラムに対して設定されたものではなく + assertThat(mb.empId.getPrimaryKey(), is(nullValue())); + + // テーブルに対して属性として設定されたものである + assertThat(mb.tableEmp.getAttributes().contains(mb.empPk), is(true)); + + // このPKを外すと + assertThat(mb.tableEmp.getAttributes().remove(mb.empPk), is(true)); + + // empIdはPKではなくなる + assertThat(mb.empId.checkPrimaryKeyColumn(), is(false)); + + // 今度はPKカラムに対して設定し + mb.empId.setPrimaryKey(mb.empPk); + + // カラムに対するgetPrimaryKeyで取得できることを確認する + assertThat(mb.empId.getPrimaryKey(), is(mb.empPk)); + + // PKはテーブルに対して属性として設定されたものではないが + assertThat(mb.tableEmp.getAttributes().contains(mb.empPk), is(false)); + + // empIdがPK扱いとなる + assertThat(mb.empId.checkPrimaryKeyColumn(), is(true)); + + // ここでノーマライズすると + mb.rootModel.normalize(); + + // カラムに設定されたPKは、テーブルに対するPKに戻る。 + assertThat(mb.empId.getPrimaryKey(), is(nullValue())); + assertThat(mb.tableEmp.getAttributes().contains(mb.empPk), is(true)); + assertThat(mb.empId.checkPrimaryKeyColumn(), is(true)); + } } Added: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/attribute/ColumnModelImplTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/attribute/ColumnModelImplTest.java (rev 0) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/attribute/ColumnModelImplTest.java 2009-05-03 00:54:59 UTC (rev 3345) @@ -0,0 +1,102 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/05/03 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.internal.model.attribute; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import org.jiemamy.Artemis; +import org.jiemamy.Jiemamy; +import org.jiemamy.internal.test.CoreTestModelBuilder; +import org.jiemamy.internal.test.ReflectionDialectProvider; +import org.jiemamy.model.attribute.ColumnModel; + +/** + * {@link ColumnModelImpl}のテストクラス。 + * + * @author daisuke + */ +public class ColumnModelImplTest { + + private CoreTestModelBuilder mb; + + + /** + * テストを初期化する。 + * + * @throws Exception 例外が発生した場合 + */ + @Before + public void setUp() throws Exception { + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); + mb = new CoreTestModelBuilder(jiemamy); + mb.build(); + } + + /** + * テストの情報を破棄する。 + * + * @throws Exception 例外が発生した場合 + */ + @After + public void tearDown() throws Exception { + mb = null; + } + + /** + * {@link ColumnModel#checkPrimaryKeyColumn()}のテスト。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test01_isPartOfPrimaryKeyColumns() throws Exception { + assertThat(mb.deptId.checkPrimaryKeyColumn(), is(true)); + assertThat(mb.deptDeptName.checkPrimaryKeyColumn(), is(false)); + assertThat(mb.deptDeptNo.checkPrimaryKeyColumn(), is(false)); + + // empIdはPKである + assertThat(mb.empId.checkPrimaryKeyColumn(), is(true)); + + // PKを外すと + assertThat(mb.tableEmp.getAttributes().remove(mb.empPk), is(true)); + + // empIdはPKではなくなる + assertThat(mb.empId.checkPrimaryKeyColumn(), is(false)); + + // カラムに対してPKは設定されていない + assertThat(mb.empId.getPrimaryKey(), is(nullValue())); + + // そこにPKを設定する + mb.empId.setPrimaryKey(mb.empPk); + + // そするとPK扱いとなる + assertThat(mb.empId.checkPrimaryKeyColumn(), is(true)); + + // しかし、テーブルのattributesには含まれていない + assertThat(mb.tableEmp.getAttributes().contains(mb.empPk), is(false)); + + // カラムに対するgetPrimaryKeyでPKが取れる + assertThat(mb.empId.getPrimaryKey(), is(mb.empPk)); + } +} Property changes on: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/attribute/ColumnModelImplTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/entity/AbstractEntityModelTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/entity/AbstractEntityModelTest.java (rev 0) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/entity/AbstractEntityModelTest.java 2009-05-03 00:54:59 UTC (rev 3345) @@ -0,0 +1,151 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/05/03 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.internal.model.entity; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.hasItems; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +import org.jiemamy.Artemis; +import org.jiemamy.Jiemamy; +import org.jiemamy.internal.test.CoreTestModelBuilder; +import org.jiemamy.internal.test.CoreTestModelBuilder2; +import org.jiemamy.internal.test.ReflectionDialectProvider; +import org.jiemamy.model.entity.EntityModel; + +/** + * {@link AbstractEntityModel}のテストクラス。 + * + * @author daisuke + */ +public class AbstractEntityModelTest { + + /** + * {@link EntityModel#findSuperEntities(boolean)} + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test01_findSuperEntities_empDept() throws Exception { + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); + CoreTestModelBuilder mb = new CoreTestModelBuilder(jiemamy); + mb.build(); + // /- EMP -> DEPT + // `___^ + // 矢印を正順に辿る + + assertThat(mb.tableEmp.findSuperEntities(true), hasItems((EntityModel) mb.tableDept, mb.tableEmp)); + assertThat(mb.tableEmp.findSuperEntities(false), hasItems((EntityModel) mb.tableDept, mb.tableEmp)); + + assertThat(mb.tableDept.findSuperEntities(true).size(), is(0)); + assertThat(mb.tableDept.findSuperEntities(false).size(), is(0)); + assertThat(mb.tableEmp.findSuperEntities(true).size(), is(2)); + assertThat(mb.tableEmp.findSuperEntities(false).size(), is(2)); + } + + /** + * {@link EntityModel#findSubEntities(boolean)} + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test02_findSubEntities_empDept() throws Exception { + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); + CoreTestModelBuilder mb = new CoreTestModelBuilder(jiemamy); + mb.build(); + // /- EMP -> DEPT + // `___^ + // 矢印を逆順に辿る + + assertThat(mb.tableDept.findSubEntities(true), hasItem((EntityModel) mb.tableEmp)); + assertThat(mb.tableDept.findSubEntities(false), hasItem((EntityModel) mb.tableEmp)); + assertThat(mb.tableEmp.findSubEntities(true), hasItem((EntityModel) mb.tableEmp)); + assertThat(mb.tableEmp.findSubEntities(false), hasItem((EntityModel) mb.tableEmp)); + + assertThat(mb.tableDept.findSubEntities(true).size(), is(1)); + assertThat(mb.tableDept.findSubEntities(false).size(), is(1)); + assertThat(mb.tableEmp.findSubEntities(true).size(), is(1)); + assertThat(mb.tableEmp.findSubEntities(false).size(), is(1)); + } + + /** + * {@link EntityModel#findSuperEntities( boolean)} + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test03_findSuperEntities_order() throws Exception { + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); + CoreTestModelBuilder2 mb = new CoreTestModelBuilder2(jiemamy); + mb.build(); + // DETAIL +-> ORDER +-> USER + // +-> ITEM + // 矢印を正順に辿る + + assertThat(mb.tableDetail.findSuperEntities(true), hasItems((EntityModel) mb.tableOrder, mb.tableUser, + mb.tableItem)); + assertThat(mb.tableDetail.findSuperEntities(false), hasItems((EntityModel) mb.tableOrder, mb.tableItem)); + assertThat(mb.tableOrder.findSuperEntities(true), hasItem((EntityModel) mb.tableUser)); + assertThat(mb.tableOrder.findSuperEntities(false), hasItem((EntityModel) mb.tableUser)); + + assertThat(mb.tableDetail.findSuperEntities(true).size(), is(3)); + assertThat(mb.tableDetail.findSuperEntities(false).size(), is(2)); + assertThat(mb.tableItem.findSuperEntities(true).size(), is(0)); + assertThat(mb.tableItem.findSuperEntities(false).size(), is(0)); + assertThat(mb.tableOrder.findSuperEntities(true).size(), is(1)); + assertThat(mb.tableOrder.findSuperEntities(false).size(), is(1)); + assertThat(mb.tableUser.findSuperEntities(true).size(), is(0)); + assertThat(mb.tableUser.findSuperEntities(false).size(), is(0)); + } + + /** + * {@link EntityModel#findSubEntities(boolean)} + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test04_findSubEntities_order() throws Exception { + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); + CoreTestModelBuilder2 mb = new CoreTestModelBuilder2(jiemamy); + mb.build(); + // DETAIL +-> ORDER +-> USER + // +-> ITEM + // 矢印を逆順に辿る + + assertThat(mb.tableDetail.findSubEntities(true).size(), is(0)); + assertThat(mb.tableDetail.findSubEntities(false).size(), is(0)); + assertThat(mb.tableItem.findSubEntities(true).size(), is(1)); + assertThat(mb.tableItem.findSubEntities(false).size(), is(1)); + assertThat(mb.tableOrder.findSubEntities(true).size(), is(1)); + assertThat(mb.tableOrder.findSubEntities(false).size(), is(1)); + assertThat(mb.tableUser.findSubEntities(true).size(), is(2)); + assertThat(mb.tableUser.findSubEntities(false).size(), is(1)); + + assertThat(mb.tableItem.findSubEntities(true), hasItem((EntityModel) mb.tableDetail)); + assertThat(mb.tableItem.findSubEntities(false), hasItem((EntityModel) mb.tableDetail)); + assertThat(mb.tableOrder.findSubEntities(true), hasItem((EntityModel) mb.tableDetail)); + assertThat(mb.tableOrder.findSubEntities(false), hasItem((EntityModel) mb.tableDetail)); + assertThat(mb.tableUser.findSubEntities(true), hasItems((EntityModel) mb.tableOrder, mb.tableDetail)); + assertThat(mb.tableUser.findSubEntities(false), hasItem((EntityModel) mb.tableOrder)); + } + +} Property changes on: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/entity/AbstractEntityModelTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Deleted: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/ColumnUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/ColumnUtilTest.java 2009-05-03 00:18:26 UTC (rev 3344) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/ColumnUtilTest.java 2009-05-03 00:54:59 UTC (rev 3345) @@ -1,102 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/21 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.utils.model; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import org.jiemamy.Artemis; -import org.jiemamy.Jiemamy; -import org.jiemamy.internal.test.CoreTestModelBuilder; -import org.jiemamy.internal.test.ReflectionDialectProvider; -import org.jiemamy.model.attribute.ColumnModel; - -/** - * {@link ColumnUtil}のテストクラス。 - * - * @author daisuke - */ -public class ColumnUtilTest { - - private CoreTestModelBuilder mb; - - - /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); - mb = new CoreTestModelBuilder(jiemamy); - mb.build(); - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - mb = null; - } - - /** - * {@link ColumnModel#checkPrimaryKeyColumn()}のテスト。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test01_isPartOfPrimaryKeyColumns() throws Exception { - assertThat(mb.deptId.checkPrimaryKeyColumn(), is(true)); - assertThat(mb.deptDeptName.checkPrimaryKeyColumn(), is(false)); - assertThat(mb.deptDeptNo.checkPrimaryKeyColumn(), is(false)); - - // empIdはPKである - assertThat(mb.empId.checkPrimaryKeyColumn(), is(true)); - - // PKを外すと - assertThat(mb.tableEmp.getAttributes().remove(mb.empPk), is(true)); - - // empIdはPKではなくなる - assertThat(mb.empId.checkPrimaryKeyColumn(), is(false)); - - // カラムに対してPKは設定されていない - assertThat(mb.empId.getPrimaryKey(), is(nullValue())); - - // そこにPKを設定する - mb.empId.setPrimaryKey(mb.empPk); - - // そするとPK扱いとなる - assertThat(mb.empId.checkPrimaryKeyColumn(), is(true)); - - // しかし、テーブルのattributesには含まれていない - assertThat(mb.tableEmp.getAttributes().contains(mb.empPk), is(false)); - - // カラムに対するgetPrimaryKeyでPKが取れる - assertThat(mb.empId.getPrimaryKey(), is(mb.empPk)); - } -} Deleted: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/EntityUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/EntityUtilTest.java 2009-05-03 00:18:26 UTC (rev 3344) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/EntityUtilTest.java 2009-05-03 00:54:59 UTC (rev 3345) @@ -1,150 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/08/10 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.utils.model; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.hasItems; -import static org.junit.Assert.assertThat; - -import org.junit.Test; - -import org.jiemamy.Artemis; -import org.jiemamy.Jiemamy; -import org.jiemamy.internal.test.CoreTestModelBuilder; -import org.jiemamy.internal.test.CoreTestModelBuilder2; -import org.jiemamy.internal.test.ReflectionDialectProvider; -import org.jiemamy.model.entity.EntityModel; - -/** - * {@link EntityUtil}のテストクラス。 - * - * @author daisuke - */ -public class EntityUtilTest { - - /** - * {@link EntityModel#findSuperEntities(boolean)} - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test01_findSuperEntities_empDept() throws Exception { - Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); - CoreTestModelBuilder mb = new CoreTestModelBuilder(jiemamy); - mb.build(); - // /- EMP -> DEPT - // `___^ - // 矢印を正順に辿る - - assertThat(mb.tableEmp.findSuperEntities(true), hasItems((EntityModel) mb.tableDept, mb.tableEmp)); - assertThat(mb.tableEmp.findSuperEntities(false), hasItems((EntityModel) mb.tableDept, mb.tableEmp)); - - assertThat(mb.tableDept.findSuperEntities(true).size(), is(0)); - assertThat(mb.tableDept.findSuperEntities(false).size(), is(0)); - assertThat(mb.tableEmp.findSuperEntities(true).size(), is(2)); - assertThat(mb.tableEmp.findSuperEntities(false).size(), is(2)); - } - - /** - * {@link EntityModel#findSubEntities(boolean)} - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test02_findSubEntities_empDept() throws Exception { - Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); - CoreTestModelBuilder mb = new CoreTestModelBuilder(jiemamy); - mb.build(); - // /- EMP -> DEPT - // `___^ - // 矢印を逆順に辿る - - assertThat(mb.tableDept.findSubEntities(true), hasItem((EntityModel) mb.tableEmp)); - assertThat(mb.tableDept.findSubEntities(false), hasItem((EntityModel) mb.tableEmp)); - assertThat(mb.tableEmp.findSubEntities(true), hasItem((EntityModel) mb.tableEmp)); - assertThat(mb.tableEmp.findSubEntities(false), hasItem((EntityModel) mb.tableEmp)); - - assertThat(mb.tableDept.findSubEntities(true).size(), is(1)); - assertThat(mb.tableDept.findSubEntities(false).size(), is(1)); - assertThat(mb.tableEmp.findSubEntities(true).size(), is(1)); - assertThat(mb.tableEmp.findSubEntities(false).size(), is(1)); - } - - /** - * {@link EntityModel#findSuperEntities( boolean)} - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test03_findSuperEntities_order() throws Exception { - Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); - CoreTestModelBuilder2 mb = new CoreTestModelBuilder2(jiemamy); - mb.build(); - // DETAIL +-> ORDER +-> USER - // +-> ITEM - // 矢印を正順に辿る - - assertThat(mb.tableDetail.findSuperEntities(true), hasItems((EntityModel) mb.tableOrder, mb.tableUser, - mb.tableItem)); - assertThat(mb.tableDetail.findSuperEntities(false), hasItems((EntityModel) mb.tableOrder, mb.tableItem)); - assertThat(mb.tableOrder.findSuperEntities(true), hasItem((EntityModel) mb.tableUser)); - assertThat(mb.tableOrder.findSuperEntities(false), hasItem((EntityModel) mb.tableUser)); - - assertThat(mb.tableDetail.findSuperEntities(true).size(), is(3)); - assertThat(mb.tableDetail.findSuperEntities(false).size(), is(2)); - assertThat(mb.tableItem.findSuperEntities(true).size(), is(0)); - assertThat(mb.tableItem.findSuperEntities(false).size(), is(0)); - assertThat(mb.tableOrder.findSuperEntities(true).size(), is(1)); - assertThat(mb.tableOrder.findSuperEntities(false).size(), is(1)); - assertThat(mb.tableUser.findSuperEntities(true).size(), is(0)); - assertThat(mb.tableUser.findSuperEntities(false).size(), is(0)); - } - - /** - * {@link EntityModel#findSubEntities(boolean)} - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test04_findSubEntities_order() throws Exception { - Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); - CoreTestModelBuilder2 mb = new CoreTestModelBuilder2(jiemamy); - mb.build(); - // DETAIL +-> ORDER +-> USER - // +-> ITEM - // 矢印を逆順に辿る - - assertThat(mb.tableDetail.findSubEntities(true).size(), is(0)); - assertThat(mb.tableDetail.findSubEntities(false).size(), is(0)); - assertThat(mb.tableItem.findSubEntities(true).size(), is(1)); - assertThat(mb.tableItem.findSubEntities(false).size(), is(1)); - assertThat(mb.tableOrder.findSubEntities(true).size(), is(1)); - assertThat(mb.tableOrder.findSubEntities(false).size(), is(1)); - assertThat(mb.tableUser.findSubEntities(true).size(), is(2)); - assertThat(mb.tableUser.findSubEntities(false).size(), is(1)); - - assertThat(mb.tableItem.findSubEntities(true), hasItem((EntityModel) mb.tableDetail)); - assertThat(mb.tableItem.findSubEntities(false), hasItem((EntityModel) mb.tableDetail)); - assertThat(mb.tableOrder.findSubEntities(true), hasItem((EntityModel) mb.tableDetail)); - assertThat(mb.tableOrder.findSubEntities(false), hasItem((EntityModel) mb.tableDetail)); - assertThat(mb.tableUser.findSubEntities(true), hasItems((EntityModel) mb.tableOrder, mb.tableDetail)); - assertThat(mb.tableUser.findSubEntities(false), hasItem((EntityModel) mb.tableOrder)); - } -} Deleted: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/ForeignKeyUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/ForeignKeyUtilTest.java 2009-05-03 00:18:26 UTC (rev 3344) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/ForeignKeyUtilTest.java 2009-05-03 00:54:59 UTC (rev 3345) @@ -1,69 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/02/23 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.utils.model; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import org.jiemamy.internal.test.ReflectionDialectProvider; -import org.jiemamy.internal.test.CoreTestModelBuilder; - -/** - * {@link ForeignKeyUtil}のテストクラス。 - * - * @author daisuke - */ -public class ForeignKeyUtilTest { - - private CoreTestModelBuilder mb; - - - /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - mb = new CoreTestModelBuilder(new ReflectionDialectProvider()); - mb.build(); - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - mb = null; - } - - /** - * TODO for daisuke - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test01_() throws Exception { - // TODO - } - -} Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/RootModelUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/RootModelUtilTest.java 2009-05-03 00:18:26 UTC (rev 3344) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/RootModelUtilTest.java 2009-05-03 00:54:59 UTC (rev 3345) @@ -19,25 +19,17 @@ package org.jiemamy.utils.model; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; import static org.junit.Assert.assertThat; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.jiemamy.Jiemamy; -import org.jiemamy.JiemamyFactory; import org.jiemamy.dialect.Dialect; import org.jiemamy.dialect.generic.GenericDialect; -import org.jiemamy.internal.builder.TableBuilderImpl; -import org.jiemamy.internal.builder.ViewBuilderImpl; import org.jiemamy.internal.test.CoreTestModelBuilder; import org.jiemamy.internal.test.ReflectionDialectProvider; import org.jiemamy.model.RootModel; -import org.jiemamy.model.entity.TableModel; -import org.jiemamy.model.entity.ViewModel; /** * {@link RootModelUtil}のテストクラス。 @@ -71,39 +63,6 @@ } /** - * {@link RootModel#findDialect()}のテスト。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test01_getDialect() throws Exception { - Dialect dialect = mb.rootModel.findDialect(); - assertThat(dialect, is(notNullValue())); - assertThat(dialect.toString(), is(mb.rootModel.getDialectClassName())); - } - - /** - * rootModelから特定のエンティティを抽出するテスト。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test01_rootModelから特定のエンティティを抽出するテスト() throws Exception { - Jiemamy jiemamy = Jiemamy.newInstance(); - JiemamyFactory factory = jiemamy.getFactory(); - RootModel rootModel = factory.getRootModel(); - - rootModel.getEntities().add(new TableBuilderImpl(factory, "table1").build()); - rootModel.getEntities().add(new TableBuilderImpl(factory, "table2").build()); - rootModel.getEntities().add(new TableBuilderImpl(factory, "table3").build()); - rootModel.getEntities().add(new ViewBuilderImpl(factory, "view1").build()); - rootModel.getEntities().add(new ViewBuilderImpl(factory, "view2").build()); - - assertThat(rootModel.findEntities(TableModel.class).size(), is(3)); - assertThat(rootModel.findEntities(ViewModel.class).size(), is(2)); - } - - /** * {@link RootModelUtil#setDialect(RootModel, Class)}, * {@link RootModelUtil#setDialect(RootModel, Dialect)}のテストクラス。 * @@ -122,47 +81,4 @@ RootModelUtil.setDialect(rootModel, new GenericDialect()); assertThat(rootModel.getDialectClassName(), is(GenericDialect.class.getName())); } - - /** - * {@link RootModel#normalize()}のテスト。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test03_normalize() throws Exception { - // empIdはPKである - assertThat(mb.empId.checkPrimaryKeyColumn(), is(true)); - - // PKはカラムに対して設定されたものではなく - assertThat(mb.empId.getPrimaryKey(), is(nullValue())); - - // テーブルに対して属性として設定されたものである - assertThat(mb.tableEmp.getAttributes().contains(mb.empPk), is(true)); - - // このPKを外すと - assertThat(mb.tableEmp.getAttributes().remove(mb.empPk), is(true)); - - // empIdはPKではなくなる - assertThat(mb.empId.checkPrimaryKeyColumn(), is(false)); - - // 今度はPKカラムに対して設定し - mb.empId.setPrimaryKey(mb.empPk); - - // カラムに対するgetPrimaryKeyで取得できることを確認する - assertThat(mb.empId.getPrimaryKey(), is(mb.empPk)); - - // PKはテーブルに対して属性として設定されたものではないが - assertThat(mb.tableEmp.getAttributes().contains(mb.empPk), is(false)); - - // empIdがPK扱いとなる - assertThat(mb.empId.checkPrimaryKeyColumn(), is(true)); - - // ここでノーマライズすると - mb.rootModel.normalize(); - - // カラムに設定されたPKは、テーブルに対するPKに戻る。 - assertThat(mb.empId.getPrimaryKey(), is(nullValue())); - assertThat(mb.tableEmp.getAttributes().contains(mb.empPk), is(true)); - assertThat(mb.empId.checkPrimaryKeyColumn(), is(true)); - } } Deleted: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/TableUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/TableUtilTest.java 2009-05-03 00:18:26 UTC (rev 3344) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/TableUtilTest.java 2009-05-03 00:54:59 UTC (rev 3345) @@ -1,69 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/02/23 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.utils.model; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import org.jiemamy.internal.test.ReflectionDialectProvider; -import org.jiemamy.internal.test.CoreTestModelBuilder; - -/** - * {@link TableUtil}のテストクラス。 - * - * @author daisuke - */ -public class TableUtilTest { - - private CoreTestModelBuilder mb; - - - /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - mb = new CoreTestModelBuilder(new ReflectionDialectProvider()); - mb.build(); - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - mb = null; - } - - /** - * TODO for daisuke - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test01_() throws Exception { - // TODO - } - -} Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/JiemamyNamespace.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/JiemamyNamespace.java 2009-05-03 00:18:26 UTC (rev 3344) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/JiemamyNamespace.java 2009-05-03 00:54:59 UTC (rev 3345) @@ -44,9 +44,9 @@ String getPrefix(); /** - * TODO for daisuke + * XMLスキーマリソースが存在するURLを取得する。 * - * @return XMLスキーマのURL. may be null. + * @return XMLスキーマリソースが存在するURL. may be null. * @since 0.2 */ String getXmlSchemaLocation();