use of org.rembx.jeeshop.rest.WebApplicationException in project jeeshop by remibantos.
the class UsersCT method create_shouldThrowBadRequestExceptionExWhenUserAddressHasAnId.
@Test
public void create_shouldThrowBadRequestExceptionExWhenUserAddressHasAnId() throws Exception {
User user = new User();
user.setLogin("toto@toto.com");
Address address = new Address();
address.setId(1L);
user.setAddress(address);
try {
service.create(sessionContextMock, 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 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(sessionContextMock, 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 MailTemplatesCT method create_shouldThrowConflictException_WhenThereIsAlreadyAMailTemplateWithSameLocaleAndName.
@Test
public void create_shouldThrowConflictException_WhenThereIsAlreadyAMailTemplateWithSameLocaleAndName() {
MailTemplate mailTemplate = new MailTemplate("Newsletter1", "fr_FR", "test content", "Test Subject");
try {
service.create(mailTemplate);
fail("Should have thrown exception");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.CONFLICT);
}
}
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(sessionContextMock, 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 MailTemplates method create.
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed(ADMIN)
public MailTemplate create(MailTemplate mailTemplate) {
MailTemplate existingTpl = mailTemplateFinder.findByNameAndLocale(mailTemplate.getName(), mailTemplate.getLocale());
if (existingTpl != null) {
throw new WebApplicationException(Response.Status.CONFLICT);
}
entityManager.persist(mailTemplate);
return mailTemplate;
}
Aggregations