### Question:
InitService { public InitState setOAuthClientDetails(OAuthClientDetails oauthClientDetails) { isInitStateElseThrow(InitStateName.SET_OAUTH_CLIENT_DETAILS); oauthClientDetailsService.fillDefaultValues(oauthClientDetails); oauthConfigurationService.updateOAuthConfiguration(oauthClientDetails); oauthClientDetailsService.encodeClientSecret(oauthClientDetails); oauthClientDetailsService.updateOAuthClientDetails(oauthClientDetails); return nextInitState(); }  @EventListener(ApplicationReadyEvent.class) void onApplicationEvent(); InitState getInitState(); InitState saveInitState(InitState initState); boolean checkInitState(InitStateName initStateName); InitState setOAuthClientDetails(OAuthClientDetails oauthClientDetails); InitState setAdminUser(User adminUser, String password); InitState setAzureAdminUser(AdminUser adminUser);  }### Answer:
@Test public void setOAuthClientDetails_throwsExceptionWhenInWrongInitState() { initState.setInitState(InitStateName.INITIALIZED); initState.setId(1L); iterable = Collections.singletonList(initState); when(initStateRepository.findAll()).thenReturn(iterable); try { initService.setOAuthClientDetails(new OAuthClientDetails()); fail(); } catch (Exception e) { assertTrue(e instanceof InvalidInitStateException); } }
@Test public void setOAuthClientDetails_setsClientDetails() { initState.setInitState(InitStateName.SET_OAUTH_CLIENT_DETAILS); initState.setId(1L); iterable = Collections.singletonList(initState); when(initStateRepository.findAll()).thenReturn(iterable); try { OAuthClientDetails oauthClientDetails = new OAuthClientDetails(); initService.setOAuthClientDetails(oauthClientDetails); verify(oauthClientDetailsService).encodeClientSecret(oauthClientDetails); verify(oauthClientDetailsService).fillDefaultValues(oauthClientDetails); verify(oauthClientDetailsService).updateOAuthClientDetails(oauthClientDetails); verify(oauthConfigurationService).updateOAuthConfiguration(any()); } catch (Exception e) { fail(e.getClass().getName()); } }