Search in sources :

Example 1 with PilotUser

use of com.sanction.thunder.models.PilotUser in project thunder by RohanNagar.

the class UserResourceTest method testUpdateUser.

@Test
public void testUpdateUser() {
    when(usersDao.findByEmail(email.getAddress())).thenReturn(user);
    when(usersDao.update(null, updatedUser)).thenReturn(updatedUser);
    Response response = resource.updateUser(key, "password", null, updatedUser);
    PilotUser result = (PilotUser) response.getEntity();
    assertEquals(Response.Status.OK, response.getStatusInfo());
    assertEquals(updatedUser, result);
}
Also used : Response(javax.ws.rs.core.Response) PilotUser(com.sanction.thunder.models.PilotUser) Test(org.junit.Test)

Example 2 with PilotUser

use of com.sanction.thunder.models.PilotUser in project thunder by RohanNagar.

the class UserResourceTest method testUpdateUserWithNewEmail.

@Test
public void testUpdateUserWithNewEmail() {
    when(usersDao.findByEmail("existingEmail")).thenReturn(user);
    when(usersDao.update("existingEmail", updatedUser)).thenReturn(updatedUser);
    Response response = resource.updateUser(key, "password", "existingEmail", updatedUser);
    PilotUser result = (PilotUser) response.getEntity();
    assertEquals(Response.Status.OK, response.getStatusInfo());
    assertEquals(updatedUser, result);
}
Also used : Response(javax.ws.rs.core.Response) PilotUser(com.sanction.thunder.models.PilotUser) Test(org.junit.Test)

Example 3 with PilotUser

use of com.sanction.thunder.models.PilotUser in project thunder by RohanNagar.

the class UserResourceTest method testPostUserInvalidEmail.

@Test
public void testPostUserInvalidEmail() {
    PilotUser user = new PilotUser(badEmail, "password", "", "", "");
    Response response = resource.postUser(key, user);
    assertEquals(Response.Status.BAD_REQUEST, response.getStatusInfo());
}
Also used : Response(javax.ws.rs.core.Response) PilotUser(com.sanction.thunder.models.PilotUser) Test(org.junit.Test)

Example 4 with PilotUser

use of com.sanction.thunder.models.PilotUser in project thunder by RohanNagar.

the class UserResourceTest method testDeleteUser.

@Test
public void testDeleteUser() {
    when(usersDao.findByEmail(email.getAddress())).thenReturn(user);
    when(usersDao.delete(email.getAddress())).thenReturn(user);
    Response response = resource.deleteUser(key, "password", email.getAddress());
    PilotUser result = (PilotUser) response.getEntity();
    assertEquals(Response.Status.OK, response.getStatusInfo());
    assertEquals(user, result);
}
Also used : Response(javax.ws.rs.core.Response) PilotUser(com.sanction.thunder.models.PilotUser) Test(org.junit.Test)

Example 5 with PilotUser

use of com.sanction.thunder.models.PilotUser in project thunder by RohanNagar.

the class UserResourceTest method testPostUser.

@Test
public void testPostUser() {
    when(usersDao.insert(any(PilotUser.class))).thenReturn(updatedUser);
    Response response = resource.postUser(key, user);
    PilotUser result = (PilotUser) response.getEntity();
    assertEquals(Response.Status.CREATED, response.getStatusInfo());
    assertEquals(updatedUser, result);
}
Also used : Response(javax.ws.rs.core.Response) PilotUser(com.sanction.thunder.models.PilotUser) Test(org.junit.Test)

Aggregations

PilotUser (com.sanction.thunder.models.PilotUser)26 Test (org.junit.Test)20 Response (javax.ws.rs.core.Response)9 DatabaseException (com.sanction.thunder.dao.DatabaseException)6 Email (com.sanction.thunder.models.Email)4 Expected (com.amazonaws.services.dynamodbv2.document.Expected)3 Item (com.amazonaws.services.dynamodbv2.document.Item)3 DeleteItemSpec (com.amazonaws.services.dynamodbv2.document.spec.DeleteItemSpec)2 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