2121package net .sf .eclipsecs .checkstyle ;
2222
2323import static java .nio .charset .StandardCharsets .UTF_8 ;
24- import static org .junit .jupiter .api .Assertions .assertEquals ;
25- import static org .junit .jupiter .api .Assertions .assertTrue ;
24+ import static org .assertj .core .api .Assertions .assertThat ;
2625
2726import java .io .File ;
2827import java .io .FileInputStream ;
@@ -56,13 +55,13 @@ public void testMetadataFiles() throws Exception {
5655
5756 final Set <String > packages = CheckUtil .getPackages (modules );
5857
59- assertTrue (modules . size () > 0 , "no modules" );
58+ assertThat (modules ). as ( " modules"). isNotEmpty ( );
6059
6160 for (String p : packages ) {
62- assertTrue (new File (getEclipseCsPath (p , "" )).exists (), "folder " + p + " must exist in eclipsecs" );
61+ assertThat (new File (getEclipseCsPath (p , "" ))) .exists ();
6362
6463 final Set <Class <?>> packgeModules = CheckUtil .getModulesInPackage (modules , p );
65- assertTrue (packgeModules . size () > 0 , "package must have modules" );
64+ assertThat (packgeModules ). as ( "package modules" ). isNotEmpty ( );
6665
6766 validateEclipseCsMetaXmlFile (new File (getEclipseCsPath (p , "/checkstyle-metadata.xml" )), p );
6867
@@ -72,36 +71,48 @@ public void testMetadataFiles() throws Exception {
7271 }
7372
7473 private static void validateEclipseCsMetaXmlFile (File file , String packge ) throws Exception {
75- assertTrue (file .exists (), "'checkstyle-metadata.xml' must exist in eclipsecs inside " + packge );
74+ assertThat (file )
75+ .withFailMessage (
76+ () -> "'checkstyle-metadata.xml' must exist in eclipsecs inside " + packge )
77+ .exists ();
7678
7779 final String input = new String (Files .readAllBytes (file .toPath ()), UTF_8 );
7880 final Document document = XmlUtil .getRawXml (file .getAbsolutePath (), input , input );
7981
8082 final NodeList ruleGroups = document .getElementsByTagName ("rule-group-metadata" );
8183
82- assertEquals (1 , ruleGroups .getLength (), packge + " checkstyle-metadata.xml must contain only one rule group" );
84+ assertThat (ruleGroups .getLength ())
85+ .withFailMessage (
86+ () -> packge + " checkstyle-metadata.xml must contain only one rule group" )
87+ .isEqualTo (1 );
8388
8489 for (int position = 0 ; position < ruleGroups .getLength (); position ++) {
8590 final Node ruleGroup = ruleGroups .item (position );
8691 final Set <Node > children = XmlUtil .getChildrenElements (ruleGroup );
8792
88- assertEquals (0 , children .size (), packge + " checkstyle-metadata.xml must contain no rules" );
93+ assertThat (children )
94+ .withFailMessage (() -> packge + " checkstyle-metadata.xml must contain no rules" )
95+ .isEmpty ();
8996 }
9097 }
9198
9299 private static void validateEclipseCsMetaPropFile (File file , String packge ) throws Exception {
93- assertTrue (file .exists (), "'checkstyle-metadata.properties' must exist in eclipsecs inside " + packge );
100+ assertThat (file ).withFailMessage (
101+ () -> "'checkstyle-metadata.properties' must exist in eclipsecs inside " + packge )
102+ .exists ();
94103
95104 final Properties prop = new Properties ();
96105 prop .load (new FileInputStream (file ));
97106
98107 final Set <Object > properties = new HashSet <>(Collections .list (prop .keys ()));
99108
100- assertEquals (1 , properties .size (),
101- packge + " checkstyle-metadata.properties must contain only the rule group name" );
109+ assertThat (properties ).withFailMessage (
110+ () -> packge + " checkstyle-metadata.properties must contain only the rule group name" )
111+ .hasSize (1 );
102112
103- assertTrue (properties .iterator ().next ().toString ().endsWith (".group" ),
104- packge + " checkstyle-metadata.properties must contain only the rule group name" );
113+ assertThat (properties .iterator ().next ().toString ()).withFailMessage (
114+ () -> packge + " checkstyle-metadata.properties must contain only the rule group name" )
115+ .endsWith (".group" );
105116 }
106117
107118 private static String getEclipseCsPath (String packageName , String fileName ) throws IOException {
0 commit comments