77import org .javawebstack .orm .exception .ORMConfigurationException ;
88import org .javawebstack .orm .test .ORMTestCase ;
99import org .javawebstack .orm .test .shared .models .Datatype ;
10+ import org .javawebstack .orm .test .shared .models .JustCharArray ;
1011import org .javawebstack .orm .test .shared .models .JustString ;
1112import org .javawebstack .orm .test .shared .verification .Field ;
1213import org .junit .jupiter .api .BeforeEach ;
@@ -32,20 +33,25 @@ public class DefaultSizeTest extends ORMTestCase {
3233 private static final long MAX_SIZE_MEDIUMTEXT = (long ) Math .floor ((16777215 - BYTES_OVERHEAD_MEDIUMTEXT ) / 4 );
3334 private static final long MAX_SIZE_LONGTEXT = (long ) Math .floor ((4294967295L - BYTES_OVERHEAD_LONGTEXT ) / 4 );
3435
35- final static String tableName = "just_strings" ;
36+ final static String tableNameString = "just_strings" ;
37+ final static String columnNameString = "string" ;
38+
39+ // Not renaming the table name as this is not focus of the test
40+ final static String tableNameCharArray = "just_char_arraies" ;
41+ final static String columnNameCharArray = "char_array" ;
3642
3743 @ Test
3844 public void testStringUsesDefaultSizeChar () throws ORMConfigurationException , SQLException {
3945 setUpWithDefaultSize (JustString .class , 1 );
40- (new Field ("just_strings" , "string" )).assertType ("char(1)" );
46+ (new Field (tableNameString , columnNameString )).assertType ("char(1)" );
4147 }
4248
4349 @ Test
4450 public void testStringUsesDefaultSizeVarchar () throws ORMConfigurationException , SQLException {
4551 int [] parameters = {2 , 3 , 123 , 1234 , 12345 , (int ) MAX_SIZE_VARCHAR - 1 , (int ) MAX_SIZE_VARCHAR };
4652 for ( int singleParameter : parameters ) {
4753 setUpWithDefaultSize (JustString .class , singleParameter );
48- (new Field ("just_strings" , "string" )).assertType (String .format ("varchar(%s)" , singleParameter ));
54+ (new Field (tableNameString , columnNameString )).assertType (String .format ("varchar(%s)" , singleParameter ));
4955 }
5056 }
5157
@@ -54,7 +60,7 @@ public void testStringUsesDefaultSizeMediumText() throws ORMConfigurationExcepti
5460 int [] parameters = {(int ) MAX_SIZE_VARCHAR + 1 , 123456 , 1234567 , (int ) MAX_SIZE_MEDIUMTEXT - 1 };
5561 for ( int singleParameter : parameters ) {
5662 setUpWithDefaultSize (JustString .class , singleParameter );
57- (new Field ("just_strings" , "string" )).assertType ("mediumtext" );
63+ (new Field (tableNameString , columnNameString )).assertType ("mediumtext" );
5864 }
5965 }
6066
@@ -63,7 +69,40 @@ public void testStringUsesDefaultSizeLongText() throws ORMConfigurationException
6369 int [] parameters = {(int ) MAX_SIZE_MEDIUMTEXT + 1 , 123456789 , 123467890 , Integer .MAX_VALUE };
6470 for ( int singleParameter : parameters ) {
6571 setUpWithDefaultSize (JustString .class , singleParameter );
66- (new Field ("just_strings" , "string" )).assertType ("longtext" );
72+ (new Field (tableNameString , columnNameString )).assertType ("longtext" );
73+ }
74+ }
75+
76+ @ Test
77+ public void testCharArrayUsesDefaultSizeChar () throws ORMConfigurationException , SQLException {
78+ setUpWithDefaultSize (JustCharArray .class , 1 );
79+ (new Field (tableNameCharArray , columnNameCharArray )).assertType ("char(1)" );
80+ }
81+
82+ @ Test
83+ public void testCharArrayUsesDefaultSizeVarchar () throws ORMConfigurationException , SQLException {
84+ int [] parameters = {2 , 3 , 123 , 1234 , 12345 , (int ) MAX_SIZE_VARCHAR - 1 , (int ) MAX_SIZE_VARCHAR };
85+ for ( int singleParameter : parameters ) {
86+ setUpWithDefaultSize (JustCharArray .class , singleParameter );
87+ (new Field (tableNameCharArray , columnNameCharArray )).assertType (String .format ("varchar(%s)" , singleParameter ));
88+ }
89+ }
90+
91+ @ Test
92+ public void testCharArrayUsesDefaultSizeMediumText () throws ORMConfigurationException , SQLException {
93+ int [] parameters = {(int ) MAX_SIZE_VARCHAR + 1 , 123456 , 1234567 , (int ) MAX_SIZE_MEDIUMTEXT - 1 };
94+ for ( int singleParameter : parameters ) {
95+ setUpWithDefaultSize (JustCharArray .class , singleParameter );
96+ (new Field (tableNameCharArray , columnNameCharArray )).assertType ("mediumtext" );
97+ }
98+ }
99+
100+ @ Test
101+ public void testCharArrayUsesDefaultSizeLongText () throws ORMConfigurationException , SQLException {
102+ int [] parameters = {(int ) MAX_SIZE_MEDIUMTEXT + 1 , 123456789 , 123467890 , Integer .MAX_VALUE };
103+ for ( int singleParameter : parameters ) {
104+ setUpWithDefaultSize (JustCharArray .class , singleParameter );
105+ (new Field (tableNameCharArray , columnNameCharArray )).assertType ("longtext" );
67106 }
68107 }
69108
0 commit comments