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

michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git


The following commit(s) were added to refs/heads/master by this push:
     new 21cf41f  [MRESOLVER-109] AndDependencySelector should override toString
21cf41f is described below

commit 21cf41fb2a59b8c5ccf5b790071083978d4a7a0d
Author: Michael Boyles <michaelboy...@hotmail.co.uk>
AuthorDate: Sat Sep 12 14:39:41 2020 +0100

    [MRESOLVER-109] AndDependencySelector should override toString
    
    This closes #69
---
 .../util/graph/selector/AndDependencySelector.java | 18 ++++++++++
 .../selector/ExclusionDependencySelector.java      | 15 +++++++++
 .../graph/selector/OptionalDependencySelector.java |  6 ++++
 .../graph/selector/ScopeDependencySelector.java    |  8 +++++
 .../graph/selector/StaticDependencySelector.java   |  6 ++++
 .../graph/selector/AndDependencySelectorTest.java  | 15 +++++++++
 .../selector/ExclusionDependencySelectorTest.java  | 39 ++++++++++++++++++++++
 .../selector/OptionalDependencySelectorTest.java   | 36 ++++++++++++++++++++
 .../selector/ScopeDependencySelectorTest.java      | 38 +++++++++++++++++++++
 .../selector/StaticDependencySelectorTest.java     | 36 ++++++++++++++++++++
 10 files changed, 217 insertions(+)

diff --git 
a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/AndDependencySelector.java
 
b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/AndDependencySelector.java
index a99bb99..8b11c8a 100644
--- 
a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/AndDependencySelector.java
+++ 
b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/AndDependencySelector.java
@@ -22,6 +22,7 @@ package org.eclipse.aether.util.graph.selector;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.Set;
 
@@ -203,4 +204,21 @@ public final class AndDependencySelector
         return hashCode;
     }
 
+    @Override
+    public String toString()
+    {
+        StringBuilder builder = new StringBuilder().append( 
this.getClass().getSimpleName() ).append( '(' );
+        Iterator<? extends DependencySelector> iterator = 
this.selectors.iterator();
+        while ( iterator.hasNext() )
+        {
+            final DependencySelector selector = iterator.next();
+            builder.append( selector.toString() );
+            if ( iterator.hasNext() ) // not last
+            {
+                builder.append( " && " );
+            }
+        }
+        return builder.append( ')' ).toString();
+    }
+
 }
diff --git 
a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ExclusionDependencySelector.java
 
b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ExclusionDependencySelector.java
index 746313a..cd7def0 100644
--- 
a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ExclusionDependencySelector.java
+++ 
b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ExclusionDependencySelector.java
@@ -190,6 +190,21 @@ public final class ExclusionDependencySelector
         return hashCode;
     }
 
+    @Override
+    public String toString()
+    {
+        StringBuilder builder = new StringBuilder().append( 
this.getClass().getSimpleName() ).append( '(' );
+        for ( int i = 0; i < this.exclusions.length; i++ )
+        {
+            builder.append( this.exclusions[i] );
+            if ( i < this.exclusions.length - 1 )
+            {
+                builder.append( ", " );
+            }
+        }
+        return builder.append( ')' ).toString();
+    }
+
     private static class ExclusionComparator
         implements Comparator<Exclusion>
     {
diff --git 
a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/OptionalDependencySelector.java
 
b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/OptionalDependencySelector.java
index 69bbda4..145484c 100644
--- 
a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/OptionalDependencySelector.java
+++ 
b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/OptionalDependencySelector.java
@@ -86,4 +86,10 @@ public final class OptionalDependencySelector
         return hash;
     }
 
+    @Override
+    public String toString()
+    {
+        return String.format( "%s(depth: %d)", 
this.getClass().getSimpleName(), this.depth );
+    }
+
 }
diff --git 
a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ScopeDependencySelector.java
 
b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ScopeDependencySelector.java
index 127fdf3..75a8fd6 100644
--- 
a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ScopeDependencySelector.java
+++ 
b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ScopeDependencySelector.java
@@ -146,4 +146,12 @@ public final class ScopeDependencySelector
         return hash;
     }
 
+    @Override
+    public String toString()
+    {
+        return String.format(
+            "%s(included: %s, excluded: %s, transitive: %s)", 
getClass().getSimpleName(), included, excluded, transitive
+        );
+    }
+
 }
