Search in sources :

Example 6 with Discount

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

the class DiscountsCT method delete_shouldRemove_for_admin.

@Test
public void delete_shouldRemove_for_admin() {
    tester.setAdminUser();
    Discount discount = new Discount("discount888", "a discount", ORDER, DISCOUNT_RATE, QUANTITY, null, 0.1, 2.0, 1, true, null, null, false, "test@test.com");
    tester.test_delete(discount);
    assertThat(tester.getEntityManager().find(Discount.class, discount.getId())).isNull();
}
Also used : Discount(org.rembx.jeeshop.catalog.model.Discount) Test(org.junit.jupiter.api.Test)

Example 7 with Discount

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

the class DiscountsCT method create_shouldPersist_for_admin_user.

@Test
public void create_shouldPersist_for_admin_user() {
    tester.setAdminUser();
    Discount discount = new Discount("discount777", "a discount", ORDER, DISCOUNT_RATE, AMOUNT, null, 0.1, 2.0, 1, true, null, null, false, "test@test.com");
    Discount createdDiscount = tester.test_create(discount);
    assertThat(createdDiscount).isNotNull();
    assertThat(createdDiscount.getOwner()).isEqualTo("test@test.com");
}
Also used : Discount(org.rembx.jeeshop.catalog.model.Discount) Test(org.junit.jupiter.api.Test)

Example 8 with Discount

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

the class DiscountsCT method find_withIdOfVisibleDiscount_ShouldReturnExpectedDiscount.

@Test
public void find_withIdOfVisibleDiscount_ShouldReturnExpectedDiscount() {
    Discount catalogItem = localService.find(tester.getSecurityContext(), tester.getFixtures().aVisibleDisount().getId(), null);
    assertThat(catalogItem).isEqualTo(tester.getFixtures().aVisibleDisount());
    assertThat(catalogItem.isVisible()).isTrue();
}
Also used : Discount(org.rembx.jeeshop.catalog.model.Discount) Test(org.junit.jupiter.api.Test)

Example 9 with Discount

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

the class DiscountsCT method delete_shouldRemove_for_store_admin.

@Test
public void delete_shouldRemove_for_store_admin() {
    tester.setStoreAdminUser();
    Discount discount = new Discount("discount888", "a discount", ORDER, DISCOUNT_RATE, QUANTITY, null, 0.1, 2.0, 1, true, null, null, false, TestCatalog.OWNER);
    tester.test_delete(discount);
    assertThat(tester.getEntityManager().find(Discount.class, discount.getId())).isNull();
}
Also used : Discount(org.rembx.jeeshop.catalog.model.Discount) Test(org.junit.jupiter.api.Test)

Example 10 with Discount

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

the class DiscountsCT method delete_shouldThrowForbiddenException_for_store_admin.

@Test
public void delete_shouldThrowForbiddenException_for_store_admin() {
    try {
        tester.setStoreAdminUser();
        Discount discount = new Discount("discount888", "a discount", ORDER, DISCOUNT_RATE, QUANTITY, null, 0.1, 2.0, 1, true, null, null, false, "test@test.com");
        tester.test_delete(discount);
        fail("Should have throw an exception");
    } catch (WebApplicationException e) {
        assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.FORBIDDEN);
    }
}
Also used : Discount(org.rembx.jeeshop.catalog.model.Discount) WebApplicationException(org.rembx.jeeshop.rest.WebApplicationException) Test(org.junit.jupiter.api.Test)

Aggregations

Discount (org.rembx.jeeshop.catalog.model.Discount)12 Test (org.junit.jupiter.api.Test)6 JPAQueryFactory (com.querydsl.jpa.impl.JPAQueryFactory)2 Date (java.util.Date)2 Test (org.junit.Test)2 WebApplicationException (org.rembx.jeeshop.rest.WebApplicationException)2 Product (org.rembx.jeeshop.catalog.model.Product)1 SKU (org.rembx.jeeshop.catalog.model.SKU)1 OrderDiscount (org.rembx.jeeshop.order.model.OrderDiscount)1 User (org.rembx.jeeshop.user.model.User)1