25
25
import org .junit .*;
26
26
import org .junit .runner .RunWith ;
27
27
import pl .project13 .core .git .GitDescribeConfig ;
28
+ import pl .project13 .core .util .GenericFileManager ;
28
29
import pl .project13 .core .util .JsonManager ;
29
30
import pl .project13 .core .util .XmlManager ;
30
31
import pl .project13 .core .util .YmlManager ;
@@ -445,6 +446,7 @@ public void shouldGenerateCustomPropertiesFileProperties(boolean useNativeGit) t
445
446
public void shouldGenerateCustomPropertiesFileJson (boolean useNativeGit ) throws Exception {
446
447
// given
447
448
File dotGitDirectory = createTmpDotGitDirectory (AvailableGitTestRepo .WITH_ONE_COMMIT_WITH_SPECIAL_CHARACTERS );
449
+ CommitIdPropertiesOutputFormat commitIdPropertiesOutputFormat = CommitIdPropertiesOutputFormat .JSON ;
448
450
449
451
File targetFilePath = sandbox .resolve ("custom-git.json" ).toFile ();
450
452
targetFilePath .delete ();
@@ -455,15 +457,15 @@ public void shouldGenerateCustomPropertiesFileJson(boolean useNativeGit) throws
455
457
.setUseNativeGit (useNativeGit )
456
458
.setShouldGenerateGitPropertiesFile (true )
457
459
.setGenerateGitPropertiesFilename (targetFilePath )
458
- .setPropertiesOutputFormat (CommitIdPropertiesOutputFormat . JSON )
460
+ .setPropertiesOutputFormat (commitIdPropertiesOutputFormat )
459
461
.build ();
460
462
Properties properties = new Properties ();
461
463
462
464
// when
463
465
GitCommitIdPlugin .runPlugin (cb , properties );
464
466
// then
465
467
assertThat (targetFilePath ).exists ();
466
- Properties p = JsonManager . readJsonProperties ( targetFilePath , StandardCharsets . UTF_8 );
468
+ Properties p = GenericFileManager . readPropertiesAsUtf8 ( commitIdPropertiesOutputFormat , targetFilePath );
467
469
assertThat (p .size () > 10 );
468
470
Assert .assertEquals (p , properties );
469
471
}
@@ -473,6 +475,7 @@ public void shouldGenerateCustomPropertiesFileJson(boolean useNativeGit) throws
473
475
public void shouldGenerateCustomPropertiesFileXml (boolean useNativeGit ) throws Exception {
474
476
// given
475
477
File dotGitDirectory = createTmpDotGitDirectory (AvailableGitTestRepo .WITH_ONE_COMMIT_WITH_SPECIAL_CHARACTERS );
478
+ CommitIdPropertiesOutputFormat commitIdPropertiesOutputFormat = CommitIdPropertiesOutputFormat .XML ;
476
479
477
480
File targetFilePath = sandbox .resolve ("custom-git.xml" ).toFile ();
478
481
targetFilePath .delete ();
@@ -483,15 +486,15 @@ public void shouldGenerateCustomPropertiesFileXml(boolean useNativeGit) throws E
483
486
.setUseNativeGit (useNativeGit )
484
487
.setShouldGenerateGitPropertiesFile (true )
485
488
.setGenerateGitPropertiesFilename (targetFilePath )
486
- .setPropertiesOutputFormat (CommitIdPropertiesOutputFormat . XML )
489
+ .setPropertiesOutputFormat (commitIdPropertiesOutputFormat )
487
490
.build ();
488
491
Properties properties = new Properties ();
489
492
490
493
// when
491
494
GitCommitIdPlugin .runPlugin (cb , properties );
492
495
// then
493
496
assertThat (targetFilePath ).exists ();
494
- Properties p = XmlManager . readXmlProperties ( targetFilePath , StandardCharsets . UTF_8 );
497
+ Properties p = GenericFileManager . readPropertiesAsUtf8 ( commitIdPropertiesOutputFormat , targetFilePath );
495
498
assertThat (p .size () > 10 );
496
499
Assert .assertEquals (p , properties );
497
500
}
@@ -501,6 +504,7 @@ public void shouldGenerateCustomPropertiesFileXml(boolean useNativeGit) throws E
501
504
public void shouldGenerateCustomPropertiesFileYml (boolean useNativeGit ) throws Exception {
502
505
// given
503
506
File dotGitDirectory = createTmpDotGitDirectory (AvailableGitTestRepo .WITH_ONE_COMMIT_WITH_SPECIAL_CHARACTERS );
507
+ CommitIdPropertiesOutputFormat commitIdPropertiesOutputFormat = CommitIdPropertiesOutputFormat .YML ;
504
508
505
509
File targetFilePath = sandbox .resolve ("custom-git.yml" ).toFile ();
506
510
targetFilePath .delete ();
@@ -511,15 +515,15 @@ public void shouldGenerateCustomPropertiesFileYml(boolean useNativeGit) throws E
511
515
.setUseNativeGit (useNativeGit )
512
516
.setShouldGenerateGitPropertiesFile (true )
513
517
.setGenerateGitPropertiesFilename (targetFilePath )
514
- .setPropertiesOutputFormat (CommitIdPropertiesOutputFormat . YML )
518
+ .setPropertiesOutputFormat (commitIdPropertiesOutputFormat )
515
519
.build ();
516
520
Properties properties = new Properties ();
517
521
518
522
// when
519
523
GitCommitIdPlugin .runPlugin (cb , properties );
520
524
// then
521
525
assertThat (targetFilePath ).exists ();
522
- Properties p = YmlManager . readYmlProperties ( targetFilePath , StandardCharsets . UTF_8 );
526
+ Properties p = GenericFileManager . readPropertiesAsUtf8 ( commitIdPropertiesOutputFormat , targetFilePath );
523
527
assertThat (p .size () > 10 );
524
528
Assert .assertEquals (p , properties );
525
529
}
0 commit comments