[java-shib-metadata] branch main updated: Use NonNull Set and List creation methods
Rod Widdowson
rdw at steadingsoftware.com
Tue Jan 24 14:22:04 UTC 2023
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-shib-metadata.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-metadata.git;a=commit;h=2a221f27f71390e0c14470e65d38b84b8df5a54a
The following commit(s) were added to refs/heads/main by this push:
new 2a221f27 Use NonNull Set and List creation methods
2a221f27 is described below
commit 2a221f27f71390e0c14470e65d38b84b8df5a54a
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Jan 24 14:12:04 2023 +0000
Use NonNull Set and List creation methods
---
.../net/shibboleth/idp/saml/metadata/ScopesContainer.java | 5 +++--
.../shibboleth/idp/saml/metadata/ScopesContainerTest.java | 13 +++++++------
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/shib-metadata-api/src/main/java/net/shibboleth/idp/saml/metadata/ScopesContainer.java b/shib-metadata-api/src/main/java/net/shibboleth/idp/saml/metadata/ScopesContainer.java
index 0a52efc6..e72eadcb 100644
--- a/shib-metadata-api/src/main/java/net/shibboleth/idp/saml/metadata/ScopesContainer.java
+++ b/shib-metadata-api/src/main/java/net/shibboleth/idp/saml/metadata/ScopesContainer.java
@@ -33,6 +33,7 @@ import org.opensaml.saml.saml2.metadata.IDPSSODescriptor;
import net.shibboleth.idp.saml.xmlobject.Scope;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.primitive.StringSupport;
@@ -44,10 +45,10 @@ import net.shibboleth.shared.primitive.StringSupport;
public class ScopesContainer {
/** The (non Regexp) scopes. */
- @Nonnull private Set<String> simpleScopes = Collections.emptySet();
+ @Nonnull private Set<String> simpleScopes = CollectionSupport.emptySet();
/** The Regexp scopes. */
- @Nonnull private List<Predicate<String>> regexpScopes = Collections.emptyList();
+ @Nonnull private List<Predicate<String>> regexpScopes = CollectionSupport.emptyList();
/** Sets the non-regexp Scopes.
* <br> We force the input to be a set so as to enforce no duplicates and any performance hit as a result.
diff --git a/shib-metadata-api/src/test/java/net/shibboleth/idp/saml/metadata/ScopesContainerTest.java b/shib-metadata-api/src/test/java/net/shibboleth/idp/saml/metadata/ScopesContainerTest.java
index 88ef9f68..30a38300 100644
--- a/shib-metadata-api/src/test/java/net/shibboleth/idp/saml/metadata/ScopesContainerTest.java
+++ b/shib-metadata-api/src/test/java/net/shibboleth/idp/saml/metadata/ScopesContainerTest.java
@@ -21,10 +21,11 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import java.util.Collections;
-import java.util.Set;
import org.testng.annotations.Test;
+import net.shibboleth.shared.collection.CollectionSupport;
+
/**
* Tests for the {@link ScopesContainer}.
*/
@@ -37,14 +38,14 @@ public class ScopesContainerTest {
scopes.setRegexpScopes(null);
scopes.setSimpleScopes(Collections.emptySet());
assertFalse(scopes.matchesScope("foo"));
- scopes.setRegexpScopes(Set.of(""));
+ scopes.setRegexpScopes(CollectionSupport.singleton(""));
scopes.setSimpleScopes(Collections.singleton((String)null));
assertFalse(scopes.matchesScope("foo"));
}
@Test public void stringOnly() {
final ScopesContainer scopes = new ScopesContainer();
- scopes.setSimpleScopes(Set.of("foo", "bar", "james"));
+ scopes.setSimpleScopes(CollectionSupport.setOf("foo", "bar", "james"));
assertFalse(scopes.matchesScope("jimmy"));
assertTrue(scopes.matchesScope("foo"));
assertTrue(scopes.matchesScope("bar"));
@@ -53,7 +54,7 @@ public class ScopesContainerTest {
@Test public void regexpOnly() {
final ScopesContainer scopes = new ScopesContainer();
- scopes.setRegexpScopes(Set.of("^.*fo.*b$"));
+ scopes.setRegexpScopes(CollectionSupport.singleton("^.*fo.*b$"));
assertFalse(scopes.matchesScope("jimmy"));
assertFalse(scopes.matchesScope("foo"));
assertFalse(scopes.matchesScope("foobd"));
@@ -63,8 +64,8 @@ public class ScopesContainerTest {
@Test public void both() {
final ScopesContainer scopes = new ScopesContainer();
- scopes.setRegexpScopes(Set.of("^.*fo.*b$"));
- scopes.setSimpleScopes(Set.of("foo", "bar", "james"));
+ scopes.setRegexpScopes(CollectionSupport.singleton("^.*fo.*b$"));
+ scopes.setSimpleScopes(CollectionSupport.setOf("foo", "bar", "james"));
assertFalse(scopes.matchesScope("jimmy"));
assertTrue(scopes.matchesScope("james"));
assertTrue(scopes.matchesScope("foo"));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list