### Question:
CasAuthenticationProviderSecurityBuilder implements SecurityBuilder<CasAuthenticationProvider> { @Override public CasAuthenticationProvider build() { CasAuthenticationProvider provider; if (serviceResolutionMode == CasSecurityProperties.ServiceResolutionMode.DYNAMIC) { provider = new DynamicProxyCallbackUrlCasAuthenticationProvider(); } else { provider = new CasAuthenticationProvider(); } provider.setAuthenticationUserDetailsService(authenticationUserDetailsService); provider.setKey(key); provider.setTicketValidator(ticketValidator); if (messageSource != null) { provider.setMessageSource(messageSource); } if (statelessTicketCache != null) { provider.setStatelessTicketCache(statelessTicketCache); } if (grantedAuthoritiesMapper != null) { provider.setAuthoritiesMapper(grantedAuthoritiesMapper); } return provider; }  @Override CasAuthenticationProvider build();  }### Answer:
@Test public void build_Default_ResolutionModeStatic() { assertThat(builder.build()).isExactlyInstanceOf(CasAuthenticationProvider.class); }
@Test public void build_WithDynamicResolutionMode_InstanceOfDynamicProxyCallbackUrlCasAuthenticationProvider() { builder.serviceResolutionMode(CasSecurityProperties.ServiceResolutionMode.DYNAMIC); assertThat(builder.build()).isExactlyInstanceOf(DynamicProxyCallbackUrlCasAuthenticationProvider.class); }
@Test public void build_AnyParameters_InjectInsideCasAuthenticationProvider() { String key = "key"; AuthenticationUserDetailsService userDetailsService = Mockito.mock(AuthenticationUserDetailsService.class); GrantedAuthoritiesMapper grantedAuthoritiesMapper = Mockito.mock(GrantedAuthoritiesMapper.class); MessageSource messageSource = Mockito.mock(MessageSource.class); StatelessTicketCache statelessTicketCache = Mockito.mock(StatelessTicketCache.class); TicketValidator ticketValidator = Mockito.mock(TicketValidator.class); builder.key(key) .authenticationUserDetailsService(userDetailsService) .grantedAuthoritiesMapper(grantedAuthoritiesMapper) .messageSource(messageSource) .statelessTicketCache(statelessTicketCache) .ticketValidator(ticketValidator); assertThat(builder.build()) .extracting("key", "authenticationUserDetailsService", "authoritiesMapper", "statelessTicketCache", "ticketValidator") .usingElementComparator((Comparator<Object>) (o1, o2) -> (o1 == o2) ? 0 : -1) .containsOnly(key, userDetailsService, grantedAuthoritiesMapper, statelessTicketCache, ticketValidator); assertThat(builder.build()).hasFieldOrPropertyWithValue("messages.messageSource", messageSource); }