55import java .sql .ResultSet ;
66import java .sql .SQLException ;
77
8+ import static org .junit .jupiter .api .Assertions .assertFalse ;
89import static org .junit .jupiter .api .Assertions .assertTrue ;
910
1011public 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