diff --git 
a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/StaticDependencySelector.java
 
b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/StaticDependencySelector.java
index 41ce0e0..e3acc35 100644
--- 
a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/StaticDependencySelector.java
+++ 
b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/StaticDependencySelector.java
@@ -76,4 +76,10 @@ public final class StaticDependencySelector
         return hash;
     }
 
+    @Override
+    public String toString()
+    {
+        return String.format( "%s(%s)", this.getClass().getSimpleName(), 
this.select ? "Select all" : "Exclude all" );
+    }
+
 }
diff --git 
a/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/AndDependencySelectorTest.java
 
b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/AndDependencySelectorTest.java
index b0f2b09..3a6bb1b 100644
--- 
a/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/AndDependencySelectorTest.java
+++ 
b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/AndDependencySelectorTest.java
@@ -65,6 +65,11 @@ public class AndDependencySelectorTest
             return child;
         }
 
+        @Override
+        public String toString()
+        {
+            return "Dummy(" + select + ')';
+        }
     }
 
     @Test
@@ -150,4 +155,14 @@ public class AndDependencySelectorTest
         assertEquals( selector1.hashCode(), selector2.hashCode() );
     }
 
+    @Test
+    public void testToString()
+    {
+        DependencySelector andSelector = new AndDependencySelector(
+            new DummyDependencySelector( true ),
+            new DummyDependencySelector( false )
+        );
+        assertEquals("AndDependencySelector(Dummy(true) && Dummy(false))", 
andSelector.toString());
+    }
+
 }
diff --git 
a/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/ExclusionDependencySelectorTest.java
 
b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/ExclusionDependencySelectorTest.java
new file mode 100644
index 0000000..67081ba
--- /dev/null
+++ 
b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/ExclusionDependencySelectorTest.java
@@ -0,0 +1,39 @@
+package org.eclipse.aether.util.graph.selector;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.junit.Assert.*;
+
+import org.eclipse.aether.graph.Exclusion;
+import org.junit.Test;
+
+import java.util.Collections;
+
+public class ExclusionDependencySelectorTest
+{
+    @Test
+    public void testToString()
+    {
+        assertEquals(
+            "ExclusionDependencySelector(a:b:d:c)",
+            new ExclusionDependencySelector( Collections.singletonList( new 
Exclusion("a", "b", "c", "d") ) ).toString()
+        );
+    }
+}
diff --git 
a/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/OptionalDependencySelectorTest.java
 
b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/OptionalDependencySelectorTest.java
new file mode 100644
index 0000000..b2c3708
--- /dev/null
+++ 
b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/OptionalDependencySelectorTest.java
@@ -0,0 +1,36 @@
+package org.eclipse.aether.util.graph.selector;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class OptionalDependencySelectorTest
+{
+    @Test
+    public void testToString()
+    {
+        assertEquals(
+            "OptionalDependencySelector(depth: 0)",
+            new OptionalDependencySelector().toString()
+        );
+    }
+}
\ No newline at end of file
diff --git 
a/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/ScopeDependencySelectorTest.java
 
b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/ScopeDependencySelectorTest.java
new file mode 100644
index 0000000..7d84258
--- /dev/null
+++ 
b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/ScopeDependencySelectorTest.java
@@ -0,0 +1,38 @@
+package org.eclipse.aether.util.graph.selector;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import java.util.Collections;
+
+public class ScopeDependencySelectorTest
+{
+    @Test
+    public void testToString()
+    {
+        assertEquals(
+            "ScopeDependencySelector(included: [foo], excluded: [bar], 
transitive: false)",
+            new ScopeDependencySelector(Collections.singleton( "foo" ), 
Collections.singleton( "bar" ) ).toString()
+        );
+    }
+}
\ No newline at end of file
diff --git 
a/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/StaticDependencySelectorTest.java
 
b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/StaticDependencySelectorTest.java
new file mode 100644
index 0000000..79ccce6
--- /dev/null
+++ 
b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/selector/StaticDependencySelectorTest.java
@@ -0,0 +1,36 @@
+package org.eclipse.aether.util.graph.selector;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class StaticDependencySelectorTest
+{
+    @Test
+    public void testToString()
+    {
+        assertEquals(
+            "StaticDependencySelector(Select all)",
+            new StaticDependencySelector( true ).toString()
+        );
+    }
+}
\ No newline at end of file

Reply via email to