[maven-ejb-plugin] branch MEJB-129 created (now a2eefc2)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[maven-ejb-plugin] branch MEJB-129 created (now a2eefc2)

michaelo
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch MEJB-129
in repository https://gitbox.apache.org/repos/asf/maven-ejb-plugin.git.


      at a2eefc2  [MEJB-129] Refactor IncludesExcludes to reduce code duplication

This branch includes the following new commits:

     new a2eefc2  [MEJB-129] Refactor IncludesExcludes to reduce code duplication

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Reply | Threaded
Open this post in threaded view
|

[maven-ejb-plugin] 01/01: [MEJB-129] Refactor IncludesExcludes to reduce code duplication

michaelo
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch MEJB-129
in repository https://gitbox.apache.org/repos/asf/maven-ejb-plugin.git

commit a2eefc2914695cdcb3cb372bb0fa50f4d3a4840a
Author: Piotrek Żygieło <[hidden email]>
AuthorDate: Sun Apr 12 21:41:23 2020 +0200

    [MEJB-129] Refactor IncludesExcludes to reduce code duplication
   
    This closes #3
---
 .../apache/maven/plugins/ejb/IncludesExcludes.java | 24 ++++++++--------------
 .../maven/plugins/ejb/IncludesExcludesTest.java    | 17 +++++++++++++++
 2 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/ejb/IncludesExcludes.java b/src/main/java/org/apache/maven/plugins/ejb/IncludesExcludes.java
index 2b5e0a7..18e79e8 100644
--- a/src/main/java/org/apache/maven/plugins/ejb/IncludesExcludes.java
+++ b/src/main/java/org/apache/maven/plugins/ejb/IncludesExcludes.java
@@ -46,33 +46,27 @@ public class IncludesExcludes
 
     public String[] resultingIncludes()
     {
-        String[] result = new String[0];
-        if ( includes.isEmpty() )
-        {
-            result = defaultIncludes.toArray( new String[defaultIncludes.size()] );
-        }
-        else
-        {
-            result = includes.toArray( new String[includes.size()] );
-        }
-
-        return result;
+        return resultingXcludes( includes, defaultIncludes );
     }
 
     public String[] resultingExcludes()
     {
+        return resultingXcludes( excludes, defaultExcludes );
+    }
+
+    private static String[] resultingXcludes( List<String> currentXcludes, List<String> defaultXcludes )
+    {
         String[] result = new String[0];
-        if ( excludes.isEmpty() )
+        if ( currentXcludes.isEmpty() )
         {
-            result = defaultExcludes.toArray( new String[defaultExcludes.size()] );
+            result = defaultXcludes.toArray( new String[defaultXcludes.size()] );
         }
         else
         {
-            result = excludes.toArray( new String[excludes.size()] );
+            result = currentXcludes.toArray( new String[currentXcludes.size()] );
         }
 
         return result;
-
     }
 
     private List<String> makeNonNullList( List<String> in )
diff --git a/src/test/java/org/apache/maven/plugins/ejb/IncludesExcludesTest.java b/src/test/java/org/apache/maven/plugins/ejb/IncludesExcludesTest.java
index 430de25..5261d21 100644
--- a/src/test/java/org/apache/maven/plugins/ejb/IncludesExcludesTest.java
+++ b/src/test/java/org/apache/maven/plugins/ejb/IncludesExcludesTest.java
@@ -79,4 +79,21 @@ public class IncludesExcludesTest
         assertThat( ie.resultingExcludes() ).isEqualTo( new String[0] );
     }
 
+    @Test
+    public void nonNullIncludesShouldResultInTheSameIncludes()
+    {
+        IncludesExcludes ie = new IncludesExcludes( Arrays.asList( "**/package.html" ), null,
+                                                    Arrays.asList( "**/site.html" ), null );
+
+        assertThat( ie.resultingIncludes() ).isEqualTo( new String[] { "**/package.html" } );
+    }
+
+    @Test
+    public void nonNullExcludesShouldResultInTheSameExcludes()
+    {
+        IncludesExcludes ie = new IncludesExcludes( null, Arrays.asList( "**/package.html" ),
+                                                    null, Arrays.asList( "**/site.html" ) );
+
+        assertThat( ie.resultingExcludes() ).isEqualTo( new String[] { "**/package.html" } );
+    }
 }