Search in sources :

Example 6 with Category

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

the class CategoriesCT method find_idOfCategoryWithPresentation_WithNotSupportedLocaleSpecifiedShouldReturnFallbackLocalePresentation.

@Test
public void find_idOfCategoryWithPresentation_WithNotSupportedLocaleSpecifiedShouldReturnFallbackLocalePresentation() {
    tester.setPublicUser();
    Category category = localService.find(tester.getSecurityContext(), tester.getFixtures().aCategoryWithPresentation().getId(), "it_IT");
    assertThat(category).hasLocalizedPresentationShortDescription(Locale.ENGLISH.toString(), PresentationTexts.TEXT_1000);
}
Also used : Category(org.rembx.jeeshop.catalog.model.Category) Test(org.junit.jupiter.api.Test)

Example 7 with Category

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

the class CategoriesCT method create_withoutOwner_shouldThrow_BadRequestEx_for_admin.

@Test
public void create_withoutOwner_shouldThrow_BadRequestEx_for_admin() {
    try {
        tester.setAdminUser();
        Category category = new Category("name", "description");
        tester.test_create(category);
        fail("should have thrown ex");
    } catch (WebApplicationException e) {
        assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.BAD_REQUEST);
    }
}
Also used : Category(org.rembx.jeeshop.catalog.model.Category) WebApplicationException(org.rembx.jeeshop.rest.WebApplicationException) Test(org.junit.jupiter.api.Test)

Example 8 with Category

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

the class CategoriesCT method find_idOfCategoryWithPresentation_ShouldReturnExpectedPresentation.

@Test
public void find_idOfCategoryWithPresentation_ShouldReturnExpectedPresentation() {
    tester.setPublicUser();
    Category actual = localService.find(tester.getSecurityContext(), tester.getFixtures().aCategoryWithPresentation().getId(), Locale.ENGLISH.toString());
    assertThat(actual).hasLocalizedPresentationShortDescription(Locale.ENGLISH.toString(), PresentationTexts.TEXT_1000);
}
Also used : Category(org.rembx.jeeshop.catalog.model.Category) Test(org.junit.jupiter.api.Test)

Example 9 with Category

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

the class CategoriesCT method modifyUnknownCategory_ShouldThrowNotFoundException.

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

Example 10 with Category

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

the class CategoriesCT method create_shouldSetupOwner_for_admin.

@Test
public void create_shouldSetupOwner_for_admin() {
    tester.setAdminUser();
    Category category = new Category("name", "description", new Date(), new Date(), false, "test@test.com");
    category.setOwner(TestCatalog.OWNER);
    Category actualCategory = tester.test_create(category);
    assertThat(actualCategory).isNotNull();
    assertThat(actualCategory.getOwner()).isEqualTo(TestCatalog.OWNER);
}
Also used : Category(org.rembx.jeeshop.catalog.model.Category) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

Category (org.rembx.jeeshop.catalog.model.Category)17 Test (org.junit.jupiter.api.Test)12 ArrayList (java.util.ArrayList)4 Catalog (org.rembx.jeeshop.catalog.model.Catalog)4 WebApplicationException (org.rembx.jeeshop.rest.WebApplicationException)4 Date (java.util.Date)2 PermitAll (javax.annotation.security.PermitAll)2 RolesAllowed (javax.annotation.security.RolesAllowed)2 Transactional (javax.transaction.Transactional)1 Test (org.junit.Test)1