Search in sources :

Example 11 with SKU

use of org.rembx.jeeshop.catalog.model.SKU in project jeeshop by remibantos.

the class SKUsCT method delete_shouldRemove.

@Test
public void delete_shouldRemove() {
    entityManager.getTransaction().begin();
    SKU sku = new SKU("Test", "", null, null, null, null, null, null, null);
    entityManager.persist(sku);
    entityManager.getTransaction().commit();
    entityManager.getTransaction().begin();
    service.delete(sku.getId());
    entityManager.getTransaction().commit();
    assertThat(entityManager.find(SKU.class, sku.getId())).isNull();
}
Also used : SKU(org.rembx.jeeshop.catalog.model.SKU) Test(org.junit.Test)

Example 12 with SKU

use of org.rembx.jeeshop.catalog.model.SKU in project jeeshop by remibantos.

the class SKUsCT method delete_shouldThrow_Forbidden_for_store_Admin.

@Test
public void delete_shouldThrow_Forbidden_for_store_Admin() {
    try {
        tester.setStoreAdminUser();
        SKU sku = new SKU("Test", "");
        sku.setOwner("test@test.org");
        tester.test_delete(sku);
        fail("should have throw an exception");
    } catch (WebApplicationException e) {
        assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.FORBIDDEN);
    }
}
Also used : WebApplicationException(org.rembx.jeeshop.rest.WebApplicationException) SKU(org.rembx.jeeshop.catalog.model.SKU) Test(org.junit.jupiter.api.Test)

Example 13 with SKU

use of org.rembx.jeeshop.catalog.model.SKU in project jeeshop by remibantos.

the class SKUsCT method delete_shouldRemove_for_store_Admin.

@Test
public void delete_shouldRemove_for_store_Admin() {
    tester.setStoreAdminUser();
    SKU sku = new SKU("Test", "");
    sku.setOwner(TestCatalog.OWNER);
    tester.test_delete(sku);
    assertThat(tester.getEntityManager().find(SKU.class, sku.getId())).isNull();
}
Also used : SKU(org.rembx.jeeshop.catalog.model.SKU) Test(org.junit.jupiter.api.Test)

Example 14 with SKU

use of org.rembx.jeeshop.catalog.model.SKU in project jeeshop by remibantos.

the class SKUsCT method create_shouldPersistAndAttachOwner_for_store_admin.

@Test
public void create_shouldPersistAndAttachOwner_for_store_admin() {
    tester.setStoreAdminUser();
    SKU sku = new SKU("name", "description", 1.0, 2, "reference", new Date(), new Date(), false, 1, null);
    SKU createdSKU = tester.test_create(sku);
    assertThat(createdSKU).isNotNull();
    assertThat(createdSKU.getOwner()).isEqualTo(TestCatalog.OWNER);
}
Also used : SKU(org.rembx.jeeshop.catalog.model.SKU) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 15 with SKU

use of org.rembx.jeeshop.catalog.model.SKU in project jeeshop by remibantos.

the class SKUsCT method create_shouldPersistAndAttachOwner_for_admin.

@Test
public void create_shouldPersistAndAttachOwner_for_admin() {
    tester.setAdminUser();
    SKU sku = new SKU("name", "description", 1.0, 2, "reference", new Date(), new Date(), false, 1, "test@test.com");
    SKU createdSKU = tester.test_create(sku);
    assertThat(createdSKU).isNotNull();
    assertThat(createdSKU.getOwner()).isEqualTo("test@test.com");
}
Also used : SKU(org.rembx.jeeshop.catalog.model.SKU) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

SKU (org.rembx.jeeshop.catalog.model.SKU)17 Test (org.junit.jupiter.api.Test)12 WebApplicationException (org.rembx.jeeshop.rest.WebApplicationException)4 Date (java.util.Date)3 OrderItem (org.rembx.jeeshop.order.model.OrderItem)3 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 Order (org.rembx.jeeshop.order.model.Order)2 Discount (org.rembx.jeeshop.catalog.model.Discount)1 Product (org.rembx.jeeshop.catalog.model.Product)1 User (org.rembx.jeeshop.user.model.User)1