Search in sources :

Example 16 with DatabaseException

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

the class UserResourceTest method testUpdateUserLookupNotFound.

@Test
public void testUpdateUserLookupNotFound() {
    when(usersDao.findByEmail(email.getAddress())).thenThrow(new DatabaseException(DatabaseError.USER_NOT_FOUND));
    Response response = resource.updateUser(key, "password", null, user);
    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 17 with DatabaseException

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

the class UserResourceTest method testUpdateUserConflict.

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

Example 18 with DatabaseException

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

the class UserResourceTest method testDeleteUserDatabaseDown.

@Test
public void testDeleteUserDatabaseDown() {
    when(usersDao.findByEmail(email.getAddress())).thenReturn(user);
    when(usersDao.delete(email.getAddress())).thenThrow(new DatabaseException(DatabaseError.DATABASE_DOWN));
    Response response = resource.deleteUser(key, "password", email.getAddress());
    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 19 with DatabaseException

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

the class UserResourceTest method testGetUserDatabaseDown.

@Test
public void testGetUserDatabaseDown() {
    when(usersDao.findByEmail(email.getAddress())).thenThrow(new DatabaseException(DatabaseError.DATABASE_DOWN));
    Response response = resource.getUser(key, "password", email.getAddress());
    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 20 with DatabaseException

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

the class UserResourceTest method testUpdateUserLookupUnsupportedData.

@Test
public void testUpdateUserLookupUnsupportedData() {
    when(usersDao.findByEmail(email.getAddress())).thenThrow(new DatabaseException(DatabaseError.REQUEST_REJECTED));
    Response response = resource.updateUser(key, "password", null, user);
    assertEquals(Response.Status.INTERNAL_SERVER_ERROR, response.getStatusInfo());
}
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