@@ -300,8 +300,7 @@ public void shouldGenerateDescribeWithTagOnlyWhenForceLongFormatIsFalse(boolean
300300 mojo .execute ();
301301
302302 // then
303- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.commit.id.describe" );
304- assertThat (targetProject .getProperties ().getProperty ("git.commit.id.describe" )).isEqualTo ("v1.0.0-dirty" );
303+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.commit.id.describe" , "v1.0.0-dirty" );
305304 }
306305
307306 @ Test
@@ -324,13 +323,9 @@ public void shouldGenerateDescribeWithTagOnlyWhenForceLongFormatIsFalseAndAbbrev
324323 mojo .execute ();
325324
326325 // then
327- Set < String > propNames = targetProject .getProperties (). stringPropertyNames ( );
326+ assertPropertyPresentAndEqual ( targetProject .getProperties (), "git.commit.id.describe" , "v1.0.0" );
328327
329- assertThat (propNames ).contains ("git.commit.id.describe" );
330- assertThat (targetProject .getProperties ().getProperty ("git.commit.id.describe" )).isEqualTo ("v1.0.0" );
331-
332- assertThat (propNames ).contains ("git.commit.id.describe-short" );
333- assertThat (targetProject .getProperties ().getProperty ("git.commit.id.describe-short" )).isEqualTo ("v1.0.0" );
328+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.commit.id.describe-short" , "v1.0.0" );
334329 }
335330
336331 @ Test
@@ -353,8 +348,7 @@ public void shouldGenerateDescribeWithTagAndZeroAndCommitIdWhenForceLongFormatIs
353348 mojo .execute ();
354349
355350 // then
356- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.commit.id.describe" );
357- assertThat (targetProject .getProperties ().getProperty ("git.commit.id.describe" )).isEqualTo ("v1.0.0-0-gde4db35" );
351+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.commit.id.describe" , "v1.0.0-0-gde4db35" );
358352 }
359353
360354 @ Test
@@ -377,13 +371,9 @@ public void shouldGenerateDescribeWithTagAndZeroAndCommitIdWhenForceLongFormatIs
377371 mojo .execute ();
378372
379373 // then
380- Set <String > propNames = targetProject .getProperties ().stringPropertyNames ();
381-
382- assertThat (propNames ).contains ("git.commit.id.describe" );
383- assertThat (targetProject .getProperties ().getProperty ("git.commit.id.describe" )).isEqualTo ("v1.0.0-0-gde4db35917" );
374+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.commit.id.describe" , "v1.0.0-0-gde4db35917" );
384375
385- assertThat (propNames ).contains ("git.commit.id.describe-short" );
386- assertThat (targetProject .getProperties ().getProperty ("git.commit.id.describe-short" )).isEqualTo ("v1.0.0-0" );
376+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.commit.id.describe-short" , "v1.0.0-0" );
387377 }
388378
389379 @ Test
@@ -405,8 +395,7 @@ public void shouldGenerateCommitIdAbbrevWithDefaultLength(boolean useNativeGit)
405395 mojo .execute ();
406396
407397 // then
408- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.commit.id.abbrev" );
409- assertThat (targetProject .getProperties ().getProperty ("git.commit.id.abbrev" )).isEqualTo ("de4db35" );
398+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.commit.id.abbrev" , "de4db35" );
410399 }
411400
412401 @ Test
@@ -527,8 +516,7 @@ public void shouldAlwaysPrintGitDescribe(boolean useNativeGit) throws Exception
527516 mojo .execute ();
528517
529518 // then
530- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.commit.id.describe" );
531- assertThat (targetProject .getProperties ().getProperty ("git.commit.id.describe" )).isEqualTo ("0b0181b" );
519+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.commit.id.describe" , "0b0181b" );
532520 }
533521
534522 @ Test
@@ -674,11 +662,9 @@ public void shouldGenerateClosestTagInformationWhenOnATag(boolean useNativeGit)
674662 mojo .execute ();
675663
676664 // then
677- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.closest.tag.name" );
678- assertThat (targetProject .getProperties ().getProperty ("git.closest.tag.name" )).isEqualTo ("v1.0.0" );
665+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.closest.tag.name" , "v1.0.0" );
679666
680- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.closest.tag.commit.count" );
681- assertThat (targetProject .getProperties ().getProperty ("git.closest.tag.commit.count" )).isEqualTo ("0" );
667+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.closest.tag.commit.count" , "0" );
682668 }
683669
684670 @ Test
@@ -703,11 +689,9 @@ public void shouldGenerateClosestTagInformationWhenOnATagAndDirty(boolean useNat
703689 mojo .execute ();
704690
705691 // then
706- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.closest.tag.name" );
707- assertThat (targetProject .getProperties ().getProperty ("git.closest.tag.name" )).isEqualTo ("v1.0.0" );
692+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.closest.tag.name" , "v1.0.0" );
708693
709- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.closest.tag.commit.count" );
710- assertThat (targetProject .getProperties ().getProperty ("git.closest.tag.commit.count" )).isEqualTo ("0" );
694+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.closest.tag.commit.count" , "0" );
711695 }
712696
713697
@@ -736,11 +720,9 @@ public void shouldGenerateClosestTagInformationWhenCommitHasTwoTags(boolean useN
736720
737721 // then
738722 // AvailableGitTestRepo.WITH_COMMIT_THAT_HAS_TWO_TAGS ==> Where the newest-tag was created latest
739- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.closest.tag.name" );
740- assertThat (targetProject .getProperties ().getProperty ("git.closest.tag.name" )).isEqualTo ("newest-tag" );
723+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.closest.tag.name" , "newest-tag" );
741724
742- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.closest.tag.commit.count" );
743- assertThat (targetProject .getProperties ().getProperty ("git.closest.tag.commit.count" )).isEqualTo ("0" );
725+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.closest.tag.commit.count" , "0" );
744726 }
745727
746728 @ Test
@@ -777,11 +759,9 @@ public void shouldUseDateFormatTimeZone(boolean useNativeGit) throws Exception {
777759
778760 // then
779761 Properties properties = targetProject .getProperties ();
780- assertThat (properties .stringPropertyNames ()).contains ("git.commit.time" );
781- assertThat (properties .getProperty ("git.commit.time" )).isEqualTo (expectedTimeZoneOffset );
762+ assertPropertyPresentAndEqual (properties , "git.commit.time" , expectedTimeZoneOffset );
782763
783- assertThat (properties .stringPropertyNames ()).contains ("git.build.time" );
784- assertThat (properties .getProperty ("git.build.time" )).isEqualTo (expectedTimeZoneOffset );
764+ assertPropertyPresentAndEqual (properties , "git.build.time" , expectedTimeZoneOffset );
785765
786766 // set the timezone back
787767 TimeZone .setDefault (currentDefaultTimeZone );
@@ -893,17 +873,13 @@ public void shouldGenerateClosestTagInformationWithExcludeLightweightTagsForClos
893873 mojo .execute ();
894874
895875 // then
896- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.commit.id.abbrev" );
897- assertThat (targetProject .getProperties ().getProperty ("git.commit.id.abbrev" )).isEqualTo ("b6a73ed" );
876+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.commit.id.abbrev" , "b6a73ed" );
898877
899- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.commit.id.describe" );
900- assertThat (targetProject .getProperties ().getProperty ("git.commit.id.describe" )).isEqualTo ("annotated-tag-2-gb6a73ed74-customDirtyMark" );
878+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.commit.id.describe" , "annotated-tag-2-gb6a73ed74-customDirtyMark" );
901879
902- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.closest.tag.name" );
903- assertThat (targetProject .getProperties ().getProperty ("git.closest.tag.name" )).isEqualTo ("annotated-tag" );
880+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.closest.tag.name" , "annotated-tag" );
904881
905- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.closest.tag.commit.count" );
906- assertThat (targetProject .getProperties ().getProperty ("git.closest.tag.commit.count" )).isEqualTo ("2" );
882+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.closest.tag.commit.count" , "2" );
907883 }
908884
909885 @ Test
@@ -930,17 +906,13 @@ public void shouldGenerateClosestTagInformationWithIncludeLightweightTagsForClos
930906 mojo .execute ();
931907
932908 // then
933- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.commit.id.abbrev" );
934- assertThat (targetProject .getProperties ().getProperty ("git.commit.id.abbrev" )).isEqualTo ("b6a73ed" );
909+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.commit.id.abbrev" , "b6a73ed" );
935910
936- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.commit.id.describe" );
937- assertThat (targetProject .getProperties ().getProperty ("git.commit.id.describe" )).isEqualTo ("lightweight-tag-1-gb6a73ed74-customDirtyMark" );
911+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.commit.id.describe" , "lightweight-tag-1-gb6a73ed74-customDirtyMark" );
938912
939- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.closest.tag.name" );
940- assertThat (targetProject .getProperties ().getProperty ("git.closest.tag.name" )).isEqualTo ("lightweight-tag" );
913+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.closest.tag.name" , "lightweight-tag" );
941914
942- assertThat (targetProject .getProperties ().stringPropertyNames ()).contains ("git.closest.tag.commit.count" );
943- assertThat (targetProject .getProperties ().getProperty ("git.closest.tag.commit.count" )).isEqualTo ("1" );
915+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.closest.tag.commit.count" , "1" );
944916 }
945917
946918 private GitDescribeConfig createGitDescribeConfig (boolean forceLongFormat , int abbrev ) {
@@ -956,6 +928,11 @@ private void alterMojoSettings(String parameterName, Object parameterValue) {
956928 setInternalState (mojo , parameterName , parameterValue );
957929 }
958930
931+ private void assertPropertyPresentAndEqual (Properties properties , String key , String expected ) {
932+ assertThat (properties .stringPropertyNames ()).contains (key );
933+ assertThat (properties .getProperty (key )).isEqualTo (expected );
934+ }
935+
959936 private void assertGitPropertiesPresentInProject (Properties properties ) {
960937 assertThat (properties ).satisfies (new ContainsKeyCondition ("git.build.time" ));
961938 assertThat (properties ).satisfies (new ContainsKeyCondition ("git.build.host" ));
0 commit comments