use of com.cubrid.common.core.common.model.DBMethod in project cubrid-manager by CUBRID.
the class SchemaInfoTest method testData.
/**
* test data
*
*/
public void testData() {
assertNull(classname);
assertNull(type);
assertNull(owner);
assertNull(virtual);
assertNull(dbname);
assertNull(is_partitiongroup);
assertNull(partitiongroupname);
assertNull(classAttributes);
// DBAttribute
assertNull(attributes);
// DBMethod
assertNull(classMethods);
// DBMethod
assertNull(methods);
// DBResolution
assertNull(classResolutions);
// DBResolution
assertNull(resolutions);
// Constraint
assertNull(constraints);
// add super classes
assertNull(superClasses);
assertNull(subClasses);
assertNull(oidList);
assertNull(methodFiles);
assertNull(querySpecs);
assertNull(partitions);
SchemaInfo schemaInfo = new SchemaInfo();
schemaInfo.getConstraints();
schemaInfo.getDBMethodByName("name");
schemaInfo.addResolution(new DBResolution());
schemaInfo.addResolution(new DBResolution());
schemaInfo.addResolution(new DBResolution(), true);
schemaInfo.addResolution(new DBResolution(), false);
schemaInfo.clone();
schemaInfo.getInheritAttributes();
schemaInfo.getLocalAttributes();
schemaInfo.getInheritClassAttributes();
//create List<SchemaInfo>
List<SchemaInfo> supers = new ArrayList<SchemaInfo>();
supers.add(schemaInfo);
schemaInfo.getPK(supers);
schemaInfo.getConstraintByName("constraintName");
schemaInfo.getConstraintByName("name", "type");
schemaInfo.removeConstraintByName("name", "type");
schemaInfo.removeUniqueByAttrName("constraintName");
schemaInfo.getFKConstraint("name");
schemaInfo.getFKConstraints();
schemaInfo.removeFKConstraint("constraintName");
schemaInfo.isAttributeUnique(new DBAttribute(), supers);
schemaInfo.getForeignTables();
//create constraint
String name = "name";
String type = "FOREIGN KEY";
int keyCount = 6;
// String
List<String> rules = new ArrayList<String>();
rules.add("REFERENCES aa");
// test getters and setters
Constraint constraintYes = new Constraint(name, type);
constraintYes.setName(name);
constraintYes.setType(type);
constraintYes.setKeyCount(keyCount);
constraintYes.setRules(rules);
schemaInfo.addConstraint(constraintYes);
schemaInfo.getFKConstraints();
schemaInfo.getForeignTables();
schemaInfo.removeFKConstraint(constraintYes);
schemaInfo.addConstraint(constraintYes);
schemaInfo.removeFKConstraint("name");
schemaInfo.addConstraint(constraintYes);
schemaInfo.addQuerySpec("name");
schemaInfo.addMethodFile("constraintName");
schemaInfo.addMethod(null);
schemaInfo.addClassMethod(null);
schemaInfo.removeConstraintByName("name", "type");
schemaInfo.removeDBAttributeByName("name", false);
partitions = null;
schemaInfo.getPartitionByName("name");
schemaInfo.isSystemClass();
schemaInfo.setType("system");
schemaInfo.isSystemClass();
schemaInfo.setClassname("classname");
schemaInfo.compareTo(schemaInfo);
schemaInfo.hashCode();
//+test the equal()
assertTrue(schemaInfo.equals(schemaInfo));
assertFalse(schemaInfo.equals(null));
assertFalse(schemaInfo.equals("other object"));
//-test the equal()
schemaInfo.getMethodFiles();
schemaInfo.getClassMethods();
schemaInfo.getMethods();
schemaInfo.getLocalClassAttributes();
schemaInfo.getSubClasses();
schemaInfo.getOidList();
List<PartitionInfo> partitiona = new ArrayList<PartitionInfo>();
//create partition
String className = "className";
String partitionName = "partitionName";
@SuppressWarnings("unused") String partitionClassName = "partitionClassName";
PartitionType partitionType = PartitionType.HASH;
String partitionExpr = "partitionExpr";
final List<String> partitionValues = new ArrayList<String>();
int rows = -1;
PartitionInfo partitionInfo3 = new PartitionInfo(className, partitionName, partitionType, partitionExpr, partitionValues, rows);
partitiona.add(partitionInfo3);
schemaInfo.setPartitionList(partitiona);
schemaInfo.getPartitionByName("name");
schemaInfo.getQuerySpecs();
SchemaInfo schemaInfoOld = new SchemaInfo();
schemaInfo.setAttributes(attributes);
schemaInfo.setSuperClasses(superClasses);
schemaInfo.setClassAttributes(classAttributes);
schemaInfo.setClassResolutions(classResolutions);
schemaInfo.setResolutions(classResolutions);
schemaInfoOld.equals(schemaInfo);
//create DBMethod();
String sname = "name";
String inherit = "inherit";
String function = "function";
// test getters and setters
DBMethod dbMethod = new DBMethod();
dbMethod.setName(sname);
dbMethod.setInherit(inherit);
dbMethod.setFunction(function);
DBMethod dbMethod3 = new DBMethod();
dbMethod3.setName("notsame");
dbMethod3.setInherit("notsame");
dbMethod3.setFunction("notsame");
SchemaInfo schemaInfo3 = new SchemaInfo();
schemaInfo3.addMethod(dbMethod);
schemaInfo3.addClassMethod(dbMethod);
schemaInfo3.getDBMethodByName("name");
SchemaInfo schemaInfo2 = new SchemaInfo();
//create DBAttribute
String dname = "name";
String dtype = "type";
// it belongs to which class
String dinherit = "inherit";
boolean indexed = true;
boolean notNull = true;
boolean shared = true;
boolean unique = true;
String defaultValue = "defaultValue";
DBAttribute dbAttribute1 = new DBAttribute(dname, dtype, dinherit, indexed, notNull, shared, unique, defaultValue, null);
DBAttribute dbAttribute2 = new DBAttribute(dname, dtype, dinherit, indexed, notNull, shared, unique, defaultValue, null);
DBAttribute dbAttribute3 = new DBAttribute("notsame", dtype, dinherit, indexed, notNull, shared, unique, defaultValue, null);
//+test the equal()
SchemaInfo schemaInfo1 = new SchemaInfo();
schemaInfo1.addAttribute(dbAttribute2);
schemaInfo2.addAttribute(dbAttribute3);
schemaInfoOld.equals(schemaInfo1);
schemaInfo2.equals(schemaInfo1);
schemaInfoOld.addAttribute(dbAttribute2);
schemaInfo2.removeDBAttributeByName("notsame", false);
schemaInfo2.addAttribute(dbAttribute2);
schemaInfo1.addClassAttribute(dbAttribute2);
schemaInfo2.addClassAttribute(dbAttribute3);
schemaInfoOld.equals(schemaInfo1);
schemaInfo2.equals(schemaInfo1);
schemaInfoOld.addClassAttribute(dbAttribute2);
schemaInfo2.removeDBAttributeByName("notsame", true);
schemaInfo2.addAttribute(dbAttribute2);
schemaInfo1.addClassMethod(dbMethod);
schemaInfo2.addClassMethod(dbMethod3);
schemaInfo2.equals(schemaInfo1);
schemaInfoOld.equals(schemaInfo1);
schemaInfoOld.addClassMethod(dbMethod);
schemaInfo2.getClassMethods().clear();
schemaInfo2.addClassMethod(dbMethod);
//create DBResolution
String rname = "name";
String rclassName = "className";
String alias = "alias";
boolean isClassResolution = true;
DBResolution dbResolution = new DBResolution(rname, rclassName, alias);
dbResolution.setName(rname);
dbResolution.setClassName(rclassName);
dbResolution.setAlias(alias);
dbResolution.setClassResolution(isClassResolution);
DBResolution dbResolution3 = new DBResolution(rname, rclassName, alias);
dbResolution3.setName("notsame");
dbResolution3.setClassName(rclassName);
dbResolution3.setAlias(alias);
dbResolution3.setClassResolution(isClassResolution);
schemaInfo1.addClassResolution(dbResolution);
schemaInfo2.addClassResolution(dbResolution3);
schemaInfoOld.equals(schemaInfo1);
schemaInfo2.equals(schemaInfo1);
schemaInfoOld.addClassResolution(dbResolution);
schemaInfo2.getClassResolutions().clear();
schemaInfo2.addClassResolution(dbResolution);
schemaInfo1.setClassname("classname");
schemaInfo2.setClassname("notsame");
schemaInfoOld.equals(schemaInfo1);
schemaInfo2.equals(schemaInfo1);
schemaInfoOld.setClassname("classname");
schemaInfo2.setClassname("classname");
schemaInfo1.setClassname("classname");
schemaInfo2.setClassname("notsame");
schemaInfoOld.equals(schemaInfo1);
schemaInfo2.equals(schemaInfo1);
schemaInfoOld.setClassname("classname");
schemaInfo2.setClassname("classname");
schemaInfo2.addConstraint(new Constraint(false));
schemaInfoOld.equals(schemaInfo1);
schemaInfo2.equals(schemaInfo1);
schemaInfoOld.addConstraint(constraintYes);
schemaInfo2.getConstraints().clear();
schemaInfo2.addConstraint(constraintYes);
schemaInfo1.setDbname("dbname");
schemaInfo2.setDbname("notsame");
schemaInfoOld.equals(schemaInfo1);
schemaInfo2.equals(schemaInfo1);
schemaInfoOld.setDbname("dbname");
schemaInfo2.setDbname("dbname");
schemaInfo1.setPartitionGroup("isPartitiongroup");
schemaInfo2.setPartitionGroup("notsame");
schemaInfoOld.equals(schemaInfo1);
schemaInfo2.equals(schemaInfo1);
schemaInfoOld.setPartitionGroup("isPartitiongroup");
schemaInfo2.setPartitionGroup("isPartitiongroup");
schemaInfo1.setOwner("owner");
schemaInfo2.setOwner("notsame");
schemaInfoOld.equals(schemaInfo1);
schemaInfo2.equals(schemaInfo1);
schemaInfoOld.setOwner("owner");
schemaInfo2.setOwner("owner");
schemaInfo1.addResolution(dbResolution);
schemaInfo2.addResolution(dbResolution3);
schemaInfoOld.equals(schemaInfo1);
schemaInfo2.equals(schemaInfo1);
schemaInfoOld.addResolution(dbResolution);
schemaInfo2.getResolutions().clear();
schemaInfo2.addResolution(dbResolution);
schemaInfo1.getSuperClasses().clear();
schemaInfo1.addSuperClass("superClass");
schemaInfo2.addSuperClass("notsame");
schemaInfoOld.equals(schemaInfo1);
schemaInfo2.equals(schemaInfo1);
schemaInfoOld.addSuperClass("superClass");
schemaInfo2.getSuperClasses().clear();
schemaInfo2.addSuperClass("superClass");
schemaInfo1.setType("type");
schemaInfo2.setType("notsame");
schemaInfoOld.equals(schemaInfo1);
schemaInfo2.equals(schemaInfo1);
schemaInfoOld.setType("type");
schemaInfo2.setType("type");
schemaInfo1.setVirtual("virtual");
schemaInfo2.setVirtual("notsame");
schemaInfoOld.equals(schemaInfo1);
schemaInfo2.equals(schemaInfo1);
schemaInfoOld.setVirtual("virtual");
schemaInfo2.setVirtual("virtual");
//+test the equal()
schemaInfo.addDBAttribute(dbAttribute2, true);
schemaInfo.addDBAttribute(dbAttribute2, false);
schemaInfo.replaceDBAttributeByName(dbAttribute1, dbAttribute2, true, supers);
schemaInfo.replaceDBAttributeByName(dbAttribute1, dbAttribute2, false, supers);
schemaInfo.setClassname("inherit");
schemaInfo.getLocalClassAttributes();
constraintYes.setType("UNIQUE");
List<String> a = new ArrayList<String>();
a.add("name");
constraintYes.setAttributes(a);
schemaInfo.addConstraint(constraintYes);
schemaInfo.removeUniqueByAttrName("name");
}
use of com.cubrid.common.core.common.model.DBMethod in project cubrid-manager by CUBRID.
the class DBMethodTest method testDBMethod.
/**
* Test DBMethod
*/
public final void testDBMethod() {
String name = "name";
String inherit = "inherit";
List<String> arguments = null;
String function = "function";
// test getters and setters
DBMethod dbMethod = new DBMethod();
dbMethod.setName(name);
dbMethod.setInherit(inherit);
dbMethod.setFunction(function);
assertEquals(dbMethod.getName(), name);
assertEquals(dbMethod.getInherit(), inherit);
assertEquals(dbMethod.getFunction(), function);
dbMethod.addArgument("argument");
dbMethod.getArguments();
arguments = new ArrayList<String>();
arguments.add("aa");
dbMethod.addArgument("argument");
}
Aggregations