@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()); }
@Override public Optional<AuthenticationTypeDetails> getAuthenticationTypeDetails(AuthenticationType authenticationType) { Optional<AuthenticationTypeEntity> authenticationTypeEntity = authenticationTypeRepository.findById(authenticationType.getId()); return authenticationTypeEntity.map(entity -> new AuthenticationTypeDetails(entity.getId(), entity.getName())); }
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())); } }
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); }
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); }
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);  }