CustomAuthorizerSecurityContextFactory extends AbstractSecurityContextFactory { @Override protected boolean isValid() { return getRawPrincipalIdSafe() instanceof String; } protected  CustomAuthorizerSecurityContextFactory(GatewayRequest request);   }
@Test public void isValid_ValidPrincipalIdGiven_ShouldBeValid() { GatewayRequest request = createRequestMock("principalId"); assertTrue(createSecurityContextFactory(request).isValid()); }
@Test public void isValid_InvalidPrincipalIdGiven_ShouldNotBeValid() { GatewayRequest request = createRequestMock(1); assertFalse(createSecurityContextFactory(request).isValid()); }