use of org.rembx.jeeshop.catalog.model.Product in project jeeshop by remibantos.
the class ProductsCT method delete_shouldRemove.
@Test
public void delete_shouldRemove() {
tester.setStoreAdminUser();
Product product = new Product("Test", "", null, null, null, "test@test.com");
product.setOwner(TestCatalog.OWNER);
tester.test_delete(product);
assertThat(tester.getEntityManager().find(Product.class, product.getId())).isNull();
}
use of org.rembx.jeeshop.catalog.model.Product in project jeeshop by remibantos.
the class ProductsCT method create_shouldPersist.
@Test
public void create_shouldPersist() {
Product product = new Product("name", "description", new Date(), new Date(), false);
entityManager.getTransaction().begin();
service.create(product);
entityManager.getTransaction().commit();
assertThat(entityManager.find(Product.class, product.getId())).isNotNull();
entityManager.remove(product);
}
use of org.rembx.jeeshop.catalog.model.Product in project jeeshop by remibantos.
the class ProductsCT method create_withoutOwner_shouldThrow_BadRequest_for_admin.
@Test
public void create_withoutOwner_shouldThrow_BadRequest_for_admin() {
try {
tester.setAdminUser();
Product product = new Product("name");
tester.test_create(product);
fail("Should have thrown an exception");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.BAD_REQUEST);
}
}
use of org.rembx.jeeshop.catalog.model.Product in project jeeshop by remibantos.
the class ProductsCT method delete_NonManagedEntity_shouldThrow_Forbidden.
@Test
public void delete_NonManagedEntity_shouldThrow_Forbidden() {
try {
tester.setStoreAdminUser();
Product product = new Product("Test", "", null, null, null, "test@test.com");
tester.test_delete(product);
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.FORBIDDEN);
}
}
Aggregations