Search in sources :

Example 1 with SKU

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

the class SKUsCT method modify_ShouldThrowForbiddenException_for_store_admin.

@Test
public void modify_ShouldThrowForbiddenException_for_store_admin() {
    tester.setSAnotherStoreAdminUser();
    SKU sku = new SKU(tester.getFixtures().aVisibleSKU().getId(), "New name");
    try {
        tester.test_modify(sku);
        ;
        fail("should have thrown ex");
    } 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 2 with SKU

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

the class SKUsCT method delete_shouldRemove_for_admin.

@Test
public void delete_shouldRemove_for_admin() {
    tester.setAdminUser();
    SKU sku = new SKU("Test", "");
    sku.setOwner("an@owner.fr");
    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 3 with SKU

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

the class SKUsCT method create_shouldThrow_BadRequest_for_Admin.

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

Example 4 with SKU

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

the class SKUsCT method modifyUnknownSKU_ShouldThrowNotFoundException.

@Test
public void modifyUnknownSKU_ShouldThrowNotFoundException() {
    SKU detachedProductToModify = new SKU(9999L, null, null, null, null, null, null, null, null, null);
    try {
        localService.modify(tester.getSecurityContext(), detachedProductToModify);
        fail("should have thrown ex");
    } catch (WebApplicationException e) {
        assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
    }
}
Also used : WebApplicationException(org.rembx.jeeshop.rest.WebApplicationException) SKU(org.rembx.jeeshop.catalog.model.SKU) Test(org.junit.jupiter.api.Test)

Example 5 with SKU

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

the class SKUsCT method find_withIdOfVisibleSKU_ShouldReturnExpectedSKU.

@Test
public void find_withIdOfVisibleSKU_ShouldReturnExpectedSKU() {
    SKU catalogItem = localService.find(tester.getSecurityContext(), tester.getFixtures().aVisibleSKU().getId(), null);
    assertThat(catalogItem).isEqualTo(tester.getFixtures().aVisibleSKU());
    assertThat(catalogItem.isVisible()).isTrue();
}
Also used : SKU(org.rembx.jeeshop.catalog.model.SKU) 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