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

modify test

parent 0895cc61
No related branches found
No related tags found
No related merge requests found
{
"name" : "BranchAccountMovement",
"entityList" : [ {
"name" : "branch",
"attributeList" : [ {
"name" : "sortcode",
"dataType" : "INT",
"isPrimary" : true,
"nullable" : false,
"layoutInfo" : {
"layoutX" : 0.0,
"layoutY" : 0.0
}
}, {
"name" : "bname",
"dataType" : "VARCHAR",
"isPrimary" : false,
"nullable" : false,
"layoutInfo" : {
"layoutX" : 0.0,
"layoutY" : 0.0
}
}, {
"name" : "cash",
"dataType" : "DOUBLE",
"isPrimary" : false,
"nullable" : false,
"layoutInfo" : {
"layoutX" : 0.0,
"layoutY" : 0.0
}
} ],
"layoutInfo" : {
"layoutX" : 0.0,
"layoutY" : 0.0
}
}, {
"name" : "account",
"attributeList" : [ {
"name" : "no",
"dataType" : "INT",
"isPrimary" : true,
"nullable" : false,
"layoutInfo" : {
"layoutX" : 0.0,
"layoutY" : 0.0
}
}, {
"name" : "type",
"dataType" : "CHAR",
"isPrimary" : false,
"nullable" : false,
"layoutInfo" : {
"layoutX" : 0.0,
"layoutY" : 0.0
}
}, {
"name" : "cname",
"dataType" : "VARCHAR",
"isPrimary" : false,
"nullable" : false,
"layoutInfo" : {
"layoutX" : 0.0,
"layoutY" : 0.0
}
}, {
"name" : "rate",
"dataType" : "DOUBLE",
"isPrimary" : false,
"nullable" : true,
"layoutInfo" : {
"layoutX" : 0.0,
"layoutY" : 0.0
}
} ],
"layoutInfo" : {
"layoutX" : 0.0,
"layoutY" : 0.0
}
}, {
"name" : "movement",
"attributeList" : [ {
"name" : "mid",
"dataType" : "INT",
"isPrimary" : true,
"nullable" : false,
"layoutInfo" : {
"layoutX" : 0.0,
"layoutY" : 0.0
}
}, {
"name" : "amount",
"dataType" : "DOUBLE",
"isPrimary" : false,
"nullable" : false,
"layoutInfo" : {
"layoutX" : 0.0,
"layoutY" : 0.0
}
}, {
"name" : "tdate",
"dataType" : "DATETIME",
"isPrimary" : false,
"nullable" : false,
"layoutInfo" : {
"layoutX" : 0.0,
"layoutY" : 0.0
}
} ],
"layoutInfo" : {
"layoutX" : 0.0,
"layoutY" : 0.0
}
} ],
"relationshipList" : [ {
"name" : "holds",
"firstEntity" : "account",
"firstCardinality" : "1:1",
"secondEntity" : "branch",
"secondCardinality" : "0:N",
"layoutInfo" : {
"layoutX" : 0.0,
"layoutY" : 0.0
}
}, {
"name" : "has",
"firstEntity" : "account",
"firstCardinality" : "0:N",
"secondEntity" : "movement",
"secondCardinality" : "1:1",
"layoutInfo" : {
"layoutX" : 0.0,
"layoutY" : 0.0
}
} ]
}
\ No newline at end of file
......@@ -98,7 +98,7 @@ public class Relationship {
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)) {
if (!secondEntity.getViewID().equals(this.viewID)) {
throw new ERException(String.format("entity: %s does not belong to this view", secondEntity.getName()));
}
}
......
......@@ -4,9 +4,6 @@
'http://mybatis.org/dtd/mybatis-3-config.dtd'>
<configuration>
<properties resource='jdbc-postgre.properties'/>
<settings>
<setting name="logImpl" value="LOG4J2"/>
</settings>
<typeHandlers>
<typeHandler handler="org.apache.ibatis.type.EnumOrdinalTypeHandler"
javaType="com.ic.er.common.RelatedObjType"/>
......
......@@ -4,9 +4,6 @@
'http://mybatis.org/dtd/mybatis-3-config.dtd'>
<configuration>
<properties resource='jdbc.properties'/>
<settings>
<setting name="logImpl" value="LOG4J2"/>
</settings>
<typeHandlers>
<typeHandler handler="org.apache.ibatis.type.EnumOrdinalTypeHandler"
javaType="com.ic.er.common.RelatedObjType"/>
......
......@@ -9,6 +9,9 @@ import org.junit.Test;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.assertThrows;
......@@ -35,7 +38,7 @@ public class TestER {
@Test
public void drawER() throws IOException {
View example = ER.createView("BranchAccountMovement", "tw");
View example = ER.createView("BranchAccountMovement", "");
Entity branch = example.addEntity("branch");
branch.addAttribute("sortcode", DataType.INT, true, false);
......@@ -60,7 +63,11 @@ public class TestER {
FileWriter myWriter = new FileWriter(String.format("%s.json", example.getName()));
myWriter.write(jsonString);
myWriter.close();
}
@Test
public void loadFromJSONTest() throws IOException {
String jsonString = Files.readString(Path.of("BranchAccountMovement.json"), Charset.defaultCharset());
View view = ER.loadFromJSON(jsonString);
Assert.assertNotNull(view);
}
......
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