cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [3/3] cayenne git commit: CAY-2116 Split schema synchronization code in a separate module
Date Fri, 30 Sep 2016 14:50:23 GMT
CAY-2116 Split schema synchronization code in a separate module

* unifying object name generators under cayenne-dbsync
* removing unused classes (probably work in progress)


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/fc27ef7a
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/fc27ef7a
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/fc27ef7a

Branch: refs/heads/master
Commit: fc27ef7ae6dbe296a7974da45a5738d10e923cee
Parents: 041cb78
Author: Andrus Adamchik <andrus@objectstyle.com>
Authored: Fri Sep 30 17:34:49 2016 +0300
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Fri Sep 30 17:45:59 2016 +0300

----------------------------------------------------------------------
 .../cayenne/dbsync/reverse/mapper/DbType.java   | 194 -------------
 .../mapper/DefaultJdbc2JavaTypeMapper.java      | 282 -------------------
 .../reverse/mapper/Jdbc2JavaTypeMapper.java     |  33 ---
 .../naming/LegacyObjectNameGenerator.java       |   2 +-
 .../dbsync/reverse/mapper/DbTypeTest.java       |  87 ------
 5 files changed, 1 insertion(+), 597 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/fc27ef7a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/mapper/DbType.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/mapper/DbType.java
b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/mapper/DbType.java
deleted file mode 100644
index 9f829ea..0000000
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/mapper/DbType.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you 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.apache.cayenne.dbsync.reverse.mapper;
-
-import org.apache.cayenne.util.EqualsBuilder;
-import org.apache.cayenne.util.HashCodeBuilder;
-import org.apache.commons.lang.builder.CompareToBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import static org.apache.commons.lang.StringUtils.isBlank;
-
-/**
- * @since 4.0
- */
-public class DbType implements Comparable<DbType> {
-
-    private static final Log LOG = LogFactory.getLog(DbType.class);
-
-    public final String jdbc;
-
-    public final Integer length;
-    public final Integer precision;
-    public final Integer scale;
-    public final Boolean notNull;
-
-    public DbType(String jdbc) {
-        this(jdbc, null, null, null, null);
-    }
-
-    public DbType(String jdbc, Integer length, Integer precision, Integer scale, Boolean
notNull) {
-        if (isBlank(jdbc)) {
-            throw new IllegalArgumentException("Jdbc type can't be null");
-        }
-        this.jdbc = jdbc;
-
-        this.length = getValidInt(length);
-        this.precision = getValidInt(precision);
-        this.scale = getValidInt(scale);
-        this.notNull = notNull;
-    }
-
-    public String getJdbc() {
-        return jdbc;
-    }
-
-    public Integer getLength() {
-        return length;
-    }
-
-    public Integer getPrecision() {
-        return precision;
-    }
-
-    public Integer getScale() {
-        return scale;
-    }
-
-    public Boolean getNotNull() {
-        return notNull;
-    }
-
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (obj == this) {
-            return true;
-        }
-        if (obj.getClass() != getClass()) {
-            return false;
-        }
-        DbType rhs = (DbType) obj;
-        return new EqualsBuilder()
-                .append(this.jdbc, rhs.jdbc)
-                .append(this.length, rhs.length)
-                .append(this.precision, rhs.precision)
-                .append(this.scale, rhs.scale)
-                .append(this.notNull, rhs.notNull)
-                .isEquals();
-    }
-
-    @Override
-    public int hashCode() {
-        return new HashCodeBuilder()
-                .append(jdbc)
-                .append(length)
-                .append(precision)
-                .append(scale)
-                .append(notNull)
-                .toHashCode();
-    }
-
-
-    @Override
-    public String toString() {
-        String res = jdbc;
-
-        String len = "*";
-        if (isPositive(length)) {
-            len = length.toString();
-        }
-        if (isPositive(precision)) {
-            len = precision.toString();
-        }
-
-        res += " (" + len;
-        if (isPositive(scale)) {
-            res += ", " + scale;
-        }
-        res += ")";
-
-        if (notNull != null && notNull) {
-            res += " NOT NULL";
-        }
-
-        return res;
-    }
-
-    private boolean isPositive(Integer num) {
-        return num != null && num > 0;
-    }
-
-    private Integer getValidInt(Integer num) {
-        if (num == null || num > 0) {
-            return num;
-        }
-
-        LOG.warn("Invalid int value '" + num + "'");
-        return null;
-    }
-
-    /**
-     * Compare by specificity the most specific DbPath should be first in ordered list
-     */
-    @Override
-    public int compareTo(DbType dbType) {
-        return new CompareToBuilder()
-                .append(dbType.jdbc, jdbc)
-                .append(dbType.getSpecificity(), getSpecificity())
-                .append(dbType.length, length)
-                .append(dbType.precision, precision)
-                .append(dbType.scale, scale)
-                .append(dbType.notNull, notNull)
-                .toComparison();
-    }
-
-    private int getSpecificity() {
-        int res = 0;
-        if (isPositive(length)) {
-            res += 100;
-        }
-        if (isPositive(precision)) {
-            res += 100;
-        }
-        if (isPositive(scale)) {
-            res += 10;
-        }
-        if (this.notNull != null) {
-            res += 5;
-        }
-
-        return res;
-    }
-
-    public boolean isCover(DbType type) {
-        return this.jdbc.equals(type.jdbc)
-            && (isCover(length, type.length) || length == null && type.length
== null && isCover(precision, type.precision))
-            && isCover(scale, type.scale)
-            && isCover(notNull, type.notNull);
-    }
-
-    private boolean isCover(Object a, Object b) {
-        return a == null || a.equals(b);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fc27ef7a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/mapper/DefaultJdbc2JavaTypeMapper.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/mapper/DefaultJdbc2JavaTypeMapper.java
b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/mapper/DefaultJdbc2JavaTypeMapper.java
deleted file mode 100644
index 0af1690..0000000
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/mapper/DefaultJdbc2JavaTypeMapper.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you 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.apache.cayenne.dbsync.reverse.mapper;
-
-import org.apache.cayenne.dba.TypesMapping;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.util.Util;
-
-import java.io.Serializable;
-import java.math.BigInteger;
-import java.sql.Types;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-/**
- * @since 4.0.
- */
-public class DefaultJdbc2JavaTypeMapper implements Jdbc2JavaTypeMapper {
-
-	// Never use "-1" or any other normal integer, since there
-	// is a big chance it is being reserved in java.sql.Types
-	public static final int NOT_DEFINED = Integer.MAX_VALUE;
-
-	// char constants for Java data types
-	public static final String JAVA_LONG = "java.lang.Long";
-	public static final String JAVA_BYTES = "byte[]";
-	public static final String JAVA_BOOLEAN = "java.lang.Boolean";
-	public static final String JAVA_STRING = "java.lang.String";
-	public static final String JAVA_SQLDATE = "java.sql.Date";
-	public static final String JAVA_UTILDATE = "java.util.Date";
-	public static final String JAVA_BIGDECIMAL = "java.math.BigDecimal";
-	public static final String JAVA_DOUBLE = "java.lang.Double";
-	public static final String JAVA_FLOAT = "java.lang.Float";
-	public static final String JAVA_INTEGER = "java.lang.Integer";
-	public static final String JAVA_SHORT = "java.lang.Short";
-	public static final String JAVA_BYTE = "java.lang.Byte";
-	public static final String JAVA_TIME = "java.sql.Time";
-	public static final String JAVA_TIMESTAMP = "java.sql.Timestamp";
-	public static final String JAVA_BLOB = "java.sql.Blob";
-
-	/**
-	 * Keys: java class names, Values: SQL int type definitions from
-	 * java.sql.Types
-	 */
-	private final Map<String, Integer> javaSqlEnum = new HashMap<>();
-
-	private final Map<DbType, String> mapping = new HashMap<>();
-	private final SortedSet<DbType> dbTypes = new TreeSet<>();
-
-	private Map<String, String> classToPrimitive;
-
-	{
-		add(Types.BIGINT, JAVA_LONG);
-		add(Types.BINARY, JAVA_BYTES);
-		add(Types.BIT, JAVA_BOOLEAN);
-		add(Types.BOOLEAN, JAVA_BOOLEAN);
-		add(Types.BLOB, JAVA_BYTES);
-		add(Types.CLOB, JAVA_STRING);
-		add(Types.NCLOB, JAVA_STRING);
-		add(Types.SQLXML, JAVA_STRING);
-		add(Types.CHAR, JAVA_STRING);
-		add(Types.NCHAR, JAVA_STRING);
-		add(Types.DATE, JAVA_UTILDATE);
-		add(Types.DECIMAL, JAVA_BIGDECIMAL);
-		add(Types.DOUBLE, JAVA_DOUBLE);
-		add(Types.FLOAT, JAVA_FLOAT);
-		add(Types.INTEGER, JAVA_INTEGER);
-		add(Types.LONGVARCHAR, JAVA_STRING);
-		add(Types.LONGNVARCHAR, JAVA_STRING);
-		add(Types.LONGVARBINARY, JAVA_BYTES);
-		add(Types.NUMERIC, JAVA_BIGDECIMAL);
-		add(Types.REAL, JAVA_FLOAT);
-		add(Types.SMALLINT, JAVA_SHORT);
-		add(Types.TINYINT, JAVA_SHORT);
-		add(Types.TIME, JAVA_UTILDATE);
-		add(Types.TIMESTAMP, JAVA_UTILDATE);
-		add(Types.VARBINARY, JAVA_BYTES);
-		add(Types.VARCHAR, JAVA_STRING);
-		add(Types.NVARCHAR, JAVA_STRING);
-
-		javaSqlEnum.put(JAVA_LONG, Types.BIGINT);
-		javaSqlEnum.put(JAVA_BYTES, Types.BINARY);
-		javaSqlEnum.put(JAVA_BOOLEAN, Types.BIT);
-		javaSqlEnum.put(JAVA_STRING, Types.VARCHAR);
-		javaSqlEnum.put(JAVA_SQLDATE, Types.DATE);
-		javaSqlEnum.put(JAVA_UTILDATE, Types.DATE);
-		javaSqlEnum.put(JAVA_TIMESTAMP, Types.TIMESTAMP);
-		javaSqlEnum.put(JAVA_BIGDECIMAL, Types.DECIMAL);
-		javaSqlEnum.put(JAVA_DOUBLE, Types.DOUBLE);
-		javaSqlEnum.put(JAVA_FLOAT, Types.FLOAT);
-		javaSqlEnum.put(JAVA_INTEGER, Types.INTEGER);
-		javaSqlEnum.put(JAVA_SHORT, Types.SMALLINT);
-		javaSqlEnum.put(JAVA_BYTE, Types.SMALLINT);
-		javaSqlEnum.put(JAVA_TIME, Types.TIME);
-		javaSqlEnum.put(JAVA_TIMESTAMP, Types.TIMESTAMP);
-
-		// add primitives
-		javaSqlEnum.put("byte", Types.TINYINT);
-		javaSqlEnum.put("int", Types.INTEGER);
-		javaSqlEnum.put("short", Types.SMALLINT);
-		javaSqlEnum.put("char", Types.CHAR);
-		javaSqlEnum.put("double", Types.DOUBLE);
-		javaSqlEnum.put("long", Types.BIGINT);
-		javaSqlEnum.put("float", Types.FLOAT);
-		javaSqlEnum.put("boolean", Types.BIT);
-
-		classToPrimitive = new HashMap<>();
-		classToPrimitive.put(Byte.class.getName(), "byte");
-		classToPrimitive.put(Long.class.getName(), "long");
-		classToPrimitive.put(Double.class.getName(), "double");
-		classToPrimitive.put(Boolean.class.getName(), "boolean");
-		classToPrimitive.put(Float.class.getName(), "float");
-		classToPrimitive.put(Short.class.getName(), "short");
-		classToPrimitive.put(Integer.class.getName(), "int");
-	}
-
-	private Boolean usePrimitives;
-
-	/**
-	 * Returns default java.sql.Types type by the Java type name.
-	 *
-	 * @param className
-	 *            Fully qualified Java Class name.
-	 * @return The SQL type or NOT_DEFINED if no type found.
-	 */
-	public int getJdbcTypeByJava(DbAttribute attribute, String className) {
-		if (className == null) {
-			return NOT_DEFINED;
-		}
-
-		Integer type = javaSqlEnum.get(className);
-		if (type != null) {
-			return type;
-		}
-
-		// try to load a Java class - some nonstandard mappings may work
-		try {
-			return getSqlTypeByJava(attribute, Util.getJavaClass(className));
-		} catch (Throwable th) {
-			return NOT_DEFINED;
-		}
-	}
-
-	public void add(int jdbcType, String java) {
-		add(new DbType(TypesMapping.getSqlNameByType(jdbcType)), java);
-	}
-
-	@Override
-	public void add(DbType type, String java) {
-		mapping.put(type, java);
-		dbTypes.add(type);
-	}
-
-	/**
-	 * Guesses a default JDBC type for the Java class.
-	 *
-	 * @since 1.1
-	 */
-	protected int getSqlTypeByJava(DbAttribute attribute, Class<?> javaClass) {
-		if (javaClass == null) {
-			return NOT_DEFINED;
-		}
-
-		// check standard mapping of class and superclasses
-		Class<?> aClass = javaClass;
-		while (aClass != null) {
-
-			String name;
-
-			if (aClass.isArray()) {
-				name = aClass.getComponentType().getName() + "[]";
-			} else {
-				name = aClass.getName();
-			}
-
-			Object type = javaSqlEnum.get(name);
-			if (type != null) {
-				return ((Number) type).intValue();
-			}
-
-			aClass = aClass.getSuperclass();
-		}
-
-		// check non-standard JDBC types that are still supported by JPA
-		if (javaClass.isArray()) {
-
-			Class<?> elementType = javaClass.getComponentType();
-			if (Character.class.isAssignableFrom(elementType) || Character.TYPE.isAssignableFrom(elementType))
{
-				return Types.VARCHAR;
-			} else if (Byte.class.isAssignableFrom(elementType) || Byte.TYPE.isAssignableFrom(elementType))
{
-				return Types.VARBINARY;
-			}
-		}
-
-		if (Calendar.class.isAssignableFrom(javaClass)) {
-			return Types.TIMESTAMP;
-		}
-
-		if (BigInteger.class.isAssignableFrom(javaClass)) {
-			return Types.BIGINT;
-		}
-
-		if (Serializable.class.isAssignableFrom(javaClass)) {
-			// serializable check should be the last one when all other mapping
-			// attempts failed
-			return Types.VARBINARY;
-		}
-
-		return NOT_DEFINED;
-	}
-
-	/**
-	 * Get the corresponding Java type by its java.sql.Types counterpart. Note
-	 * that this method should be used as a last resort, with explicit mapping
-	 * provided by user used as a first choice, as it can only guess how to map
-	 * certain types, such as NUMERIC, etc.
-	 *
-	 * @return Fully qualified Java type name or null if not found.
-	 */
-	@Override
-	public String getJavaByJdbcType(DbAttribute attribute, int type) {
-		String jdbcType = TypesMapping.getSqlNameByType(type);
-		DbType dbType;
-		if (attribute != null) {
-			dbType = new DbType(jdbcType, attribute.getMaxLength(), attribute.getAttributePrecision(),
-					attribute.getScale(), attribute.isMandatory());
-		} else {
-			dbType = new DbType(jdbcType);
-		}
-
-		String typeName = getJavaByJdbcType(dbType);
-
-		if (usePrimitives != null && usePrimitives) {
-			String primitive = classToPrimitive.get(typeName);
-			if (primitive != null) {
-				return primitive;
-			}
-		}
-
-		return typeName;
-	}
-
-	public String getJavaByJdbcType(DbType type) {
-		for (DbType t : dbTypes) {
-			if (t.isCover(type)) {
-				// because dbTypes sorted by specificity we will take first and
-				// the most specific matching
-				// that applicable for attribute
-				return mapping.get(t);
-			}
-		}
-
-		return null;
-	}
-
-	public Boolean getUsePrimitives() {
-		return usePrimitives;
-	}
-
-	public void setUsePrimitives(Boolean usePrimitives) {
-		this.usePrimitives = usePrimitives;
-	}
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fc27ef7a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/mapper/Jdbc2JavaTypeMapper.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/mapper/Jdbc2JavaTypeMapper.java
b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/mapper/Jdbc2JavaTypeMapper.java
deleted file mode 100644
index 71d86d5..0000000
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/mapper/Jdbc2JavaTypeMapper.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you 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.apache.cayenne.dbsync.reverse.mapper;
-
-import org.apache.cayenne.map.DbAttribute;
-
-/**
- * @since 4.0.
- */
-public interface Jdbc2JavaTypeMapper {
-
-    String getJavaByJdbcType(DbAttribute attribute, int type);
-
-    int getJdbcTypeByJava(DbAttribute attribute, String className);
-
-    void add(DbType type, String java);
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fc27ef7a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/LegacyObjectNameGenerator.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/LegacyObjectNameGenerator.java
b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/LegacyObjectNameGenerator.java
index 290dba8..11ac007 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/LegacyObjectNameGenerator.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/LegacyObjectNameGenerator.java
@@ -28,7 +28,7 @@ import org.apache.cayenne.map.naming.NameConverter;
  * BasicNamingStrategy is an naming strategy that creates names in Cayenne's
  * old-fashioned manner, i.e. the same way Cayenne did before 3.0
  * 
- * @since 3.0
+ * @since 4.0
  */
 public class LegacyObjectNameGenerator implements ObjectNameGenerator {
     public String createDbRelationshipName(

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fc27ef7a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/mapper/DbTypeTest.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/mapper/DbTypeTest.java
b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/mapper/DbTypeTest.java
deleted file mode 100644
index f2cb475..0000000
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/mapper/DbTypeTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.cayenne.dbsync.reverse.mapper;
-
-import org.junit.Test;
-
-import java.util.Iterator;
-import java.util.TreeSet;
-
-import static org.junit.Assert.*;
-
-public class DbTypeTest {
-
-    @Test
-    public void testCompareTo() throws Exception {
-        TreeSet<DbType> set = new TreeSet<DbType>();
-        set.add(new DbType("type-01", null, null, null, null));
-        set.add(new DbType("type-02", null, null, null, null));
-        set.add(new DbType("type-02", 1, null, null, null));
-        set.add(new DbType("type-02", 2, null, null, null));
-        set.add(new DbType("type-02", 2, null, null, true));
-        set.add(new DbType("type-02", 2, null, null, false));
-        set.add(new DbType("type-02", 2, null, 5, null));
-        set.add(new DbType("type-02", 2, null, 5, false));
-        set.add(new DbType("type-02", 2, null, 5, true));
-        set.add(new DbType("type-02", null, 8, 5, true));
-        set.add(new DbType("type-02", null, 9, 5, true));
-
-        Iterator<DbType> iterator = set.iterator();
-        assertEquals(new DbType("type-02", 2, null, 5, true), iterator.next());
-        assertEquals(new DbType("type-02", 2, null, 5, false), iterator.next());
-        assertEquals(new DbType("type-02", null, 9, 5, true), iterator.next());
-        assertEquals(new DbType("type-02", null, 8, 5, true), iterator.next());
-        assertEquals(new DbType("type-02", 2, null, 5, null), iterator.next());
-        assertEquals(new DbType("type-02", 2, null, null, true), iterator.next());
-        assertEquals(new DbType("type-02", 2, null, null, false), iterator.next());
-        assertEquals(new DbType("type-02", 2, null, null, null), iterator.next());
-        assertEquals(new DbType("type-02", 1, null, null, null), iterator.next());
-        assertEquals(new DbType("type-02", null, null, null, null), iterator.next());
-        assertEquals(new DbType("type-01", null, null, null, null), iterator.next());
-    }
-
-    @Test
-    public void testCover() throws Exception {
-        DbType typeJava = new DbType("java");
-        assertTrue(typeJava.isCover(typeJava));
-        assertTrue(typeJava.isCover(new DbType("java", 1, 1, 1, null)));
-        assertTrue(typeJava.isCover(new DbType("java", 1, null, null, null)));
-        assertTrue(typeJava.isCover(new DbType("java", null, 1, null, null)));
-        assertTrue(typeJava.isCover(new DbType("java", null, null, 1, null)));
-        assertTrue(typeJava.isCover(new DbType("java", null, null, null, true)));
-        assertTrue(typeJava.isCover(new DbType("java", null, null, null, false)));
-        assertFalse(typeJava.isCover(new DbType("java1", null, null, null, null)));
-
-        DbType typeWithLength = new DbType("java", 1, null, null, null);
-        assertTrue(typeWithLength.isCover(typeWithLength));
-        assertTrue(typeWithLength.isCover(new DbType("java", 1, null, 1, null)));
-        assertTrue(typeWithLength.isCover(new DbType("java", 1, null, 1, true)));
-        assertTrue(typeWithLength.isCover(new DbType("java", 1, null, null, true)));
-        assertTrue(typeWithLength.isCover(new DbType("java", 1, 1, null, true)));
-        assertFalse(typeWithLength.isCover(new DbType("java", 2, null, null, null)));
-        assertFalse(typeWithLength.isCover(new DbType("java", null, null, null, true)));
-        assertFalse(typeWithLength.isCover(new DbType("java1", 2, null, null, null)));
-
-        DbType typeWithLengthAndNotNull = new DbType("java", 1, null, null, true);
-        assertTrue(typeWithLength.isCover(typeWithLengthAndNotNull));
-        assertTrue(typeWithLength.isCover(new DbType("java", 1, null, 1, true)));
-        assertTrue(typeWithLength.isCover(new DbType("java", 1, 1, 1, true)));
-    }
-}
\ No newline at end of file


Mime
View raw message