[java-identity-provider] 02/02: IDP-2069 Null handling

Rod Widdowson rdw at steadingsoftware.com
Tue Feb 28 10:32:41 UTC 2023


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

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

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

commit 31e2ec4f6dc4b91ec71df32abe2815368dd0af0b
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Feb 28 09:38:25 2023 +0000

    IDP-2069 Null handling
    
    https://shibboleth.atlassian.net/browse/IDP-2069
    
    Cleanup idp-consent-impl tests
---
 .../impl/CurrentConsentIdsAuditExtractorTest.java  |  4 +-
 ...CurrentConsentIsApprovedAuditExtractorTest.java |  8 ++-
 .../CurrentConsentValuesAuditExtractorTest.java    |  4 +-
 .../impl/AbstractAttributeReleaseActionTest.java   |  8 ++-
 .../impl/AttributeReleaseFlowDescriptorTest.java   |  5 +-
 .../impl/PopulateAttributeReleaseContextTest.java  | 33 ++++++----
 .../flow/ar/impl/ReleaseAttributesTest.java        | 15 +++--
 .../idp/consent/flow/impl/ExtractConsentTest.java  | 11 ++--
 .../flow/impl/PopulateConsentContextTest.java      | 12 +++-
 .../AbstractConsentIndexedStorageActionTest.java   | 17 +++--
 .../impl/AbstractConsentStorageActionTest.java     | 34 ++++++----
 .../impl/CreateGlobalConsentResultTest.java        |  2 +-
 .../flow/storage/impl/CreateResultTest.java        | 15 +++--
 .../storage/impl/ReadConsentFromStorageTest.java   |  4 +-
 .../flow/storage/impl/UpdateCounterTest.java       |  6 +-
 .../shibboleth/idp/consent/impl/ConsentTest.java   |  5 +-
 .../idp/consent/impl/ConsentTestingSupport.java    | 12 ++--
 ...ttributeDisplayNameDescriptionFunctionTest.java | 19 +++---
 .../impl/AttributeReleaseConsentFunctionTest.java  | 69 +++++++++++++------
 .../impl/AttributeValueLookupFunctionTest.java     |  7 +-
 .../impl/AttributeValuesHashFunctionTest.java      | 12 ++--
 .../impl/CounterStorageKeyComparatorTest.java      |  2 +-
 .../logic/impl/CounterStorageKeyFunctionTest.java  | 23 +++++--
 .../logic/impl/FlowIdLookupFunctionTest.java       | 14 ++--
 .../logic/impl/IsConsentRequiredPredicateTest.java | 77 +++++++++++-----------
 .../idp/consent/logic/impl/JoinFunctionTest.java   |  7 +-
 .../impl/MessageSourceConsentFunctionTest.java     | 39 +++++++----
 .../storage/impl/CollectionSerializerTest.java     | 10 ++-
 .../storage/impl/ConsentSerializerTest.java        | 21 +++---
 29 files changed, 318 insertions(+), 177 deletions(-)

diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/audit/impl/CurrentConsentIdsAuditExtractorTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/audit/impl/CurrentConsentIdsAuditExtractorTest.java
index ee1d292ad..0c3364ff5 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/audit/impl/CurrentConsentIdsAuditExtractorTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/audit/impl/CurrentConsentIdsAuditExtractorTest.java
@@ -37,7 +37,9 @@ public class CurrentConsentIdsAuditExtractorTest extends AbstractConsentAuditExt
     }
 
     @Test public void testNoCurrentConsents() {
-        prc.getSubcontext(ConsentContext.class).getCurrentConsents().clear();
+        final ConsentContext ctx = prc.getSubcontext(ConsentContext.class);
+        assert ctx != null;
+        ctx.getCurrentConsents().clear();
         Assert.assertEquals(extractor.apply(prc), Collections.emptyList());
     }
 
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/audit/impl/CurrentConsentIsApprovedAuditExtractorTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/audit/impl/CurrentConsentIsApprovedAuditExtractorTest.java
index 5c5fb2e86..66c4ec56a 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/audit/impl/CurrentConsentIsApprovedAuditExtractorTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/audit/impl/CurrentConsentIsApprovedAuditExtractorTest.java
@@ -37,12 +37,16 @@ public class CurrentConsentIsApprovedAuditExtractorTest extends AbstractConsentA
     }
 
     @Test public void testNoCurrentConsents() {
-        prc.getSubcontext(ConsentContext.class).getCurrentConsents().clear();
+        final ConsentContext ctx = prc.getSubcontext(ConsentContext.class);
+        assert ctx != null;
+        ctx.getCurrentConsents().clear();
         Assert.assertEquals(extractor.apply(prc), Collections.emptyList());
     }
 
     @Test public void testExtraction() {
-        prc.getSubcontext(ConsentContext.class).getCurrentConsents().get("consent1").setApproved(true);
+        final ConsentContext ctx = prc.getSubcontext(ConsentContext.class);
+        assert ctx != null;
+        ctx.getCurrentConsents().get("consent1").setApproved(true);
         Assert.assertEquals(extractor.apply(prc), List.of(true, false));
     }
 }
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/audit/impl/CurrentConsentValuesAuditExtractorTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/audit/impl/CurrentConsentValuesAuditExtractorTest.java
index fb7257cdc..88b4fa975 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/audit/impl/CurrentConsentValuesAuditExtractorTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/audit/impl/CurrentConsentValuesAuditExtractorTest.java
@@ -37,7 +37,9 @@ public class CurrentConsentValuesAuditExtractorTest extends AbstractConsentAudit
     }
 
     @Test public void testNoCurrentConsents() {
-        prc.getSubcontext(ConsentContext.class).getCurrentConsents().clear();
+        final ConsentContext ctx = prc.getSubcontext(ConsentContext.class);
+        assert ctx != null;
+        ctx.getCurrentConsents().clear();
         Assert.assertEquals(extractor.apply(prc), Collections.emptyList());
     }
 
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/AbstractAttributeReleaseActionTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/AbstractAttributeReleaseActionTest.java
index 9d63e08c1..f08f4374a 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/AbstractAttributeReleaseActionTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/AbstractAttributeReleaseActionTest.java
@@ -17,6 +17,8 @@
 
 package net.shibboleth.idp.consent.flow.ar.impl;
 
+import org.testng.annotations.BeforeMethod;
+
 import net.shibboleth.idp.attribute.context.AttributeContext;
 import net.shibboleth.idp.consent.context.AttributeReleaseContext;
 import net.shibboleth.idp.consent.flow.impl.AbstractConsentActionTest;
@@ -24,8 +26,6 @@ import net.shibboleth.idp.consent.impl.ConsentTestingSupport;
 import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
 import net.shibboleth.profile.context.RelyingPartyContext;
 
-import org.testng.annotations.BeforeMethod;
-
 /** {@link AbstractAttributeReleaseAction} unit test. */
 public abstract class AbstractAttributeReleaseActionTest extends AbstractConsentActionTest {
 
@@ -43,6 +43,8 @@ public abstract class AbstractAttributeReleaseActionTest extends AbstractConsent
 
         descriptor = new AttributeReleaseFlowDescriptor();
         descriptor.setId("test");
-        prc.getSubcontext(ProfileInterceptorContext.class, false).setAttemptedFlow(descriptor);
+        final ProfileInterceptorContext ctx = prc.getSubcontext(ProfileInterceptorContext.class);
+        assert ctx != null;
+        ctx.setAttemptedFlow(descriptor);
     }
 }
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/AttributeReleaseFlowDescriptorTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/AttributeReleaseFlowDescriptorTest.java
index 90608a70f..93ca8add9 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/AttributeReleaseFlowDescriptorTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/AttributeReleaseFlowDescriptorTest.java
@@ -35,6 +35,8 @@ public class AttributeReleaseFlowDescriptorTest {
 
     private AttributeReleaseFlowDescriptor descriptor;
 
+    private Object nullObj;
+    
     @BeforeMethod public void setUp() {
         descriptor = new AttributeReleaseFlowDescriptor();
         descriptor.setId("test");
@@ -48,8 +50,9 @@ public class AttributeReleaseFlowDescriptorTest {
         Assert.assertNotNull(descriptor.getAttributeValuesHashFunction());
     }
 
+    @SuppressWarnings({ "null", "unchecked" })
     @Test(expectedExceptions = ConstraintViolationException.class) public void testNullAttributeValuesHashFunction() {
-        descriptor.setAttributeValuesHashFunction(null);
+        descriptor.setAttributeValuesHashFunction((Function<Collection<IdPAttributeValue>, String>) nullObj);
     }
 
     @Test(expectedExceptions = UnmodifiableComponentException.class) public void
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/PopulateAttributeReleaseContextTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/PopulateAttributeReleaseContextTest.java
index bd49ace59..0182dda5f 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/PopulateAttributeReleaseContextTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/PopulateAttributeReleaseContextTest.java
@@ -28,6 +28,12 @@ import java.util.function.Predicate;
 
 import javax.annotation.Nullable;
 
+import org.springframework.webflow.execution.Event;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Ordering;
+
 import net.shibboleth.idp.attribute.IdPAttribute;
 import net.shibboleth.idp.attribute.StringAttributeValue;
 import net.shibboleth.idp.attribute.context.AttributeContext;
@@ -39,12 +45,6 @@ import net.shibboleth.idp.profile.testing.ActionTestingSupport;
 import net.shibboleth.profile.context.RelyingPartyContext;
 import net.shibboleth.shared.component.ComponentInitializationException;
 
-import org.springframework.webflow.execution.Event;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Ordering;
-
 /** {@link PopulateAttributeReleaseContext} unit test. */
 @SuppressWarnings("javadoc")
 public class PopulateAttributeReleaseContextTest extends AbstractAttributeReleaseActionTest {
@@ -65,7 +65,7 @@ public class PopulateAttributeReleaseContextTest extends AbstractAttributeReleas
         ActionTestingSupport.assertProceedEvent(event);
 
         final AttributeReleaseContext arc = prc.getSubcontext(AttributeReleaseContext.class, false);
-        Assert.assertNotNull(arc);
+        assert arc!= null;
         Assert.assertEquals(arc.getConsentableAttributes(), ConsentTestingSupport.newAttributeMap());
     }
 
@@ -79,7 +79,7 @@ public class PopulateAttributeReleaseContextTest extends AbstractAttributeReleas
         ActionTestingSupport.assertProceedEvent(event);
 
         final AttributeReleaseContext arc = prc.getSubcontext(AttributeReleaseContext.class, false);
-        Assert.assertNotNull(arc);
+        assert arc!= null;
         Assert.assertNotEquals(arc.getConsentableAttributes(), ConsentTestingSupport.newAttributeMap());
         Assert.assertTrue(arc.getConsentableAttributes().containsKey("attribute1"));
         Assert.assertTrue(arc.getConsentableAttributes().containsKey("attribute2"));
@@ -100,7 +100,7 @@ public class PopulateAttributeReleaseContextTest extends AbstractAttributeReleas
         ActionTestingSupport.assertProceedEvent(event);
 
         final AttributeReleaseContext arc = prc.getSubcontext(AttributeReleaseContext.class, false);
-        Assert.assertNotNull(arc);
+        assert arc!= null;
         Assert.assertEquals(arc.getConsentableAttributes(), orderedAttributes);
     }
 
@@ -122,7 +122,7 @@ public class PopulateAttributeReleaseContextTest extends AbstractAttributeReleas
         ActionTestingSupport.assertProceedEvent(event);
 
         final AttributeReleaseContext arc = prc.getSubcontext(AttributeReleaseContext.class, false);
-        Assert.assertNotNull(arc);
+        assert arc!= null;
         Assert.assertEquals(arc.getConsentableAttributes(), orderedAttributes);
     }
 
