src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
DefaultClientIDLookupFunction implements ContextDataLookupFunction<MessageContext, ClientID> { @Override public ClientID apply(@Nullable MessageContext input) { if (input == null) { return null; } Object message = input.getMessage(); if (!(message instanceof AuthenticationRequest)) { return null; } return ((Authenticat...
@SuppressWarnings("unchecked") @Test public void testNullInput() { Assert.assertNull(lookup.apply(null)); ctx.setMessage(null); Assert.assertNull(lookup.apply(null)); } @Test public void testSuccess() { Assert.assertEquals(new ClientID("000123"), lookup.apply(ctx)); }
UserInfoRequestClientIDLookupFunction implements ContextDataLookupFunction<MessageContext, ClientID> { @Override public ClientID apply(@Nullable MessageContext input) { if (input == null) { return null; } if (!(input.getParent() instanceof ProfileRequestContext)) { return null; } MessageContext msgCtx = ((ProfileReques...
@SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testNullInput() { lookup = new UserInfoRequestClientIDLookupFunction(); Assert.assertNull(lookup.apply(null)); oidcCtx.setTokenClaimsSet(null); Assert.assertNull(lookup.apply(prc.getInboundMessageContext())); prc.getOutboundMessageContext().removeSubcontext...
DefaultValidRedirectUrisLookupFunction implements ContextDataLookupFunction<ProfileRequestContext, Set<URI>> { @Override @Nullable public Set<URI> apply(@Nullable final ProfileRequestContext input) { if (input == null || input.getInboundMessageContext() == null) { return null; } OIDCMetadataContext ctx = input.getInbou...
@Test public void testSuccess() { Assert.assertNotNull(lookup.apply(prc)); } @SuppressWarnings("unchecked") @Test public void testNoInput() { Assert.assertNull(lookup.apply(null)); ctx.setClientInformation(null); Assert.assertNull(lookup.apply(prc)); prc.getInboundMessageContext().removeSubcontext(OIDCMetadataContext.c...
OIDCAuthenticationResponseContextLookupFunction implements ContextDataLookupFunction<ProfileRequestContext, OIDCAuthenticationResponseContext> { @Override @Nullable public OIDCAuthenticationResponseContext apply(@Nullable final ProfileRequestContext input) { if (input == null || input.getOutboundMessageContext() == nul...
@Test public void testSuccess() { Assert.assertNotNull(lookup.apply(prc)); } @SuppressWarnings("unchecked") @Test public void testNoInput() { Assert.assertNull(lookup.apply(null)); prc.getOutboundMessageContext().removeSubcontext(OIDCAuthenticationResponseContext.class); Assert.assertNull(lookup.apply(prc)); prc.setOut...
FilesystemMetadataValueResolver extends AbstractFileOIDCEntityResolver<Identifier, Object> implements RefreshableMetadataValueResolver { @Override public Object resolveSingle(ProfileRequestContext profileRequestContext) throws ResolverException { return resolve(profileRequestContext).iterator().next(); } FilesystemMeta...
@Test public void testString() throws Exception { final FilesystemMetadataValueResolver resolver = initTests("/org/geant/idpextension/oidc/metadata/impl/dyn-value1.json"); final Object value = resolver.resolveSingle(null); Assert.assertNotNull(value); Assert.assertTrue(value instanceof String); Assert.assertEquals(valu...
DefaultResponseClaimsSetLookupFunction implements ContextDataLookupFunction<ProfileRequestContext, ClaimsSet> { @Override @Nullable public ClaimsSet apply(@Nullable final ProfileRequestContext input) { if (input == null || input.getOutboundMessageContext() == null) { return null; } OIDCAuthenticationResponseContext ctx...
@Test public void testSuccess() { Assert.assertEquals("sub", (String) lookup.apply(prc).getClaim("sub")); } @SuppressWarnings("unchecked") @Test public void testNoInput() { Assert.assertNull(lookup.apply(null)); oidcCtx.setIDToken(null); Assert.assertNull(lookup.apply(prc)); prc.getOutboundMessageContext().removeSubcon...
TokenRequestClientIDLookupFunction implements ContextDataLookupFunction<MessageContext, ClientID> { @Override public ClientID apply(@Nullable MessageContext input) { if (input == null) { return null; } Object message = input.getMessage(); if (!(message instanceof AbstractOptionallyAuthenticatedRequest)) { return null; ...
@SuppressWarnings("unchecked") @Test public void testNullInput() { Assert.assertNull(lookup.apply(null)); ctx.setMessage(new String("totallynotmessage")); Assert.assertNull(lookup.apply(null)); ctx.setMessage(null); Assert.assertNull(lookup.apply(null)); } @Test public void testSuccess() { Assert.assertEquals(new Clien...
ValidatedRedirectURILookupFunction implements ContextDataLookupFunction<ProfileRequestContext, URI> { @Override @Nullable public URI apply(@Nullable final ProfileRequestContext input) { if (input == null || input.getOutboundMessageContext() == null) { return null; } OIDCAuthenticationResponseContext ctx = input.getOutb...
@SuppressWarnings("unchecked") @Test public void testNoInput() { Assert.assertNull(lookup.apply(null)); oidcCtx.setRedirectURI(null); Assert.assertNull(lookup.apply(prc)); prc.getOutboundMessageContext().removeSubcontext(OIDCAuthenticationResponseContext.class); Assert.assertNull(lookup.apply(prc)); prc.setOutboundMess...
DefaultAuthTimeLookupFunction implements ContextDataLookupFunction<ProfileRequestContext, Long> { @Override @Nullable public Long apply(@Nullable final ProfileRequestContext input) { if (input == null) { return null; } AuthenticationContext authCtx = input.getSubcontext(AuthenticationContext.class, false); if (authCtx ...
@Test public void testSuccess() { Assert.assertEquals(instant.getTime(), (long) lookup.apply(prc)); } @Test public void testNoCtxts() { Assert.assertNull(lookup.apply(null)); authCtx.setAuthenticationResult(null); Assert.assertNull(lookup.apply(prc)); prc.removeSubcontext(AuthenticationContext.class); Assert.assertNull...
ProfileResponderIdLookupFunction extends AbstractIdentifiableInitializableComponent implements ContextDataLookupFunction<ProfileRequestContext, String> { @Override @Nullable public String apply(@Nullable final ProfileRequestContext input) { if (profileResponders.containsKey(input.getProfileId())) { return profileRespon...
@Test public void testSuccess() throws ComponentInitializationException { prc.setProfileId("unknown"); Assert.assertEquals(lookup.apply(prc), "defaultvalue"); prc.setProfileId("id1"); Assert.assertEquals(lookup.apply(prc), "value1"); prc.setProfileId("id2"); Assert.assertEquals(lookup.apply(prc), "value2"); }
AbstractTokenClaimsLookupFunction implements ContextDataLookupFunction<ProfileRequestContext, T> { @Override @Nullable public T apply(@Nullable final ProfileRequestContext input) { if (input == null || input.getOutboundMessageContext() == null) { return null; } OIDCAuthenticationResponseContext oidcResponseContext = in...
@Test public void testSubjectSuccess() { Assert.assertEquals("subject", mock.apply(prc)); } @Test public void testNoCtxts() { Assert.assertNull(mock.apply(null)); prc.setOutboundMessageContext(null); Assert.assertNull(mock.apply(prc)); prc.setOutboundMessageContext(new MessageContext()); Assert.assertNull(mock.apply(pr...
DefaultOIDCMetadataContextLookupFunction implements ContextDataLookupFunction<ProfileRequestContext, OIDCMetadataContext> { @Override @Nullable public OIDCMetadataContext apply(@Nullable final ProfileRequestContext input) { if (input == null || input.getInboundMessageContext() == null) { return null; } return i...
@Test public void testSuccess() { OIDCMetadataContext ctx = lookup.apply(prc); Assert.assertNotNull(ctx); } @Test public void testNoMetadataCtx() { prc.getInboundMessageContext().removeSubcontext(OIDCMetadataContext.class); Assert.assertNull(lookup.apply(prc)); } @SuppressWarnings("unchecked") @Test public void testNoM...
RevocationCache extends AbstractIdentifiableInitializableComponent { public void setStorage(@Nonnull final StorageService storageService) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); storage = Constraint.isNotNull(storageService, "StorageService cannot be null"); final StorageCapabilities...
@Test public void testInit() { revocationCache = new RevocationCache(); try { revocationCache.setStorage(null); Assert.fail("Null StorageService should have caused constraint violation"); } catch (Exception e) { } try { revocationCache.setStorage(new ClientStorageService()); Assert.fail("ClientStorageService should hav...
RevocationCache extends AbstractIdentifiableInitializableComponent { @Duration public void setEntryExpiration(@Positive @Duration final long entryExpiration) { expires = Constraint.isGreaterThan(0, entryExpiration, "revocation cache entry expiration must be greater than 0"); } RevocationCache(); @Duration void setEntry...
@Test (expectedExceptions = ConstraintViolationException.class) public void testExpirationSetter() throws ComponentInitializationException { revocationCache.setEntryExpiration(0); }
RevocationCache extends AbstractIdentifiableInitializableComponent { @NonnullAfterInit public StorageService getStorage() { return storage; } RevocationCache(); @Duration void setEntryExpiration(@Positive @Duration final long entryExpiration); @NonnullAfterInit StorageService getStorage(); void setStorage(@Nonnull fina...
@Test public void testStorageGetter() throws ComponentInitializationException { Assert.assertEquals(storageService, revocationCache.getStorage()); }
JSONSuccessResponse implements SuccessResponse { @Override public HTTPResponse toHTTPResponse() { HTTPResponse httpResponse = new HTTPResponse(HTTPResponse.SC_OK); httpResponse.setContentType(CommonContentTypes.APPLICATION_JSON); if (cacheControl != null) { httpResponse.setCacheControl(cacheControl); } if (pragma != nu...
@Test public void testSuccess() throws ParseException { response = new JSONSuccessResponse(content, "no-store", "no-cache"); HTTPResponse httpResponse = response.toHTTPResponse(); Assert.assertEquals(HTTPResponse.SC_OK, httpResponse.getStatusCode()); Assert.assertEquals("application/json; charset=UTF-8", httpResponse.g...
StorageServiceClientInformationManager extends BaseStorageServiceClientInformationComponent implements ClientInformationManager { @Override public void storeClientInformation(final OIDCClientInformation clientInformation, final Long expiration) throws ClientInformationManagerException { log.debug("Attempting to store c...
@Test public void testStore() throws Exception { final OIDCClientInformation clientInformation = initializeInformation(); manager.storeClientInformation(clientInformation, null); final CriteriaSet criteria = initializeCriteria(); final OIDCClientInformation result = resolver.resolveSingle(criteria); Assert.assertNotNul...
OIDCCoreProtocolConfiguration extends AbstractOIDCFlowAwareProfileConfiguration implements InitializableComponent, AuthenticationProfileConfiguration { public void setResolveAttributes(final boolean resolve) { resolveAttributes = resolve; } OIDCCoreProtocolConfiguration(); OIDCCoreProtocolConfiguration(@Nonnull @NotEm...
@Test void testsetResolveAttributes() { Assert.assertTrue(config.isResolveAttributes()); config.setResolveAttributes(false); Assert.assertFalse(config.isResolveAttributes()); }
OIDCCoreProtocolConfiguration extends AbstractOIDCFlowAwareProfileConfiguration implements InitializableComponent, AuthenticationProfileConfiguration { public void setDefaultAuthenticationMethods(@Nonnull @NonnullElements final List<Principal> contexts) { Constraint.isNotNull(contexts, "List of contexts cannot be null"...
@Test void testsetDefaultAuthenticationMethods() { Assert.assertTrue(config.getDefaultAuthenticationMethods().isEmpty()); List<Principal> principals = new ArrayList<Principal>(); principals.add(new AuthenticationMethodPrincipal("value")); config.setDefaultAuthenticationMethods(principals); Assert.assertTrue( config.get...
OIDCCoreProtocolConfiguration extends AbstractOIDCFlowAwareProfileConfiguration implements InitializableComponent, AuthenticationProfileConfiguration { @Duration public void setRefreshTokenLifetime(@Positive @Duration final long lifetime) { refreshTokenLifetime = Constraint.isGreaterThan(0, lifetime, "refresh token lif...
@Test void testsetRefreshTokenLifetime() { config.setRefreshTokenLifetimeLookupStrategy(null); config.setRefreshTokenLifetime(100); Assert.assertEquals(config.getRefreshTokenLifetime(), 100); }
OIDCCoreProtocolConfiguration extends AbstractOIDCFlowAwareProfileConfiguration implements InitializableComponent, AuthenticationProfileConfiguration { @Duration public void setAccessTokenLifetime(@Positive @Duration final long lifetime) { accessTokenLifetime = Constraint.isGreaterThan(0, lifetime, "access token lifeti...
@Test void testsetAccessTokenLifetime() { config.setAccessTokenLifetime(100); Assert.assertEquals(config.getAccessTokenLifetime(), 100); }
AuthenticationContextClassReferencePrincipal implements CloneablePrincipal { @Override public AuthenticationContextClassReferencePrincipal clone() throws CloneNotSupportedException { final AuthenticationContextClassReferencePrincipal copy = (AuthenticationContextClassReferencePrincipal) super.clone(); copy.authnContext...
@Test public void testClone() throws CloneNotSupportedException { Assert.assertEquals(principal, principal.clone()); }
OIDCCoreProtocolConfiguration extends AbstractOIDCFlowAwareProfileConfiguration implements InitializableComponent, AuthenticationProfileConfiguration { @Duration public void setAuthorizeCodeLifetime(@Positive @Duration final long lifetime) { authorizeCodeLifetime = Constraint.isGreaterThan(0, lifetime, "authorize code ...
@Test void testsetAuthorizeCodeLifetime() { config.setAuthorizeCodeLifetime(100); Assert.assertEquals(config.getAuthorizeCodeLifetime(), 100); }
OIDCCoreProtocolConfiguration extends AbstractOIDCFlowAwareProfileConfiguration implements InitializableComponent, AuthenticationProfileConfiguration { @Duration public void setIDTokenLifetime(@Positive @Duration final long lifetime) { idTokenLifetime = Constraint.isGreaterThan(0, lifetime, "id token lifetime must be g...
@Test void testsetIDTokenLifetime() { config.setIDTokenLifetime(100); Assert.assertEquals(config.getIDTokenLifetime(), 100); }
OIDCCoreProtocolConfiguration extends AbstractOIDCFlowAwareProfileConfiguration implements InitializableComponent, AuthenticationProfileConfiguration { public void setAcrRequestAlwaysEssential(boolean isAlways) { acrRequestAlwaysEssential = isAlways; } OIDCCoreProtocolConfiguration(); OIDCCoreProtocolConfiguration(@No...
@Test void testsetAcrRequestAlwaysEssential() { Assert.assertFalse(config.getAcrRequestAlwaysEssential()); config.setAcrRequestAlwaysEssential(true); Assert.assertTrue(config.getAcrRequestAlwaysEssential()); }
OIDCCoreProtocolConfiguration extends AbstractOIDCFlowAwareProfileConfiguration implements InitializableComponent, AuthenticationProfileConfiguration { public void setAdditionalAudiencesForIdToken( @Nonnull @NonnullElements @NotLive @Unmodifiable Collection<String> audiences) { Constraint.isNotNull(audiences, "Collecti...
@Test void testsetAdditionalAudiencesForIdToken() { Assert.assertTrue(config.getAdditionalAudiencesForIdToken().isEmpty()); Collection<String> audiences = new ArrayList<String>(); audiences.add("value"); config.setAdditionalAudiencesForIdToken(audiences); Assert.assertTrue(config.getAdditionalAudiencesForIdToken().cont...
OIDCCoreProtocolConfiguration extends AbstractOIDCFlowAwareProfileConfiguration implements InitializableComponent, AuthenticationProfileConfiguration { public void setAuthenticationFlows(@Nonnull @NonnullElements final Collection<String> flows) { Constraint.isNotNull(flows, "Collection of flows cannot be null"); authen...
@Test void testsetAuthenticationFlows() { Assert.assertTrue(config.getAuthenticationFlows().isEmpty()); Collection<String> flows = new ArrayList<String>(); flows.add("value"); config.setAuthenticationFlows(flows); Assert.assertTrue(config.getAuthenticationFlows().contains("value")); }
OIDCCoreProtocolConfiguration extends AbstractOIDCFlowAwareProfileConfiguration implements InitializableComponent, AuthenticationProfileConfiguration { public void setPostAuthenticationFlows(@Nonnull @NonnullElements final Collection<String> flows) { Constraint.isNotNull(flows, "Collection of flows cannot be null"); po...
@Test void testsetPostAuthenticationFlows() { Assert.assertTrue(config.getPostAuthenticationFlows().isEmpty()); Collection<String> flows = new ArrayList<String>(); flows.add("value"); config.setPostAuthenticationFlows(flows); Assert.assertTrue(config.getPostAuthenticationFlows().contains("value")); }
SubjectActivationCondition implements Predicate<ProfileRequestContext> { @Override public boolean apply(ProfileRequestContext input) { final MessageContext outboundMessageCtx = input.getOutboundMessageContext(); if (outboundMessageCtx == null) { return true; } OIDCAuthenticationResponseContext oidcResponseContext = out...
@Test public void testSubjectExists() { Assert.assertFalse(lookup.apply(prc)); } @Test public void testNoSubject() { respCtx.setSubject(null); Assert.assertTrue(lookup.apply(prc)); } @Test public void testNoOIDCResponseCtx() { prc.getOutboundMessageContext().removeSubcontext(OIDCAuthenticationResponseContext.class); As...
AuthenticationContextClassReferencePrincipal implements CloneablePrincipal { @Override public String toString() { return MoreObjects.toStringHelper(this).add("authnContextClassReference", authnContextClassReference) .toString(); } AuthenticationContextClassReferencePrincipal( @Nonnull @NotEmpty @ParameterNa...
@Test public void testToString() { Assert.assertEquals(principal.toString(), "AuthenticationContextClassReferencePrincipal{authnContextClassReference=" + principal.getName() + "}"); }
AttributeResolutionSubjectLookupFunction extends AbstractIdentifiableInitializableComponent implements ContextDataLookupFunction<ProfileRequestContext, String> { @Override @Nullable public String apply(@Nullable final ProfileRequestContext input) { AttributeContext attributeCtx = attributeContextLookupStrategy.apply(in...
@Test public void testSuccess() throws ComponentInitializationException { Assert.assertEquals(lookup.apply(prc), "joe"); } @Test public void testNoAttributeCtx() throws ComponentInitializationException { prc.getSubcontext(RelyingPartyContext.class).removeSubcontext(AttributeContext.class); Assert.assertNull(lookup.appl...
AttributeResolutionSubjectLookupFunction extends AbstractIdentifiableInitializableComponent implements ContextDataLookupFunction<ProfileRequestContext, String> { public void setAttributeContextLookupStrategy( @Nonnull final Function<ProfileRequestContext, AttributeContext> strategy) { ComponentSupport.ifInitializedThro...
@Test(expectedExceptions = ConstraintViolationException.class) public void testFailNullStrategy() throws ComponentInitializationException { lookup = new AttributeResolutionSubjectLookupFunction(); lookup.setAttributeContextLookupStrategy(null); }
EncodeMessage extends AbstractProfileAction { public void setMessageEncoderFactory(@Nonnull final MessageEncoderFactory factory) { encoderFactory = Constraint.isNotNull(factory, "MessageEncoderFactory cannot be null"); } void setMessageEncoderFactory(@Nonnull final MessageEncoderFactory factory); void setMessageEncode...
@SuppressWarnings("unchecked") @Test public void testDecodeMessage() throws Exception { EncodeMessage action = new EncodeMessage(); action.setMessageEncoderFactory(new MockEncoderFactory()); action.initialize(); action.execute(profileCtx); ActionTestingSupport.assertProceedEvent(profileCtx); Assert.assertEquals(encoder...
SetSectorIdentifierForAttributeResolution extends AbstractOIDCAuthenticationRequestAction { public void setSectorIdentifierLookupStrategy(@Nonnull final Function<ProfileRequestContext, String> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); sectorIdentifierLookupStrategy = Constrai...
@Test(expectedExceptions = ConstraintViolationException.class) public void testNullStrategySectorIdentifier() { action = new SetSectorIdentifierForAttributeResolution(); action.setSectorIdentifierLookupStrategy(null); }
SetSectorIdentifierForAttributeResolution extends AbstractOIDCAuthenticationRequestAction { public void setSubjectTypeLookupStrategy(@Nonnull final Function<ProfileRequestContext, SubjectType> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); subjectTypeLookupStrategy = Constraint.is...
@Test(expectedExceptions = ConstraintViolationException.class) public void testNullStrategySubjectType() { action = new SetSectorIdentifierForAttributeResolution(); action.setSubjectTypeLookupStrategy(null); }
RevokeConsent extends AbstractOIDCResponseAction { public void setPromptLookupStrategy(@Nonnull final Function<ProfileRequestContext, Prompt> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); promptLookupStrategy = Constraint.isNotNull(strategy, "PromptLookupStrategy lookup strategy ...
@Test(expectedExceptions = ConstraintViolationException.class) public void testNullStrategy() throws NoSuchAlgorithmException, ComponentInitializationException { action = new RevokeConsent(); action.setPromptLookupStrategy(null); }
OIDCClientInformationEncryptionParametersResolver extends BasicEncryptionParametersResolver { @Override @Nullable public EncryptionParameters resolveSingle(@Nonnull final CriteriaSet criteria) throws ResolverException { Constraint.isNotNull(criteria, "CriteriaSet was null"); Constraint.isNotNull(criteria.get(Encryption...
@Test public void testIdTokenParameters() throws ResolverException { EncryptionParameters params = resolver.resolveSingle(criteria); Assert.assertEquals("RSA-OAEP-256", params.getKeyTransportEncryptionAlgorithm()); Assert.assertEquals("A192CBC-HS384", params.getDataEncryptionAlgorithm()); Assert.assertNotNull(params.ge...
InitializeAuthenticationContext extends AbstractOIDCAuthenticationRequestAction { public void setLoginHintLookupStrategy(@Nonnull final Function<ProfileRequestContext, String> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); loginHintLookupStrategy = Constraint.isNotNull(strategy, "...
@Test(expectedExceptions = ConstraintViolationException.class) public void testSetNullLoginHintLookupStrategy() throws Exception { action = new InitializeAuthenticationContext(); action.setLoginHintLookupStrategy(null); }
InitializeAuthenticationContext extends AbstractOIDCAuthenticationRequestAction { public void setPromptLookupStrategy(@Nonnull final Function<ProfileRequestContext, Prompt> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); promptLookupStrategy = Constraint.isNotNull(strategy, "Prompt...
@Test(expectedExceptions = ConstraintViolationException.class) public void testSetNullPromptLookupStrategy() throws Exception { action = new InitializeAuthenticationContext(); action.setPromptLookupStrategy(null); }
InitializeAuthenticationContext extends AbstractOIDCAuthenticationRequestAction { public void setMaxAgeLookupStrategy(@Nonnull final Function<ProfileRequestContext, Long> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); maxAgeLookupStrategy = Constraint.isNotNull(strategy, "MaxAgeLo...
@Test(expectedExceptions = ConstraintViolationException.class) public void testSetNullMaxAgeLookupStrategy() throws Exception { action = new InitializeAuthenticationContext(); action.setMaxAgeLookupStrategy(null); }
EncryptProcessedToken extends AbstractOIDCResponseAction { public void setEncryptionContextLookupStrategy( @Nonnull final Function<ProfileRequestContext, EncryptionContext> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); encryptionContextLookupStrategy = Constraint.isNotNull(strate...
@SuppressWarnings("rawtypes") @Test(expectedExceptions = UnmodifiableComponentException.class) public void testInitializationFail() { action.setEncryptionContextLookupStrategy( Functions.compose(new ChildContextLookup<>(EncryptionContext.class, false), new ChildContextLookup<ProfileRequestContext, RelyingPartyContext>(...
SetTokenDeliveryAttributesFromTokenToResponseContext extends AbstractOIDCResponseAction { public void setDeliveryClaimsLookupStrategy(@Nonnull final Function<ProfileRequestContext, ClaimsSet> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); deliveryClaimsLookupStrategy = Constraint....
@Test(expectedExceptions = ConstraintViolationException.class) public void testNullStrategyDClaims() { action = new SetTokenDeliveryAttributesFromTokenToResponseContext(); action.setDeliveryClaimsLookupStrategy(null); }
SetTokenDeliveryAttributesFromTokenToResponseContext extends AbstractOIDCResponseAction { public void setIDTokenDeliveryClaimsLookupStrategy( @Nullable final Function<ProfileRequestContext, ClaimsSet> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); idTokenDeliveryClaimsLookupStrate...
@Test public void testNullStrategyIDTokenDClaims() throws ComponentInitializationException, URISyntaxException { init(); action = new SetTokenDeliveryAttributesFromTokenToResponseContext(); action.setIDTokenDeliveryClaimsLookupStrategy(null); action.initialize(); final Event event = action.execute(requestCtx); ActionTe...
SetTokenDeliveryAttributesFromTokenToResponseContext extends AbstractOIDCResponseAction { public void setUserinfoDeliveryClaimsLookupStrategy( @Nullable final Function<ProfileRequestContext, ClaimsSet> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); userinfoDeliveryClaimsLookupStra...
@Test public void testNullStrategyUIDClaims() throws ComponentInitializationException, URISyntaxException { init(); action = new SetTokenDeliveryAttributesFromTokenToResponseContext(); action.setUserinfoDeliveryClaimsLookupStrategy(null); action.initialize(); final Event event = action.execute(requestCtx); ActionTestin...
InitializeUnverifiedRelyingPartyContext extends AbstractProfileAction { public void setRelyingPartyContextCreationStrategy( @Nonnull final Function<ProfileRequestContext, RelyingPartyContext> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); relyingPartyContextCreationStrategy = Cons...
@Test(expectedExceptions = ConstraintViolationException.class) public void testFailsNullRelyingPartyContextCreationStrategy() { action = new InitializeUnverifiedRelyingPartyContext(); action.setRelyingPartyContextCreationStrategy(null); }
PopulateOIDCEncryptionParameters extends AbstractProfileAction { public void setConfigurationLookupStrategy( @Nonnull final Function<ProfileRequestContext, List<EncryptionConfiguration>> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); configurationLookupStrategy = Constraint.isNotN...
@Test(expectedExceptions = ConstraintViolationException.class) public void testFailureNullStrategyConf() { action = new PopulateOIDCEncryptionParameters(); action.setConfigurationLookupStrategy(null); }
PopulateOIDCEncryptionParameters extends AbstractProfileAction { public void setEncryptionContextLookupStrategy( @Nonnull final Function<ProfileRequestContext, EncryptionContext> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); encryptionContextLookupStrategy = Constraint.isNotNull(...
@Test(expectedExceptions = ConstraintViolationException.class) public void testFailureNullStrategyEncrContext() { action = new PopulateOIDCEncryptionParameters(); action.setEncryptionContextLookupStrategy(null); }
PopulateOIDCEncryptionParameters extends AbstractProfileAction { public void setOIDCMetadataContextContextLookupStrategy( @Nonnull final Function<ProfileRequestContext, OIDCMetadataContext> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); oidcMetadataContextLookupStrategy = Constrai...
@Test(expectedExceptions = ConstraintViolationException.class) public void testFailureNullStrategyMetadataContext() { action = new PopulateOIDCEncryptionParameters(); action.setOIDCMetadataContextContextLookupStrategy(null); }
PopulateOIDCEncryptionParameters extends AbstractProfileAction { public void setEncryptionParametersResolver(@Nonnull final EncryptionParametersResolver newResolver) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); encParamsresolver = Constraint.isNotNull(newResolver, "EncryptionParametersRes...
@Test(expectedExceptions = ConstraintViolationException.class) public void testFailureNullStrategyEncrParamas() { action = new PopulateOIDCEncryptionParameters(); action.setEncryptionParametersResolver(null); }
InitializeRelyingPartyContext extends AbstractProfileAction { public void setOidcMetadataContextLookupStrategy( @Nonnull final Function<ProfileRequestContext, OIDCMetadataContext> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); oidcMetadataContextLookupStrategy = Constraint.isNotNu...
@Test(expectedExceptions = ConstraintViolationException.class) public void testFailsNullOidcMetadataContextLookupStrategy() { action = new InitializeRelyingPartyContext(); action.setOidcMetadataContextLookupStrategy(null); }
InitializeRelyingPartyContext extends AbstractProfileAction { public void setClientIDLookupStrategy(@Nonnull final Function<MessageContext, ClientID> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); clientIDLookupStrategy = Constraint.isNotNull(strategy, "ClientIDLookupStrategy look...
@Test(expectedExceptions = ConstraintViolationException.class) public void testFailsNullClientIDLookupStrategy() { action = new InitializeRelyingPartyContext(); action.setClientIDLookupStrategy(null); }
InitializeRelyingPartyContext extends AbstractProfileAction { public void setRelyingPartyContextCreationStrategy( @Nonnull final Function<ProfileRequestContext, RelyingPartyContext> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); relyingPartyContextCreationStrategy = Constraint.isN...
@Test(expectedExceptions = ConstraintViolationException.class) public void testFailsNullRelyingPartyContextCreationStrategy() { action = new InitializeRelyingPartyContext(); action.setRelyingPartyContextCreationStrategy(null); }
FormOutboundDiscoveryResponse extends AbstractProfileAction { public void setMetadataResolver(final ProviderMetadataResolver resolver) { metadataResolver = Constraint.isNotNull(resolver, "The metadata resolver cannot be null!"); } FormOutboundDiscoveryResponse(); void setMetadataResolver(final ProviderMetadataResolver ...
@Test public void testStatic() throws Exception { action.setMetadataResolver(initMetadataResolver()); action.initialize(); ActionTestingSupport.assertProceedEvent(action.execute(requestCtx)); Assert.assertTrue(profileRequestCtx.getOutboundMessageContext().getMessage() instanceof JSONSuccessResponse); final JSONSuccessR...
CheckRedirectURIs extends AbstractProfileAction { protected boolean checkForbiddenHostname(final Set<URI> redirectURIs, final String hostname) { for (final URI redirectUri : redirectURIs) { if (hostname.equalsIgnoreCase(redirectUri.getHost())) { log.trace("{} Found forbidden {} as the hostname in the redirect URIs", ge...
@SuppressWarnings({"rawtypes", "unchecked"}) @Test public void testCheckForbiddenHostname() throws Exception { Assert.assertFalse(action.checkForbiddenHostname(new HashSet(Arrays.asList(new URI("custom.test:/testing"))), "testing")); Assert.assertTrue(action.checkForbiddenHostname(new HashSet(Arrays.asList(new URI("cus...
ValidateAccessToken extends AbstractOIDCUserInfoValidationResponseAction { public void setRevocationCache(@Nonnull final RevocationCache cache) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); revocationCache = Constraint.isNotNull(cache, "ReplayCache cannot be null"); } ValidateAccessToken(@...
@Test public void testFailsRevoked() throws NoSuchAlgorithmException, ComponentInitializationException, URISyntaxException, DataSealerException { action = new ValidateAccessToken(getDataSealer()); action.setRevocationCache(new MockRevocationCache(true, true)); action.initialize(); TokenClaimsSet claims = new AccessToke...
OIDCClientInformationSignatureSigningParametersResolver extends BasicSignatureSigningParametersResolver { @Nullable public SignatureSigningParameters resolveSingle(@Nonnull final CriteriaSet criteria) throws ResolverException { Constraint.isNotNull(criteria, "CriteriaSet was null"); Constraint.isNotNull(criteria.get(Si...
@Test public void testIdTokenParameters() throws ResolverException { SignatureSigningParameters params = resolver.resolveSingle(criteria); Assert.assertEquals(params.getSignatureAlgorithm(), "RS256"); Assert.assertTrue(params.getSigningCredential().getPrivateKey() instanceof RSAPrivateKey); } @Test public void testDefa...
AddScopeToClientMetadata extends AbstractOIDCClientMetadataPopulationAction { public void setDefaultScope(final Scope scope) { defaultScope = Constraint.isNotNull(scope, "The default scope cannot be null"); } AddScopeToClientMetadata(); void setDefaultScope(final Scope scope); Scope getDefaultScope(); }
@Test(expectedExceptions = ConstraintViolationException.class) public void testNullDefault() { action = new AddScopeToClientMetadata(); action.setDefaultScope(null); } @Test public void testNullScopeCustomDefault() throws ComponentInitializationException { action = new AddScopeToClientMetadata(); Scope defaultScope = n...
AddScopeToClientMetadata extends AbstractOIDCClientMetadataPopulationAction { public Scope getDefaultScope() { return defaultScope; } AddScopeToClientMetadata(); void setDefaultScope(final Scope scope); Scope getDefaultScope(); }
@Test public void testNullScope() throws ComponentInitializationException { OIDCClientMetadata input = new OIDCClientMetadata(); OIDCClientMetadata output = new OIDCClientMetadata(); setUpContext(input, output); Assert.assertNull(action.execute(requestCtx)); Assert.assertEquals(output.getScope(), action.getDefaultScope...
AddUserInfoShell extends AbstractOIDCResponseAction { public void setIssuerLookupStrategy(@Nonnull final Function<ProfileRequestContext, String> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); issuerLookupStrategy = Constraint.isNotNull(strategy, "IssuerLookupStrategy lookup strate...
@Test(expectedExceptions = ConstraintViolationException.class) public void testNullIssuerLookupStrategy() { action = new AddUserInfoShell(); action.setIssuerLookupStrategy(null); }
AddUserInfoShell extends AbstractOIDCResponseAction { public void setRelyingPartyContextLookupStrategy( @Nonnull final Function<ProfileRequestContext, RelyingPartyContext> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); relyingPartyContextLookupStrategy = Constraint.isNotNull(strat...
@Test(expectedExceptions = ConstraintViolationException.class) public void testNullRelyingPartyContextLookupStrategy() { action = new AddUserInfoShell(); action.setRelyingPartyContextLookupStrategy(null); }
AddUserInfoShell extends AbstractOIDCResponseAction { public void setUserInfoSigningAlgLookupStrategy(@Nonnull final Function<ProfileRequestContext, JWSAlgorithm> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); userInfoSigAlgStrategy = Constraint.isNotNull(strategy, "User Info Sign...
@Test(expectedExceptions = ConstraintViolationException.class) public void testNulltUserInfoSigningAlgLookupStrategy() { action = new AddUserInfoShell(); action.setUserInfoSigningAlgLookupStrategy(null); }
ValidateGrant extends AbstractOIDCTokenResponseAction { public void setReplayCache(@Nonnull final ReplayCache cache) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); replayCache = Constraint.isNotNull(cache, "ReplayCache cannot be null"); } ValidateGrant(@Nonnull @ParameterName(name = "sealer...
@Test(expectedExceptions = ConstraintViolationException.class) public void testNoRevocationCache() throws NoSuchAlgorithmException, ComponentInitializationException { action = new ValidateGrant(getDataSealer()); ReplayCache replayCache = new ReplayCache(); MemoryStorageService storageService = new MemoryStorageService(...
ValidateGrant extends AbstractOIDCTokenResponseAction { public void setRevocationCache(@Nonnull final RevocationCache cache) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); revocationCache = Constraint.isNotNull(cache, "ReplayCache cannot be null"); } ValidateGrant(@Nonnull @ParameterName(na...
@Test(expectedExceptions = ConstraintViolationException.class) public void testNoReplayCache() throws NoSuchAlgorithmException, ComponentInitializationException { action = new ValidateGrant(getDataSealer()); action.setRevocationCache(new MockRevocationCache(false, true)); action.initialize(); }
SetSubjectToResponseContext extends AbstractOIDCResponseAction { public void setSubjectLookupStrategy(@Nonnull final Function<ProfileRequestContext, String> strategy) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); subjectLookupStrategy = Constraint.isNotNull(strategy, "SubjectLookupStrategy...
@Test(expectedExceptions = ConstraintViolationException.class) public void testNoStrategy() throws NoSuchAlgorithmException, ComponentInitializationException { action = new SetSubjectToResponseContext(); action.setSubjectLookupStrategy(null); } @Test(expectedExceptions = UnmodifiableComponentException.class) public voi...
OIDCByteAttributeEncoder extends AbstractOIDCAttributeEncoder { @SuppressWarnings("rawtypes") @Override public JSONObject encode(IdPAttribute idpAttribute) throws AttributeEncodingException { Constraint.isNotNull(idpAttribute, "Attribute to encode cannot be null"); String attributeString = ""; JSONObject obj = new JSON...
@Test public void testEncodingNull() throws ComponentInitializationException, AttributeEncodingException { init(); boolean exceptionOccurred = false; try { encoder.encode(null); } catch (ConstraintViolationException e) { exceptionOccurred = true; } Assert.assertTrue(exceptionOccurred); } @Test public void testEncoding(...
OIDCStringAttributeEncoder extends AbstractOIDCAttributeEncoder { @Override public JSONObject encode(IdPAttribute idpAttribute) throws AttributeEncodingException { Constraint.isNotNull(idpAttribute, "Attribute to encode cannot be null"); log.debug("Encoding attribute {}", idpAttribute.getId()); JSONObject obj = new JSO...
@Test public void testEncodingNull() throws ComponentInitializationException, AttributeEncodingException { init(); boolean exceptionOccurred = false; try { encoder.encode(null); } catch (ConstraintViolationException e) { exceptionOccurred = true; } Assert.assertTrue(exceptionOccurred); } @Test public void testEncodingS...
OIDCScopedStringAttributeEncoder extends AbstractOIDCAttributeEncoder { @SuppressWarnings("rawtypes") @Override public JSONObject encode(IdPAttribute idpAttribute) throws AttributeEncodingException { Constraint.isNotNull(idpAttribute, "Attribute to encode cannot be null"); Constraint.isNotNull(scopeDelimiter, "Scope de...
@Test public void testEncodingNull() throws ComponentInitializationException, AttributeEncodingException { init(); boolean exceptionOccurred = false; try { encoder.encode(null); } catch (ConstraintViolationException e) { exceptionOccurred = true; } Assert.assertTrue(exceptionOccurred); } @Test public void testEncodingW...
AttributeInOIDCRequestedClaimsMatcher extends AbstractIdentifiableInitializableComponent implements Matcher { @SuppressWarnings("rawtypes") @Override public Set<IdPAttributeValue<?>> getMatchingValues(@Nonnull IdPAttribute attribute, @Nonnull AttributeFilterContext filtercontext) { ComponentSupport.ifNotInitializedThro...
@Test public void testNoEncoders() throws Exception { setUp(false, false); matcher.initialize(); attribute.setEncoders(null); Assert.assertNull(matcher.getMatchingValues(attribute, filtercontext)); } @SuppressWarnings("unchecked") @Test public void testFailNoMsgCtx() throws Exception { setUp(false, false); matcher.init...
CredentialMetadataValueResolver extends AbstractIdentifiableInitializableComponent implements MetadataValueResolver { @Override public Object resolveSingle(ProfileRequestContext profileRequestContext) throws ResolverException { Iterator<Object> iterator = resolve(profileRequestContext).iterator(); if (iterator.hasNext(...
@Test public void testRsa() throws Exception { final CredentialMetadataValueResolver resolver = initResolver("src/test/resources/org/geant/idpextension/oidc/metadata/impl/idp-signing-rs256.jwk"); final Object result = resolver.resolveSingle(profileRequestCtx); Assert.assertNotNull(result); System.out.println(result); A...
AttributeOIDCScopePolicyRule extends AbstractStringPolicyRule { @SuppressWarnings("rawtypes") @Override public Tristate matches(@Nonnull final AttributeFilterContext filterContext) { ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this); ProfileRequestContext profileRequestContext = new RecursiveT...
@Test public void testMatch() throws Exception { Assert.assertEquals(Tristate.TRUE, rule.matches(filtercontext)); } @Test public void testNoMatch() throws Exception { Scope scope = new Scope(); scope.add("openid"); scope.add("test_no_match"); authRespCtx.setScope(scope); Assert.assertEquals(Tristate.FALSE, rule.matches...
RefreshTokenClaimsSet extends TokenClaimsSet { public static RefreshTokenClaimsSet parse(String refreshTokenClaimsSet) throws ParseException { JWTClaimsSet atClaimsSet = JWTClaimsSet.parse(refreshTokenClaimsSet); verifyParsedClaims(VALUE_TYPE_RF, atClaimsSet); return new RefreshTokenClaimsSet(atClaimsSet); } RefreshTok...
@Test public void testSerialization() throws ParseException, DataSealerException { init(); RefreshTokenClaimsSet rfClaimsSet2 = RefreshTokenClaimsSet.parse(rfClaimsSet.serialize()); Assert.assertEquals(rfClaimsSet2.getACR(), acr.getValue()); RefreshTokenClaimsSet rfClaimsSet3 = RefreshTokenClaimsSet.parse(rfClaimsSet2....
AuthorizeCodeClaimsSet extends TokenClaimsSet { public static AuthorizeCodeClaimsSet parse(String authorizeCodeClaimsSet) throws ParseException { JWTClaimsSet acClaimsSet = JWTClaimsSet.parse(authorizeCodeClaimsSet); verifyParsedClaims(VALUE_TYPE_AC, acClaimsSet); return new AuthorizeCodeClaimsSet(acClaimsSet); } priva...
@Test public void testSerialization() throws ParseException, DataSealerException { init(); AuthorizeCodeClaimsSet acClaimsSet2 = AuthorizeCodeClaimsSet.parse(acClaimsSet.serialize()); Assert.assertEquals(acClaimsSet2.getACR(), acr.getValue()); AuthorizeCodeClaimsSet acClaimsSet3 = AuthorizeCodeClaimsSet.parse(acClaimsS...
AccessTokenClaimsSet extends TokenClaimsSet { public static AccessTokenClaimsSet parse(String accessTokenClaimsSet) throws ParseException { JWTClaimsSet atClaimsSet = JWTClaimsSet.parse(accessTokenClaimsSet); verifyParsedClaims(VALUE_TYPE_AT, atClaimsSet); return new AccessTokenClaimsSet(atClaimsSet); } AccessTokenClai...
@Test public void testSerialization() throws ParseException, DataSealerException { init(); AccessTokenClaimsSet acClaimsSet2 = AccessTokenClaimsSet.parse(atClaimsSet.serialize()); Assert.assertEquals(acClaimsSet2.getACR(), acr.getValue()); AccessTokenClaimsSet acClaimsSet3 = AccessTokenClaimsSet.parse(acClaimsSet2.seri...
ChaosMonkeyScheduler { public void reloadConfig() { String cronExpression = config.getRuntimeAssaultCronExpression(); boolean active = !"OFF".equals(cronExpression); if (currentTask != null) { Logger.info("Cancelling previous task"); currentTask.cancel(); currentTask = null; } if (active) { CronTask task = new CronTask...
@Test void shouldScheduleANewTaskAfterAnUpdate() { String schedule = "*/1 * * * * ?"; ScheduledTask oldTask = mock(ScheduledTask.class); ScheduledTask newTask = mock(ScheduledTask.class); when(config.getRuntimeAssaultCronExpression()).thenReturn(schedule); when(registrar.scheduleCronTask(any())).thenReturn(oldTask, new...
LatencyAssault implements ChaosMonkeyRequestAssault { @Override public void attack() { Logger.debug("Chaos Monkey - timeout"); atomicTimeoutGauge.set(determineLatency()); if (metricEventPublisher != null) { metricEventPublisher.publishMetricEvent(MetricType.LATENCY_ASSAULT); metricEventPublisher.publishMetricEvent(Metr...
@Test void threadSleepHasBeenCalled() { int latencyRangeStart = 100; int latencyRangeEnd = 200; TestLatencyAssaultExecutor executor = new TestLatencyAssaultExecutor(); when(assaultProperties.getLatencyRangeStart()).thenReturn(latencyRangeStart); when(assaultProperties.getLatencyRangeEnd()).thenReturn(latencyRangeEnd); ...
KillAppAssault implements ChaosMonkeyRuntimeAssault, ApplicationContextAware { @Override public void attack() { try { Logger.info("Chaos Monkey - I am killing your Application!"); if (metricEventPublisher != null) { metricEventPublisher.publishMetricEvent(MetricType.KILLAPP_ASSAULT); } int exit = SpringApplication.exit...
@Test void killsSpringBootApplication() { KillAppAssault killAppAssault = new KillAppAssault(null, metricsMock); killAppAssault.attack(); verify(mockAppender, times(2)).doAppend(captorLoggingEvent.capture()); assertEquals(Level.INFO, captorLoggingEvent.getAllValues().get(0).getLevel()); assertEquals(Level.INFO, captorL...
GreetingService { public String greet() { return "Greetings from the server side!"; } GreetingService( HelloRepo helloRepo, HelloRepoSearchAndSorting repoSearchAndSorting, HelloRepoJpa helloRepoJpa, HelloRepoAnnotation helloRepoAnnotation); String greet(); String greetFromRepo(); String greetFro...
@Test public void greet() { assertThat(greetingService.greet(), is("Greetings from the server side!")); }
GreetingService { public String greetFromRepo() { Hello databaseSide = helloRepo.save(new Hello(0, "Greetings from the database side")); return databaseSide.getMessage(); } GreetingService( HelloRepo helloRepo, HelloRepoSearchAndSorting repoSearchAndSorting, HelloRepoJpa helloRepoJpa, HelloRepoA...
@Test public void greetFromRepo() { String message = "message"; Hello saveObject = new Hello(0, message); when(helloRepoMock.save(any(Hello.class))).thenReturn(saveObject); assertThat(greetingService.greetFromRepo(), is(message)); verify(helloRepoMock, times(1)).save(any(Hello.class)); verifyNoMoreInteractions( helloRe...
GreetingService { public String greetFromRepoPagingSorting() { Hello databaseSide = repoSearchAndSorting.save( new Hello(0, "Greetings from the paging and sorting database side")); Optional<Hello> byId = repoSearchAndSorting.findById(databaseSide.getId()); return byId.orElse(new Hello(-99, "not found")).getMessage(); }...
@Test public void testPagingAndSorting() { String message = "message"; Hello saveObject = new Hello(0, message); when(helloRepoSearchAndSortingMock.save(any(Hello.class))).thenReturn(saveObject); when(helloRepoSearchAndSortingMock.findById(saveObject.getId())) .thenReturn(Optional.of(saveObject)); assertThat(greetingSe...
GreetingService { public String greetFromRepoJpa() { Hello databaseSide = helloRepoJpa.save(new Hello(0, "Greetings from the paging and sorting database side")); Optional<Hello> byId = helloRepoJpa.findById(databaseSide.getId()); return byId.orElse(new Hello(-99, "not found")).getMessage(); } GreetingService( Hel...
@Test public void testJpaRepo() { String message = "message"; Hello saveObject = new Hello(0, message); when(helloRepoJpaMock.save(any(Hello.class))).thenReturn(saveObject); when(helloRepoJpaMock.findById(saveObject.getId())).thenReturn(Optional.of(saveObject)); assertThat(greetingService.greetFromRepoJpa(), is(message...
GreetingService { public String greetFromRepoAnnotation() { Hello databaseSide = helloRepoAnnotation.save( new Hello(0, "Greetings from the paging and sorting database side")); Optional<Hello> byId = helloRepoAnnotation.findById(databaseSide.getId()); return byId.orElse(new Hello(-99, "not found")).getMessage(); } Gree...
@Test public void testAnnotationRepo() { String message = "message"; Hello saveObject = new Hello(0, message); when(helloRepoAnnotationMock.save(any(Hello.class))).thenReturn(saveObject); when(helloRepoAnnotationMock.findById(saveObject.getId())).thenReturn(Optional.of(saveObject)); assertThat(greetingService.greetFrom...
ExponentialMovingAverage { public static long predictNext(TreeMap<Integer, Long> laps) { float smoothing = (((float) 2) / (laps.size() + 1)); long previousEMA = laps.get(laps.firstKey()); Set<Integer> keys = laps.keySet(); for (Iterator<Integer> i = keys.iterator(); i.hasNext();) { Integer key = i.next(); previousEMA =...
@Test public void test() { TreeMap<Integer, Long> laps = new TreeMap<Integer, Long>(); laps.put(1, (long) 2227); laps.put(2, (long) 2219); laps.put(3, (long) 2208); laps.put(4, (long) 2217); laps.put(5, (long) 2213); laps.put(6, (long) 2223); laps.put(7, (long) 2243); laps.put(8, (long) 2224); laps.put(9, (long) 2229);...
MyService { @GET @Path("/helloworld") public String helloWorld() { return "Hello World!"; } @GET @Path("/helloworld") String helloWorld(); @GET @Path("/friends/{name}") Response getFriends(@PathParam("name") String name, @Context GraphDatabaseService db); @POST @Path("/permissions") Response permissions(String body, @...
@Test public void shouldRespondToHelloWorld() { assertEquals("Hello World!", service.helloWorld()); }
MyService { @GET @Path("/friends/{name}") public Response getFriends(@PathParam("name") String name, @Context GraphDatabaseService db) throws IOException { ExecutionEngine executionEngine = new ExecutionEngine(db); ExecutionResult result = executionEngine.execute("START person=node:Users(unique_id={n}) MATCH person-[:K...
@Test public void shouldQueryDbForFriends() throws IOException { Response response = service.getFriends("B", db); List list = objectMapper.readValue((String) response.getEntity(), List.class); assertEquals(new HashSet<String>(Arrays.asList("A", "C")), new HashSet<String>(list)); }
MyService { @POST @Path("/permissions") public Response permissions(String body, @Context GraphDatabaseService db) throws IOException { String[] splits = body.split(","); PermissionRequest ids = new PermissionRequest(splits[0], splits[1]); Set<String> documents = new HashSet<String>(); Set<Node> documentNodes = new Has...
@Test public void shouldRespondToPermissions() throws BadInputException, IOException { String ids = "A,DOC1 DOC2 DOC3 DOC4 DOC5 DOC6 DOC7"; Response response = service.permissions(ids, db); List list = objectMapper.readValue((String) response.getEntity(), List.class); assertEquals(new HashSet<String>(Arrays.asList("DOC...
InstructionLoader { void loadInstruction() { bannerComponentTree.loadInstruction(textView); } InstructionLoader(TextView textView, @NonNull BannerText bannerText); InstructionLoader(TextView textView, BannerComponentTree bannerComponentTree); }
@Test public void loadInstruction() { TextView textView = mock(TextView.class); BannerComponentTree bannerComponentTree = mock(BannerComponentTree.class); InstructionLoader instructionLoader = new InstructionLoader(textView, bannerComponentTree); instructionLoader.loadInstruction(); verify(bannerComponentTree).loadInst...
MapFpsDelegate implements OnTrackingModeChangedListener, OnTrackingModeTransitionListener { @Override public void onTransitionFinished(int trackingMode) { updateCameraTracking(trackingMode); } MapFpsDelegate(MapView mapView, MapBatteryMonitor batteryMonitor); @Override void onTrackingModeChanged(int trackingMode); @Ove...
@Test public void onTransitionFinished_resetFpsWhenNotTracking() { MapView mapView = mock(MapView.class); MapFpsDelegate delegate = new MapFpsDelegate(mapView, mock(MapBatteryMonitor.class)); delegate.onTransitionFinished(NavigationCamera.NAVIGATION_TRACKING_MODE_NONE); verify(mapView).setMaximumFps(eq(Integer.MAX_VALU...
MapFpsDelegate implements OnTrackingModeChangedListener, OnTrackingModeTransitionListener { @Override public void onTransitionCancelled(int trackingMode) { updateCameraTracking(trackingMode); } MapFpsDelegate(MapView mapView, MapBatteryMonitor batteryMonitor); @Override void onTrackingModeChanged(int trackingMode); @Ov...
@Test public void onTransitionCancelled_resetFpsWhenNotTracking() { MapView mapView = mock(MapView.class); MapFpsDelegate delegate = new MapFpsDelegate(mapView, mock(MapBatteryMonitor.class)); delegate.onTransitionCancelled(NavigationCamera.NAVIGATION_TRACKING_MODE_NONE); verify(mapView).setMaximumFps(eq(Integer.MAX_VA...
MapFpsDelegate implements OnTrackingModeChangedListener, OnTrackingModeTransitionListener { void updateEnabled(boolean isEnabled) { this.isEnabled = isEnabled; resetMaxFps(!isEnabled); } MapFpsDelegate(MapView mapView, MapBatteryMonitor batteryMonitor); @Override void onTrackingModeChanged(int trackingMode); @Override ...
@Test public void updateEnabledFalse_maxFpsReset() { MapView mapView = mock(MapView.class); MapFpsDelegate delegate = new MapFpsDelegate(mapView, mock(MapBatteryMonitor.class)); delegate.updateEnabled(false); mapView.setMaximumFps(eq(Integer.MAX_VALUE)); }
MapWayNameChangedListener implements OnWayNameChangedListener { @Override public void onWayNameChanged(@NonNull String wayName) { for (OnWayNameChangedListener listener : listeners) { listener.onWayNameChanged(wayName); } } MapWayNameChangedListener(List<OnWayNameChangedListener> listeners); @Override void onWayNameCha...
@Test public void onWayNameChanged_listenersAreUpdated() { List<OnWayNameChangedListener> listeners = new ArrayList<>(); OnWayNameChangedListener listener = mock(OnWayNameChangedListener.class); listeners.add(listener); MapWayNameChangedListener wayNameChangedListener = new MapWayNameChangedListener(listeners); String ...
MapPaddingAdjustor { void adjustLocationIconWith(@NonNull int[] customPadding) { this.customPadding = customPadding; updatePaddingWith(customPadding); } MapPaddingAdjustor(@NonNull MapView mapView, MapboxMap mapboxMap); MapPaddingAdjustor(MapboxMap mapboxMap, int[] defaultPadding); static final int BOTTOMSHEET_PADDI...
@Test public void adjustLocationIconWith_customPaddingIsSet() { MapboxMap mapboxMap = mock(MapboxMap.class); int[] defaultPadding = {0, 250, 0, 0}; int[] customPadding = {0, 0, 0, 0}; MapPaddingAdjustor paddingAdjustor = new MapPaddingAdjustor(mapboxMap, defaultPadding); paddingAdjustor.adjustLocationIconWith(customPad...
MapPaddingAdjustor { boolean isUsingDefault() { return customPadding == null; } MapPaddingAdjustor(@NonNull MapView mapView, MapboxMap mapboxMap); MapPaddingAdjustor(MapboxMap mapboxMap, int[] defaultPadding); static final int BOTTOMSHEET_PADDING_MULTIPLIER_PORTRAIT; static final int BOTTOMSHEET_PADDING_MULTIPLIER_L...
@Test public void isUsingDefault_trueWithoutCustomPadding() { MapboxMap mapboxMap = mock(MapboxMap.class); int[] defaultPadding = {0, 250, 0, 0}; MapPaddingAdjustor paddingAdjustor = new MapPaddingAdjustor(mapboxMap, defaultPadding); assertTrue(paddingAdjustor.isUsingDefault()); }
MapPaddingAdjustor { void updatePaddingWith(int[] padding) { mapboxMap.setPadding(padding[0], padding[1], padding[2], padding[3]); } MapPaddingAdjustor(@NonNull MapView mapView, MapboxMap mapboxMap); MapPaddingAdjustor(MapboxMap mapboxMap, int[] defaultPadding); static final int BOTTOMSHEET_PADDING_MULTIPLIER_PORTRA...
@Test public void updatePaddingWithZero_updatesMapToZeroPadding() { MapboxMap mapboxMap = mock(MapboxMap.class); int[] defaultPadding = {0, 250, 0, 0}; MapPaddingAdjustor paddingAdjustor = new MapPaddingAdjustor(mapboxMap, defaultPadding); paddingAdjustor.updatePaddingWith(new int[]{0, 0, 0, 0}); verify(mapboxMap).setP...
MapPaddingAdjustor { @NonNull int[] retrieveCurrentPadding() { return mapboxMap.getPadding(); } MapPaddingAdjustor(@NonNull MapView mapView, MapboxMap mapboxMap); MapPaddingAdjustor(MapboxMap mapboxMap, int[] defaultPadding); static final int BOTTOMSHEET_PADDING_MULTIPLIER_PORTRAIT; static final int BOTTOMSHEET_PADD...
@Test public void retrieveCurrentPadding_returnsCurrentMapPadding() { MapboxMap mapboxMap = mock(MapboxMap.class); int[] defaultPadding = {0, 250, 0, 0}; MapPaddingAdjustor paddingAdjustor = new MapPaddingAdjustor(mapboxMap, defaultPadding); paddingAdjustor.retrieveCurrentPadding(); verify(mapboxMap).getPadding(); }
MapLayerInteractor { void updateLayerVisibility(boolean isVisible, String layerIdentifier) { List<Layer> layers = mapboxMap.getStyle().getLayers(); updateLayerWithVisibility(layerIdentifier, layers, isVisible); } MapLayerInteractor(MapboxMap mapboxMap); }
@Test public void updateLayerVisibility_visibilityIsSet() { LineLayer anySymbolOrLineLayer = mock(LineLayer.class); when(anySymbolOrLineLayer.getSourceLayer()).thenReturn("any"); List<Layer> layers = buildLayerListWith(anySymbolOrLineLayer); MapboxMap map = mock(MapboxMap.class); when(map.getStyle()).thenReturn(mock(St...
UrlDensityMap extends SparseArray<String> { @NonNull public String get(String url) { return url + super.get(displayDensity); } UrlDensityMap(int displayDensity, @NonNull SdkVersionChecker sdkVersionChecker); @NonNull String get(String url); }
@Test public void checksAndroidLollipopMr1AndTwoHundredAndEightyDensityReturnsTwoXPngUrl() { int twoHundredAndEightyDensityDpi = 280; SdkVersionChecker lollipopMr1Checker = new SdkVersionChecker(22); UrlDensityMap urlDensityMap = new UrlDensityMap(twoHundredAndEightyDensityDpi, lollipopMr1Checker); String anyUrl = "any...
MapLayerInteractor { boolean isLayerVisible(String layerIdentifier) { List<Layer> layers = mapboxMap.getStyle().getLayers(); return findLayerVisibility(layerIdentifier, layers); } MapLayerInteractor(MapboxMap mapboxMap); }
@Test public void isLayerVisible_visibleReturnsTrue() { SymbolLayer anySymbolOrLineLayer = mock(SymbolLayer.class); when(anySymbolOrLineLayer.getSourceLayer()).thenReturn("any"); when(anySymbolOrLineLayer.getVisibility()).thenReturn(visibility(Property.VISIBLE)); List<Layer> layers = buildLayerListWith(anySymbolOrLineL...
WaynameFeatureFinder { @NonNull List<Feature> queryRenderedFeatures(@NonNull PointF point, String[] layerIds) { return mapboxMap.queryRenderedFeatures(point, layerIds); } WaynameFeatureFinder(MapboxMap mapboxMap); }
@Test public void queryRenderedFeatures_mapboxMapIsCalled() { MapboxMap mapboxMap = mock(MapboxMap.class); WaynameFeatureFinder featureFinder = new WaynameFeatureFinder(mapboxMap); PointF point = mock(PointF.class); String[] layerIds = {"id", "id"}; featureFinder.queryRenderedFeatures(point, layerIds); verify(mapboxMap...
NavigationSymbolManager { void addDestinationMarkerFor(@NonNull Point position) { if (destinationSymbol != null) { symbolManager.delete(destinationSymbol); markersSymbols.remove(destinationSymbol.getId()); } SymbolOptions options = createSymbolOptionsFor(position); destinationSymbol = createSymbolFrom(options); } Navig...
@Test public void addDestinationMarkerFor_symbolManagerAddsOptions() { SymbolManager symbolManager = mock(SymbolManager.class); Symbol symbol = buildSymbolWith(DEFAULT_SYMBOL_ID, DEFAULT_SYMBOL_ICON_IMAGE); when(symbolManager.create(any(SymbolOptions.class))).thenReturn(symbol); NavigationSymbolManager navigationSymbol...
NavigationSymbolManager { Symbol addCustomSymbolFor(@NonNull SymbolOptions options) { return createSymbolFrom(options); } NavigationSymbolManager(@NonNull SymbolManager symbolManager); }
@Test public void addCustomSymbolFor_symbolManagerCreatesSymbol() { Symbol symbol = buildSymbolWith(DEFAULT_SYMBOL_ID, DEFAULT_SYMBOL_ICON_IMAGE); SymbolOptions symbolOptions = mock(SymbolOptions.class); SymbolManager symbolManager = buildSymbolManager(symbolOptions, symbol); NavigationSymbolManager navigationSymbolMan...