Search in sources :

Example 36 with WebApplicationException

use of org.rembx.jeeshop.rest.WebApplicationException 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)

Example 37 with WebApplicationException

use of org.rembx.jeeshop.rest.WebApplicationException in project jeeshop by remibantos.

the class DiscountsCT method modifyUnknownDiscount_ShouldThrowNotFoundException.

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

Example 38 with WebApplicationException

use of org.rembx.jeeshop.rest.WebApplicationException 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 39 with WebApplicationException

use of org.rembx.jeeshop.rest.WebApplicationException 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)

Example 40 with WebApplicationException

use of org.rembx.jeeshop.rest.WebApplicationException in project jeeshop by remibantos.

the class StoresCT method modify_shouldThrowNotFound_for_store_admin.

@Test
public void modify_shouldThrowNotFound_for_store_admin() {
    try {
        tester.setStoreAdminUser();
        Store store = new Store(666L, "Superstore");
        tester.test_modify(store);
        fail("Should have throw an exception");
    } catch (WebApplicationException e) {
        assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
    }
}
Also used : WebApplicationException(org.rembx.jeeshop.rest.WebApplicationException) Store(org.rembx.jeeshop.catalog.model.Store) Test(org.junit.jupiter.api.Test)

Aggregations

WebApplicationException (org.rembx.jeeshop.rest.WebApplicationException)55 Test (org.junit.jupiter.api.Test)34 RolesAllowed (javax.annotation.security.RolesAllowed)19 Transactional (javax.transaction.Transactional)9 Catalog (org.rembx.jeeshop.catalog.model.Catalog)9 User (org.rembx.jeeshop.user.model.User)9 Store (org.rembx.jeeshop.catalog.model.Store)7 TestUser (org.rembx.jeeshop.user.test.TestUser)7 MailTemplate (org.rembx.jeeshop.user.model.MailTemplate)5 Category (org.rembx.jeeshop.catalog.model.Category)4 SKU (org.rembx.jeeshop.catalog.model.SKU)4 TestCatalog (org.rembx.jeeshop.catalog.test.TestCatalog)4 Order (org.rembx.jeeshop.order.model.Order)4 BasicUserPrincipal (org.apache.http.auth.BasicUserPrincipal)3 Product (org.rembx.jeeshop.catalog.model.Product)3 Address (org.rembx.jeeshop.user.model.Address)3 TestMailTemplate (org.rembx.jeeshop.user.test.TestMailTemplate)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 PermitAll (javax.annotation.security.PermitAll)2