@@ -142,7 +142,11 @@ public class PopulateAttributeReleaseContextTest extends AbstractAttributeReleas
         final List<IdPAttribute> attributes = new ArrayList<>();
         attributes.addAll(ConsentTestingSupport.newAttributeMap().values());
         attributes.add(attribute4);
-        prc.getSubcontext(RelyingPartyContext.class).getSubcontext(AttributeContext.class).setIdPAttributes(attributes);
+        final RelyingPartyContext rpCtx = prc.getSubcontext(RelyingPartyContext.class);
+        assert rpCtx != null;
+        final AttributeContext ac = rpCtx.getSubcontext(AttributeContext.class);
+        assert ac != null;
+        ac.setIdPAttributes(attributes);
 
         action = new PopulateAttributeReleaseContext();
         ((PopulateAttributeReleaseContext) action).setAttributePredicate(e->true);
@@ -155,12 +159,14 @@ public class PopulateAttributeReleaseContextTest extends AbstractAttributeReleas
         ActionTestingSupport.assertProceedEvent(event);
 
         final AttributeReleaseContext arc = prc.getSubcontext(AttributeReleaseContext.class);
-        Assert.assertNotNull(arc);
+        assert arc!= null;
         Assert.assertEquals(arc.getConsentableAttributes(), orderedAttributes);
     }
 
     @Test public void testMissingAttributeContext() throws Exception {
-        prc.getSubcontext(RelyingPartyContext.class).removeSubcontext(AttributeContext.class);
+        final RelyingPartyContext ctx = prc.getSubcontext(RelyingPartyContext.class);
+        assert ctx != null;
+        ctx.removeSubcontext(AttributeContext.class);
 
         action = new PopulateAttributeReleaseContext();
         ((PopulateAttributeReleaseContext) action).setAttributePredicate(e -> true);
@@ -177,6 +183,7 @@ public class PopulateAttributeReleaseContextTest extends AbstractAttributeReleas
         /** {@inheritDoc} */
         public boolean test(@Nullable final IdPAttribute input) {
 
+            assert input != null;
             if (input.getId().equals("attribute1") || input.getId().equals("attribute2")) {
                 return true;
             }
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/ReleaseAttributesTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/ReleaseAttributesTest.java
index 015f179c3..0de4068c1 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/ReleaseAttributesTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/ar/impl/ReleaseAttributesTest.java
@@ -56,6 +56,7 @@ public class ReleaseAttributesTest extends AbstractAttributeReleaseActionTest {
         consent.put(consentToAttribute2.getId(), consentToAttribute2);
 
         final ConsentContext consentCtx = prc.getSubcontext(ConsentContext.class);
+        assert consentCtx!=null;
         consentCtx.getPreviousConsents().putAll(consent);
 
         arc = prc.getSubcontext(AttributeReleaseContext.class);
@@ -73,9 +74,10 @@ public class ReleaseAttributesTest extends AbstractAttributeReleaseActionTest {
 
         ActionTestingSupport.assertProceedEvent(event);
 
-        final AttributeContext attrCtx =
-                prc.getSubcontext(RelyingPartyContext.class).getSubcontext(AttributeContext.class);
-        Assert.assertNotNull(attrCtx);
+        final RelyingPartyContext rpCtx = prc.getSubcontext(RelyingPartyContext.class);
+        assert rpCtx != null;
+        final AttributeContext attrCtx = rpCtx.getSubcontext(AttributeContext.class);
+        assert attrCtx != null;
         Assert.assertEquals(attrCtx.getIdPAttributes().size(), 1);
         Assert.assertTrue(attrCtx.getIdPAttributes().containsKey("attribute1"));
         Assert.assertFalse(attrCtx.getIdPAttributes().containsKey("attribute2"));
@@ -94,10 +96,11 @@ public class ReleaseAttributesTest extends AbstractAttributeReleaseActionTest {
         final Event event = action.execute(src);
 
         ActionTestingSupport.assertProceedEvent(event);
+        final RelyingPartyContext rpCtx = prc.getSubcontext(RelyingPartyContext.class);
+        assert rpCtx != null;
+        final AttributeContext attrCtx = rpCtx .getSubcontext(AttributeContext.class);
+        assert attrCtx != null;
 
-        final AttributeContext attrCtx =
-                prc.getSubcontext(RelyingPartyContext.class).getSubcontext(AttributeContext.class);
-        Assert.assertNotNull(attrCtx);
         Assert.assertEquals(attrCtx.getIdPAttributes().size(), 2);
         Assert.assertTrue(attrCtx.getIdPAttributes().containsKey("attribute1"));
         Assert.assertTrue(attrCtx.getIdPAttributes().containsKey("attribute2"));
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/impl/ExtractConsentTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/impl/ExtractConsentTest.java
index 7d7e54fa2..5c4f48a46 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/impl/ExtractConsentTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/impl/ExtractConsentTest.java
@@ -36,6 +36,7 @@ public class ExtractConsentTest extends AbstractConsentActionTest {
 
     @BeforeMethod public void setUpCurrentConsents() throws Exception {
         final ConsentContext consentContext = prc.getSubcontext(ConsentContext.class, false);
+        assert consentContext!= null;
         consentContext.getCurrentConsents().putAll(ConsentTestingSupport.newConsentMap());
     }
 
@@ -48,10 +49,10 @@ public class ExtractConsentTest extends AbstractConsentActionTest {
         ActionTestingSupport.assertEvent(event, EventIds.INVALID_PROFILE_CTX);
 
         final ConsentContext consentContext = prc.getSubcontext(ConsentContext.class, false);
-        Assert.assertNotNull(consentContext);
+        assert consentContext!= null;
         final Consent consent1 = consentContext.getCurrentConsents().get("consent1");
         final Consent consent2 = consentContext.getCurrentConsents().get("consent2");
-        Assert.assertNotNull(consent1);
+        assert consent1!= null && consent2!= null;
         Assert.assertNotNull(consent2);
         Assert.assertFalse(consent1.isApproved());
         Assert.assertFalse(consent2.isApproved());
@@ -68,7 +69,7 @@ public class ExtractConsentTest extends AbstractConsentActionTest {
         ActionTestingSupport.assertProceedEvent(event);
 
         final ConsentContext consentContext = prc.getSubcontext(ConsentContext.class, false);
-        Assert.assertNotNull(consentContext);
+        assert consentContext!= null;
         final Consent consent1 = consentContext.getCurrentConsents().get("consent1");
         final Consent consent2 = consentContext.getCurrentConsents().get("consent2");
         Assert.assertNotNull(consent1);
@@ -90,7 +91,7 @@ public class ExtractConsentTest extends AbstractConsentActionTest {
         ActionTestingSupport.assertProceedEvent(event);
 
         final ConsentContext consentContext = prc.getSubcontext(ConsentContext.class, false);
-        Assert.assertNotNull(consentContext);
+        assert consentContext!= null;
         final Consent consent1 = consentContext.getCurrentConsents().get("consent1");
         final Consent consent2 = consentContext.getCurrentConsents().get("consent2");
         Assert.assertNotNull(consent1);
@@ -113,7 +114,7 @@ public class ExtractConsentTest extends AbstractConsentActionTest {
         ActionTestingSupport.assertProceedEvent(event);
 
         final ConsentContext consentContext = prc.getSubcontext(ConsentContext.class, false);
-        Assert.assertNotNull(consentContext);
+        assert consentContext!= null;
         final Consent consent1 = consentContext.getCurrentConsents().get("consent1");
         final Consent consent2 = consentContext.getCurrentConsents().get("consent2");
         Assert.assertNotNull(consent1);
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/impl/PopulateConsentContextTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/impl/PopulateConsentContextTest.java
index c265f9678..e2c1ffc13 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/impl/PopulateConsentContextTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/impl/PopulateConsentContextTest.java
@@ -17,12 +17,17 @@
 
 package net.shibboleth.idp.consent.flow.impl;
 
+import net.shibboleth.idp.consent.Consent;
 import net.shibboleth.idp.consent.context.ConsentContext;
 import net.shibboleth.idp.consent.impl.ConsentTestingSupport;
 import net.shibboleth.idp.profile.testing.ActionTestingSupport;
 import net.shibboleth.shared.logic.ConstraintViolationException;
 import net.shibboleth.shared.logic.FunctionSupport;
 
+import java.util.Map;
+import java.util.function.Function;
+
+import org.opensaml.profile.context.ProfileRequestContext;
 import org.springframework.webflow.execution.Event;
 import org.testng.Assert;
 import org.testng.annotations.Test;
@@ -31,9 +36,12 @@ import org.testng.annotations.Test;
 @SuppressWarnings("javadoc")
 public class PopulateConsentContextTest extends AbstractConsentActionTest {
 
+    private Object nullObj;
+    
+    @SuppressWarnings({ "null", "unchecked" })
     @Test(expectedExceptions = ConstraintViolationException.class) public void testNullCurrentConsentsFunction()
             throws Exception {
-        action = new PopulateConsentContext(null);
+        action = new PopulateConsentContext((Function<ProfileRequestContext, Map<String, Consent>>) nullObj);
         action.initialize();
     }
 
@@ -46,7 +54,7 @@ public class PopulateConsentContextTest extends AbstractConsentActionTest {
         ActionTestingSupport.assertProceedEvent(event);
 
         final ConsentContext consentContext = prc.getSubcontext(ConsentContext.class, false);
-        Assert.assertNotNull(consentContext);
+        assert consentContext!= null;
         Assert.assertEquals(consentContext.getCurrentConsents(), ConsentTestingSupport.newConsentMap());
     }
 
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentIndexedStorageActionTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentIndexedStorageActionTest.java
index 5399d2683..f15ea708f 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentIndexedStorageActionTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentIndexedStorageActionTest.java
@@ -19,13 +19,17 @@ package net.shibboleth.idp.consent.flow.storage.impl;
 
 import java.io.IOException;
 import java.util.Collection;
+import java.util.List;
+import java.util.function.Function;
 
 import net.shibboleth.idp.consent.storage.impl.CollectionSerializer;
+import net.shibboleth.shared.collection.Pair;
 import net.shibboleth.shared.component.UnmodifiableComponentException;
 import net.shibboleth.shared.logic.FunctionSupport;
 
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.opensaml.storage.StorageRecord;
+import org.opensaml.storage.StorageSerializer;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
@@ -33,6 +37,8 @@ import org.testng.annotations.Test;
 @SuppressWarnings("javadoc")
 public abstract class AbstractConsentIndexedStorageActionTest extends AbstractConsentStorageActionTest {
 
+    private Object nullObj;
+
     protected void populateAction() throws Exception {
         super.populateAction();
         ((AbstractConsentIndexedStorageAction) action).setStorageIndexKeyLookupStrategy(FunctionSupport
@@ -41,7 +47,7 @@ public abstract class AbstractConsentIndexedStorageActionTest extends AbstractCo
 
     protected Collection<String> readStorageKeysFromIndex() throws IOException {
         final StorageRecord<?> index = getMemoryStorageService().read("context", "_index");
-        Assert.assertNotNull(index);
+        assert index!=null;
 
         final CollectionSerializer collectionSerializer =
                 (CollectionSerializer) ((AbstractConsentIndexedStorageAction) action).getStorageKeysSerializer();
@@ -50,22 +56,25 @@ public abstract class AbstractConsentIndexedStorageActionTest extends AbstractCo
         return collectionSerializer.deserialize(0, "context", "_index", index.getValue(), index.getExpiration());
     }
     
+    @SuppressWarnings({ "null", "unchecked" })
     @Test(expectedExceptions = UnmodifiableComponentException.class)
     public void testUnmodifiableStorageIndexKeyStrategy() throws Exception {
         action.initialize();
-        ((AbstractConsentIndexedStorageAction) action).setStorageIndexKeyLookupStrategy(null);
+        ((AbstractConsentIndexedStorageAction) action).setStorageIndexKeyLookupStrategy((Function<ProfileRequestContext, String>) nullObj);
     }
     
+    @SuppressWarnings({ "null", "unchecked" })
     @Test(expectedExceptions = UnmodifiableComponentException.class)
     public void testUnmodifiableStorageKeysSerializerStrategy() throws Exception {
         action.initialize();
-        ((AbstractConsentIndexedStorageAction) action).setStorageKeysSerializer(null);
+        ((AbstractConsentIndexedStorageAction) action).setStorageKeysSerializer((StorageSerializer<Collection<String>>) nullObj);
     }
     
+    @SuppressWarnings({ "null", "unchecked" })
     @Test(expectedExceptions = UnmodifiableComponentException.class)
     public void testUnmodifiableStorageKeysStrategy() throws Exception {
         action.initialize();
-        ((AbstractConsentIndexedStorageAction) action).setStorageKeysStrategy(null);
+        ((AbstractConsentIndexedStorageAction) action).setStorageKeysStrategy((Function<Pair<ProfileRequestContext, List<String>>, List<String>>) nullObj);
     }
 
 }
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentStorageActionTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentStorageActionTest.java
index 4d8a9ea00..50c88f96e 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentStorageActionTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentStorageActionTest.java
@@ -19,16 +19,19 @@ package net.shibboleth.idp.consent.flow.storage.impl;
 
 import java.io.IOException;
 import java.util.Map;
+import java.util.function.Function;
 
 import net.shibboleth.idp.consent.Consent;
 import net.shibboleth.idp.consent.flow.impl.AbstractConsentActionTest;
 import net.shibboleth.idp.consent.storage.impl.ConsentSerializer;
 import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
+import net.shibboleth.idp.profile.interceptor.ProfileInterceptorFlowDescriptor;
 import net.shibboleth.shared.component.UnmodifiableComponentException;
 import net.shibboleth.shared.logic.FunctionSupport;
 
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.opensaml.storage.StorageRecord;
+import org.opensaml.storage.StorageSerializer;
 import org.opensaml.storage.impl.MemoryStorageService;
 import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
@@ -38,6 +41,8 @@ import org.testng.annotations.Test;
 @SuppressWarnings("javadoc")
 public abstract class AbstractConsentStorageActionTest extends AbstractConsentActionTest {
 
+    private Object nullObj;
+
     protected void populateAction() throws Exception {
         ((AbstractConsentStorageAction) action).setStorageContextLookupStrategy(FunctionSupport
                 .<ProfileRequestContext, String> constant("context"));
@@ -52,23 +57,25 @@ public abstract class AbstractConsentStorageActionTest extends AbstractConsentAc
         storageService.initialize();
 
         final ProfileInterceptorContext pic = prc.getSubcontext(ProfileInterceptorContext.class);
-        Assert.assertNotNull(pic);
-        Assert.assertNotNull(pic.getAttemptedFlow());
-        pic.getAttemptedFlow().setStorageService(storageService);
+        assert pic!=null;
+        final ProfileInterceptorFlowDescriptor flow = pic.getAttemptedFlow();
+        assert flow!=null;
+        flow.setStorageService(storageService);
     }
 
     protected MemoryStorageService getMemoryStorageService() {
         final ProfileInterceptorContext pic = prc.getSubcontext(ProfileInterceptorContext.class);
-        Assert.assertNotNull(pic);
-        Assert.assertNotNull(pic.getAttemptedFlow());
-        Assert.assertNotNull(pic.getAttemptedFlow().getStorageService());
-        Assert.assertTrue(pic.getAttemptedFlow().getStorageService() instanceof MemoryStorageService);
-        return (MemoryStorageService) pic.getAttemptedFlow().getStorageService();
+        assert pic!=null;
+        final ProfileInterceptorFlowDescriptor flow = pic.getAttemptedFlow();
+        assert flow!=null;
+        Assert.assertNotNull(flow.getStorageService());
+        Assert.assertTrue(flow.getStorageService() instanceof MemoryStorageService);
+        return (MemoryStorageService) flow.getStorageService();
     }
 
     protected Map<String, Consent> readConsentsFromStorage() throws IOException {
         final StorageRecord<?> record = getMemoryStorageService().read("context", "key");
-        Assert.assertNotNull(record);
+        assert record!=null;
 
         final ConsentSerializer consentSerializer =
                 (ConsentSerializer) ((AbstractConsentStorageAction) action).getStorageSerializer();
@@ -77,22 +84,25 @@ public abstract class AbstractConsentStorageActionTest extends AbstractConsentAc
         return consentSerializer.deserialize(0, "context", "key", record.getValue(), record.getExpiration());
     }
 
+    @SuppressWarnings({ "null", "unchecked" })
     @Test(expectedExceptions = UnmodifiableComponentException.class)
     public void testUnmodifiableInterceptorContextStrategy() throws Exception {
         action.initialize();
-        ((AbstractConsentStorageAction) action).setStorageContextLookupStrategy(null);
+        ((AbstractConsentStorageAction) action).setStorageContextLookupStrategy((Function<ProfileRequestContext, String>) nullObj);
     }
     
+    @SuppressWarnings({ "null", "unchecked" })
     @Test(expectedExceptions = UnmodifiableComponentException.class)
     public void testUnmodifiableStorageKeyStrategy() throws Exception {
         action.initialize();
-        ((AbstractConsentStorageAction) action).setStorageKeyLookupStrategy(null);
+        ((AbstractConsentStorageAction) action).setStorageKeyLookupStrategy((Function<ProfileRequestContext, String>) nullObj);
     }
     
+    @SuppressWarnings({ "null", "unchecked" })
     @Test(expectedExceptions = UnmodifiableComponentException.class)
     public void testUnmodifiableStorageSerializerStrategy() throws Exception {
         action.initialize();
-        ((AbstractConsentStorageAction) action).setStorageSerializer(null);
+        ((AbstractConsentStorageAction) action).setStorageSerializer((StorageSerializer<Map<String, Consent>>) nullObj);
     }
 
 }
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/CreateGlobalConsentResultTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/CreateGlobalConsentResultTest.java
index 3d42dac08..5a98b23e4 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/CreateGlobalConsentResultTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/CreateGlobalConsentResultTest.java
@@ -47,7 +47,7 @@ public class CreateGlobalConsentResultTest extends AbstractConsentIndexedStorage
         ActionTestingSupport.assertProceedEvent(event);
 
         final ProfileInterceptorContext pic = prc.getSubcontext(ProfileInterceptorContext.class, false);
-        Assert.assertNotNull(pic);
+        assert pic!=null;
         Assert.assertEquals(pic.getResults().size(), 0);
 
         final Collection<String> keys = readStorageKeysFromIndex();
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/CreateResultTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/CreateResultTest.java
index c1a9103cb..d4eb472b4 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/CreateResultTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/CreateResultTest.java
@@ -55,7 +55,8 @@ public class CreateResultTest extends AbstractConsentIndexedStorageActionTest {
 
     protected Map<String, Consent> readConsentFromStorage(@Nonnull final String key) throws Exception {
         final StorageRecord<?> record = getMemoryStorageService().read("context", key);
-        Assert.assertNotNull(record);
+        assert record!=null;
+
         final ConsentSerializer serializer = new ConsentSerializer();
 
         return serializer.deserialize(0, "context", key, record.getValue(), record.getExpiration());
@@ -74,7 +75,7 @@ public class CreateResultTest extends AbstractConsentIndexedStorageActionTest {
         ActionTestingSupport.assertProceedEvent(event);
 
         final ProfileInterceptorContext pic = prc.getSubcontext(ProfileInterceptorContext.class, false);
-        Assert.assertNotNull(pic);
+        assert pic!=null;
         Assert.assertEquals(pic.getResults().size(), 0);
 
         final StorageRecord<?> record = getMemoryStorageService().read("context", "key");
@@ -86,6 +87,7 @@ public class CreateResultTest extends AbstractConsentIndexedStorageActionTest {
         action.initialize();
 
         final ConsentContext consentCtx = prc.getSubcontext(ConsentContext.class);
+        assert consentCtx!=null;
         consentCtx.getCurrentConsents().putAll(ConsentTestingSupport.newConsentMap());
 
         final Event event = action.execute(src);
@@ -93,7 +95,7 @@ public class CreateResultTest extends AbstractConsentIndexedStorageActionTest {
         ActionTestingSupport.assertProceedEvent(event);
 
         final ProfileInterceptorContext pic = prc.getSubcontext(ProfileInterceptorContext.class, false);
-        Assert.assertNotNull(pic);
+        assert pic!=null;
         Assert.assertEquals(pic.getResults().size(), 0);
 
         final Map<String, Consent> consents = readConsentsFromStorage();
@@ -113,6 +115,7 @@ public class CreateResultTest extends AbstractConsentIndexedStorageActionTest {
         testCreateResult();
 
         final StorageRecord<?> record = getMemoryStorageService().read("context", "key");
+        assert record!=null;
         Assert.assertEquals(record.getValue(),
                 "[{\"id\":101,\"v\":\"value1\",\"appr\":false},{\"id\":102,\"v\":\"value2\",\"appr\":false}]");
     }
@@ -121,13 +124,14 @@ public class CreateResultTest extends AbstractConsentIndexedStorageActionTest {
         action.initialize();
 
         final ConsentContext consentCtx = prc.getSubcontext(ConsentContext.class);
+        assert consentCtx!=null;
         consentCtx.getCurrentConsents().putAll(ConsentTestingSupport.newConsentMap());
 
         ActionTestingSupport.assertProceedEvent(action.execute(src));
         ActionTestingSupport.assertProceedEvent(action.execute(src));
 
         final ProfileInterceptorContext pic = prc.getSubcontext(ProfileInterceptorContext.class, false);
-        Assert.assertNotNull(pic);
+        assert pic!=null;
         Assert.assertEquals(pic.getResults().size(), 0);
 
         final Map<String, Consent> consents = readConsentsFromStorage();
@@ -147,6 +151,7 @@ public class CreateResultTest extends AbstractConsentIndexedStorageActionTest {
         testUpdateResult();
 
         final StorageRecord<?> record = getMemoryStorageService().read("context", "key");
+        assert record!=null;
         Assert.assertEquals(record.getValue(),
                 "[{\"id\":101,\"v\":\"value1\",\"appr\":false},{\"id\":102,\"v\":\"value2\",\"appr\":false}]");
     }
@@ -156,6 +161,7 @@ public class CreateResultTest extends AbstractConsentIndexedStorageActionTest {
         descriptor.setMaximumNumberOfStoredRecords(2);
 
         final ConsentContext consentCtx = prc.getSubcontext(ConsentContext.class);
+        assert consentCtx!=null;
         consentCtx.getCurrentConsents().putAll(ConsentTestingSupport.newConsentMap());
 
         // key1
@@ -200,6 +206,7 @@ public class CreateResultTest extends AbstractConsentIndexedStorageActionTest {
         descriptor.setExpandedNumberOfStoredRecords(0);
 
         final ConsentContext consentCtx = prc.getSubcontext(ConsentContext.class);
+        assert consentCtx!=null;            
         consentCtx.getCurrentConsents().putAll(ConsentTestingSupport.newConsentMap());
 
         // can't test unlimited, so test 10
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/ReadConsentFromStorageTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/ReadConsentFromStorageTest.java
index 439d6b6c8..c858576fb 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/ReadConsentFromStorageTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/ReadConsentFromStorageTest.java
@@ -49,7 +49,7 @@ public class ReadConsentFromStorageTest extends AbstractConsentStorageActionTest
         ActionTestingSupport.assertProceedEvent(event);
 
         final ConsentContext consentCtx = prc.getSubcontext(ConsentContext.class);
-        Assert.assertNotNull(consentCtx);
+        assert consentCtx!=null;
         Assert.assertEquals(consentCtx.getPreviousConsents(), ConsentTestingSupport.newConsentMap());
     }
 
@@ -61,7 +61,7 @@ public class ReadConsentFromStorageTest extends AbstractConsentStorageActionTest
         ActionTestingSupport.assertProceedEvent(event);
 
         final ConsentContext consentCtx = prc.getSubcontext(ConsentContext.class);
-        Assert.assertNotNull(consentCtx);
+        assert consentCtx!=null;
         Assert.assertTrue(consentCtx.getPreviousConsents().isEmpty());
     }
 }
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/UpdateCounterTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/UpdateCounterTest.java
index 92d9f1166..34cf3c6fd 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/UpdateCounterTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/flow/storage/impl/UpdateCounterTest.java
@@ -42,7 +42,7 @@ public class UpdateCounterTest extends AbstractConsentStorageActionTest {
         ActionTestingSupport.assertProceedEvent(event);
 
         final StorageRecord<?> record = getMemoryStorageService().read("context", "key");
-        Assert.assertNotNull(record);
+        assert record!=null;
         Assert.assertEquals(record.getVersion(), 1);
     }
 
@@ -54,7 +54,7 @@ public class UpdateCounterTest extends AbstractConsentStorageActionTest {
         ActionTestingSupport.assertProceedEvent(event);
 
         StorageRecord<?> record = getMemoryStorageService().read("context", "key");
-        Assert.assertNotNull(record);
+        assert record!=null;
         Assert.assertEquals(record.getVersion(), 1);
 
         event = action.execute(src);
@@ -62,7 +62,7 @@ public class UpdateCounterTest extends AbstractConsentStorageActionTest {
         ActionTestingSupport.assertProceedEvent(event);
 
         record = getMemoryStorageService().read("context", "key");
-        Assert.assertNotNull(record);
+        assert record!=null;
         Assert.assertEquals(record.getVersion(), 2);
     }
 
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/impl/ConsentTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/impl/ConsentTest.java
index d981f6615..fb82a5a15 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/impl/ConsentTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/impl/ConsentTest.java
@@ -29,6 +29,8 @@ import org.testng.annotations.Test;
 public class ConsentTest {
 
     private Consent consent;
+    
+    private Object nullObj;
 
     @BeforeMethod public void setUp() {
         consent = new Consent();
@@ -45,8 +47,9 @@ public class ConsentTest {
         consent.setValue("");
     }
 
+    @SuppressWarnings("null")
     @Test(expectedExceptions = ConstraintViolationException.class) public void testNullValue() {
-        consent.setValue(null);
+        consent.setValue((String) nullObj);
     }
 
     @Test public void testValue() {
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/impl/ConsentTestingSupport.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/impl/ConsentTestingSupport.java
index 156a67c28..9c03c23b9 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/impl/ConsentTestingSupport.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/impl/ConsentTestingSupport.java
@@ -24,6 +24,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.annotation.Nonnull;
+
 import net.shibboleth.idp.attribute.IdPAttribute;
 import net.shibboleth.idp.attribute.IdPAttributeValue;
 import net.shibboleth.idp.attribute.StringAttributeValue;
@@ -36,7 +38,7 @@ import net.shibboleth.idp.consent.storage.impl.ConsentResult;
 @SuppressWarnings("javadoc")
 public class ConsentTestingSupport {
 
-    public static Map<String, Consent> newConsentMap() {
+    @Nonnull public static Map<String, Consent> newConsentMap() {
         final Consent consent1 = new Consent();
         consent1.setId("consent1");
         consent1.setValue("value1");
@@ -56,11 +58,11 @@ public class ConsentTestingSupport {
         ORDER1,
         ORDER2,
     }
-    public static final Map<String, IdPAttribute> newAttributeMap() {
+    @Nonnull public static final Map<String, IdPAttribute> newAttributeMap() {
         return newAttributeMap(MapType.SORTED);
     }
 
-    public static final Map<String, IdPAttribute> newAttributeMap(final MapType order) {
+    @Nonnull public static final Map<String, IdPAttribute> newAttributeMap(final MapType order) {
         final IdPAttributeValue value1a = new StringAttributeValue("Avalue1");
         final IdPAttributeValue value1b = new StringAttributeValue("Bvalue1");
         final IdPAttributeValue value1c = new StringAttributeValue("Cvalue1");
@@ -99,7 +101,7 @@ public class ConsentTestingSupport {
         return map;
     }
 
-    public static final List<ConsentResult> newConsentResults() {
+    @Nonnull public static final List<ConsentResult> newConsentResults() {
         final List<ConsentResult> consentResults = new ArrayList<>();
         consentResults.add(new ConsentResult("context1", "key1", "value1", null));
         consentResults.add(new ConsentResult("context2", "key1", "value1", null));
@@ -107,7 +109,7 @@ public class ConsentTestingSupport {
         return consentResults;
     }
 
-    public static Map<String, Integer> newSymbolicsMap() {
+    @Nonnull public static Map<String, Integer> newSymbolicsMap() {
         final Map<String, Integer> map = new HashMap<>();
         map.put("consent1", 101);
         map.put("consent2", 102);
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeDisplayNameDescriptionFunctionTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeDisplayNameDescriptionFunctionTest.java
index b2e58df17..6148f5735 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeDisplayNameDescriptionFunctionTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeDisplayNameDescriptionFunctionTest.java
@@ -26,11 +26,14 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.function.Function;
 
+import javax.annotation.Nonnull;
+
 import jakarta.servlet.http.HttpServletRequest;
 
 import net.shibboleth.idp.attribute.IdPAttribute;
 import net.shibboleth.idp.attribute.transcoding.AttributeTranscoderRegistry;
 import net.shibboleth.idp.attribute.transcoding.TranscodingRule;
+import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.component.ComponentInitializationException;
 import net.shibboleth.shared.service.ReloadableService;
 import net.shibboleth.shared.service.ServiceableComponent;
@@ -165,7 +168,7 @@ public class AttributeDisplayNameDescriptionFunctionTest {
         }
 
         /** {@inheritDoc} */
-        public ServiceableComponent<AttributeTranscoderRegistry> getServiceableComponent() {
+        public @Nonnull ServiceableComponent<AttributeTranscoderRegistry> getServiceableComponent() {
             return this;
         }
 
@@ -175,27 +178,27 @@ public class AttributeDisplayNameDescriptionFunctionTest {
         }
 
         /** {@inheritDoc} */
-        public Map<Locale, String> getDisplayNames(IdPAttribute attribute) {
+        public @Nonnull Map<Locale, String> getDisplayNames(@Nonnull IdPAttribute attribute) {
             return names;
         }
 
         /** {@inheritDoc} */
-        public Map<Locale, String> getDescriptions(IdPAttribute attribute) {
+        public @Nonnull Map<Locale, String> getDescriptions(@Nonnull IdPAttribute attribute) {
             return descriptions;
         }
 
         /** {@inheritDoc} */
-        public Collection<TranscodingRule> getTranscodingRules(IdPAttribute from, Class<?> to) {
-            return null;
+        public @Nonnull Collection<TranscodingRule> getTranscodingRules(@Nonnull IdPAttribute from, @Nonnull Class<?> to) {
+            return CollectionSupport.emptyList();
         }
 
         /** {@inheritDoc} */
-        public <T> Collection<TranscodingRule> getTranscodingRules(T from) {
-            return null;
+        public @Nonnull <T> Collection<TranscodingRule> getTranscodingRules(@Nonnull T from) {
+            return CollectionSupport.emptyList();
         }
 
         /** {@inheritDoc} */
-        public AttributeTranscoderRegistry getComponent() {
+        public @Nonnull AttributeTranscoderRegistry getComponent() {
             return this;
         }
 
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeReleaseConsentFunctionTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeReleaseConsentFunctionTest.java
index f7589ace2..187b77185 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeReleaseConsentFunctionTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeReleaseConsentFunctionTest.java
@@ -32,6 +32,7 @@ import net.shibboleth.idp.consent.impl.ConsentTestingSupport;
 import net.shibboleth.idp.consent.impl.ConsentTestingSupport.MapType;
 import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
 import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
+import net.shibboleth.idp.profile.interceptor.ProfileInterceptorFlowDescriptor;
 import net.shibboleth.idp.profile.testing.RequestContextBuilder;
 
 import org.opensaml.profile.context.ProfileRequestContext;
@@ -72,13 +73,13 @@ public class AttributeReleaseConsentFunctionTest {
         final ProfileInterceptorContext pic = new ProfileInterceptorContext();
         pic.setAttemptedFlow(flowDescriptor);
         prc.addSubcontext(pic);
+        final ProfileInterceptorContext pic2 = prc.getSubcontext(ProfileInterceptorContext.class);
+        assert pic2!= null;
+        final ProfileInterceptorFlowDescriptor flow = pic2.getAttemptedFlow();
+        assert flow != null;
+        Assert.assertTrue(flow  instanceof ConsentFlowDescriptor);
 
-        Assert.assertNotNull(prc.getSubcontext(ProfileInterceptorContext.class));
-        Assert.assertNotNull(prc.getSubcontext(ProfileInterceptorContext.class).getAttemptedFlow());
-        Assert.assertTrue(prc.getSubcontext(ProfileInterceptorContext.class).getAttemptedFlow() instanceof ConsentFlowDescriptor);
-
-        Assert.assertEquals(((ConsentFlowDescriptor) prc.getSubcontext(ProfileInterceptorContext.class)
-                .getAttemptedFlow()).compareValues(), compareValues);
+        Assert.assertEquals(((ConsentFlowDescriptor) flow).compareValues(), compareValues);
     }
 
     @Test public void testNullInput() {
@@ -95,7 +96,10 @@ public class AttributeReleaseConsentFunctionTest {
     @Test public void testNullConsentFlowDescriptor() {
         prc.addSubcontext(new ConsentContext());
         prc.addSubcontext(new ProfileInterceptorContext());
-        Assert.assertNull(prc.getSubcontext(ProfileInterceptorContext.class).getAttemptedFlow());
+        final ProfileInterceptorContext pic2 = prc.getSubcontext(ProfileInterceptorContext.class);
+        assert pic2!= null;
+        final ProfileInterceptorFlowDescriptor flow = pic2.getAttemptedFlow();
+        assert flow == null;
 
         Assert.assertNull(function.apply(prc));
     }
@@ -112,9 +116,12 @@ public class AttributeReleaseConsentFunctionTest {
         prc.addSubcontext(new ConsentContext());
         prc.addSubcontext(new AttributeReleaseContext(), true);
         setUpDescriptor(false);
-        Assert.assertTrue(prc.getSubcontext(AttributeReleaseContext.class).getConsentableAttributes().isEmpty());
-
-        Assert.assertTrue(function.apply(prc).isEmpty());
+        final AttributeReleaseContext arc =prc.getSubcontext(AttributeReleaseContext.class); 
+        assert arc != null;
+        Assert.assertTrue(arc.getConsentableAttributes().isEmpty());
+        final Map<String, Consent> res = function.apply(prc);
+        assert res != null;
+        Assert.assertTrue(res.isEmpty());
     }
 
     @Test public void testNoPreviousConsents() {
@@ -123,8 +130,12 @@ public class AttributeReleaseConsentFunctionTest {
         arc.getConsentableAttributes().putAll(ConsentTestingSupport.newAttributeMap());
         prc.addSubcontext(arc);
         setUpDescriptor(false);
-        Assert.assertFalse(prc.getSubcontext(AttributeReleaseContext.class).getConsentableAttributes().isEmpty());
-        Assert.assertTrue(prc.getSubcontext(ConsentContext.class).getPreviousConsents().isEmpty());
+        final AttributeReleaseContext arc2 =prc.getSubcontext(AttributeReleaseContext.class); 
+        assert arc2 != null;
+        Assert.assertFalse(arc2.getConsentableAttributes().isEmpty());
+        ConsentContext consentContext = prc.getSubcontext(ConsentContext.class);
+        assert consentContext != null;
+        Assert.assertTrue(consentContext.getPreviousConsents().isEmpty());
 
         final Map<String, Consent> expected = new HashMap<>();
         for (final IdPAttribute attr : ConsentTestingSupport.newAttributeMap().values()) {
@@ -142,8 +153,12 @@ public class AttributeReleaseConsentFunctionTest {
         arc.getConsentableAttributes().putAll(ConsentTestingSupport.newAttributeMap());
         prc.addSubcontext(arc);
         setUpDescriptor(true);
-        Assert.assertFalse(prc.getSubcontext(AttributeReleaseContext.class).getConsentableAttributes().isEmpty());
-        Assert.assertTrue(prc.getSubcontext(ConsentContext.class).getPreviousConsents().isEmpty());
+        final AttributeReleaseContext arc2 =prc.getSubcontext(AttributeReleaseContext.class); 
+        assert arc2 != null;
+        Assert.assertFalse(arc2.getConsentableAttributes().isEmpty());
+        ConsentContext consentContext = prc.getSubcontext(ConsentContext.class);
+        assert consentContext != null;
+        Assert.assertTrue(consentContext.getPreviousConsents().isEmpty());
 
         final Map<String, Consent> expected = new HashMap<>();
         for (final IdPAttribute attr : ConsentTestingSupport.newAttributeMap().values()) {
@@ -168,8 +183,12 @@ public class AttributeReleaseConsentFunctionTest {
         arc.getConsentableAttributes().putAll(ConsentTestingSupport.newAttributeMap());
         prc.addSubcontext(arc);
         setUpDescriptor(false);
-        Assert.assertFalse(prc.getSubcontext(AttributeReleaseContext.class).getConsentableAttributes().isEmpty());
-        Assert.assertFalse(prc.getSubcontext(ConsentContext.class).getPreviousConsents().isEmpty());
+        final AttributeReleaseContext arc2 =prc.getSubcontext(AttributeReleaseContext.class); 
+        assert arc2 != null;
+        Assert.assertFalse(arc2.getConsentableAttributes().isEmpty());
+        ConsentContext consentContext = prc.getSubcontext(ConsentContext.class);
+        assert consentContext != null;
+        Assert.assertFalse(consentContext.getPreviousConsents().isEmpty());
 
         final Map<String, Consent> expected = new HashMap<>();
         for (final IdPAttribute attr : ConsentTestingSupport.newAttributeMap().values()) {
@@ -198,8 +217,12 @@ public class AttributeReleaseConsentFunctionTest {
         arc.getConsentableAttributes().putAll(ConsentTestingSupport.newAttributeMap());
         prc.addSubcontext(arc);
         setUpDescriptor(true);
-        Assert.assertFalse(prc.getSubcontext(AttributeReleaseContext.class).getConsentableAttributes().isEmpty());
-        Assert.assertFalse(prc.getSubcontext(ConsentContext.class).getPreviousConsents().isEmpty());
+        final AttributeReleaseContext arc2 =prc.getSubcontext(AttributeReleaseContext.class); 
+        assert arc2 != null;
+        Assert.assertFalse(arc2.getConsentableAttributes().isEmpty());
+        ConsentContext consentContext = prc.getSubcontext(ConsentContext.class);
+        assert consentContext != null;
+        Assert.assertFalse(consentContext.getPreviousConsents().isEmpty());
 
         final Map<String, Consent> expected = new HashMap<>();
         for (final IdPAttribute attr : ConsentTestingSupport.newAttributeMap().values()) {
@@ -233,6 +256,7 @@ public class AttributeReleaseConsentFunctionTest {
         setUpDescriptor(true);
 
         final Map<String, Consent> firstResult = function.apply(prc);
+        assert firstResult != null;
         final Consent firstConsent = firstResult.get("attribute1");
         assertTrue(firstConsent.isApproved());
 
@@ -248,6 +272,7 @@ public class AttributeReleaseConsentFunctionTest {
         setUpDescriptor(true);
 
         final Map<String, Consent> secondResult = function.apply(prc);
+        assert secondResult != null;
         final Consent secondConsent = secondResult.get("attribute1");
         assertTrue(secondConsent.isApproved());
     }
@@ -266,8 +291,12 @@ public class AttributeReleaseConsentFunctionTest {
         arc.getConsentableAttributes().putAll(ConsentTestingSupport.newAttributeMap());
         prc.addSubcontext(arc);
         setUpDescriptor(true);
-        Assert.assertFalse(prc.getSubcontext(AttributeReleaseContext.class).getConsentableAttributes().isEmpty());
-        Assert.assertFalse(prc.getSubcontext(ConsentContext.class).getPreviousConsents().isEmpty());
+        final AttributeReleaseContext arc2 =prc.getSubcontext(AttributeReleaseContext.class); 
+        assert arc2 != null;
+        Assert.assertFalse(arc2.getConsentableAttributes().isEmpty());
+        ConsentContext consentContext = prc.getSubcontext(ConsentContext.class);
+        assert consentContext != null;
+        Assert.assertFalse(consentContext.getPreviousConsents().isEmpty());
 
         final Map<String, Consent> expected = new HashMap<>();
         for (final IdPAttribute attr : ConsentTestingSupport.newAttributeMap().values()) {
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunctionTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunctionTest.java
index 02dd15c52..34d4ec028 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunctionTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunctionTest.java
@@ -45,6 +45,8 @@ public class AttributeValueLookupFunctionTest {
     private RequestContext src;
 
     private ProfileRequestContext prc;
+    
+    private String nullObj;
 
     @BeforeMethod public void setUp() throws Exception {
         src = new RequestContextBuilder().buildRequestContext();
@@ -68,8 +70,9 @@ public class AttributeValueLookupFunctionTest {
         function = new AttributeValueLookupFunction("");
     }
 
+    @SuppressWarnings("null")
     @Test(expectedExceptions = ConstraintViolationException.class) public void testNullConstructor() {
-        function = new AttributeValueLookupFunction(null);
+        function = new AttributeValueLookupFunction(nullObj);
     }
 
     @Test public void testNullProfileRequestContext() {
@@ -92,6 +95,7 @@ public class AttributeValueLookupFunctionTest {
     @Test public void testAttributeWithNoValues() {
         final AttributeContext attributeCtx =
                 prc.getOrCreateSubcontext(RelyingPartyContext.class).getSubcontext(AttributeContext.class);
+        assert attributeCtx!=null;
         attributeCtx.setIdPAttributes(Collections.singleton(new IdPAttribute("EmptyAttribute")));
 
         function = new AttributeValueLookupFunction("EmptyAttribute");
@@ -106,6 +110,7 @@ public class AttributeValueLookupFunctionTest {
 
         final AttributeContext attributeCtx =
                 prc.getOrCreateSubcontext(RelyingPartyContext.class).getSubcontext(AttributeContext.class);
+        assert attributeCtx!=null;
         attributeCtx.setIdPAttributes(Collections.singleton(byteAttribute));
 
         function = new AttributeValueLookupFunction("ByteAttribute");
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeValuesHashFunctionTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeValuesHashFunctionTest.java
index 3b566d599..f868ac3da 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeValuesHashFunctionTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/AttributeValuesHashFunctionTest.java
@@ -22,6 +22,8 @@ import static org.testng.Assert.assertEquals;
 import java.util.Collections;
 import java.util.List;
 
+import javax.annotation.Nonnull;
+
 import org.opensaml.core.testing.XMLObjectBaseTestCase;
 import org.opensaml.core.xml.XMLObjectBuilder;
 import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
@@ -42,6 +44,7 @@ import net.shibboleth.idp.consent.impl.ConsentTestingSupport;
 public class AttributeValuesHashFunctionTest extends XMLObjectBaseTestCase {
 
     private AttributeValuesHashFunction function;
+    private Object nullObj;
 
     @BeforeMethod public void setUp() {
         function = new AttributeValuesHashFunction();
@@ -100,14 +103,14 @@ public class AttributeValuesHashFunctionTest extends XMLObjectBaseTestCase {
         assertEquals(function.apply(Collections.singletonList(val)), "c+NqWOijlvFBpla4r1q3F0RkpYZK7phCNe2gKb0r57o=");
     }
 
-    private IdPAttributeValue testAV(Object type) {
+    private IdPAttributeValue testAV(@Nonnull Object type) {
         return new IdPAttributeValue() {
 
-            public Object getNativeValue() {
+            public @Nonnull Object getNativeValue() {
                 return type;
             }
 
-            public String getDisplayValue() {
+            public @Nonnull String getDisplayValue() {
                 return "Display";
             }};
     }
@@ -116,7 +119,8 @@ public class AttributeValuesHashFunctionTest extends XMLObjectBaseTestCase {
         assertEquals(function.apply(Collections.singletonList(testAV("42"))), "Lt6BAjtq4qQJ6ADEZKf/s5XZxzBh6mShY/UCphriugY=");
     }
 
+    @SuppressWarnings("null")
     @Test public void unknownTypeNoValue() {
-        assertEquals(function.apply(Collections.singletonList(testAV(null))), "xPtMT+sJsVtAtjNLzPrBBlfbY/yUsAQ7Ncxxc7Q5k70=");
+        assertEquals(function.apply(Collections.singletonList(testAV(nullObj))), "xPtMT+sJsVtAtjNLzPrBBlfbY/yUsAQ7Ncxxc7Q5k70=");
     }
 }
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/CounterStorageKeyComparatorTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/CounterStorageKeyComparatorTest.java
index 3ffe7fdc3..af95617e2 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/CounterStorageKeyComparatorTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/CounterStorageKeyComparatorTest.java
@@ -42,7 +42,7 @@ public class CounterStorageKeyComparatorTest {
         keys = Arrays.asList("key1", "key2", "key3", "key4");
 
         map = new LinkedHashMap<>();
-
+        assert keys != null;
         c = new CounterStorageKeyComparator(keys, map);
     }
 
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/CounterStorageKeyFunctionTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/CounterStorageKeyFunctionTest.java
index 5da2ca6cc..e2160dc8f 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/CounterStorageKeyFunctionTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/CounterStorageKeyFunctionTest.java
@@ -20,6 +20,7 @@ package net.shibboleth.idp.consent.logic.impl;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
+import java.util.function.Function;
 
 import javax.annotation.Nonnull;
 
@@ -28,6 +29,7 @@ import net.shibboleth.idp.consent.flow.storage.impl.UpdateCounter;
 import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
 import net.shibboleth.idp.profile.context.SpringRequestContext;
 import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
+import net.shibboleth.idp.profile.interceptor.ProfileInterceptorFlowDescriptor;
 import net.shibboleth.idp.profile.testing.RequestContextBuilder;
 import net.shibboleth.shared.collection.Pair;
 import net.shibboleth.shared.component.UnmodifiableComponentException;
@@ -58,6 +60,8 @@ public class CounterStorageKeyFunctionTest {
     private Pair<ProfileRequestContext, List<String>> input;
 
     private CounterStorageKeyFunction f;
+    
+    private Object nullObj;
 
     /**
      * Create counter storage records.
@@ -67,6 +71,7 @@ public class CounterStorageKeyFunctionTest {
      * @throws IOException if a storage service error occurs
      * @throws InterruptedException if thread error occurs while sleeping
      */
+    @SuppressWarnings("null")
     protected void createCounter(@Nonnull final String key, final int iterations) throws IOException,
             InterruptedException {
 
@@ -87,16 +92,19 @@ public class CounterStorageKeyFunctionTest {
         springRequestContext.setRequestContext(src);
         prc.addSubcontext(springRequestContext);
 
-        storageService = new MemoryStorageService();
-        storageService.setId("test");
-        storageService.initialize();
+        final MemoryStorageService service = storageService = new MemoryStorageService();
+        service.setId("test");
+        service.initialize();
 
         descriptor = new ConsentFlowDescriptor();
         descriptor.setId("test");
 
         pic = new ProfileInterceptorContext();
         pic.setAttemptedFlow(descriptor);
-        pic.getAttemptedFlow().setStorageService(storageService);
+        final ProfileInterceptorFlowDescriptor flow = pic.getAttemptedFlow();
+        assert flow != null;
+        flow.setStorageService(service);
+        assert pic!=null;
         prc.addSubcontext(pic);
 
         keys = Arrays.asList("key1", "key2", "key3", "key4");
@@ -106,16 +114,18 @@ public class CounterStorageKeyFunctionTest {
         f = new CounterStorageKeyFunction();
     }
 
+    @SuppressWarnings({ "null", "unchecked" })
     @Test(expectedExceptions = UnmodifiableComponentException.class)
     public void testUnmodifiableInterceptorContextStrategy() throws Exception {
         f.initialize();
-        f.setInterceptorContextLookupStrategy(null);
+        f.setInterceptorContextLookupStrategy((Function<ProfileRequestContext, ProfileInterceptorContext>) nullObj);
     }
 
+    @SuppressWarnings({ "null", "unchecked" })
     @Test(expectedExceptions = UnmodifiableComponentException.class)
     public void testUnmodifiableStorageContextStrategy() throws Exception {
         f.initialize();
-        f.setStorageContextLookupStrategy(null);
+        f.setStorageContextLookupStrategy((Function<ProfileRequestContext, String>) nullObj);
     }
 
     @Test public void testNullPairInput() throws Exception {
@@ -172,6 +182,7 @@ public class CounterStorageKeyFunctionTest {
     @Test public void testNoStorageService() throws Exception {
         pic = new ProfileInterceptorContext();
         pic.setAttemptedFlow(descriptor);
+        assert pic != null;
         prc.addSubcontext(pic, true);
 
         f.initialize();
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/FlowIdLookupFunctionTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/FlowIdLookupFunctionTest.java
index 9c8b9d4a2..7e94dd07d 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/FlowIdLookupFunctionTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/FlowIdLookupFunctionTest.java
@@ -55,8 +55,9 @@ public class FlowIdLookupFunctionTest {
 
     @Test public void testNullWebFlowRequestContext() {
         prc.getSubcontext(SpringRequestContext.class, true);
-        Assert.assertNotNull(prc.getSubcontext(SpringRequestContext.class));
-        Assert.assertNull(prc.getSubcontext(SpringRequestContext.class).getRequestContext());
+        final SpringRequestContext context = prc.getSubcontext(SpringRequestContext.class);
+        assert context != null;
+        Assert.assertNull(context.getRequestContext());
         Assert.assertNull(function.apply(prc));
     }
 
@@ -69,9 +70,12 @@ public class FlowIdLookupFunctionTest {
     }
 
     @Test public void testFlowId() {
-        prc.getSubcontext(SpringRequestContext.class, true).setRequestContext(src);
-        Assert.assertNotNull(prc.getSubcontext(SpringRequestContext.class));
-        Assert.assertNotNull(prc.getSubcontext(SpringRequestContext.class).getRequestContext());
+        final SpringRequestContext context = prc.getSubcontext(SpringRequestContext.class, true);
+        assert context != null;
+        context.setRequestContext(src);
+        final SpringRequestContext ctx2 = prc.getSubcontext(SpringRequestContext.class);
+        assert ctx2  != null;
+        Assert.assertNotNull(ctx2.getRequestContext());
         Assert.assertEquals(function.apply(prc), "mockFlow");
     }
 }
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/IsConsentRequiredPredicateTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/IsConsentRequiredPredicateTest.java
index 69ac3bf12..cac13fd5f 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/IsConsentRequiredPredicateTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/IsConsentRequiredPredicateTest.java
@@ -26,6 +26,7 @@ import net.shibboleth.idp.consent.flow.impl.ConsentFlowDescriptor;
 import net.shibboleth.idp.consent.impl.ConsentTestingSupport;
 import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
 import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
+import net.shibboleth.idp.profile.interceptor.ProfileInterceptorFlowDescriptor;
 import net.shibboleth.idp.profile.testing.RequestContextBuilder;
 
 import org.opensaml.profile.context.ProfileRequestContext;
@@ -65,12 +66,13 @@ public class IsConsentRequiredPredicateTest {
         pic.setAttemptedFlow(descriptor);
         prc.addSubcontext(pic);
 
-        Assert.assertNotNull(prc.getSubcontext(ProfileInterceptorContext.class));
-        Assert.assertNotNull(prc.getSubcontext(ProfileInterceptorContext.class).getAttemptedFlow());
-        Assert.assertTrue(prc.getSubcontext(ProfileInterceptorContext.class).getAttemptedFlow() instanceof ConsentFlowDescriptor);
+        final ProfileInterceptorContext pic2 =prc.getSubcontext(ProfileInterceptorContext.class);
+        assert pic2 != null;
+        ProfileInterceptorFlowDescriptor flow = pic2.getAttemptedFlow();
+        assert flow != null;
+        Assert.assertTrue(flow instanceof ConsentFlowDescriptor);
 
-        Assert.assertEquals(((ConsentFlowDescriptor) prc.getSubcontext(ProfileInterceptorContext.class)
-                .getAttemptedFlow()).compareValues(), compareValues);
+        Assert.assertEquals(((ConsentFlowDescriptor) flow).compareValues(), compareValues);
     }
 
     /**
@@ -83,11 +85,11 @@ public class IsConsentRequiredPredicateTest {
         consentCtx.getCurrentConsents().putAll(ConsentTestingSupport.newConsentMap());
         prc.addSubcontext(consentCtx);
 
-        Assert.assertNotNull(prc.getSubcontext(ConsentContext.class));
-        Assert.assertFalse(prc.getSubcontext(ConsentContext.class).getPreviousConsents().isEmpty());
-        Assert.assertFalse(prc.getSubcontext(ConsentContext.class).getCurrentConsents().isEmpty());
-        Assert.assertTrue(Objects.equals(prc.getSubcontext(ConsentContext.class).getPreviousConsents(), prc
-                .getSubcontext(ConsentContext.class).getCurrentConsents()));
+        final ConsentContext ctx2 = prc.getSubcontext(ConsentContext.class);
+        assert ctx2 != null;
+        Assert.assertFalse(ctx2.getPreviousConsents().isEmpty());
+        Assert.assertFalse(ctx2.getCurrentConsents().isEmpty());
+        Assert.assertTrue(Objects.equals(ctx2.getPreviousConsents(), ctx2.getCurrentConsents()));
     }
 
     /**
@@ -103,13 +105,12 @@ public class IsConsentRequiredPredicateTest {
         consentCtx.getCurrentConsents().putAll(consentSubset);
         prc.addSubcontext(consentCtx);
 
-        Assert.assertNotNull(prc.getSubcontext(ConsentContext.class));
-        Assert.assertFalse(prc.getSubcontext(ConsentContext.class).getPreviousConsents().isEmpty());
-        Assert.assertFalse(prc.getSubcontext(ConsentContext.class).getCurrentConsents().isEmpty());
-        Assert.assertFalse(Objects.equals(prc.getSubcontext(ConsentContext.class).getPreviousConsents(), prc
-                .getSubcontext(ConsentContext.class).getCurrentConsents()));
-        Assert.assertFalse(Objects.equals(prc.getSubcontext(ConsentContext.class).getPreviousConsents().keySet(), prc
-                .getSubcontext(ConsentContext.class).getCurrentConsents().keySet()));
+        final ConsentContext ctx2 = prc.getSubcontext(ConsentContext.class);
+        assert ctx2 != null;
+        Assert.assertFalse(ctx2.getPreviousConsents().isEmpty());
+        Assert.assertFalse(ctx2.getCurrentConsents().isEmpty());
+        Assert.assertFalse(Objects.equals(ctx2.getPreviousConsents(), ctx2.getCurrentConsents()));
+        Assert.assertFalse(Objects.equals(ctx2.getPreviousConsents().keySet(), ctx2.getCurrentConsents().keySet()));
     }
 
     /**
@@ -125,11 +126,11 @@ public class IsConsentRequiredPredicateTest {
         consentCtx.getPreviousConsents().putAll(consentSubset);
         prc.addSubcontext(consentCtx);
 
-        Assert.assertNotNull(prc.getSubcontext(ConsentContext.class));
-        Assert.assertFalse(prc.getSubcontext(ConsentContext.class).getPreviousConsents().isEmpty());
-        Assert.assertFalse(prc.getSubcontext(ConsentContext.class).getCurrentConsents().isEmpty());
-        Assert.assertFalse(Objects.equals(prc.getSubcontext(ConsentContext.class).getPreviousConsents(), prc
-                .getSubcontext(ConsentContext.class).getCurrentConsents()));
+        final ConsentContext ctx2 = prc.getSubcontext(ConsentContext.class);
+        assert ctx2 != null;
+        Assert.assertFalse(ctx2.getPreviousConsents().isEmpty());
+        Assert.assertFalse(ctx2.getCurrentConsents().isEmpty());
+        Assert.assertFalse(Objects.equals(ctx2.getPreviousConsents(), ctx2.getCurrentConsents()));
     }
 
     /**
@@ -145,13 +146,12 @@ public class IsConsentRequiredPredicateTest {
         consentCtx.getCurrentConsents().putAll(consentSubset);
         prc.addSubcontext(consentCtx);
 
-        Assert.assertNotNull(prc.getSubcontext(ConsentContext.class));
-        Assert.assertFalse(prc.getSubcontext(ConsentContext.class).getPreviousConsents().isEmpty());
-        Assert.assertFalse(prc.getSubcontext(ConsentContext.class).getCurrentConsents().isEmpty());
-        Assert.assertFalse(Objects.equals(prc.getSubcontext(ConsentContext.class).getPreviousConsents(), prc
-                .getSubcontext(ConsentContext.class).getCurrentConsents()));
-        Assert.assertTrue(Objects.equals(prc.getSubcontext(ConsentContext.class).getPreviousConsents().keySet(), prc
-                .getSubcontext(ConsentContext.class).getCurrentConsents().keySet()));
+        final ConsentContext ctx2 = prc.getSubcontext(ConsentContext.class);
+        assert ctx2 != null;
+        Assert.assertFalse(ctx2.getPreviousConsents().isEmpty());
+        Assert.assertFalse(ctx2.getCurrentConsents().isEmpty());
+        Assert.assertFalse(Objects.equals(ctx2.getPreviousConsents(), ctx2.getCurrentConsents()));
+        Assert.assertTrue(Objects.equals(ctx2.getPreviousConsents().keySet(), ctx2.getCurrentConsents().keySet()));
     }
 
     @Test public void testNullInput() {
@@ -169,18 +169,20 @@ public class IsConsentRequiredPredicateTest {
         Assert.assertNotNull(prc.getSubcontext(ConsentContext.class));
 
         prc.addSubcontext(new ProfileInterceptorContext());
-        Assert.assertNotNull(prc.getSubcontext(ProfileInterceptorContext.class));
-        Assert.assertNull(prc.getSubcontext(ProfileInterceptorContext.class).getAttemptedFlow());
+        final ProfileInterceptorContext pic2 =prc.getSubcontext(ProfileInterceptorContext.class);
+        assert pic2 != null;
+        Assert.assertNull(pic2.getAttemptedFlow());
 
         Assert.assertFalse(p.test(prc));
     }
 
     @Test public void testNoPreviousConsents() {
         prc.addSubcontext(new ConsentContext());
-        Assert.assertNotNull(prc.getSubcontext(ConsentContext.class));
-        Assert.assertTrue(prc.getSubcontext(ConsentContext.class).getPreviousConsents().isEmpty());
+        final ConsentContext ctx2 = prc.getSubcontext(ConsentContext.class);
+        assert ctx2 != null;
+        Assert.assertTrue(ctx2.getPreviousConsents().isEmpty());
 
-        prc.getSubcontext(ConsentContext.class).getCurrentConsents().put("test", new Consent());
+        ctx2.getCurrentConsents().put("test", new Consent());
         setUpDescriptor(false);
 
         Assert.assertTrue(p.test(prc));
@@ -191,9 +193,10 @@ public class IsConsentRequiredPredicateTest {
         consentCtx.getPreviousConsents().putAll(ConsentTestingSupport.newConsentMap());
         prc.addSubcontext(consentCtx);
 
-        Assert.assertNotNull(prc.getSubcontext(ConsentContext.class));
-        Assert.assertFalse(prc.getSubcontext(ConsentContext.class).getPreviousConsents().isEmpty());
-        Assert.assertTrue(prc.getSubcontext(ConsentContext.class).getCurrentConsents().isEmpty());
+        final ConsentContext ctx2 = prc.getSubcontext(ConsentContext.class);
+        assert ctx2 != null;
+        Assert.assertFalse(ctx2.getPreviousConsents().isEmpty());
+        Assert.assertTrue(ctx2.getCurrentConsents().isEmpty());
 
         setUpDescriptor(false);
 
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/JoinFunctionTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/JoinFunctionTest.java
index 71ee296ab..92c2d19d4 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/JoinFunctionTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/JoinFunctionTest.java
@@ -52,12 +52,14 @@ public class JoinFunctionTest {
     }
 
     @Test public void testNullInput() {
+        assert functionA != null && functionB != null;
         function = new JoinFunction(functionA, functionB);
 
         Assert.assertNull(function.apply(null));
     }
 
     @Test public void testJoin() {
+        assert functionA != null && functionB != null;
         function = new JoinFunction(functionA, functionB);
 
         Assert.assertEquals(function.apply(prc), "a:b");
@@ -66,6 +68,7 @@ public class JoinFunctionTest {
     @Test public void testNullFirstFunctionJoin() {
         functionA = FunctionSupport.<ProfileRequestContext, String> constant(null);
 
+        assert functionA != null && functionB != null;
         function = new JoinFunction(functionA, functionB);
 
         Assert.assertEquals(function.apply(prc), "b");
@@ -73,6 +76,7 @@ public class JoinFunctionTest {
 
     @Test public void testNullSecondFunctionJoin() {
         functionB = FunctionSupport.<ProfileRequestContext, String> constant(null);
+        assert functionA != null && functionB != null;
 
         function = new JoinFunction(functionA, functionB);
 
@@ -81,7 +85,7 @@ public class JoinFunctionTest {
 
     @Test public void testEmptyFirstFunctionJoin() {
         functionA = FunctionSupport.<ProfileRequestContext, String> constant("");
-
+        assert functionA != null && functionB != null;
         function = new JoinFunction(functionA, functionB);
 
         Assert.assertEquals(function.apply(prc), ":b");
@@ -90,6 +94,7 @@ public class JoinFunctionTest {
     @Test public void testEmptySecondFunctionJoin() {
         functionB = FunctionSupport.<ProfileRequestContext, String> constant("");
 
+        assert functionA != null;
         function = new JoinFunction(functionA, functionB);
 
         Assert.assertEquals(function.apply(prc), "a:");
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/MessageSourceConsentFunctionTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/MessageSourceConsentFunctionTest.java
index b9c44e8e7..fc652fc4b 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/MessageSourceConsentFunctionTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/logic/impl/MessageSourceConsentFunctionTest.java
@@ -20,11 +20,16 @@ package net.shibboleth.idp.consent.logic.impl;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
+import java.util.function.Function;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 
 import net.shibboleth.idp.consent.Consent;
 import net.shibboleth.idp.consent.flow.impl.ConsentFlowDescriptor;
 import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
 import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
+import net.shibboleth.idp.profile.interceptor.ProfileInterceptorFlowDescriptor;
 import net.shibboleth.idp.profile.testing.RequestContextBuilder;
 import net.shibboleth.shared.component.UnmodifiableComponentException;
 import net.shibboleth.shared.logic.ConstraintViolationException;
@@ -50,6 +55,8 @@ public class MessageSourceConsentFunctionTest {
     private MessageSource messageSource;
 
     private MessageSourceConsentFunction function;
+    
+    private Object nullObject;
 
     @BeforeMethod public void setUp() throws Exception {
         src = new RequestContextBuilder().buildRequestContext();
@@ -58,6 +65,7 @@ public class MessageSourceConsentFunctionTest {
         messageSource = new MockMessageSource();
 
         function = new MessageSourceConsentFunction();
+        assert messageSource!=null;
         function.setMessageSource(messageSource);
     }
 
@@ -74,27 +82,29 @@ public class MessageSourceConsentFunctionTest {
         final ProfileInterceptorContext pic = new ProfileInterceptorContext();
         pic.setAttemptedFlow(descriptor);
         prc.addSubcontext(pic);
+        final ProfileInterceptorContext pic2 =prc.getSubcontext(ProfileInterceptorContext.class);
+        assert pic2!=null;
+        final ProfileInterceptorFlowDescriptor flow = pic2.getAttemptedFlow();
+        assert flow != null;
+        Assert.assertTrue(flow  instanceof ConsentFlowDescriptor);
 
-        Assert.assertNotNull(prc.getSubcontext(ProfileInterceptorContext.class));
-        Assert.assertNotNull(prc.getSubcontext(ProfileInterceptorContext.class).getAttemptedFlow());
-        Assert.assertTrue(prc.getSubcontext(ProfileInterceptorContext.class).getAttemptedFlow() instanceof ConsentFlowDescriptor);
-
-        Assert.assertEquals(((ConsentFlowDescriptor) prc.getSubcontext(ProfileInterceptorContext.class)
-                .getAttemptedFlow()).compareValues(), compareValues);
+        Assert.assertEquals(((ConsentFlowDescriptor) flow).compareValues(), compareValues);
     }
 
     @Test public void testNullInput() {
         Assert.assertNull(function.apply(null));
     }
 
+    @SuppressWarnings({ "null", "unchecked" })
     @Test(expectedExceptions = ConstraintViolationException.class) public void testNullIdMessageCode() throws Exception {
-        function.setConsentKeyLookupStrategy(null);
+        function.setConsentKeyLookupStrategy((Function<ProfileRequestContext, String>) nullObject);
         function.initialize();
     }
 
+    @SuppressWarnings({ "null", "unchecked" })
     @Test(expectedExceptions = ConstraintViolationException.class) public void testNullValueMessageCode()
             throws Exception {
-        function.setConsentValueMessageCodeSuffix(null);
+        function.setConsentValueMessageCodeSuffix((String) nullObject);
         function.initialize();
     }
 
@@ -129,6 +139,7 @@ public class MessageSourceConsentFunctionTest {
         Assert.assertEquals(function.apply(prc), expected);
     }
 
+    @SuppressWarnings("null")
     @Test public void testMessageSourceConsentCompareValues() throws Exception {
 
         setUpDescriptor(true);
@@ -150,7 +161,7 @@ public class MessageSourceConsentFunctionTest {
     private class MockMessageSource implements MessageSource {
 
         /** {@inheritDoc} */
-        public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
+        public String getMessage(@Nonnull String code, @Nullable Object[] args, @Nullable String defaultMessage, @Nonnull Locale locale) {
             if (code.equals("key")) {
                 return "id";
             } else if (code.equals("id.text")) {
@@ -161,7 +172,7 @@ public class MessageSourceConsentFunctionTest {
         }
 
         /** {@inheritDoc} */
-        public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException {
+        public @Nonnull String getMessage(@Nonnull String code, @Nullable Object[] args, @Nonnull Locale locale) throws NoSuchMessageException {
             if (code.equals("key")) {
                 return "id";
             } else if (code.equals("id.text")) {
@@ -171,10 +182,12 @@ public class MessageSourceConsentFunctionTest {
         }
 
         /** {@inheritDoc} */
-        public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
-            if (resolvable.getCodes()[0].equals("key")) {
+        public @Nonnull String getMessage(@Nonnull MessageSourceResolvable resolvable, @Nonnull Locale locale) throws NoSuchMessageException {
+            final String[] codes = resolvable.getCodes();
+            assert codes != null;
+            if (codes[0].equals("key")) {
                 return "id";
-            } else if (resolvable.getCodes()[0].equals("id.text")) {
+            } else if (codes[0].equals("id.text")) {
                 return "value";
             }
             throw new NoSuchMessageException("No such message");
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/storage/impl/CollectionSerializerTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/storage/impl/CollectionSerializerTest.java
index 0947508de..890e374a7 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/storage/impl/CollectionSerializerTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/storage/impl/CollectionSerializerTest.java
@@ -27,6 +27,7 @@ import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.logic.ConstraintViolationException;
 
 /** Unit tests for {@link CollectionSerializer}. */
@@ -34,14 +35,16 @@ import net.shibboleth.shared.logic.ConstraintViolationException;
 public class CollectionSerializerTest {
 
     protected CollectionSerializer serializer;
+    private Object nullObj;
 
     @BeforeMethod public void setUp() throws Exception {
         serializer = new CollectionSerializer();
         serializer.initialize();
     }
 
+    @SuppressWarnings({ "null", "unchecked" })
     @Test(expectedExceptions = ConstraintViolationException.class) public void testNull() throws Exception {
-        serializer.serialize(null);
+        serializer.serialize((Collection<String>) nullObj);
     }
 
     @Test public void testEmpty() throws Exception {
@@ -49,13 +52,14 @@ public class CollectionSerializerTest {
         Assert.assertEquals(serializer.deserialize(-1, "context", "key", "[]", null), Collections.emptyList());
     }
 
+    @SuppressWarnings("null")
     @Test public void testNullValue() throws Exception {
-        Assert.assertEquals(serializer.serialize(Collections.<String> singletonList(null)), "[]");
+        Assert.assertEquals(serializer.serialize(CollectionSupport.<String> singletonList((String)nullObj)), "[]");
         Assert.assertEquals(serializer.deserialize(-1, "context", "key", "[null]", null), Collections.emptyList());
     }
 
     @Test public void testSimple() throws IOException {
-        final Collection<String> collection = Arrays.asList("element1", "element2", "element3");
+        final Collection<String> collection = CollectionSupport.listOf("element1", "element2", "element3");
         final String serialized = serializer.serialize(collection);
         Assert.assertEquals(serialized, "[\"element1\",\"element2\",\"element3\"]");
         final Collection<String> deserialized = serializer.deserialize(-1, "context", "key", serialized, null);
diff --git a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/storage/impl/ConsentSerializerTest.java b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/storage/impl/ConsentSerializerTest.java
index 0b96bcc89..8b36fce91 100644
--- a/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/storage/impl/ConsentSerializerTest.java
+++ b/idp-consent-impl/src/test/java/net/shibboleth/idp/consent/storage/impl/ConsentSerializerTest.java
@@ -23,7 +23,9 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.function.Function;
 
-import javax.annotation.Nonnull;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
 
 import net.shibboleth.idp.attribute.IdPAttribute;
 import net.shibboleth.idp.attribute.IdPAttributeValue;
@@ -33,19 +35,10 @@ import net.shibboleth.idp.consent.logic.impl.AttributeValuesHashFunction;
 import net.shibboleth.shared.component.UnmodifiableComponentException;
 import net.shibboleth.shared.logic.ConstraintViolationException;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
 /** Unit tests for {@link ConsentSerializer}. */
 @SuppressWarnings("javadoc")
 public class ConsentSerializerTest {
 
-    /** Class logger. */
-    @Nonnull protected final Logger log = LoggerFactory.getLogger(ConsentSerializerTest.class);
-
     private static final String CONTEXT = "_context";
 
     private static final String KEY = "_key";
@@ -70,6 +63,8 @@ public class ConsentSerializerTest {
 
     protected Function<Collection<IdPAttributeValue>, String> attributeValuesHashFunction;
 
+    private Object nullObj;
+
     @BeforeMethod public void setUp() {
         serializer = new ConsentSerializer();
 
@@ -92,9 +87,10 @@ public class ConsentSerializerTest {
         consents.put(consent2.getId(), consent2);
     }
 
+    @SuppressWarnings({ "null", "unchecked" })
     @Test(expectedExceptions = ConstraintViolationException.class) public void testNull() throws Exception {
         serializer.initialize();
-        serializer.serialize(null);
+        serializer.serialize((Map<String, Consent>) nullObj);
     }
 
     @Test(expectedExceptions = ConstraintViolationException.class) public void testEmpty() throws Exception {
@@ -102,8 +98,9 @@ public class ConsentSerializerTest {
         serializer.serialize(new HashMap<String, Consent>());
     }
 
+    @SuppressWarnings({ "null", "unchecked" })
     @Test(expectedExceptions = ConstraintViolationException.class) public void testNullSymoblics() throws Exception {
-        serializer.setSymbolics(null);
+        serializer.setSymbolics((Map<String, Integer>) nullObj);
     }
 
     @Test(expectedExceptions = UnmodifiableComponentException.class) public void testMutatingSymoblics()

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


More information about the commits mailing list