CustomAuthorizerSecurityContextFactory extends AbstractSecurityContextFactory { @Override protected boolean isApplicable() { return getRawPrincipalIdSafe() != null; } protected  CustomAuthorizerSecurityContextFactory(GatewayRequest request);   }
@Test public void isApplicable_NoContextGiven_ShouldNotBeApplicable() { GatewayRequest request = mock(GatewayRequest.class); assertFalse(createSecurityContextFactory(request).isApplicable()); }
@Test public void isApplicable_NoAuthorizerDateGiven_ShouldNotBeApplicable() { GatewayRequestContext context = mock(GatewayRequestContext.class); when(context.getAuthorizer()).thenReturn(null); GatewayRequest request = mock(GatewayRequest.class); when(request.getRequestContext()).thenReturn(context); assertFalse(createSecurityContextFactory(request).isApplicable()); }
@Test public void isApplicable_ValidPrincipalIdGiven_ShouldBeApplicable() { GatewayRequest request = createRequestMock("principalId"); assertTrue(createSecurityContextFactory(request).isApplicable()); }
@Test public void isApplicable_InvalidPrincipalIdGiven_ShouldBeApplicable() { GatewayRequest request = createRequestMock(1); assertTrue(createSecurityContextFactory(request).isApplicable()); }