slawekjaranowski commented on code in PR #183: URL: https://github.com/apache/maven-enforcer/pull/183#discussion_r963331915
########## enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireFilesDontExist.java: ########## @@ -136,6 +136,34 @@ public void testFileDoesNotExist() rule.execute( EnforcerTestUtils.getHelper() ); } + @Test + public void testFileDoesNotExistSatisfyAny() + throws IOException + { + File f = File.createTempFile( "junit", null, temporaryFolder ); + f.delete(); Review Comment: Instead of creating and deleting file we can simply create File object with a wrong path ########## enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireFilesDontExist.java: ########## @@ -136,6 +136,34 @@ public void testFileDoesNotExist() rule.execute( EnforcerTestUtils.getHelper() ); } + @Test + public void testFileDoesNotExistSatisfyAny() + throws IOException + { + File f = File.createTempFile( "junit", null, temporaryFolder ); + f.delete(); + + assertFalse( f.exists() ); + + File g = File.createTempFile( "junit", null, temporaryFolder ); + + assertTrue( g.exists() ); + + rule.setFiles( new File[] { f, g.getCanonicalFile() } ); + rule.setSatisfyAny(true); + + try + { + rule.execute( EnforcerTestUtils.getHelper() ); + } + catch ( EnforcerRuleException e ) + { + fail( "Unexpected Exception:" + e.getLocalizedMessage() ); + } Review Comment: We can simply add this exception to test method signature ########## enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireFilesDontExist.java: ########## @@ -136,6 +136,34 @@ public void testFileDoesNotExist() rule.execute( EnforcerTestUtils.getHelper() ); } + @Test + public void testFileDoesNotExistSatisfyAny() + throws IOException + { + File f = File.createTempFile( "junit", null, temporaryFolder ); + f.delete(); + + assertFalse( f.exists() ); + + File g = File.createTempFile( "junit", null, temporaryFolder ); + + assertTrue( g.exists() ); + + rule.setFiles( new File[] { f, g.getCanonicalFile() } ); + rule.setSatisfyAny(true); + + try + { + rule.execute( EnforcerTestUtils.getHelper() ); + } + catch ( EnforcerRuleException e ) + { + fail( "Unexpected Exception:" + e.getLocalizedMessage() ); + } + + g.delete(); Review Comment: File was created in `@TempDir` so I hope that `junit` will remove it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org