### Question:
OAuthClientDetailsService { public OAuthClientDetails getOAuthClientDetails() { List<OAuthClientDetails> oauthClientDetails = Lists.newArrayList(oauthClientDetailsRepository.findAll()); if (!oauthClientDetails.isEmpty()) { return oauthClientDetails.get(0); } else { throw new EntityNotFoundException(); } }  void fillDefaultValues(OAuthClientDetails oauthClientDetails); void encodeClientSecret(OAuthClientDetails oauthClientDetails); OAuthClientDetails getOAuthClientDetails(); void updateOAuthClientDetails(OAuthClientDetails oauthClientDetails);  }### Answer:
@Test public void getOAuthClientDetails_expectOAuthClientDetails() { oauthClientDetails.setClientId("test"); oauthClientDetails.setClientSecret("testSecret"); oauthClientDetails.setAutoapprove("testApprove"); oauthClientDetails.setAdditionalInformation("testInformation"); oauthClientDetails.setAuthorities("testAuthorities"); oauthClientDetails.setAuthorizedGrantTypes("testGrants"); oauthClientDetails.setScope("testScope"); oauthClientDetails.setResourceIds("testResources"); oauthClientDetails.setWebServerRedirectUri("testUri"); oauthClientDetails.setAccessTokenValidity(50); oauthClientDetails.setRefreshTokenValidity(50); Iterable<OAuthClientDetails> iterable = Collections.singletonList(oauthClientDetails); when(oauthClientDetailsRepository.findAll()).thenReturn(iterable); OAuthClientDetails oauthClientDetailsFromService = oauthClientDetailsService.getOAuthClientDetails(); verify(oauthClientDetailsRepository).findAll(); assertEquals(oauthClientDetails.getClientId(), oauthClientDetails.getClientId()); assertEquals( oauthClientDetails.getRefreshTokenValidity(), oauthClientDetails.getRefreshTokenValidity()); assertEquals( oauthClientDetails.getAccessTokenValidity(), oauthClientDetails.getAccessTokenValidity()); assertEquals(oauthClientDetails.getClientSecret(), oauthClientDetails.getClientSecret()); assertEquals( oauthClientDetails.getAdditionalInformation(), oauthClientDetails.getAdditionalInformation()); assertEquals(oauthClientDetails.getAuthorities(), oauthClientDetails.getAuthorities()); assertEquals( oauthClientDetails.getAuthorizedGrantTypes(), oauthClientDetails.getAuthorizedGrantTypes()); assertEquals(oauthClientDetails.getAutoapprove(), oauthClientDetails.getAutoapprove()); assertEquals(oauthClientDetails.getResourceIds(), oauthClientDetails.getResourceIds()); assertEquals(oauthClientDetails.getScope(), oauthClientDetails.getScope()); assertEquals( oauthClientDetails.getWebServerRedirectUri(), oauthClientDetails.getWebServerRedirectUri()); }
@Test public void getOAuthClientDetails_expectException() { Iterable<OAuthClientDetails> iterable = Collections.emptyList(); when(oauthClientDetailsRepository.findAll()).thenReturn(iterable); try { oauthClientDetailsService.getOAuthClientDetails(); fail(); } catch (Exception e) { assertTrue(e instanceof EntityNotFoundException); } }