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

Rod Widdowson rdw at steadingsoftware.com
Sat Feb 25 09:00:11 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=3c8cd14bd08af9b65247e6b8b64cea8c8d6f9ee8

commit 3c8cd14bd08af9b65247e6b8b64cea8c8d6f9ee8
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Fri Feb 24 18:14:19 2023 +0000

    IDP-2069 Null handling
    
    https://shibboleth.atlassian.net/browse/IDP-2069
    
    Cleanup idp-profile-impl tests.
---
 .../audit/impl/PopulateAuditContextTest.java       |  9 +--
 .../idp/profile/audit/impl/WriteAuditLogTest.java  |  4 +-
 .../tests/AbstractProfileConfigurationTest.java    |  5 +-
 .../SpringStatusMessageLookupFunctionTest.java     | 15 +++--
 .../profile/impl/AbstractProfileActionTest.java    |  6 +-
 .../ProfileActionBeanFactoryPostProcessorTest.java | 11 ++--
 .../impl/ProfileActionBeanPostProcessorTest.java   | 11 +++-
 .../impl/SelectProfileConfigurationTest.java       | 40 +++++++++----
 .../impl/SelectRelyingPartyConfigurationTest.java  | 65 +++++++++++++---------
 .../impl/FilterFlowsByNonBrowserSupportTest.java   |  5 ++
 .../PopulateProfileInterceptorContextTest.java     |  9 ++-
 .../impl/ProfileInterceptorFlowDescriptorTest.java | 11 +++-
 .../impl/SelectProfileInterceptorFlowTest.java     | 32 ++++++-----
 ...WriteProfileInterceptorResultToStorageTest.java | 34 +++++++----
 14 files changed, 165 insertions(+), 92 deletions(-)

diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/audit/impl/PopulateAuditContextTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/audit/impl/PopulateAuditContextTest.java
index b2185cc4b..7c5975ca4 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/audit/impl/PopulateAuditContextTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/audit/impl/PopulateAuditContextTest.java
@@ -31,6 +31,7 @@ import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileR
 import net.shibboleth.idp.profile.testing.ActionTestingSupport;
 import net.shibboleth.idp.profile.testing.RequestContextBuilder;
 import net.shibboleth.profile.context.AuditContext;
+import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.component.ComponentInitializationException;
 
 import org.springframework.webflow.execution.Event;
