Search in sources :

Example 6 with PilotUser

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

the class UserResourceTest method testGetUser.

@Test
public void testGetUser() {
    when(usersDao.findByEmail(email.getAddress())).thenReturn(user);
    Response response = resource.getUser(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 7 with PilotUser

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

the class VerificationResourceTest method testVerifyUserSuccess.

@Test
public void testVerifyUserSuccess() {
    when(usersDao.findByEmail(anyString())).thenReturn(nullDatabaseTokenMockUser);
    when(usersDao.update(anyString(), any(PilotUser.class))).thenReturn(unverifiedMockUser);
    when(emailService.sendEmail(any(Email.class), anyString(), anyString(), anyString())).thenReturn(true);
    Response response = resource.createVerificationEmail(key, "test@test.com", "password");
    PilotUser result = (PilotUser) response.getEntity();
    assertEquals(response.getStatusInfo(), Response.Status.OK);
    assertEquals(unverifiedMockUser, result);
}
Also used : Response(javax.ws.rs.core.Response) Email(com.sanction.thunder.models.Email) PilotUser(com.sanction.thunder.models.PilotUser) Test(org.junit.Test)

Example 8 with PilotUser

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

the class VerificationResourceTest method testVerifyEmailSuccess.

@Test
public void testVerifyEmailSuccess() {
    when(usersDao.findByEmail("test@test.com")).thenReturn(unverifiedMockUser);
    when(usersDao.update(unverifiedMockUser.getEmail().getAddress(), verifiedMockUser)).thenReturn(verifiedMockUser);
    Response response = resource.verifyEmail("test@test.com", "verificationToken", ResponseType.JSON);
    PilotUser result = (PilotUser) response.getEntity();
    assertEquals(response.getStatusInfo(), Response.Status.OK);
    assertEquals(verifiedMockUser, result);
}
Also used : Response(javax.ws.rs.core.Response) PilotUser(com.sanction.thunder.models.PilotUser) Test(org.junit.Test)

Example 9 with PilotUser

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

the class ThunderClientTest method testSendVerificationEmail.

@Test
@SuppressWarnings("ConstantConditions")
public void testSendVerificationEmail() throws IOException {
    PilotUser response = client.sendVerificationEmail("email", password).execute().body();
    assertEquals(user.getEmail(), response.getEmail());
}
Also used : PilotUser(com.sanction.thunder.models.PilotUser) Test(org.junit.Test)

Example 10 with PilotUser

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

the class ThunderClientTest method testPostUser.

@Test
@SuppressWarnings("ConstantConditions")
public void testPostUser() throws IOException {
    PilotUser response = client.postUser(user).execute().body();
    assertEquals(user.getEmail(), response.getEmail());
}
Also used : 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