Skip to content

Commit

Permalink
[RW-706] fix integration test (#894)
Browse files Browse the repository at this point in the history
* fix integration test
  • Loading branch information
rushtong authored Jun 4, 2018
1 parent f12b2d9 commit 0253003
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.pmiops.workbench.config.WorkbenchConfig;
import org.pmiops.workbench.test.Providers;
import org.springframework.retry.backoff.NoBackOffPolicy;
import org.mockito.Mockito;

public class DirectoryServiceImplIntegrationTest {
private DirectoryServiceImpl service;
Expand Down Expand Up @@ -41,10 +42,12 @@ public void testDirectoryServiceUsernameIsTaken() {
@Test
public void testCreateAndDeleteTestUser() {
String userName = String.format("integration.test.%d", Clock.systemUTC().millis());
service.createUser("Integration", "Test", userName, "notasecret");
assertThat(service.isUsernameTaken(userName)).isTrue();
service.deleteUser(userName);
assertThat(service.isUsernameTaken(userName)).isFalse();
DirectoryServiceImpl serviceSpy = Mockito.spy(service);
Mockito.doNothing().when(serviceSpy).sendPasswordEmail(Mockito.anyString(), Mockito.anyString(), Mockito.any());
serviceSpy.createUser("Integration", "Test", userName, "notasecret");
assertThat(serviceSpy.isUsernameTaken(userName)).isTrue();
serviceSpy.deleteUser(userName);
assertThat(serviceSpy.isUsernameTaken(userName)).isFalse();
}

private static GoogleCredential getGoogleCredential() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private String randomString(){
collect(Collectors.joining(""));
}

private void sendPasswordEmail(String contactEmail, String password, User user) {
protected void sendPasswordEmail(String contactEmail, String password, User user) {
WorkbenchConfig workbenchConfig = configProvider.get();
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
Expand Down

0 comments on commit 0253003

Please sign in to comment.