use of org.rembx.jeeshop.rest.WebApplicationException in project jeeshop by remibantos.
the class UsersCT method resetPassword_shouldReturnUnauthorizedResponse_whenAuthenticatedUserDoesNotMatchLogin.
@Test
public void resetPassword_shouldReturnUnauthorizedResponse_whenAuthenticatedUserDoesNotMatchLogin() throws Exception {
try {
when(sessionContextMock.isCallerInRole(JeeshopRoles.USER)).thenReturn(true);
when(sessionContextMock.getCallerPrincipal()).thenReturn(new PrincipalImpl(testUser.firstUser().getLogin()));
service.resetPassword("not_matching_login", null, null);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.UNAUTHORIZED);
}
}
use of org.rembx.jeeshop.rest.WebApplicationException in project jeeshop by remibantos.
the class UsersCT method create_shouldThrowBadRequestExWhenUserHasAnId.
@Test
public void create_shouldThrowBadRequestExWhenUserHasAnId() throws Exception {
User user = new User();
user.setId(777L);
try {
service.create(user);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.BAD_REQUEST);
}
}
use of org.rembx.jeeshop.rest.WebApplicationException in project jeeshop by remibantos.
the class UsersCT method modifyUnknownUser_ShouldThrowNotFoundException.
@Test
public void modifyUnknownUser_ShouldThrowNotFoundException() {
User detachedUser = new User("test3@test.com", "test", "John", "Doe", "+33616161616", null, new Date(), "fr_FR", null);
detachedUser.setId(9999L);
try {
service.modify(detachedUser);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
}
}
use of org.rembx.jeeshop.rest.WebApplicationException in project jeeshop by remibantos.
the class UsersCT method create_shouldThrowBadRequestExceptionExWhenUsersCountryIsNotAvailable.
@Test
public void create_shouldThrowBadRequestExceptionExWhenUsersCountryIsNotAvailable() throws Exception {
User user = new User();
user.setLogin("toto@toto.com");
Address address = new Address();
address.setCountryIso3Code("ZZZ");
user.setAddress(address);
try {
service.create(user);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.BAD_REQUEST);
}
}
Aggregations