Skip to content

Commit

Permalink
[MENFORCER-430] Allow one of many files in RequiresFiles rules to pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
raupachz authored and slawekjaranowski committed Sep 11, 2022
1 parent da61e44 commit a06b47b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 31 deletions.
2 changes: 2 additions & 0 deletions enforcer-rules/src/site/apt/requireFilesDontExist.apt.vm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Require Files Don't Exist
* files - A list of files to check.

* allowNulls - If null files should be allowed. If allowed, they will be treated as if they do not exist. Default is false.

* satisfyAny - Allows that one of files can make the rule pass, instead of all the files. Default is false.

[]

Expand Down
2 changes: 2 additions & 0 deletions enforcer-rules/src/site/apt/requireFilesExist.apt.vm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Require Files Exist
* files - A list of files to check.

* allowNulls - If null files should be allowed. If allowed, they will be treated as if they do exist. Default is false.

* satisfyAny - Allows that one of files can make the rule pass, instead of all the files. Default is false.

[]

Expand Down
2 changes: 2 additions & 0 deletions enforcer-rules/src/site/apt/requireFilesSize.apt.vm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Require File Size
* minsize - minimum size in bytes for this file.

* allowNulls - If null files should be allowed. If allowed, they will be treated as if they do exist. Default is false.

* satisfyAny - Allows that one of files can make the rule pass, instead of all the files. Default is false.

[]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void testFileDoesNotExist()

@Test
public void testFileDoesNotExistSatisfyAny()
throws IOException
throws EnforcerRuleException, IOException
{
File f = File.createTempFile( "junit", null, temporaryFolder );
f.delete();
Expand All @@ -152,16 +152,7 @@ public void testFileDoesNotExistSatisfyAny()
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();
rule.execute( EnforcerTestUtils.getHelper() );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void testFileDoesNotExist()

@Test
public void testFileExistsSatisfyAny()
throws IOException
throws EnforcerRuleException, IOException
{
File f = File.createTempFile( "junit", null, temporaryFolder );
f.delete();
Expand All @@ -138,16 +138,7 @@ public void testFileExistsSatisfyAny()
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();
rule.execute( EnforcerTestUtils.getHelper() );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void testFileTooBig()

@Test
public void testRequireFilesSizeSatisfyAny()
throws IOException
throws EnforcerRuleException, IOException
{
File f = File.createTempFile( "junit", null, temporaryFolder );
try ( BufferedWriter out = new BufferedWriter( new FileWriter( f ) ) )
Expand All @@ -182,14 +182,7 @@ public void testRequireFilesSizeSatisfyAny()
rule.setMaxsize( 10 );
rule.setSatisfyAny(true);

try
{
rule.execute( EnforcerTestUtils.getHelper() );
}
catch ( EnforcerRuleException e )
{
fail( "Unexpected Exception:" + e.getLocalizedMessage() );
}
rule.execute( EnforcerTestUtils.getHelper() );
}

/**
Expand Down

0 comments on commit a06b47b

Please sign in to comment.