Skip to content

Commit d7d0244

Browse files
Test fields are not auto incrementing or a primary key
1 parent dbe9dae commit d7d0244

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

src/test/java/org/javawebstack/orm/test/automigrate/CommonTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public void testPrimitiveIntegerDatatype() throws SQLException {
8383

8484
checkedField.assertType(entry.getValue());
8585
checkedField.assertNullable();
86+
checkedField.assertNotPrimaryKey();
87+
checkedField.assertNotAutoIncrementing();
8688
}
8789

8890
}

src/test/java/org/javawebstack/orm/test/shared/verification/Field.java

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.sql.ResultSet;
66
import java.sql.SQLException;
77

8+
import static org.junit.jupiter.api.Assertions.assertFalse;
89
import static org.junit.jupiter.api.Assertions.assertTrue;
910

1011
public class Field extends MySQLConnectionContainer {
@@ -23,19 +24,45 @@ public Field(String tableName, String fieldName) throws SQLException {
2324
}
2425

2526
public void assertPrimaryKey() throws SQLException {
26-
assert(resultSet.getString("Key").equalsIgnoreCase("PRI"));
27+
assertTrue(
28+
resultSet.getString("Key").equalsIgnoreCase("PRI"),
29+
String.format("%s.%s should be a Primary Key but was not.", tableName, fieldName)
30+
);
31+
}
32+
33+
public void assertNotPrimaryKey() throws SQLException {
34+
assertFalse(
35+
resultSet.getString("Key").equalsIgnoreCase("PRI"),
36+
String.format("%s.%s should not be a Primary Key but was.", tableName, fieldName)
37+
);
2738
}
2839

2940
public void assertAutoIncrementing() throws SQLException {
30-
assert(resultSet.getString("Extra").equalsIgnoreCase("auto_increment"));
41+
assertTrue(
42+
resultSet.getString("Extra").equalsIgnoreCase("auto_increment"),
43+
String.format("%s.%s should be auto incrementing but was not.", tableName, fieldName)
44+
);
45+
}
46+
47+
public void assertNotAutoIncrementing() throws SQLException {
48+
assertFalse(
49+
resultSet.getString("Extra").equalsIgnoreCase("auto_increment"),
50+
String.format("%s.%s should not be auto incrementing but was.", tableName, fieldName)
51+
);
3152
}
3253

3354
public void assertNullable() throws SQLException {
34-
assert(resultSet.getString("NULL").equalsIgnoreCase("yes"));
55+
assertTrue(
56+
resultSet.getString("NULL").equalsIgnoreCase("yes"),
57+
String.format("%s.%s is not nullable but nullability was expected.", tableName, fieldName)
58+
);
3559
}
3660

3761
public void assertNotNullable() throws SQLException {
38-
assert(resultSet.getString("NULL").equalsIgnoreCase("no"));
62+
assertTrue(
63+
resultSet.getString("NULL").equalsIgnoreCase("no"),
64+
String.format("%s.%s is nullable but no nullability was expected.", tableName, fieldName)
65+
);
3966
}
4067

4168
public void assertType(String expectedType) throws SQLException {

0 commit comments

Comments
 (0)