[java-identity-provider] 30/51: Add hascode and equals tests

Rod Widdowson rdw at steadingsoftware.com
Wed Feb 6 08:43:01 EST 2019


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch master
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=015bc595fed65598832d4a4b41f6e3757724637b

commit 015bc595fed65598832d4a4b41f6e3757724637b
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Jan 22 16:58:09 2019 +0000

    Add hascode and equals tests
---
 .../resolver/PluginDependencySupportTest.java      | 63 ++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/PluginDependencySupportTest.java b/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/PluginDependencySupportTest.java
index 626465e..7d1999e 100644
--- a/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/PluginDependencySupportTest.java
+++ b/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/PluginDependencySupportTest.java
@@ -298,4 +298,67 @@ public class PluginDependencySupportTest {
         Assert.assertTrue(values.contains(new StringAttributeValue(ResolverTestSupport.EPA1_VALUES[1])));
         Assert.assertTrue(values.contains(new StringAttributeValue(ResolverTestSupport.EPA2_VALUES[1])));
     }
+    
+    @Test public void hashesAttributeDependency() {
+        final ResolverAttributeDefinitionDependency ad1 = new ResolverAttributeDefinitionDependency("ra1");
+        final ResolverAttributeDefinitionDependency ad2 = new ResolverAttributeDefinitionDependency("ra1");
+        final ResolverAttributeDefinitionDependency ad3 = new ResolverAttributeDefinitionDependency("ra3");
+        
+        Assert.assertEquals(ad1, ad2);
+        Assert.assertNotEquals(ad2, ad3);
+        Assert.assertEquals(ad1.hashCode(), ad2.hashCode());
+        Assert.assertNotEquals(ad2.hashCode(), ad3.hashCode());
+        
+        ad1.setDependencyAttributeId("ra1");
+        ad2.setDependencyAttributeId("bar");
+        Assert.assertNotEquals(ad1, ad2);
+        Assert.assertNotEquals(ad2, ad3);
+        Assert.assertNotEquals(ad1.hashCode(), ad2.hashCode());
+        Assert.assertNotEquals(ad2.hashCode(), ad3.hashCode());
+       
+        ad1.setDependencyAttributeId("bar");
+        Assert.assertEquals(ad1, ad2);
+        Assert.assertNotEquals(ad2, ad3);
+        Assert.assertEquals(ad1.hashCode(), ad2.hashCode());
+        Assert.assertNotEquals(ad2.hashCode(), ad3.hashCode());
+    }
+
+    @Test public void hashesDataConnectorDependency() {
+
+        final ResolverDataConnectorDependency dc1 = new ResolverDataConnectorDependency("dc1");
+        final ResolverDataConnectorDependency dc2 = new ResolverDataConnectorDependency("dc1");
+        final ResolverDataConnectorDependency dc3 = new ResolverDataConnectorDependency("dc3");
+
+        Assert.assertEquals(dc1, dc2);
+        Assert.assertNotEquals(dc2, dc3);
+        Assert.assertEquals(dc1.hashCode(), dc2.hashCode());
+        Assert.assertNotEquals(dc2.hashCode(), dc3.hashCode());
+        
+        dc1.setAttributeNames(Arrays.asList("a", "b"));
+        dc2.setAttributeNames(Arrays.asList("b", "a"));
+
+        Assert.assertEquals(dc1, dc2);
+        Assert.assertNotEquals(dc2, dc3);
+        Assert.assertEquals(dc1.hashCode(), dc2.hashCode());
+        Assert.assertNotEquals(dc2.hashCode(), dc3.hashCode());
+        
+        dc2.setAllAttributes(true);
+        Assert.assertNotEquals(dc1, dc2);
+        Assert.assertNotEquals(dc2, dc3);
+        Assert.assertNotEquals(dc1.hashCode(), dc2.hashCode());
+        Assert.assertNotEquals(dc2.hashCode(), dc3.hashCode());
+
+        dc1.setAllAttributes(true);
+        Assert.assertEquals(dc1, dc2);
+        Assert.assertNotEquals(dc2, dc3);
+        Assert.assertEquals(dc1.hashCode(), dc2.hashCode());
+        Assert.assertNotEquals(dc2.hashCode(), dc3.hashCode());
+
+        dc2.setAttributeNames(Arrays.asList("b", "a", "d"));
+        Assert.assertNotEquals(dc1, dc2);
+        Assert.assertNotEquals(dc2, dc3);
+        Assert.assertNotEquals(dc1.hashCode(), dc2.hashCode());
+        Assert.assertNotEquals(dc2.hashCode(), dc3.hashCode());
+        
+}
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list