Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into update
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Robertze committed Oct 22, 2015
2 parents 793994b + 7bc7d4a commit 3b76fbf
Showing 1 changed file with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ public static Test suite() {
return new TestSuite(UserRepositoryTest.class);
}

public void testGetUserDetails_Null() throws Exception {
String username = "inspector";
String sql = "SELECT firstName, lastName, department, position, " +
"permissions FROM staff WHERE username=?;";

IPersistenceService db = mock(IPersistenceService.class);
IUserRepository repo = new UserRepository(db);

when(db.executeQuery(sql, username)).thenReturn(null);

try {
Staff response = repo.getUserDetails(username);
fail("AuthenticationException expected");
} catch(AuthenticationException ex) {
verify(db).executeQuery(sql, username);
}
}

public void testGetUserDetails() throws Exception {
String username = "inspector";
String sql = "SELECT firstName, lastName, department, position, " +
Expand Down Expand Up @@ -235,7 +253,21 @@ public void testGetGetInspectors() throws Exception {
verify(db).executeQuery(anotherInspectorDetailsSql, anotherUsername);
}

public void testGetGetStaff() throws Exception {
public void testGetStaff_Null() throws Exception {
String usernameListSql = "SELECT username FROM staff WHERE username!=?;";

IPersistenceService db = mock(IPersistenceService.class);
IUserRepository repo = new UserRepository(db);

when(db.executeQuery(usernameListSql, "root")).thenReturn(null);

List<Staff> response = repo.getStaff();

assertNull(response);
verify(db).executeQuery(usernameListSql, "root");
}

public void testGetStaff() throws Exception {
String username = "inspector";
String anotherUsername = "AnotherInspector";
String usernameListSql = "SELECT username FROM staff WHERE username!=?;";
Expand Down

0 comments on commit 3b76fbf

Please sign in to comment.