@@ -23,26 +23,22 @@ final class POMOperatorDependencyQueryTest {
2323 @ Test
2424 void testBasicQuery ()
2525 throws DocumentException , IOException , URISyntaxException , XMLStreamException {
26- for (QueryType queryType : QueryType .values ()) {
27- if (queryType != QueryType .NONE ) {
28- ProjectModelFactory context = ProjectModelFactory .load (getClass ().getResource ("pom-1.xml" ));
29- context .withQueryType (queryType );
26+ ProjectModelFactory context = ProjectModelFactory .load (getClass ().getResource ("pom-1.xml" ));
27+ context .withSafeQueryType ();
3028
31- Collection <Dependency > dependencies = POMOperator .queryDependency (context .build ());
29+ Collection <Dependency > dependencies = POMOperator .queryDependency (context .build ());
3230
33- LOGGER .debug ("Dependencies found: {}" , dependencies );
31+ LOGGER .debug ("Dependencies found: {}" , dependencies );
3432
35- assertTrue ("Dependencies are not empty" , dependencies != null && !dependencies .isEmpty ());
36- }
37- }
33+ assertTrue ("Dependencies are not empty" , dependencies != null && !dependencies .isEmpty ());
3834 }
3935
4036 @ Test
4137 void testFailedSafeQuery ()
4238 throws DocumentException , IOException , URISyntaxException , XMLStreamException {
4339 ProjectModelFactory context =
4440 ProjectModelFactory .load (getClass ().getResource ("pom-broken.xml" ));
45- context .withQueryType ( QueryType . SAFE );
41+ context .withSafeQueryType ( );
4642
4743 Collection <Dependency > dependencies = POMOperator .queryDependency (context .build ());
4844
@@ -66,7 +62,7 @@ void testAllQueryTypes()
6662 }
6763
6864 ProjectModelFactory context = ProjectModelFactory .load (getClass ().getResource (pomFile ));
69- context .withQueryType ( QueryType . SAFE );
65+ context .withSafeQueryType ( );
7066
7167 Collection <Dependency > dependencies =
7268 POMOperator .queryDependency (context .build (), commandListOverride );
@@ -79,54 +75,46 @@ void testAllQueryTypes()
7975 @ Test
8076 void testTemporaryDirectory ()
8177 throws IOException , DocumentException , URISyntaxException , XMLStreamException {
82- for (QueryType queryType : QueryType .values ()) {
83- if (queryType != QueryType .NONE ) {
84- File tempDirectory = new File ("/tmp/mvn-repo-" + System .currentTimeMillis () + ".dir" );
8578
86- LOGGER . info ( "Using queryType: " + queryType + " at " + tempDirectory );
79+ File tempDirectory = new File ( "/tmp/mvn-repo- " + System . currentTimeMillis () + ".dir" );
8780
88- assertFalse ("Temp Directory does not exist initially" , tempDirectory .exists ());
89- assertEquals (
90- "There must be no files" ,
91- tempDirectory .list () != null
92- ? (int ) Files .list (tempDirectory .toPath ()).filter (Files ::isDirectory ).count ()
93- : 0 ,
94- 0 );
81+ assertFalse ("Temp Directory does not exist initially" , tempDirectory .exists ());
82+ assertEquals (
83+ "There must be no files" ,
84+ tempDirectory .list () != null
85+ ? (int ) Files .list (tempDirectory .toPath ()).filter (Files ::isDirectory ).count ()
86+ : 0 ,
87+ 0 );
9588
96- ProjectModelFactory context = ProjectModelFactory .load (getClass ().getResource ("pom-1.xml" ));
97- context .withQueryType ( queryType );
98- context .withRepositoryPath (tempDirectory );
89+ ProjectModelFactory context = ProjectModelFactory .load (getClass ().getResource ("pom-1.xml" ));
90+ context .withSafeQueryType ( );
91+ context .withRepositoryPath (tempDirectory );
9992
100- Collection <Dependency > dependencies = POMOperator .queryDependency (context .build ());
93+ Collection <Dependency > dependencies = POMOperator .queryDependency (context .build ());
10194
102- LOGGER .debug ("Dependencies found: " + dependencies );
95+ LOGGER .debug ("Dependencies found: " + dependencies );
10396
104- assertTrue ("Dependencies are not empty" , dependencies != null && !dependencies .isEmpty ());
97+ assertTrue ("Dependencies are not empty" , dependencies != null && !dependencies .isEmpty ());
10598
106- assertTrue ("Temp Directory ends up existing" , tempDirectory .exists ());
107- assertTrue ("Temp Directory is a directory" , tempDirectory .isDirectory ());
108- }
109- }
99+ assertTrue ("Temp Directory ends up existing" , tempDirectory .exists ());
100+ assertTrue ("Temp Directory is a directory" , tempDirectory .isDirectory ());
110101 }
111102
112103 @ Test
113104 void testTemporaryDirectoryAndFullyOffline ()
114105 throws IOException , DocumentException , URISyntaxException , XMLStreamException {
115- for (QueryType queryType : QueryType .values ()) {
116- if (queryType != QueryType .NONE && queryType == QueryType .SAFE ) {
117- File tempDirectory = Files .createTempDirectory ("mvn-repo" ).toFile ();
118106
119- ProjectModelFactory context = ProjectModelFactory .load (getClass ().getResource ("pom-1.xml" ));
120- context .withQueryType (queryType );
121- context .withRepositoryPath (tempDirectory );
107+ File tempDirectory = Files .createTempDirectory ("mvn-repo" ).toFile ();
122108
123- Collection <Dependency > dependencies = POMOperator .queryDependency (context .build ());
109+ ProjectModelFactory context = ProjectModelFactory .load (getClass ().getResource ("pom-1.xml" ));
110+ context .withSafeQueryType ();
111+ context .withRepositoryPath (tempDirectory );
124112
125- LOGGER . debug ( "Dependencies found: " + dependencies );
113+ Collection < Dependency > dependencies = POMOperator . queryDependency ( context . build () );
126114
127- assertTrue ("Dependencies are not empty" , ! dependencies . isEmpty () );
128- }
129- }
115+ LOGGER . debug ("Dependencies found: " + dependencies );
116+
117+ assertTrue ( "Dependencies are not empty" , ! dependencies . isEmpty ());
130118 }
131119
132120 @ Test
@@ -163,7 +151,7 @@ void testOnSyntheticDependency() throws Exception {
163151 .getBytes ());
164152
165153 ProjectModelFactory context = ProjectModelFactory .load (tempPom .toFile ());
166- context .withQueryType ( QueryType . SAFE );
154+ context .withSafeQueryType ( );
167155 context .withRepositoryPath (tempDirectory );
168156
169157 Collection <Dependency > dependencies = POMOperator .queryDependency (context .build ());
@@ -251,7 +239,7 @@ void testOnCompositeSyntheticDependency() throws Exception {
251239 Files .write (tempPom , pomContent .getBytes ());
252240
253241 ProjectModelFactory context = ProjectModelFactory .load (tempPom .toFile ());
254- context .withQueryType ( QueryType . SAFE );
242+ context .withSafeQueryType ( );
255243 context .withRepositoryPath (tempDirectory );
256244
257245 Collection <Dependency > dependencies = POMOperator .queryDependency (context .build ());
@@ -319,7 +307,7 @@ void testOnCompositeSyntheticDependencyIncompleteButWithParser() throws Exceptio
319307 Files .write (tempPom , pomContent .getBytes ());
320308
321309 ProjectModelFactory context = ProjectModelFactory .load (tempPom .toFile ());
322- context .withQueryType ( QueryType . SAFE );
310+ context .withSafeQueryType ( );
323311 context .withRepositoryPath (tempDirectory );
324312
325313 List <Command > commandList = getCommandListFor ("QueryByParsing" );
@@ -365,7 +353,7 @@ void testOfflineQueryResolution() throws Exception {
365353 File pomFile = new File (getClass ().getResource ("nested/child/pom/pom-3-child.xml" ).getFile ());
366354
367355 ProjectModelFactory context = ProjectModelFactory .load (pomFile );
368- context .withQueryType ( QueryType . SAFE );
356+ context .withSafeQueryType ( );
369357 context .withRepositoryPath (tempDirectory );
370358
371359 Collection <Dependency > dependencies = POMOperator .queryDependency (context .build ());
0 commit comments