2525import org .junit .*;
2626import org .junit .runner .RunWith ;
2727import pl .project13 .core .git .GitDescribeConfig ;
28+ import pl .project13 .core .util .GenericFileManager ;
2829import pl .project13 .core .util .JsonManager ;
2930import pl .project13 .core .util .XmlManager ;
3031import pl .project13 .core .util .YmlManager ;
@@ -445,6 +446,7 @@ public void shouldGenerateCustomPropertiesFileProperties(boolean useNativeGit) t
445446 public void shouldGenerateCustomPropertiesFileJson (boolean useNativeGit ) throws Exception {
446447 // given
447448 File dotGitDirectory = createTmpDotGitDirectory (AvailableGitTestRepo .WITH_ONE_COMMIT_WITH_SPECIAL_CHARACTERS );
449+ CommitIdPropertiesOutputFormat commitIdPropertiesOutputFormat = CommitIdPropertiesOutputFormat .JSON ;
448450
449451 File targetFilePath = sandbox .resolve ("custom-git.json" ).toFile ();
450452 targetFilePath .delete ();
@@ -455,15 +457,15 @@ public void shouldGenerateCustomPropertiesFileJson(boolean useNativeGit) throws
455457 .setUseNativeGit (useNativeGit )
456458 .setShouldGenerateGitPropertiesFile (true )
457459 .setGenerateGitPropertiesFilename (targetFilePath )
458- .setPropertiesOutputFormat (CommitIdPropertiesOutputFormat . JSON )
460+ .setPropertiesOutputFormat (commitIdPropertiesOutputFormat )
459461 .build ();
460462 Properties properties = new Properties ();
461463
462464 // when
463465 GitCommitIdPlugin .runPlugin (cb , properties );
464466 // then
465467 assertThat (targetFilePath ).exists ();
466- Properties p = JsonManager . readJsonProperties ( targetFilePath , StandardCharsets . UTF_8 );
468+ Properties p = GenericFileManager . readPropertiesAsUtf8 ( commitIdPropertiesOutputFormat , targetFilePath );
467469 assertThat (p .size () > 10 );
468470 Assert .assertEquals (p , properties );
469471 }
@@ -473,6 +475,7 @@ public void shouldGenerateCustomPropertiesFileJson(boolean useNativeGit) throws
473475 public void shouldGenerateCustomPropertiesFileXml (boolean useNativeGit ) throws Exception {
474476 // given
475477 File dotGitDirectory = createTmpDotGitDirectory (AvailableGitTestRepo .WITH_ONE_COMMIT_WITH_SPECIAL_CHARACTERS );
478+ CommitIdPropertiesOutputFormat commitIdPropertiesOutputFormat = CommitIdPropertiesOutputFormat .XML ;
476479
477480 File targetFilePath = sandbox .resolve ("custom-git.xml" ).toFile ();
478481 targetFilePath .delete ();
@@ -483,15 +486,15 @@ public void shouldGenerateCustomPropertiesFileXml(boolean useNativeGit) throws E
483486 .setUseNativeGit (useNativeGit )
484487 .setShouldGenerateGitPropertiesFile (true )
485488 .setGenerateGitPropertiesFilename (targetFilePath )
486- .setPropertiesOutputFormat (CommitIdPropertiesOutputFormat . XML )
489+ .setPropertiesOutputFormat (commitIdPropertiesOutputFormat )
487490 .build ();
488491 Properties properties = new Properties ();
489492
490493 // when
491494 GitCommitIdPlugin .runPlugin (cb , properties );
492495 // then
493496 assertThat (targetFilePath ).exists ();
494- Properties p = XmlManager . readXmlProperties ( targetFilePath , StandardCharsets . UTF_8 );
497+ Properties p = GenericFileManager . readPropertiesAsUtf8 ( commitIdPropertiesOutputFormat , targetFilePath );
495498 assertThat (p .size () > 10 );
496499 Assert .assertEquals (p , properties );
497500 }
@@ -501,6 +504,7 @@ public void shouldGenerateCustomPropertiesFileXml(boolean useNativeGit) throws E
501504 public void shouldGenerateCustomPropertiesFileYml (boolean useNativeGit ) throws Exception {
502505 // given
503506 File dotGitDirectory = createTmpDotGitDirectory (AvailableGitTestRepo .WITH_ONE_COMMIT_WITH_SPECIAL_CHARACTERS );
507+ CommitIdPropertiesOutputFormat commitIdPropertiesOutputFormat = CommitIdPropertiesOutputFormat .YML ;
504508
505509 File targetFilePath = sandbox .resolve ("custom-git.yml" ).toFile ();
506510 targetFilePath .delete ();
@@ -511,15 +515,15 @@ public void shouldGenerateCustomPropertiesFileYml(boolean useNativeGit) throws E
511515 .setUseNativeGit (useNativeGit )
512516 .setShouldGenerateGitPropertiesFile (true )
513517 .setGenerateGitPropertiesFilename (targetFilePath )
514- .setPropertiesOutputFormat (CommitIdPropertiesOutputFormat . YML )
518+ .setPropertiesOutputFormat (commitIdPropertiesOutputFormat )
515519 .build ();
516520 Properties properties = new Properties ();
517521
518522 // when
519523 GitCommitIdPlugin .runPlugin (cb , properties );
520524 // then
521525 assertThat (targetFilePath ).exists ();
522- Properties p = YmlManager . readYmlProperties ( targetFilePath , StandardCharsets . UTF_8 );
526+ Properties p = GenericFileManager . readPropertiesAsUtf8 ( commitIdPropertiesOutputFormat , targetFilePath );
523527 assertThat (p .size () > 10 );
524528 Assert .assertEquals (p , properties );
525529 }
0 commit comments