Skip to content
Snippets Groups Projects
Commit 752999f4 authored by 汤伟's avatar 汤伟 Committed by Wei
Browse files

joint development save

parent 26715750
No related branches found
No related tags found
No related merge requests found
Showing
with 137 additions and 75 deletions
package com.ic.er;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.ic.er.exception.ERException;
import com.ic.er.common.RelatedObjType;
......@@ -22,18 +21,20 @@ public class Attribute {
private String name;
private DataType dataType;
private Boolean isPrimary;
private Boolean nullable;
private LayoutInfo layoutInfo;
private Date gmtCreate;
private Date gmtModified;
protected Attribute(Long ID, Long entityID, Long viewID, String name, DataType dataType,
Boolean isPrimary, LayoutInfo layoutInfo, Double layoutX, Double layoutY, Date gmtCreate, Date gmtModified) {
Boolean isPrimary, Boolean nullable, LayoutInfo layoutInfo, Double layoutX, Double layoutY, Date gmtCreate, Date gmtModified) {
this.ID = ID;
this.entityID = entityID;
this.viewID = viewID;
this.name = name;
this.dataType = dataType;
this.isPrimary = isPrimary;
this.nullable = nullable;
this.layoutInfo = layoutInfo;
this.gmtCreate = gmtCreate;
this.gmtModified = gmtModified;
......@@ -52,7 +53,7 @@ public class Attribute {
private void insertDB() throws PersistenceException {
try {
AttributeDO aDo = new AttributeDO(this.ID, this.entityID, this.viewID, this.name, this.dataType, this.isPrimary, 0, this.gmtCreate, this.gmtModified);
AttributeDO aDo = new AttributeDO(this.ID, this.entityID, this.viewID, this.name, this.dataType, this.isPrimary, this.nullable, 0, this.gmtCreate, this.gmtModified);
int ret = ER.attributeMapper.insert(aDo);
if (ret == 0) {
throw new ERException("insertDB fail");
......@@ -67,7 +68,7 @@ public class Attribute {
ER.attributeMapper.deleteByID(this.ID);
}
public void updateInfo(String name, DataType dataType, Boolean isPrimary) throws ERException {
public void updateInfo(String name, DataType dataType, Boolean isPrimary, Boolean nullable) throws ERException {
if (name != null) {
this.name = name;
}
......@@ -77,15 +78,25 @@ public class Attribute {
if (isPrimary != null) {
this.isPrimary = isPrimary;
}
List<Attribute> attributeList = Attribute.queryByAttribute(new AttributeDO(null, this.entityID, this.viewID, this.name, null, null, null, null, null));
if (attributeList.size() != 0) {
throw new ERException(String.format("attribute with name: %s already exists", this.name));
if (nullable != null) {
this.nullable = nullable;
}
attributeList = Attribute.queryByAttribute(new AttributeDO(null, this.entityID, this.viewID, null, null, true, null, null, null));
if (isPrimary != null && isPrimary && attributeList.size() != 0) {
throw new ERException(String.format("attribute that is primary key already exists, name: %s", attributeList.get(0).getName()));
if (name != null) {
List<Attribute> attributeList = Attribute.queryByAttribute(new AttributeDO(null, this.entityID, this.viewID, name, null, null, null, null, null, null));
if (attributeList.size() != 0 && !attributeList.get(0).getID().equals(this.ID)) {
throw new ERException(String.format("attribute with name: %s already exists", this.name));
}
}
if (isPrimary != null && isPrimary) {
List<Attribute> attributeList = Attribute.queryByAttribute(new AttributeDO(null, this.entityID, this.viewID, null, null, true, null, null, null, null));
if (attributeList.size() != 0 && !attributeList.get(0).getID().equals(this.ID)) {
throw new ERException(String.format("attribute that is primary key already exists, name: %s", attributeList.get(0).getName()));
}
}
if (this.nullable && this.isPrimary) {
throw new ERException("primary attribute cannot be null");
}
ER.attributeMapper.updateByID(new AttributeDO(this.ID, this.entityID, this.viewID, this.name, this.dataType, this.isPrimary, 0, this.gmtCreate, new Date()));
ER.attributeMapper.updateByID(new AttributeDO(this.ID, this.entityID, this.viewID, this.name, this.dataType, this.isPrimary, this.nullable, 0, this.gmtCreate, new Date()));
}
public void updateLayoutInfo(Double layoutX, Double layoutY, Double height, Double width) throws ERException {
......
......@@ -46,23 +46,26 @@ public class Entity {
}
public Attribute addAttribute(String attributeName, DataType dataType, Boolean isPrimary) {
return addAttribute(attributeName, dataType, isPrimary, 0.0, 0.0);
public Attribute addAttribute(String attributeName, DataType dataType, Boolean isPrimary, Boolean nullable) {
return addAttribute(attributeName, dataType, isPrimary, nullable, 0.0, 0.0);
}
public Attribute addAttribute(String attributeName, DataType dataType, Boolean isPrimary, Double layoutX, Double layoutY) {
public Attribute addAttribute(String attributeName, DataType dataType, Boolean isPrimary, Boolean nullable, Double layoutX, Double layoutY) {
if (attributeName.equals("")) {
throw new ERException("attributeName cannot be empty");
}
List<Attribute> attributeList = Attribute.queryByAttribute(new AttributeDO(null, this.ID, this.viewID, attributeName, null, null, null, null, null));
if (isPrimary && nullable) {
throw new ERException("primary attribute cannot be null");
}
List<Attribute> attributeList = Attribute.queryByAttribute(new AttributeDO(null, this.ID, this.viewID, attributeName, null, null, null, null, null, null));
if (attributeList.size() != 0) {
throw new ERException(String.format("attribute with name: %s already exists", this.name));
}
attributeList = Attribute.queryByAttribute(new AttributeDO(null, this.ID, this.viewID, null, null, true, null, null, null));
attributeList = Attribute.queryByAttribute(new AttributeDO(null, this.ID, this.viewID, null, null, null, true, null, null, null));
if (isPrimary && attributeList.size() != 0) {
throw new ERException(String.format("attribute that is primary key already exists, name: %s", attributeList.get(0).getName()));
}
Attribute attribute = new Attribute(0L, this.ID, this.viewID, attributeName, dataType, isPrimary, null, layoutX, layoutY, new Date(), new Date());
Attribute attribute = new Attribute(0L, this.ID, this.viewID, attributeName, dataType, isPrimary, nullable, null, layoutX, layoutY, new Date(), new Date());
this.attributeList.add(attribute);
return attribute;
}
......@@ -99,9 +102,11 @@ public class Entity {
if (name != null) {
this.name = name;
}
List<Entity> entities = Entity.queryByEntity(new EntityDO(null, name, this.ID, null, null, null));
if (entities.size() != 0) {
throw new ERException(String.format("entity with name: %s already exists", name));
if (name != null) {
List<Entity> entities = Entity.queryByEntity(new EntityDO(null, name, this.ID, null, null, null));
if (entities.size() != 0 && !entities.get(0).getID().equals(this.ID)) {
throw new ERException(String.format("entity with name: %s already exists", name));
}
}
ER.entityMapper.updateByID(new EntityDO(this.ID, this.name, this.viewID, 0, this.gmtCreate, new Date()));
}
......
......@@ -92,12 +92,18 @@ public class Relationship {
if (Entity.queryByID(firstEntity.getID()) == null) {
throw new ERException(String.format("entity with ID: %d not found", firstEntity.getID()));
}
if (!firstEntity.getViewID().equals(this.viewID)) {
throw new ERException(String.format("entity: %s does not belong to this view", firstEntity.getName()));
}
}
if (secondEntity != null) {
this.secondEntity = secondEntity;
if (Entity.queryByID(secondEntity.getID()) == null) {
throw new ERException(String.format("entity with ID: %d not found", secondEntity.getID()));
}
if (!secondEntity.getViewID().equals(this.ID)) {
throw new ERException(String.format("entity: %s does not belong to this view", secondEntity.getName()));
}
}
if (firstCardinality != null) {
this.firstCardinality = firstCardinality;
......
......@@ -23,7 +23,7 @@ public class Trans {
protected static Attribute TransformFromDB(AttributeDO attributeDO) {
LayoutInfo layoutInfo = LayoutInfo.queryByObjIDAndObjType(attributeDO.getID(), RelatedObjType.ATTRIBUTE);
return new Attribute(attributeDO.getID(), attributeDO.getEntityID(), attributeDO.getViewID(),
attributeDO.getName(), attributeDO.getDataType(), attributeDO.getIsPrimary(),
attributeDO.getName(), attributeDO.getDataType(), attributeDO.getIsPrimary(), attributeDO.getNullable(),
layoutInfo, 0.0, 0.0, attributeDO.getGmtCreate(), attributeDO.getGmtModified());
}
......
......@@ -77,6 +77,9 @@ public class View {
if (relationshipName.equals("")) {
throw new ERException("relationshipName cannot be empty");
}
if (firstEntity.getID().equals(secondEntity.getID())) {
throw new ERException("relationship cannot be created on the same entity");
}
if (Entity.queryByID(firstEntity.getID()) == null) {
throw new ERException(String.format("entity with ID: %d not found", firstEntity.getID()));
}
......@@ -89,6 +92,12 @@ public class View {
if (Relationship.queryByRelationship(new RelationshipDO(secondEntity.getID(), firstEntity.getID())).size() != 0) {
throw new ERException(String.format("relation between entity %s and %s already exists", firstEntity.getName(), secondEntity.getName()));
}
if (!firstEntity.getViewID().equals(this.ID)) {
throw new ERException(String.format("entity: %s does not belong to this view", firstEntity.getName()));
}
if (!secondEntity.getViewID().equals(this.ID)) {
throw new ERException(String.format("entity: %s does not belong to this view", secondEntity.getName()));
}
Relationship relationship = new Relationship(0L, relationshipName, this.ID, firstEntity, secondEntity, firstCardinality, secondCardinality, null, new Date(), new Date());
this.relationshipList.add(relationship);
return relationship;
......@@ -114,7 +123,7 @@ public class View {
}
}
public String ToJSON() {
public String toJSON() {
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json;
try {
......
......@@ -39,7 +39,8 @@ public class ViewDeserializer extends StdDeserializer<View> {
String attributeName = attributeJSONNode.get("name").textValue();
DataType attributeDataType = DataType.valueOf(attributeJSONNode.get("dataType").textValue());
Boolean attributeIsPrimary = attributeJSONNode.get("isPrimary").booleanValue();
entity.addAttribute(attributeName, attributeDataType, attributeIsPrimary);
Boolean attributeNullable = attributeJSONNode.get("nullable").booleanValue();
entity.addAttribute(attributeName, attributeDataType, attributeIsPrimary, attributeNullable);
entityNameMap.put(entityName, entity);
}
JsonNode layoutInfoJSONNode = entityJSONNode.get("layoutInfo");
......
......@@ -17,6 +17,7 @@ public class AttributeDO {
private String name;
private DataType dataType;
private Boolean isPrimary;
private Boolean nullable;
private Integer isDelete;
private Date gmtCreate;
private Date gmtModified;
......
......@@ -11,6 +11,7 @@
<result column="name" property="name"/>
<result column="data_type" property="dataType"/>
<result column="is_primary" property="isPrimary"/>
<result column="is_null" property="isNull"/>
<result column="is_delete" property="isDelete"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="gmt_modified" property="gmtModified"/>
......@@ -22,14 +23,14 @@
<select id="selectByID" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
id,entity_id,view_id,name,data_type,is_primary,is_delete,gmt_create,gmt_modified
id,entity_id,view_id,name,data_type,is_primary,nullable,is_delete,gmt_create,gmt_modified
from attribute
where id = #{id,jdbcType=BIGINT} and is_delete = 0
</select>
<select id="selectByAttribute" parameterType="com.ic.er.entity.AttributeDO" resultMap="BaseResultMap">
select
id,entity_id,view_id,name,data_type,is_primary,is_delete,gmt_create,gmt_modified
id,entity_id,view_id,name,data_type,is_primary,nullable,is_delete,gmt_create,gmt_modified
from attribute
<where>
<if test="ID != null">
......@@ -50,6 +51,9 @@
<if test="isPrimary != null">
and is_primary = #{isPrimary,jdbcType=TINYINT}
</if>
<if test="nullable != null">
and nullable = #{nullable,jdbcType=TINYINT}
</if>
<if test="gmtCreate != null">
and gmt_create = #{gmtCreate,jdbcType=DATETIME}
</if>
......@@ -78,6 +82,9 @@
<if test="isPrimary != null">
is_primary,
</if>
<if test="nullable != null">
nullable,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="entityID != null">
......@@ -95,6 +102,9 @@
<if test="isPrimary != null">
#{isPrimary,jdbcType=TINYINT},
</if>
<if test="nullable != null">
#{nullable,jdbcType=TINYINT},
</if>
</trim>
</insert>
......@@ -122,6 +132,9 @@
<if test="isPrimary != null">
is_primary = #{isPrimary,jdbcType=TINYINT},
</if>
<if test="nullable != null">
nullable = #{nullable,jdbcType=TINYINT},
</if>
</set>
where id = #{ID,jdbcType=BIGINT} and is_delete = 0
</update>
......
......@@ -6,6 +6,7 @@ CREATE TABLE attribute (
name varchar(255) NOT NULL COMMENT 'attribute name',
data_type varchar(50) NOT NULL COMMENT 'attribute type',
is_primary tinyint NOT NULL DEFAULT 0 COMMENT '0-not a primary key, 1-primary key, default 0',
nullable tinyint NOT NULL DEFAULT 0 COMMENT '0-not null, 1-nullable, default 0',
is_delete tinyint NOT NULL DEFAULT 0 COMMENT '0-undeleted,1-delete,default 0',
gmt_create datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Create time',
gmt_modified datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Modified time',
......
......@@ -25,23 +25,25 @@ public class TestAttribute {
@Test
public void addAttributeTest() {
Attribute a1 = testEntity.addAttribute("teacher_id", DataType.VARCHAR, true);
Attribute a2 = testEntity.addAttribute("name", DataType.VARCHAR, false);
Attribute a3 = testEntity.addAttribute("age", DataType.INT, false);
assertThrows(ERException.class, () -> testEntity.addAttribute("testPrimaryWithNullable", DataType.INT, true, true));
Attribute a1 = testEntity.addAttribute("teacher_id", DataType.VARCHAR, true, false);
Attribute a2 = testEntity.addAttribute("name", DataType.VARCHAR, false, false);
Attribute a3 = testEntity.addAttribute("age", DataType.INT, false, true);
Assert.assertNotNull(a1);
Assert.assertNotNull(a2);
Assert.assertNotNull(a3);
assertThrows(ERException.class, () -> testEntity.addAttribute("age", DataType.INT, false));
assertThrows(ERException.class, () -> testEntity.addAttribute("new primary", DataType.INT, true));
assertThrows(ERException.class, () -> testEntity.addAttribute("age", DataType.INT, false, false));
assertThrows(ERException.class, () -> testEntity.addAttribute("new primary", DataType.INT, true, false));
}
@Test
public void updateTest() {
Attribute backup = testEntity.addAttribute("backup", DataType.VARCHAR, true);
Attribute a1 = testEntity.addAttribute("teacher_id", DataType.VARCHAR, false);
Attribute backup = testEntity.addAttribute("backup", DataType.VARCHAR, true, false);
Attribute a1 = testEntity.addAttribute("teacher_id", DataType.VARCHAR, false, false);
String newName = "new_teacher_id";
a1.updateInfo(newName, null, null);
a1.updateInfo(newName, null, null, null);
a1.updateLayoutInfo(1.0, 2.0, 3.0, 4.0);
List<Attribute> attributeList = Attribute.queryByAttribute(new AttributeDO(a1.getID()));
......@@ -52,20 +54,21 @@ public class TestAttribute {
Assert.assertEquals(attributeList.get(0).getLayoutInfo().getHeight(), Double.valueOf(3.0));
Assert.assertEquals(attributeList.get(0).getLayoutInfo().getWidth(), Double.valueOf(4.0));
assertThrows(ERException.class, () -> a1.updateInfo("backup", null, null));
assertThrows(ERException.class, () -> a1.updateInfo(null, null, true));
assertThrows(ERException.class, () -> a1.updateInfo("backup", null, null, null));
assertThrows(ERException.class, () -> a1.updateInfo(null, null, true, null));
assertThrows(ERException.class, () -> backup.updateInfo(null, null, null, true));
}
@Test
public void selectByIDTest() {
Attribute a1 = testEntity.addAttribute("teacher_id", DataType.VARCHAR, true);
Attribute a1 = testEntity.addAttribute("teacher_id", DataType.VARCHAR, true, false);
Attribute attribute = Attribute.queryByID(a1.getID());
Assert.assertNotNull(attribute);
}
@Test(expected = ERException.class)
public void deleteByIDTest() {
Attribute a1 = testEntity.addAttribute("teacher_id", DataType.VARCHAR, true);
Attribute a1 = testEntity.addAttribute("teacher_id", DataType.VARCHAR, true, false);
// delete
a1.deleteDB();
......
......@@ -31,32 +31,34 @@ public class TestER {
}
@Test
public void jsonTest() throws IOException {
View firstView = ER.createView("first view", "tw");
public void drawER() throws IOException {
View example = ER.createView("BranchAccountMovement", "tw");
Entity teacher = firstView.addEntity("teacher");
teacher.addAttribute("teacher_id", DataType.VARCHAR, true);
teacher.addAttribute("name", DataType.VARCHAR, false);
teacher.addAttribute("age", DataType.INT, false);
Entity branch = example.addEntity("branch");
branch.addAttribute("sortcode", DataType.INT, true, false);
branch.addAttribute("bname", DataType.VARCHAR, false, false);
branch.addAttribute("cash", DataType.DOUBLE, false, false);
Entity student = firstView.addEntity("student");
student.addAttribute("student_id", DataType.VARCHAR, true);
student.addAttribute("name", DataType.VARCHAR, false);
student.addAttribute("grade", DataType.INT, false);
Entity account = example.addEntity("account");
account.addAttribute("no", DataType.INT, true, false);
account.addAttribute("type", DataType.CHAR, false, false);
account.addAttribute("cname", DataType.VARCHAR, false, false);
account.addAttribute("rate", DataType.DOUBLE, false, true);
Relationship ts = firstView.createRelationship("teaches", teacher, student, Cardinality.OneToMany, Cardinality.OneToMany);
Entity movement = example.addEntity("movement");
movement.addAttribute("mid", DataType.INT, true, false);
movement.addAttribute("amount", DataType.DOUBLE, false, false);
movement.addAttribute("tdate", DataType.DATETIME, false, false);
String jsonString = firstView.ToJSON();
FileWriter myWriter = new FileWriter("first view.json");
Relationship holds = example.createRelationship("holds", account, branch, Cardinality.OneToOne, Cardinality.ZeroToMany);
Relationship has = example.createRelationship("has", account, movement, Cardinality.ZeroToMany, Cardinality.OneToOne);
String jsonString = example.toJSON();
FileWriter myWriter = new FileWriter(String.format("%s.json", example.getName()));
myWriter.write(jsonString);
myWriter.close();
View view = ER.loadFromJSON(jsonString);
Assert.assertNotNull(view);
}
@Test
public void getCardi() {
System.out.println(Cardinality.getFromValue("1:N"));
}
}
......@@ -61,7 +61,7 @@ public class TestEntity {
@Test(expected = ERException.class)
public void attributeTest() {
Entity teacher = testView.addEntity("teacher");
Attribute teacherID = teacher.addAttribute("teacher_id", DataType.INT, true);
Attribute teacherID = teacher.addAttribute("teacher_id", DataType.INT, true, false);
Assert.assertNotEquals(teacher.getID(), Long.valueOf(0));
teacher.updateInfo("new teacher name");
......
......@@ -14,17 +14,23 @@ import java.util.List;
public class TestRelationship {
private View testView;
private View secondView;
private Entity teacher;
private Entity student;
private Entity classroom;
private Entity secondViewEntity1;
private Entity secondViewEntity2;
@Before
public void init() throws Exception {
ER.initialize(true);
testView = ER.createView("testView", "wt22");
secondView = ER.createView("secondView", "wt22");
teacher = testView.addEntity("teacher");
student = testView.addEntity("student");
classroom = testView.addEntity("classroom");
secondViewEntity1 = secondView.addEntity("ent1");
secondViewEntity2 = secondView.addEntity("ent2");
Assert.assertNotNull(teacher);
Assert.assertNotNull(student);
Assert.assertNotNull(classroom);
......@@ -32,6 +38,8 @@ public class TestRelationship {
@Test
public void createRelationshipTest() {
assertThrows(ERException.class, () -> secondView.createRelationship("teaches", student, teacher, Cardinality.ZeroToMany, Cardinality.ZeroToMany));
Relationship relationship = testView.createRelationship("teaches", teacher, student, Cardinality.ZeroToMany, Cardinality.ZeroToMany);
Assert.assertNotNull(relationship);
Assert.assertEquals(relationship.getID(), Long.valueOf(1L));
......@@ -64,6 +72,7 @@ public class TestRelationship {
Relationship teachClassroom = testView.createRelationship("teaches", teacher, classroom, Cardinality.ZeroToMany, Cardinality.ZeroToMany);
assertThrows(ERException.class, () -> teachClassroom.updateInfo(newName, teacher, student, newCardi, newCardi));
assertThrows(ERException.class, () -> teachClassroom.updateInfo(newName, secondViewEntity1, secondViewEntity2, newCardi, newCardi));
}
@Test
......
......@@ -21,14 +21,14 @@ public class TestView {
View testView = ER.createView("testView", "wt22");
Entity teacher = testView.addEntity("teacher");
teacher.addAttribute("teacher_id", DataType.VARCHAR, true);
teacher.addAttribute("name", DataType.VARCHAR, false);
teacher.addAttribute("age", DataType.INT, false);
teacher.addAttribute("teacher_id", DataType.VARCHAR, true, false);
teacher.addAttribute("name", DataType.VARCHAR, false, false);
teacher.addAttribute("age", DataType.INT, false, false);
Entity student = testView.addEntity("student");
student.addAttribute("student_id", DataType.VARCHAR, true);
student.addAttribute("name", DataType.VARCHAR, false);
student.addAttribute("grade", DataType.INT, false);
student.addAttribute("student_id", DataType.VARCHAR, true, false);
student.addAttribute("name", DataType.VARCHAR, false, false);
student.addAttribute("grade", DataType.INT, false, false);
Relationship ts = testView.createRelationship("teaches", teacher, student, Cardinality.ZeroToMany, Cardinality.ZeroToMany);
......@@ -91,14 +91,14 @@ public class TestView {
View firstView = ER.createView("first view", "tw");
Entity teacher = firstView.addEntity("teacher");
teacher.addAttribute("teacher_id", DataType.VARCHAR, true);
teacher.addAttribute("name", DataType.VARCHAR, false);
teacher.addAttribute("age", DataType.INT, false);
teacher.addAttribute("teacher_id", DataType.VARCHAR, true, false);
teacher.addAttribute("name", DataType.VARCHAR, false, false);
teacher.addAttribute("age", DataType.INT, false, false);
Entity student = firstView.addEntity("student");
student.addAttribute("student_id", DataType.VARCHAR, true);
student.addAttribute("name", DataType.VARCHAR, false);
student.addAttribute("grade", DataType.INT, false);
student.addAttribute("student_id", DataType.VARCHAR, true, false);
student.addAttribute("name", DataType.VARCHAR, false, false);
student.addAttribute("grade", DataType.INT, false, false);
Relationship ts = firstView.createRelationship("teaches", teacher, student, Cardinality.ZeroToMany, Cardinality.ZeroToMany);
Assert.assertNotNull(ts);
......
......@@ -34,6 +34,7 @@ public class attributeMapperTest {
String dataType = "int";
Boolean isPrimary = true;
Boolean nullable = false;
int isDelete = 0;
......@@ -42,9 +43,9 @@ public class attributeMapperTest {
Date gmtModified = new Date();
AttributeDO attributeDO = new AttributeDO(0L, entityID, viewID, name, DataType.INT, isPrimary, isDelete, gmtCreate, gmtModified);
AttributeDO attributeDO2 = new AttributeDO(0L, entityID, viewID, name, DataType.INT, isPrimary, isDelete, gmtCreate, gmtModified);
AttributeDO attributeDO3 = new AttributeDO(0L, entityID, viewID, name, DataType.INT, isPrimary, isDelete, gmtCreate, gmtModified);
AttributeDO attributeDO = new AttributeDO(0L, entityID, viewID, name, DataType.INT, isPrimary, nullable, isDelete, gmtCreate, gmtModified);
AttributeDO attributeDO2 = new AttributeDO(0L, entityID, viewID, name, DataType.INT, isPrimary, nullable, isDelete, gmtCreate, gmtModified);
AttributeDO attributeDO3 = new AttributeDO(0L, entityID, viewID, name, DataType.INT, isPrimary, nullable, isDelete, gmtCreate, gmtModified);
int ret = ER.attributeMapper.insert(attributeDO);
int ret2 = ER.attributeMapper.insert(attributeDO2);
......@@ -58,7 +59,7 @@ public class attributeMapperTest {
public void selectByAttributeTest() {
Long entityID = 456L;
AttributeDO attributeDO = new AttributeDO(0L, entityID, 789L, "abc", DataType.VARCHAR, true, 0, null, null);
AttributeDO attributeDO = new AttributeDO(0L, entityID, 789L, "abc", DataType.VARCHAR, false, true, 0, null, null);
int ret = ER.attributeMapper.insert(attributeDO);
Assert.assertEquals(ret, 1);
List<AttributeDO> attributeDOList = ER.attributeMapper.selectByAttribute(attributeDO);
......@@ -76,7 +77,7 @@ public class attributeMapperTest {
Long newEntityID = 789L;
// create
AttributeDO attributeDO = new AttributeDO(0L, entityID, 789L, "abc", DataType.VARCHAR, true, 0, null, null);
AttributeDO attributeDO = new AttributeDO(0L, entityID, 789L, "abc", DataType.VARCHAR, false, true, 0, null, null);
int ret = ER.attributeMapper.insert(attributeDO);
Assert.assertEquals(ret, 1);
Assert.assertEquals(attributeDO.getEntityID(), entityID);
......@@ -91,7 +92,7 @@ public class attributeMapperTest {
Long newEntityID = 789L;
// create
AttributeDO attributeDO = new AttributeDO(0L, entityID, 789L, "abc", DataType.VARCHAR, true, 0, null, null);
AttributeDO attributeDO = new AttributeDO(0L, entityID, 789L, "abc", DataType.VARCHAR, false, true, 0, null, null);
int ret = ER.attributeMapper.insert(attributeDO);
Assert.assertEquals(ret, 1);
Assert.assertEquals(attributeDO.getEntityID(), entityID);
......@@ -111,7 +112,7 @@ public class attributeMapperTest {
Long entityID = 456L;
// create
AttributeDO attributeDO = new AttributeDO(0L, entityID, 789L, "abc", DataType.VARCHAR, true, 0, null, null);
AttributeDO attributeDO = new AttributeDO(0L, entityID, 789L, "abc", DataType.VARCHAR, false, true, 0, null, null);
int ret = ER.attributeMapper.insert(attributeDO);
Assert.assertEquals(ret, 1);
Assert.assertEquals(attributeDO.getEntityID(), entityID);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment