99import java .nio .file .Files ;
1010import java .nio .file .Path ;
1111import java .nio .file .attribute .PosixFilePermission ;
12+ import java .time .Instant ;
13+ import java .util .Date ;
1214import java .util .Set ;
1315import java .util .concurrent .atomic .AtomicReference ;
1416
@@ -128,7 +130,18 @@ void calculateOptimalTotalSplit_withMaxCalculations() throws Exception {
128130 copyResourceToTarget (projectFolder , "tests/NoTimingOneTest.java" , "NoTimingOneTest.java" , PERMISSIONS );
129131 copyResourceToTarget (projectFolder , "tests/NoTimingTwoTest.java" , "NoTimingTwoTest.java" , PERMISSIONS );
130132
131- jCommander .parse ("-i" , "0" , "-t" , "4" , "-g" , "**/*Test.java" , "-j" , "**/junit-reports/*.xml" , "-n" , "max" , "-m" , "5" );
133+ jCommander .parse ("-i" ,
134+ "0" ,
135+ "-t" ,
136+ "4" ,
137+ "-g" ,
138+ "**/*Test.java" ,
139+ "-j" ,
140+ "**/junit-reports/*.xml" ,
141+ "-n" ,
142+ "max" ,
143+ "-m" ,
144+ "5" );
132145 assertThat (TestSplitMain .calculateOptimalTotalSplit (arguments , tmp )).isEqualTo (4 );
133146 }
134147
@@ -137,7 +150,18 @@ void calculateOptimalTotalSplit_withTooLowMaxCalculations() throws Exception {
137150 copyResourceToTarget (projectFolder , "tests/NoTimingOneTest.java" , "NoTimingOneTest.java" , PERMISSIONS );
138151 copyResourceToTarget (projectFolder , "tests/NoTimingTwoTest.java" , "NoTimingTwoTest.java" , PERMISSIONS );
139152
140- jCommander .parse ("-i" , "0" , "-t" , "1" , "-g" , "**/*Test.java" , "-j" , "**/junit-reports/*.xml" , "-n" , "max" , "-m" , "4" );
153+ jCommander .parse ("-i" ,
154+ "0" ,
155+ "-t" ,
156+ "1" ,
157+ "-g" ,
158+ "**/*Test.java" ,
159+ "-j" ,
160+ "**/junit-reports/*.xml" ,
161+ "-n" ,
162+ "max" ,
163+ "-m" ,
164+ "4" );
141165 assertThat (TestSplitMain .calculateOptimalTotalSplit (arguments , tmp )).isEqualTo (0 );
142166 }
143167
@@ -158,4 +182,32 @@ void calculateOptimalTotalSplit_withInvalidSplitIndex() throws Exception {
158182 jCommander .parse ("-i" , "1" , "-t" , "1" , "-g" , "**/*Test.java" , "-j" , "**/junit-reports/*.xml" );
159183 assertThat (TestSplitMain .calculateOptimalTotalSplit (arguments , tmp )).isEqualTo (0 );
160184 }
185+
186+ @ Test
187+ void readProperties () throws Exception {
188+ final var properties = TestSplitMain .readProperties ("split-tests-java-test.properties" );
189+ assertThat (properties ).isNotNull ();
190+ assertThat (properties .getProperty ("git.commit.time" )).isEqualTo ("2023-01-01T00:01:02+0000" );
191+ assertThat (properties .getProperty ("git.commit.id" )).isEqualTo ("4c204731e327bc2e06d2a1b02f46e4195c210d0e" );
192+ assertThat (properties .getProperty ("git.commit.id.abbrev" )).isEqualTo ("4c20473" );
193+ assertThat (properties .getProperty ("git.branch" )).isEqualTo ("master" );
194+ assertThat (properties .getProperty ("version" )).isEqualTo ("1.2.3-SNAPSHOT" );
195+ }
196+
197+ @ Test
198+ void readProperties_whenFileNotFound () throws Exception {
199+ final var properties = TestSplitMain .readProperties ("not-found.properties" );
200+ assertThat (properties ).isNotNull ();
201+ assertThat (properties ).isEmpty ();
202+ }
203+
204+ @ Test
205+ void getBuiltTime () {
206+ assertThat (TestSplitMain .getBuiltTime ("2023-01-01T00:01:02+0000" )).isEqualTo ("2023-01-01T00:01:02+0000" );
207+ }
208+
209+ @ Test
210+ void getBuiltTime_whenTimeNotParseable () {
211+ assertThat (TestSplitMain .getBuiltTime ("" )).isEqualTo (Date .from (Instant .EPOCH ));
212+ }
161213}
0 commit comments