Search in sources :

Example 21 with DatabaseException

use of com.sanction.thunder.dao.DatabaseException in project thunder by RohanNagar.

the class UserResourceTest method testUpdateUserDatabaseDown.

@Test
public void testUpdateUserDatabaseDown() {
    when(usersDao.findByEmail(email.getAddress())).thenReturn(user);
    when(usersDao.update(null, updatedUser)).thenThrow(new DatabaseException(DatabaseError.DATABASE_DOWN));
    Response response = resource.updateUser(key, "password", null, updatedUser);
    assertEquals(Response.Status.SERVICE_UNAVAILABLE, response.getStatusInfo());
}
Also used : Response(javax.ws.rs.core.Response) DatabaseException(com.sanction.thunder.dao.DatabaseException) Test(org.junit.Test)

Example 22 with DatabaseException

use of com.sanction.thunder.dao.DatabaseException in project thunder by RohanNagar.

the class UserResourceTest method testGetUserNotFound.

@Test
public void testGetUserNotFound() {
    when(usersDao.findByEmail(email.getAddress())).thenThrow(new DatabaseException(DatabaseError.USER_NOT_FOUND));
    Response response = resource.getUser(key, "password", email.getAddress());
    assertEquals(Response.Status.NOT_FOUND, response.getStatusInfo());
}
Also used : Response(javax.ws.rs.core.Response) DatabaseException(com.sanction.thunder.dao.DatabaseException) Test(org.junit.Test)

Example 23 with DatabaseException

use of com.sanction.thunder.dao.DatabaseException in project thunder by RohanNagar.

the class UserResourceTest method testDeleteUserLookupNotFound.

@Test
public void testDeleteUserLookupNotFound() {
    when(usersDao.findByEmail(email.getAddress())).thenThrow(new DatabaseException(DatabaseError.USER_NOT_FOUND));
    Response response = resource.deleteUser(key, "password", email.getAddress());
    assertEquals(Response.Status.NOT_FOUND, response.getStatusInfo());
}
Also used : Response(javax.ws.rs.core.Response) DatabaseException(com.sanction.thunder.dao.DatabaseException) Test(org.junit.Test)

Example 24 with DatabaseException

use of com.sanction.thunder.dao.DatabaseException in project thunder by RohanNagar.

the class VerificationResourceTest method testVerifyUserUpdateUserException.

@Test
public void testVerifyUserUpdateUserException() {
    when(usersDao.findByEmail(anyString())).thenReturn(nullDatabaseTokenMockUser);
    when(usersDao.update(anyString(), any(PilotUser.class))).thenThrow(new DatabaseException(DatabaseError.DATABASE_DOWN));
    Response response = resource.createVerificationEmail(key, "test@test.com", "password");
    assertEquals(response.getStatusInfo(), Response.Status.SERVICE_UNAVAILABLE);
}
Also used : Response(javax.ws.rs.core.Response) PilotUser(com.sanction.thunder.models.PilotUser) DatabaseException(com.sanction.thunder.dao.DatabaseException) Test(org.junit.Test)

Example 25 with DatabaseException

use of com.sanction.thunder.dao.DatabaseException in project thunder by RohanNagar.

the class VerificationResourceTest method testVerifyEmailUpdateUserException.

@Test
public void testVerifyEmailUpdateUserException() {
    when(usersDao.findByEmail("test@test.com")).thenReturn(unverifiedMockUser);
    when(usersDao.update(unverifiedMockUser.getEmail().getAddress(), verifiedMockUser)).thenThrow(new DatabaseException(DatabaseError.DATABASE_DOWN));
    Response response = resource.verifyEmail("test@test.com", "verificationToken", ResponseType.JSON);
    assertEquals(response.getStatusInfo(), Response.Status.SERVICE_UNAVAILABLE);
}
Also used : Response(javax.ws.rs.core.Response) DatabaseException(com.sanction.thunder.dao.DatabaseException) Test(org.junit.Test)

Aggregations

DatabaseException (com.sanction.thunder.dao.DatabaseException)25 Response (javax.ws.rs.core.Response)19 Test (org.junit.Test)19 PilotUser (com.sanction.thunder.models.PilotUser)10 Email (com.sanction.thunder.models.Email)3 GET (javax.ws.rs.GET)2 POST (javax.ws.rs.POST)2 URI (java.net.URI)1 StringJoiner (java.util.StringJoiner)1 DELETE (javax.ws.rs.DELETE)1 PUT (javax.ws.rs.PUT)1