### Question:
GitCredentialServiceImpl implements GitCredentialService { @Override public ExploratoryGitCredsDTO getGitCredentials(String user) { log.debug("Loading GIT creds for user {}", user); try { return gitCredsDAO.findGitCreds(user, CLEAR_USER_PASSWORD); } catch (Exception t) { log.error("Cannot load list of GIT creds for user: {}", user, t); throw new DlabException(String.format("Cannot load GIT credentials for user %s: %s", user, t.getLocalizedMessage()), t); } }  @Override void updateGitCredentials(UserInfo userInfo, ExploratoryGitCredsDTO formDTO); @Override ExploratoryGitCredsDTO getGitCredentials(String user);  }### Answer:
@Test public void getGitCredentials() { ExploratoryGitCredsDTO expectedEgcDto = new ExploratoryGitCredsDTO(); when(gitCredsDAO.findGitCreds(anyString(), anyBoolean())).thenReturn(expectedEgcDto); ExploratoryGitCredsDTO actualEgcDto = gitCredentialService.getGitCredentials(USER); assertNotNull(actualEgcDto); assertEquals(expectedEgcDto, actualEgcDto); verify(gitCredsDAO).findGitCreds(USER, true); verifyNoMoreInteractions(gitCredsDAO); }
@Test public void getGitCredentialsWhenMethodFindGitCredsThrowsException() { doThrow(new NullPointerException()).when(gitCredsDAO).findGitCreds(anyString(), anyBoolean()); try { gitCredentialService.getGitCredentials(USER); } catch (DlabException e) { assertEquals("Cannot load GIT credentials for user test: null", e.getMessage()); } verify(gitCredsDAO).findGitCreds(USER, true); verifyNoMoreInteractions(gitCredsDAO); }