### Question:
DefaultAuthenticationTypeAccessor implements AuthenticationTypeAccessor { @Override public Optional<AuthenticationTypeDetails> getAuthenticationTypeDetails(AuthenticationType authenticationType) { Optional<AuthenticationTypeEntity> authenticationTypeEntity = authenticationTypeRepository.findById(authenticationType.getId()); return authenticationTypeEntity.map(entity -> new AuthenticationTypeDetails(entity.getId(), entity.getName())); } @Autowired  DefaultAuthenticationTypeAccessor(AuthenticationTypeRepository authenticationTypeRepository); @Override Optional<AuthenticationTypeDetails> getAuthenticationTypeDetails(AuthenticationType authenticationType); @Override Optional<AuthenticationType> getAuthenticationType(Long id);  }### Answer:
@Test public void getAuthenticationTypeDetailsTest() { AuthenticationTypeRepository authenticationTypeRepository = Mockito.mock(AuthenticationTypeRepository.class); DefaultAuthenticationTypeAccessor authenticationTypeAccessor = new DefaultAuthenticationTypeAccessor(authenticationTypeRepository); AuthenticationTypeEntity authenticationTypeEntity = new AuthenticationTypeEntity("name-test"); Mockito.when(authenticationTypeRepository.findById(Mockito.any())).thenReturn(Optional.of(authenticationTypeEntity)); Optional<AuthenticationTypeDetails> testAuthenticationTypeDetails = authenticationTypeAccessor.getAuthenticationTypeDetails(AuthenticationType.DATABASE); assertTrue(testAuthenticationTypeDetails.isPresent()); AuthenticationTypeDetails authenticationTypeDetails = testAuthenticationTypeDetails.get(); assertEquals(authenticationTypeEntity.getName(), authenticationTypeDetails.getName()); assertEquals(authenticationTypeEntity.getId(), authenticationTypeDetails.getId()); }
@Test public void getAuthenticationTypeDetailsNullTest() { AuthenticationTypeRepository authenticationTypeRepository = Mockito.mock(AuthenticationTypeRepository.class); DefaultAuthenticationTypeAccessor authenticationTypeAccessor = new DefaultAuthenticationTypeAccessor(authenticationTypeRepository); Mockito.when(authenticationTypeRepository.findById(Mockito.any())).thenReturn(Optional.empty()); Optional<AuthenticationTypeDetails> testAuthenticationTypeDetails = authenticationTypeAccessor.getAuthenticationTypeDetails(AuthenticationType.DATABASE); assertFalse(testAuthenticationTypeDetails.isPresent()); }