@@ -68,7 +69,7 @@ public class PopulateAuditContextTest {
         ActionTestingSupport.assertProceedEvent(event);
         
         final AuditContext ac = prc.getSubcontext(AuditContext.class);
-        Assert.assertNotNull(ac);
+        assert ac != null;
         Assert.assertEquals(ac.getFieldValues("a").size(), 1);
         Assert.assertEquals(ac.getFieldValues("a").iterator().next(), "foo");
         Assert.assertTrue(ac.getFieldValues("b").isEmpty());
@@ -86,7 +87,7 @@ public class PopulateAuditContextTest {
         ActionTestingSupport.assertProceedEvent(event);
         
         final AuditContext ac = prc.getSubcontext(AuditContext.class);
-        Assert.assertNotNull(ac);
+        assert ac != null;
         Assert.assertEquals(ac.getFieldValues("a").size(), 1);
         Assert.assertEquals(ac.getFieldValues("a").iterator().next(), "foo");
         Assert.assertTrue(ac.getFieldValues("b").isEmpty());
@@ -100,14 +101,14 @@ public class PopulateAuditContextTest {
         map.put("A", new MockFunction(Arrays.asList("bar", "baz")));
         
         action.setFieldExtractors(map);
-        action.setFormattingMapParser(new FormattingMapParser(Collections.singletonMap("foo", "%A - %b %%")));
+        action.setFormattingMapParser(new FormattingMapParser(CollectionSupport.singletonMap("foo", "%A - %b %%")));
         action.initialize();
         
         final Event event = action.execute(src);
         ActionTestingSupport.assertProceedEvent(event);
         
         final AuditContext ac = prc.getSubcontext(AuditContext.class);
-        Assert.assertNotNull(ac);
+        assert ac != null;
         Assert.assertTrue(ac.getFieldValues("a").isEmpty());
         Assert.assertTrue(ac.getFieldValues("b").isEmpty());
         Assert.assertEquals(ac.getFieldValues("A").size(), 2);
diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/audit/impl/WriteAuditLogTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/audit/impl/WriteAuditLogTest.java
index 63252183b..884a4c49e 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/audit/impl/WriteAuditLogTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/audit/impl/WriteAuditLogTest.java
@@ -104,7 +104,7 @@ public class WriteAuditLogTest {
     }
     
     @Test public void testTwo() throws ComponentInitializationException {
-        final AuditContext ac = prc.getSubcontext(AuditContext.class, true);
+        final AuditContext ac = prc.getOrCreateSubcontext(AuditContext.class);
         ac.getFieldValues("A").add("foo");
         ac.getFieldValues("B").add("bar");
         ac.getFieldValues("B").add("baz");
@@ -118,7 +118,7 @@ public class WriteAuditLogTest {
     }
 
     @Test public void testMissing() throws ComponentInitializationException {
-        final AuditContext ac = prc.getSubcontext(AuditContext.class, true);
+        final AuditContext ac = prc.getOrCreateSubcontext(AuditContext.class);
         ac.getFieldValues("A").add("foo");
         ac.getFieldValues("B").add("bar");
         ac.getFieldValues("B").add("baz");
diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/config/tests/AbstractProfileConfigurationTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/config/tests/AbstractProfileConfigurationTest.java
index 024ef1acb..0c3b72114 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/config/tests/AbstractProfileConfigurationTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/config/tests/AbstractProfileConfigurationTest.java
@@ -33,14 +33,17 @@ import java.util.List;
 /** Unit test for {@link AbstractProfileConfiguration}. */
 @SuppressWarnings("javadoc")
 public class AbstractProfileConfigurationTest {
+    
+    private Object nullObj;
 
+    @SuppressWarnings("null")
     @Test
     public void testProfileId() {
         MockProfileConfiguration config = new MockProfileConfiguration("mock");
         Assert.assertEquals(config.getId(), "mock");
 
         try {
-            config = new MockProfileConfiguration(null);
+            config = new MockProfileConfiguration((String) nullObj);
             Assert.fail();
         } catch (final ConstraintViolationException e) {
 
diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/context/navigate/tests/SpringStatusMessageLookupFunctionTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/context/navigate/tests/SpringStatusMessageLookupFunctionTest.java
index a74802878..f995c1520 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/context/navigate/tests/SpringStatusMessageLookupFunctionTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/context/navigate/tests/SpringStatusMessageLookupFunctionTest.java
@@ -19,6 +19,9 @@ package net.shibboleth.idp.profile.context.navigate.tests;
 
 import java.util.Locale;
 
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
 import org.opensaml.profile.context.ProfileRequestContext;
 
 import net.shibboleth.idp.profile.context.SpringRequestContext;
@@ -46,7 +49,7 @@ public class SpringStatusMessageLookupFunctionTest {
     @BeforeMethod public void setUp() throws ComponentInitializationException {
         springRequestContext = (MockRequestContext) new RequestContextBuilder().buildRequestContext();
         prc = (ProfileRequestContext) springRequestContext.getConversationScope().get(ProfileRequestContext.BINDING_KEY);
-        prc.getSubcontext(SpringRequestContext.class, true).setRequestContext(springRequestContext);
+        prc.getOrCreateSubcontext(SpringRequestContext.class).setRequestContext(springRequestContext);
     }
 
     @Test public void testMappedMessage() {
@@ -67,7 +70,7 @@ public class SpringStatusMessageLookupFunctionTest {
     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("Mappable")) {
                 return "Mapped";
             }
@@ -75,7 +78,7 @@ public class SpringStatusMessageLookupFunctionTest {
         }
 
         /** {@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("Mappable")) {
                 return "Mapped";
             }
@@ -83,8 +86,10 @@ public class SpringStatusMessageLookupFunctionTest {
         }
 
         /** {@inheritDoc} */
-        public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
-            if (resolvable.getCodes()[0].equals("Mappable")) {
+        public @Nonnull String getMessage(@Nonnull MessageSourceResolvable resolvable, @Nonnull Locale locale) throws NoSuchMessageException {
+            final String[] codes = resolvable.getCodes();
+            assert codes != null && codes.length >=1;
+            if (codes[0].equals("Mappable")) {
                 return "Mapped";
             }
             throw new NoSuchMessageException("No such message");
diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/AbstractProfileActionTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/AbstractProfileActionTest.java
index c04698439..82dc52df8 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/AbstractProfileActionTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/AbstractProfileActionTest.java
@@ -22,6 +22,8 @@ import net.shibboleth.idp.profile.testing.ActionTestingSupport;
 import net.shibboleth.idp.profile.testing.RequestContextBuilder;
 import net.shibboleth.shared.component.UninitializedComponentException;
 
+import javax.annotation.Nonnull;
+
 import org.opensaml.profile.context.PreviousEventContext;
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.springframework.webflow.execution.Event;
@@ -119,13 +121,13 @@ public class AbstractProfileActionTest {
 
         /** {@inheritDoc} */
         @Override
-        protected void doExecute(ProfileRequestContext profileRequestContext) {
+        protected void doExecute(@Nonnull ProfileRequestContext profileRequestContext) {
 
             executed = true;
             
             final PreviousEventContext<?> prevCtx = profileRequestContext.getSubcontext(PreviousEventContext.class, false);
             if (prevEvent != null) {
-                if (prevCtx == null || !prevCtx.getEvent().equals(prevEvent)) {
+                if (prevCtx == null || !prevEvent.equals(prevCtx.getEvent())) {
                     org.opensaml.profile.action.ActionSupport.buildEvent(profileRequestContext, "InvalidPreviousEvent");
                     return;
                 }
diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/ProfileActionBeanFactoryPostProcessorTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/ProfileActionBeanFactoryPostProcessorTest.java
index 52506e80a..22caf93d2 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/ProfileActionBeanFactoryPostProcessorTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/ProfileActionBeanFactoryPostProcessorTest.java
@@ -17,6 +17,7 @@
 
 package net.shibboleth.idp.profile.impl;
 
+import org.springframework.context.ApplicationContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
 import org.testng.Assert;
@@ -30,10 +31,12 @@ import net.shibboleth.shared.annotation.Prototype;
 public class ProfileActionBeanFactoryPostProcessorTest extends AbstractTestNGSpringContextTests {
 
     @Test public void testPostProcessBeanFactory() {
-        Assert.assertTrue(applicationContext.isPrototype("MockIdPActionWithoutScopeProperty"));
-        Assert.assertTrue(applicationContext.isPrototype("MockPrototypeAnnotatedIdPActionWithoutScopeProperty"));
-        Assert.assertTrue(applicationContext.isPrototype("MockOpenSAMLActionWithoutScopeProperty"));
-        Assert.assertTrue(applicationContext.isPrototype("MockPrototypeAnnotatedOpenSAMLActionWithoutScopeProperty"));
+        final ApplicationContext ac = applicationContext;
+        assert  ac != null;
+        Assert.assertTrue(ac.isPrototype("MockIdPActionWithoutScopeProperty"));
+        Assert.assertTrue(ac.isPrototype("MockPrototypeAnnotatedIdPActionWithoutScopeProperty"));
+        Assert.assertTrue(ac.isPrototype("MockOpenSAMLActionWithoutScopeProperty"));
+        Assert.assertTrue(ac.isPrototype("MockPrototypeAnnotatedOpenSAMLActionWithoutScopeProperty"));
     }
 
     public static class MockIdPAction extends net.shibboleth.idp.profile.AbstractProfileAction {
diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/ProfileActionBeanPostProcessorTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/ProfileActionBeanPostProcessorTest.java
index b1bd0a69d..91420353e 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/ProfileActionBeanPostProcessorTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/ProfileActionBeanPostProcessorTest.java
@@ -18,6 +18,7 @@
 package net.shibboleth.idp.profile.impl;
 
 import org.springframework.beans.factory.BeanCreationException;
+import org.springframework.context.ApplicationContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
 import org.testng.Assert;
@@ -31,17 +32,21 @@ import net.shibboleth.shared.component.ComponentInitializationException;
 public class ProfileActionBeanPostProcessorTest extends AbstractTestNGSpringContextTests {
 
     @Test public void testPostProcessAfterInitialization() {
-        Object bean = null;
+        final ApplicationContext ac = applicationContext;
+        assert  ac != null;
 
-        bean = applicationContext.getBean("IdPActionWithDefaultID");
+        Object bean = null;
+        
+        bean = ac.getBean("IdPActionWithDefaultID");
         Assert.assertFalse(bean instanceof WebFlowProfileActionAdaptor);
 
-        bean = applicationContext.getBean("OpenSAMLActionWithDefaultID");
+        bean = ac.getBean("OpenSAMLActionWithDefaultID");
         Assert.assertTrue(bean instanceof WebFlowProfileActionAdaptor);
         Assert.assertTrue(((WebFlowProfileActionAdaptor) bean).isInitialized());
     }
 
     @Test(expectedExceptions = BeanCreationException.class) public void testBeanCreationException() {
+        assert applicationContext!= null;
         applicationContext.getBean("OpenSAMLExceptionAction");
     }
 
diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/SelectProfileConfigurationTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/SelectProfileConfigurationTest.java
index ff593bfab..de76fa8c5 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/SelectProfileConfigurationTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/SelectProfileConfigurationTest.java
@@ -55,7 +55,9 @@ public class SelectProfileConfigurationTest {
     public void setUp() throws ComponentInitializationException {
         src = new RequestContextBuilder().buildRequestContext();
         prc = new WebflowRequestContextProfileRequestContextLookup().apply(src);
-        prc.getSubcontext(RelyingPartyContext.class).setProfileConfig(null);
+        final RelyingPartyContext rpCtx = prc.getSubcontext(RelyingPartyContext.class);
+        assert rpCtx != null;
+        rpCtx.setProfileConfig(null);
 
         action = new SelectProfileConfiguration();
         action.initialize();        
@@ -79,7 +81,9 @@ public class SelectProfileConfigurationTest {
      * @throws Exception if something goes wrong
      */
     @Test public void testNoRelyingPartyConfiguration() throws Exception {
-        prc.getSubcontext(RelyingPartyContext.class).setConfiguration(null);
+        final RelyingPartyContext rpCtx = prc.getSubcontext(RelyingPartyContext.class);
+        assert rpCtx != null;
+        rpCtx.setConfiguration(null);
 
         final Event event = action.execute(src);
         ActionTestingSupport.assertEvent(event, IdPEventIds.INVALID_RELYING_PARTY_CONFIG);
@@ -94,11 +98,13 @@ public class SelectProfileConfigurationTest {
         src = new RequestContextBuilder().setRelyingPartyProfileConfigurations(
                 Collections.<ProfileConfiguration>singleton(new MockProfileConfiguration("mock"))).buildRequestContext();
         prc = new WebflowRequestContextProfileRequestContextLookup().apply(src);
-        prc.getSubcontext(RelyingPartyContext.class).setProfileConfig(null);
+        final RelyingPartyContext rpCtx = prc.getSubcontext(RelyingPartyContext.class);
+        assert rpCtx != null;
+        rpCtx.setProfileConfig(null);
 
         final Event event = action.execute(src);
         ActionTestingSupport.assertEvent(event, IdPEventIds.INVALID_PROFILE_CONFIG);
-        Assert.assertNull(prc.getSubcontext(RelyingPartyContext.class).getProfileConfig());
+        Assert.assertNull(rpCtx.getProfileConfig());
     }
 
    /**
@@ -114,11 +120,13 @@ public class SelectProfileConfigurationTest {
        src = new RequestContextBuilder().setRelyingPartyProfileConfigurations(
                Collections.<ProfileConfiguration>singleton(new MockProfileConfiguration("mock"))).buildRequestContext();
        prc = new WebflowRequestContextProfileRequestContextLookup().apply(src);
-       prc.getSubcontext(RelyingPartyContext.class).setProfileConfig(null);
+       final RelyingPartyContext rpCtx = prc.getSubcontext(RelyingPartyContext.class);
+       assert rpCtx != null;
+       rpCtx.setProfileConfig(null);
 
        final Event event = action.execute(src);
        ActionTestingSupport.assertProceedEvent(event);
-       Assert.assertNull(prc.getSubcontext(RelyingPartyContext.class).getProfileConfig());
+       Assert.assertNull(rpCtx.getProfileConfig());
    }
 
     /**
@@ -130,15 +138,19 @@ public class SelectProfileConfigurationTest {
         src = new RequestContextBuilder().setRelyingPartyProfileConfigurations(
                 Collections.<ProfileConfiguration>singleton(new MockProfileConfiguration("mock"))).buildRequestContext();
         prc = new WebflowRequestContextProfileRequestContextLookup().apply(src);
-        prc.getSubcontext(RelyingPartyContext.class).setProfileConfig(null);
+        final RelyingPartyContext rpCtx = prc.getSubcontext(RelyingPartyContext.class);
+        assert rpCtx != null;
+        rpCtx.setProfileConfig(null);
 
         prc.setProfileId("mock");
 
         final Event event = action.execute(src);
         ActionTestingSupport.assertProceedEvent(event);
 
-        Assert.assertNotNull(prc.getSubcontext(RelyingPartyContext.class).getProfileConfig());
-        Assert.assertEquals(prc.getSubcontext(RelyingPartyContext.class).getProfileConfig().getId(), "mock");
+        final ProfileConfiguration pc = rpCtx.getProfileConfig();
+        assert pc != null;
+        
+        Assert.assertEquals(pc.getId(), "mock");
     }
     
     /**
@@ -150,7 +162,9 @@ public class SelectProfileConfigurationTest {
         src = new RequestContextBuilder().setRelyingPartyProfileConfigurations(
                 Collections.<ProfileConfiguration>singleton(new MockProfileConfiguration("mock"))).buildRequestContext();
         prc = new WebflowRequestContextProfileRequestContextLookup().apply(src);
-        prc.getSubcontext(RelyingPartyContext.class).setProfileConfig(null);
+        final RelyingPartyContext rpCtx = prc.getSubcontext(RelyingPartyContext.class);
+        assert rpCtx != null;
+        rpCtx.setProfileConfig(null);
 
         prc.setProfileId("new");
         prc.setLegacyProfileId("mock");
@@ -158,8 +172,10 @@ public class SelectProfileConfigurationTest {
         final Event event = action.execute(src);
         ActionTestingSupport.assertProceedEvent(event);
 
-        Assert.assertNotNull(prc.getSubcontext(RelyingPartyContext.class).getProfileConfig());
-        Assert.assertEquals(prc.getSubcontext(RelyingPartyContext.class).getProfileConfig().getId(), "mock");
+        final ProfileConfiguration pc = rpCtx.getProfileConfig();
+        assert pc != null;
+        
+        Assert.assertEquals(pc.getId(), "mock");
         Assert.assertEquals(prc.getProfileId(), "mock");
     }
 
diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/SelectRelyingPartyConfigurationTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/SelectRelyingPartyConfigurationTest.java
index 8f41942f3..339fb26f0 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/SelectRelyingPartyConfigurationTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/SelectRelyingPartyConfigurationTest.java
@@ -19,10 +19,18 @@ package net.shibboleth.idp.profile.impl;
 
 import java.time.Instant;
 import java.util.Collection;
-import java.util.Collections;
 
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.security.config.SecurityConfiguration;
+import org.opensaml.security.credential.Credential;
+import org.springframework.webflow.execution.Event;
+import org.springframework.webflow.execution.RequestContext;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
 import net.shibboleth.idp.profile.IdPEventIds;
 import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
 import net.shibboleth.idp.profile.testing.ActionTestingSupport;
@@ -30,6 +38,7 @@ import net.shibboleth.idp.profile.testing.RequestContextBuilder;
 import net.shibboleth.profile.context.RelyingPartyContext;
 import net.shibboleth.profile.relyingparty.RelyingPartyConfiguration;
 import net.shibboleth.profile.relyingparty.RelyingPartyConfigurationResolver;
+import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent;
 import net.shibboleth.shared.component.ComponentInitializationException;
 import net.shibboleth.shared.resolver.CriteriaSet;
@@ -37,14 +46,6 @@ import net.shibboleth.shared.resolver.ResolverException;
 import net.shibboleth.shared.service.ReloadableService;
 import net.shibboleth.shared.service.ServiceableComponent;
 
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.security.config.SecurityConfiguration;
-import org.opensaml.security.credential.Credential;
-import org.springframework.webflow.execution.Event;
-import org.springframework.webflow.execution.RequestContext;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
 /** {@link SelectRelyingPartyConfiguration} unit test. */
 public class SelectRelyingPartyConfigurationTest {
 
@@ -67,6 +68,7 @@ public class SelectRelyingPartyConfigurationTest {
     @Test public void testNoRelyingPartyContext() throws Exception {
         final RequestContext src = new RequestContextBuilder().buildRequestContext();
         final ProfileRequestContext prc = new WebflowRequestContextProfileRequestContextLookup().apply(src);
+        assert prc != null;
         prc.removeSubcontext(RelyingPartyContext.class);
 
         final SelectRelyingPartyConfiguration action = new SelectRelyingPartyConfiguration();
@@ -86,7 +88,10 @@ public class SelectRelyingPartyConfigurationTest {
     @Test public void testNoRelyingPartyConfiguration() throws Exception {
         final RequestContext src = new RequestContextBuilder().buildRequestContext();
         final ProfileRequestContext prc = new WebflowRequestContextProfileRequestContextLookup().apply(src);
-        prc.getSubcontext(RelyingPartyContext.class).setConfiguration(null);
+        assert prc != null;
+        final RelyingPartyContext rpCtx = prc.getSubcontext(RelyingPartyContext.class);
+        assert rpCtx != null;
+        rpCtx.setConfiguration(null);
 
         final SelectRelyingPartyConfiguration action = new SelectRelyingPartyConfiguration();
         action.setRelyingPartyConfigurationResolver(new MockResolver(null, null));
@@ -105,7 +110,10 @@ public class SelectRelyingPartyConfigurationTest {
     @Test public void testUnableToResolveRelyingPartyConfiguration() throws Exception {
         final RequestContext src = new RequestContextBuilder().buildRequestContext();
         final ProfileRequestContext prc = new WebflowRequestContextProfileRequestContextLookup().apply(src);
-        prc.getSubcontext(RelyingPartyContext.class).setConfiguration(null);
+        assert prc != null;
+        final RelyingPartyContext rpCtx = prc.getSubcontext(RelyingPartyContext.class);
+        assert rpCtx != null;
+        rpCtx.setConfiguration(null);
 
         final var config = new net.shibboleth.idp.profile.relyingparty.RelyingPartyConfiguration();
         config.setId("foo");
@@ -130,7 +138,10 @@ public class SelectRelyingPartyConfigurationTest {
     @Test public void testResolveRelyingPartyConfiguration() throws Exception {
         final RequestContext src = new RequestContextBuilder().buildRequestContext();
         final ProfileRequestContext prc = new WebflowRequestContextProfileRequestContextLookup().apply(src);
-        prc.getSubcontext(RelyingPartyContext.class).setConfiguration(null);
+        assert prc != null;
+        final RelyingPartyContext rpCtx = prc.getSubcontext(RelyingPartyContext.class);
+        assert rpCtx != null;
+        rpCtx.setConfiguration(null);
 
         final var config = new net.shibboleth.idp.profile.relyingparty.RelyingPartyConfiguration();
         config.setId("foo");
@@ -146,8 +157,9 @@ public class SelectRelyingPartyConfigurationTest {
 
         ActionTestingSupport.assertProceedEvent(event);
 
-        final RelyingPartyConfiguration resolvedConfig =
-                (RelyingPartyConfiguration) prc.getSubcontext(RelyingPartyContext.class).getConfiguration();
+        
+        final RelyingPartyConfiguration resolvedConfig = (RelyingPartyConfiguration) rpCtx.getConfiguration();
+        assert resolvedConfig != null;
         Assert.assertEquals(resolvedConfig.getId(), config.getId());
         Assert.assertEquals(((net.shibboleth.idp.profile.relyingparty.RelyingPartyConfiguration) resolvedConfig).getResponderId(prc),
                 config.getResponderId(prc));
@@ -161,7 +173,7 @@ public class SelectRelyingPartyConfigurationTest {
                     ServiceableComponent<RelyingPartyConfigurationResolver>, RelyingPartyConfigurationResolver {
 
         /** The relying party configuration to be returned. */
-        private RelyingPartyConfiguration configuration;
+        @Nullable RelyingPartyConfiguration configuration;
 
         /** Exception thrown by resolution attempts. */
         private ResolverException exception;
@@ -174,7 +186,7 @@ public class SelectRelyingPartyConfigurationTest {
          *            
          * @throws ComponentInitializationException 
          */
-        public MockResolver(@Nullable final RelyingPartyConfiguration relyingPartyConfiguration,
+        public MockResolver(@Nullable RelyingPartyConfiguration relyingPartyConfiguration,
                 @Nullable final ResolverException resolverException) throws ComponentInitializationException {
             configuration = relyingPartyConfiguration;
             exception = resolverException;
@@ -183,16 +195,17 @@ public class SelectRelyingPartyConfigurationTest {
         }
 
         /** {@inheritDoc} */
-        @Override public Iterable<RelyingPartyConfiguration> resolve(final CriteriaSet criteria)
+        @Override public @Nonnull Iterable<RelyingPartyConfiguration> resolve(final @Nullable CriteriaSet criteria)
                 throws ResolverException {
             if (exception != null) {
                 throw exception;
             }
-            return Collections.singleton(configuration);
+            assert configuration != null;
+            return CollectionSupport.singleton(configuration);
         }
 
         /** {@inheritDoc} */
-        @Override public RelyingPartyConfiguration resolveSingle(final CriteriaSet criteria)
+        @Override public RelyingPartyConfiguration resolveSingle(final @Nullable CriteriaSet criteria)
                 throws ResolverException {
             if (exception != null) {
                 throw exception;
@@ -201,20 +214,20 @@ public class SelectRelyingPartyConfigurationTest {
         }
 
         /** {@inheritDoc} */
-        @Override public SecurityConfiguration getDefaultSecurityConfiguration(String profileId) {
+        @Override public SecurityConfiguration getDefaultSecurityConfiguration(@Nonnull String profileId) {
             return null;
         }
 
         /** {@inheritDoc} */
         @Override
-        public Collection<Credential> getSigningCredentials() {
-            return Collections.emptyList();
+        public @Nonnull Collection<Credential> getSigningCredentials() {
+            return CollectionSupport.emptyList();
         }
 
         /** {@inheritDoc} */
         @Override
-        public Collection<Credential> getEncryptionCredentials() {
-            return Collections.emptyList();
+        public @Nonnull Collection<Credential> getEncryptionCredentials() {
+            return CollectionSupport.emptyList();
         }
 
         /** {@inheritDoc} */
@@ -243,13 +256,13 @@ public class SelectRelyingPartyConfigurationTest {
 
         /** {@inheritDoc} */
         @Override
-        public ServiceableComponent<RelyingPartyConfigurationResolver> getServiceableComponent() {
+        public @Nonnull ServiceableComponent<RelyingPartyConfigurationResolver> getServiceableComponent() {
             return this;
         }
 
         /** {@inheritDoc} */
         @Override
-        public RelyingPartyConfigurationResolver getComponent() {
+        public @Nonnull RelyingPartyConfigurationResolver getComponent() {
             return this;
         }
 
diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/FilterFlowsByNonBrowserSupportTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/FilterFlowsByNonBrowserSupportTest.java
index cd22e1d88..94128a7bc 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/FilterFlowsByNonBrowserSupportTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/FilterFlowsByNonBrowserSupportTest.java
@@ -20,6 +20,8 @@ package net.shibboleth.idp.profile.interceptor.impl;
 import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
 import net.shibboleth.idp.profile.testing.ActionTestingSupport;
 
+import static org.testng.Assert.assertEquals;
+
 import org.springframework.webflow.execution.Event;
 import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
@@ -40,6 +42,7 @@ public class FilterFlowsByNonBrowserSupportTest extends PopulateProfileIntercept
 
     @Test public void testBrowserProfile() {
         final ProfileInterceptorContext interceptorCtx = prc.getSubcontext(ProfileInterceptorContext.class);
+        assert interceptorCtx != null;
         prc.setBrowserProfile(true);
 
         final Event event = action.execute(src);
@@ -49,6 +52,7 @@ public class FilterFlowsByNonBrowserSupportTest extends PopulateProfileIntercept
 
     @Test public void testNoFiltering() {
         final ProfileInterceptorContext interceptorCtx = prc.getSubcontext(ProfileInterceptorContext.class);
+        assert interceptorCtx != null;
 
         final Event event = action.execute(src);
         ActionTestingSupport.assertProceedEvent(event);
@@ -57,6 +61,7 @@ public class FilterFlowsByNonBrowserSupportTest extends PopulateProfileIntercept
 
     @Test public void testPartialFiltering() {
         final ProfileInterceptorContext interceptorCtx = prc.getSubcontext(ProfileInterceptorContext.class);
+        assert interceptorCtx != null;
         interceptorCtx.getAvailableFlows().get("intercept/test1").setNonBrowserSupported(false);
 
         final Event event = action.execute(src);
diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/PopulateProfileInterceptorContextTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/PopulateProfileInterceptorContextTest.java
index e3388451d..8c2e5468c 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/PopulateProfileInterceptorContextTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/PopulateProfileInterceptorContextTest.java
@@ -22,12 +22,15 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
+import javax.annotation.Nonnull;
+
 import net.shibboleth.idp.profile.IdPEventIds;
 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.ActionTestingSupport;
 import net.shibboleth.idp.profile.testing.RequestContextBuilder;
+import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.logic.FunctionSupport;
 
 import org.opensaml.profile.context.ProfileRequestContext;
@@ -40,7 +43,7 @@ import org.testng.annotations.Test;
 /** {@link PopulateProfileInterceptorContext} unit test. */
 public class PopulateProfileInterceptorContextTest {
 
-    protected List<ProfileInterceptorFlowDescriptor> interceptorFlows;
+    @Nonnull protected List<ProfileInterceptorFlowDescriptor> interceptorFlows = CollectionSupport.emptyList();
 
     protected RequestContext src;
 
@@ -55,7 +58,7 @@ public class PopulateProfileInterceptorContextTest {
         src = new RequestContextBuilder().buildRequestContext();
         prc = new WebflowRequestContextProfileRequestContextLookup().apply(src);
 
-        interceptorFlows = List.of(new ProfileInterceptorFlowDescriptor(), new ProfileInterceptorFlowDescriptor(),
+        interceptorFlows = CollectionSupport.listOf(new ProfileInterceptorFlowDescriptor(), new ProfileInterceptorFlowDescriptor(),
                         new ProfileInterceptorFlowDescriptor());
         interceptorFlows.get(0).setId("intercept/test1");
         interceptorFlows.get(1).setId("intercept/test2");
@@ -78,7 +81,7 @@ public class PopulateProfileInterceptorContextTest {
      */
     @Test public void testAction() throws Exception {
         final ProfileInterceptorContext interceptorContext = prc.getSubcontext(ProfileInterceptorContext.class);
-        Assert.assertNotNull(interceptorContext);
+        assert interceptorContext != null;
         final List<ProfileInterceptorFlowDescriptor> availableFlows =
                 List.copyOf(interceptorContext.getAvailableFlows().values());
         Assert.assertEquals(availableFlows.size(), 3);
diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/ProfileInterceptorFlowDescriptorTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/ProfileInterceptorFlowDescriptorTest.java
index 61474f633..997c37b82 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/ProfileInterceptorFlowDescriptorTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/ProfileInterceptorFlowDescriptorTest.java
@@ -21,8 +21,10 @@ import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileR
 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.PredicateSupport;
 
 import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.storage.StorageService;
 import org.springframework.webflow.execution.RequestContext;
 import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
@@ -39,6 +41,8 @@ public class ProfileInterceptorFlowDescriptorTest {
     private RequestContext src;
 
     private ProfileRequestContext prc;
+    
+    private Object nullObj;
 
     @BeforeMethod public void setUp() throws Exception {
         descriptor = new ProfileInterceptorFlowDescriptor();
@@ -58,13 +62,14 @@ public class ProfileInterceptorFlowDescriptorTest {
     @Test(expectedExceptions = UnmodifiableComponentException.class)
     public void testUnmodifiableActivationCondition() throws Exception {
         descriptor.initialize();
-        descriptor.setActivationCondition(Predicates.<ProfileRequestContext> alwaysFalse());
+        descriptor.setActivationCondition(PredicateSupport.<ProfileRequestContext> alwaysFalse());
     }
 
+    @SuppressWarnings("null")
     @Test(expectedExceptions = UnmodifiableComponentException.class)
     public void testUnmodifiableStorageService() throws Exception {
         descriptor.initialize();
-        descriptor.setStorageService(null);
+        descriptor.setStorageService((StorageService) nullObj);
     }
 
     @Test(expectedExceptions = UnmodifiableComponentException.class)
@@ -84,7 +89,7 @@ public class ProfileInterceptorFlowDescriptorTest {
     }
 
     @Test public void testMutatingPredicate() throws Exception {
-        descriptor.setActivationCondition(Predicates.<ProfileRequestContext> alwaysFalse());
+        descriptor.setActivationCondition(PredicateSupport.<ProfileRequestContext> alwaysFalse());
         descriptor.initialize();
 
         Assert.assertFalse(descriptor.test(prc));
diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/SelectProfileInterceptorFlowTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/SelectProfileInterceptorFlowTest.java
index 919b4a114..910b78ce5 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/SelectProfileInterceptorFlowTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/SelectProfileInterceptorFlowTest.java
@@ -17,17 +17,16 @@
 
 package net.shibboleth.idp.profile.interceptor.impl;
 
-import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
-import net.shibboleth.idp.profile.interceptor.ProfileInterceptorFlowDescriptor;
-import net.shibboleth.idp.profile.testing.ActionTestingSupport;
-
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.springframework.webflow.execution.Event;
 import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import com.google.common.base.Predicates;
+import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
+import net.shibboleth.idp.profile.interceptor.ProfileInterceptorFlowDescriptor;
+import net.shibboleth.idp.profile.testing.ActionTestingSupport;
+import net.shibboleth.shared.logic.PredicateSupport;
 
 /** {@link SelectProfileInterceptorFlow} unit test. */
 @SuppressWarnings("javadoc")
@@ -49,33 +48,36 @@ public class SelectProfileInterceptorFlowTest extends PopulateProfileInterceptor
     @Test public void testSelect() {
 
         final Event event = action.execute(src);
+        assert event != null;
         ActionTestingSupport.assertEvent(event, ProfileInterceptorFlowDescriptor.FLOW_ID_PREFIX + "test1");
 
-        Assert.assertEquals(interceptorCtx.getAttemptedFlow(),
-                interceptorCtx.getAvailableFlows().get(ProfileInterceptorFlowDescriptor.FLOW_ID_PREFIX + "test1"));
-        Assert.assertEquals(interceptorCtx.getAttemptedFlow().getId(), event.getId());
+        final ProfileInterceptorFlowDescriptor flow =interceptorCtx.getAttemptedFlow();
+        assert flow != null && flow.equals(interceptorCtx.getAvailableFlows().get(ProfileInterceptorFlowDescriptor.FLOW_ID_PREFIX + "test1"));
+        Assert.assertEquals(flow.getId(), event.getId());
     }
 
     @Test public void testIncompleteFlows() {
         action.execute(src);
         final Event event = action.execute(src);
+        assert event != null;
         ActionTestingSupport.assertEvent(event, ProfileInterceptorFlowDescriptor.FLOW_ID_PREFIX + "test2");
 
-        Assert.assertEquals(interceptorCtx.getAttemptedFlow(),
-                interceptorCtx.getAvailableFlows().get(ProfileInterceptorFlowDescriptor.FLOW_ID_PREFIX + "test2"));
-        Assert.assertEquals(interceptorCtx.getAttemptedFlow().getId(), event.getId());
+        final ProfileInterceptorFlowDescriptor flow =interceptorCtx.getAttemptedFlow();
+        assert flow != null && flow.equals(interceptorCtx.getAvailableFlows().get(ProfileInterceptorFlowDescriptor.FLOW_ID_PREFIX + "test2"));
+        Assert.assertEquals(flow.getId(), event.getId());
     }
 
     @Test public void testPredicate() {
         interceptorCtx.getAvailableFlows().get(ProfileInterceptorFlowDescriptor.FLOW_ID_PREFIX + "test1")
-                .setActivationCondition(Predicates.<ProfileRequestContext> alwaysFalse());
+                .setActivationCondition(PredicateSupport.<ProfileRequestContext> alwaysFalse());
 
         final Event event = action.execute(src);
+        assert event != null;
         ActionTestingSupport.assertEvent(event, ProfileInterceptorFlowDescriptor.FLOW_ID_PREFIX + "test2");
 
-        Assert.assertEquals(interceptorCtx.getAttemptedFlow(),
-                interceptorCtx.getAvailableFlows().get(ProfileInterceptorFlowDescriptor.FLOW_ID_PREFIX + "test2"));
-        Assert.assertEquals(interceptorCtx.getAttemptedFlow().getId(), event.getId());
+        final ProfileInterceptorFlowDescriptor flow =interceptorCtx.getAttemptedFlow();
+        assert flow != null && flow.equals(interceptorCtx.getAvailableFlows().get(ProfileInterceptorFlowDescriptor.FLOW_ID_PREFIX + "test2"));
+        Assert.assertEquals(flow.getId(), event.getId());
     }
 
 }
\ No newline at end of file
diff --git a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/WriteProfileInterceptorResultToStorageTest.java b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/WriteProfileInterceptorResultToStorageTest.java
index 85a0f4cda..f04637ee8 100644
--- a/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/WriteProfileInterceptorResultToStorageTest.java
+++ b/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/interceptor/impl/WriteProfileInterceptorResultToStorageTest.java
@@ -78,7 +78,8 @@ public class WriteProfileInterceptorResultToStorageTest {
 
     @Test public void testNoAttemptedFlow() {
         prc.addSubcontext(new ProfileInterceptorContext(), true);
-        Assert.assertNull(prc.getSubcontext(ProfileInterceptorContext.class).getAttemptedFlow());
+        final ProfileInterceptorContext ctx = prc.getSubcontext(ProfileInterceptorContext.class);
+        assert ctx != null && ctx.getAttemptedFlow() == null;
 
         final Event event = action.execute(src);
 
@@ -86,8 +87,11 @@ public class WriteProfileInterceptorResultToStorageTest {
     }
 
     @Test public void testNoStorageService() {
-        prc.getSubcontext(ProfileInterceptorContext.class).setAttemptedFlow(new ProfileInterceptorFlowDescriptor());
-        Assert.assertNull(prc.getSubcontext(ProfileInterceptorContext.class).getAttemptedFlow().getStorageService());
+        final ProfileInterceptorContext ctx = prc.getSubcontext(ProfileInterceptorContext.class);
+        assert ctx != null;
+        ctx.setAttemptedFlow(new ProfileInterceptorFlowDescriptor());
+        final ProfileInterceptorFlowDescriptor flow = ctx.getAttemptedFlow();
+        assert flow != null && flow.getStorageService()==null;
 
         final Event event = action.execute(src);
 
@@ -96,14 +100,16 @@ public class WriteProfileInterceptorResultToStorageTest {
 
     @Test public void testCreateStorageRecord() throws Exception {
         final MockProfileInterceptorResult result = new MockProfileInterceptorResult("context", "key", "value", null);
-        prc.getSubcontext(ProfileInterceptorContext.class).getResults().add(result);
+        final ProfileInterceptorContext ctx = prc.getSubcontext(ProfileInterceptorContext.class);
+        assert ctx != null;
+        ctx. getResults().add(result);
 
         final Event event = action.execute(src);
 
         ActionTestingSupport.assertProceedEvent(event);
 
         final StorageRecord<?> storageRecord = ss.read("context", "key");
-        Assert.assertNotNull(storageRecord);
+        assert storageRecord != null;
         Assert.assertEquals(storageRecord.getValue(), "value");
         Assert.assertEquals(storageRecord.getExpiration(), null);
     }
@@ -112,14 +118,16 @@ public class WriteProfileInterceptorResultToStorageTest {
         final Instant expiration = Instant.now().plusSeconds(60);
         final MockProfileInterceptorResult result =
                 new MockProfileInterceptorResult("context", "key", "value", expiration);
-        prc.getSubcontext(ProfileInterceptorContext.class).getResults().add(result);
+        final ProfileInterceptorContext ctx = prc.getSubcontext(ProfileInterceptorContext.class);
+        assert ctx != null;
+        ctx.getResults().add(result);
 
         final Event event = action.execute(src);
 
         ActionTestingSupport.assertProceedEvent(event);
 
         final StorageRecord<?> storageRecord = ss.read("context", "key");
-        Assert.assertNotNull(storageRecord);
+        assert storageRecord != null;
         Assert.assertEquals(storageRecord.getValue(), "value");
         Assert.assertEquals(storageRecord.getExpiration(), Long.valueOf(expiration.toEpochMilli()));
     }
@@ -127,27 +135,29 @@ public class WriteProfileInterceptorResultToStorageTest {
     @Test public void testUpdateStorageRecord() throws Exception {
         final Instant expiration = Instant.now().plusSeconds(60);
         MockProfileInterceptorResult result = new MockProfileInterceptorResult("context", "key", "value", null);
-        prc.getSubcontext(ProfileInterceptorContext.class).getResults().add(result);
+        final ProfileInterceptorContext ctx = prc.getSubcontext(ProfileInterceptorContext.class);
+        assert ctx != null;
+        ctx.getResults().add(result);
 
         Event event = action.execute(src);
 
         ActionTestingSupport.assertProceedEvent(event);
 
         StorageRecord<?> storageRecord = ss.read("context", "key");
-        Assert.assertNotNull(storageRecord);
+        assert storageRecord != null;
         Assert.assertEquals(storageRecord.getValue(), "value");
         Assert.assertEquals(storageRecord.getExpiration(), null);
 
         result = new MockProfileInterceptorResult("context", "key", "value2", expiration);
-        prc.getSubcontext(ProfileInterceptorContext.class).getResults().clear();
-        prc.getSubcontext(ProfileInterceptorContext.class).getResults().add(result);
+        ctx.getResults().clear();
+        ctx.getResults().add(result);
 
         event = action.execute(src);
 
         ActionTestingSupport.assertProceedEvent(event);
 
         storageRecord = ss.read("context", "key");
-        Assert.assertNotNull(storageRecord);
+        assert storageRecord != null;
         Assert.assertEquals(storageRecord.getValue(), "value2");
         Assert.assertEquals(storageRecord.getExpiration(), Long.valueOf(expiration.toEpochMilli()));
     }

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


More information about the commits mailing list