Search in sources :

Example 6 with Product

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();
}
Also used : Product(org.rembx.jeeshop.catalog.model.Product) Test(org.junit.jupiter.api.Test)

Example 7 with Product

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);
}
Also used : Product(org.rembx.jeeshop.catalog.model.Product) Date(java.util.Date) Test(org.junit.Test)

Example 8 with 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);
    }
}
Also used : WebApplicationException(org.rembx.jeeshop.rest.WebApplicationException) Product(org.rembx.jeeshop.catalog.model.Product) Test(org.junit.jupiter.api.Test)

Example 9 with Product

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);
    }
}
Also used : WebApplicationException(org.rembx.jeeshop.rest.WebApplicationException) Product(org.rembx.jeeshop.catalog.model.Product) Test(org.junit.jupiter.api.Test)

Aggregations

Product (org.rembx.jeeshop.catalog.model.Product)9 Test (org.junit.jupiter.api.Test)7 Date (java.util.Date)3 WebApplicationException (org.rembx.jeeshop.rest.WebApplicationException)3 Test (org.junit.Test)1 Discount (org.rembx.jeeshop.catalog.model.Discount)1 SKU (org.rembx.jeeshop.catalog.model.SKU)1 User (org.rembx.jeeshop.user.model.User)1