Search in sources :

Example 11 with Category

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

the class CategoriesCT method create_shouldSetupOwner_for_store_admin.

@Test
public void create_shouldSetupOwner_for_store_admin() {
    tester.setStoreAdminUser();
    Category category = new Category("name", "");
    Category actualCategory = tester.test_create(category);
    assertThat(actualCategory).isNotNull();
    assertThat(actualCategory.getOwner()).isEqualTo(TestCatalog.OWNER);
}
Also used : Category(org.rembx.jeeshop.catalog.model.Category) Test(org.junit.jupiter.api.Test)

Example 12 with Category

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

the class CategoriesCT method find_idOfCategoryWithPresentation_WithNoLocaleSpecifiedShouldReturnFallbackLocalePresentation.

@Test
public void find_idOfCategoryWithPresentation_WithNoLocaleSpecifiedShouldReturnFallbackLocalePresentation() {
    tester.setPublicUser();
    Category category = localService.find(tester.getSecurityContext(), tester.getFixtures().aCategoryWithPresentation().getId(), null);
    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 13 with Category

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

the class CategoriesCT method create_shouldPersist.

@Test
public void create_shouldPersist() {
    Category category = new Category("name", "description", new Date(), new Date(), false);
    entityManager.getTransaction().begin();
    service.create(category);
    entityManager.getTransaction().commit();
    assertThat(entityManager.find(Category.class, category.getId())).isNotNull();
    entityManager.remove(category);
}
Also used : Category(org.rembx.jeeshop.catalog.model.Category) Date(java.util.Date) Test(org.junit.Test)

Example 14 with Category

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

the class CategoriesCT method modifyCategory_ShouldModifyCategoryAttributesAndPreserveCategoriesWhenNotProvided.

@Test
public void modifyCategory_ShouldModifyCategoryAttributesAndPreserveCategoriesWhenNotProvided() {
    tester.setAdminUser();
    Category category = new Category(tester.getFixtures().aRootCategoryWithChildCategories().getId(), "New name");
    tester.test_modify(category);
    assertThat(category.getName()).isEqualTo("New name");
    assertThat(category.getChildCategories()).isNotEmpty();
}
Also used : Category(org.rembx.jeeshop.catalog.model.Category) Test(org.junit.jupiter.api.Test)

Example 15 with Category

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

the class CategoriesCT method delete_shouldRemove.

@Test
public void delete_shouldRemove() {
    tester.setStoreAdminUser();
    Category category = new Category("Test category", "");
    category.setOwner(TestCatalog.OWNER);
    tester.test_delete(category);
    assertThat(tester.getEntityManager().find(Category.class, category.getId())).isNull();
}
Also used : Category(org.rembx.jeeshop.catalog.model.Category) 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