[java-shib-profile] branch main updated: Replace Collections/Arrays methods where possible.

Scott Cantor cantor.2 at osu.edu
Thu Apr 20 18:09:43 UTC 2023


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

scantor pushed a commit to branch main
in repository java-shib-profile.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-profile.git;a=commit;h=adae048aa496f089a67accdf6d3a16252d9b4fda

The following commit(s) were added to refs/heads/main by this push:
     new adae048  Replace Collections/Arrays methods where possible.
adae048 is described below

commit adae048aa496f089a67accdf6d3a16252d9b4fda
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Apr 20 14:09:40 2023 -0400

    Replace Collections/Arrays methods where possible.
---
 .../context/logic/DateAttributePredicateTest.java     | 19 ++++++++++---------
 .../context/logic/SimpleAttributePredicateTest.java   | 19 ++++++++++---------
 .../profile/audit/impl/AttributesAuditExtractor.java  |  6 +++---
 3 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/shib-profile-api/src/test/java/net/shibboleth/profile/context/logic/DateAttributePredicateTest.java b/shib-profile-api/src/test/java/net/shibboleth/profile/context/logic/DateAttributePredicateTest.java
index 1e73798..fcf7d0d 100644
--- a/shib-profile-api/src/test/java/net/shibboleth/profile/context/logic/DateAttributePredicateTest.java
+++ b/shib-profile-api/src/test/java/net/shibboleth/profile/context/logic/DateAttributePredicateTest.java
@@ -17,24 +17,25 @@
 
 package net.shibboleth.profile.context.logic;
 
+import static org.testng.Assert.*;
+
+import java.time.Instant;
+import java.time.ZonedDateTime;
+import java.util.ArrayList;
+import java.util.List;
+
 import net.shibboleth.idp.attribute.DateTimeAttributeValue;
 import net.shibboleth.idp.attribute.IdPAttribute;
 import net.shibboleth.idp.attribute.IdPAttributeValue;
 import net.shibboleth.idp.attribute.StringAttributeValue;
 import net.shibboleth.idp.attribute.context.AttributeContext;
 import net.shibboleth.profile.context.RelyingPartyContext;
+import net.shibboleth.shared.collection.CollectionSupport;
 
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-import java.time.Instant;
-import java.time.ZonedDateTime;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import static org.testng.Assert.*;
 
 /**
  * Unit test for {@link DateAttributePredicate}.
@@ -128,8 +129,8 @@ public class DateAttributePredicateTest {
         }
         attribute.setValues(attributeValues);
         final AttributeContext ac = new AttributeContext();
-        ac.setIdPAttributes(Collections.singletonList(attribute));
-        ac.setUnfilteredIdPAttributes(Collections.singletonList(attribute));
+        ac.setIdPAttributes(CollectionSupport.singletonList(attribute));
+        ac.setUnfilteredIdPAttributes(CollectionSupport.singletonList(attribute));
         rpc.addSubcontext(ac);
         prc.addSubcontext(rpc);
         return prc;
diff --git a/shib-profile-api/src/test/java/net/shibboleth/profile/context/logic/SimpleAttributePredicateTest.java b/shib-profile-api/src/test/java/net/shibboleth/profile/context/logic/SimpleAttributePredicateTest.java
index 04e5038..4e06a43 100644
--- a/shib-profile-api/src/test/java/net/shibboleth/profile/context/logic/SimpleAttributePredicateTest.java
+++ b/shib-profile-api/src/test/java/net/shibboleth/profile/context/logic/SimpleAttributePredicateTest.java
@@ -17,23 +17,24 @@
 
 package net.shibboleth.profile.context.logic;
 
+import static org.testng.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
 import net.shibboleth.idp.attribute.IdPAttribute;
 import net.shibboleth.idp.attribute.IdPAttributeValue;
 import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
 import net.shibboleth.idp.attribute.StringAttributeValue;
 import net.shibboleth.idp.attribute.context.AttributeContext;
 import net.shibboleth.profile.context.RelyingPartyContext;
+import net.shibboleth.shared.collection.CollectionSupport;
 
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.testng.annotations.Test;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import static org.testng.Assert.*;
 
 /**
  * Unit test for {@link SimpleAttributePredicate}.
@@ -107,8 +108,8 @@ public class SimpleAttributePredicateTest {
         }
         attribute.setValues(attributeValues);
         final AttributeContext ac = new AttributeContext();
-        ac.setIdPAttributes(Collections.singletonList(attribute));
-        ac.setUnfilteredIdPAttributes(Collections.singletonList(attribute));
+        ac.setIdPAttributes(CollectionSupport.singletonList(attribute));
+        ac.setUnfilteredIdPAttributes(CollectionSupport.singletonList(attribute));
         rpc.addSubcontext(ac);
         prc.addSubcontext(rpc);
         return prc;
diff --git a/shib-profile-impl/src/main/java/net/shibboleth/profile/audit/impl/AttributesAuditExtractor.java b/shib-profile-impl/src/main/java/net/shibboleth/profile/audit/impl/AttributesAuditExtractor.java
index ce7f324..9e2e308 100644
--- a/shib-profile-impl/src/main/java/net/shibboleth/profile/audit/impl/AttributesAuditExtractor.java
+++ b/shib-profile-impl/src/main/java/net/shibboleth/profile/audit/impl/AttributesAuditExtractor.java
@@ -18,7 +18,6 @@
 package net.shibboleth.profile.audit.impl;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.function.Function;
 import java.util.function.Predicate;
 
@@ -30,6 +29,7 @@ import org.opensaml.profile.context.ProfileRequestContext;
 
 import net.shibboleth.idp.attribute.context.AttributeContext;
 import net.shibboleth.profile.context.RelyingPartyContext;
+import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.logic.Constraint;
 
 /** {@link Function} that returns the attribute IDs from an {@link AttributeContext}. */
@@ -86,7 +86,7 @@ public class AttributesAuditExtractor implements Function<ProfileRequestContext,
     @Nullable public Collection<String> apply(@Nullable final ProfileRequestContext input) {
         
         if (activationCondition != null && !activationCondition.test(input)) {
-            return Collections.emptyList();
+            return CollectionSupport.emptyList();
         }
         
         final AttributeContext attributeCtx = attributeContextLookupStrategy.apply(input);
@@ -94,7 +94,7 @@ public class AttributesAuditExtractor implements Function<ProfileRequestContext,
             return (useUnfiltered ? attributeCtx.getUnfilteredIdPAttributes()
                     : attributeCtx.getIdPAttributes()).keySet();
         }
-        return Collections.emptyList();
+        return CollectionSupport.emptyList();
     }
 
 }
\ 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