Search in sources :

Example 1 with CatalogItem

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

the class PresentationResourceCT method createLocalizedPresentation_shouldPersistGivenPresentationAndLinkItToParentCatalogItem.

@Test
public void createLocalizedPresentation_shouldPersistGivenPresentationAndLinkItToParentCatalogItem() {
    CatalogItem parentCatalogItem = testCatalog.aCategoryWithoutPresentation();
    Presentation presentation = new Presentation(null, "presentation test", "testShortDesc", "testLongDesc");
    service = new PresentationResource(entityManager, null).init(parentCatalogItem, "fr_FR", null);
    // wrap call in transaction as method is transactional
    entityManager.getTransaction().begin();
    service.createLocalizedPresentation(presentation);
    entityManager.getTransaction().commit();
    assertThat(presentation.getId()).isNotNull();
    assertThat(entityManager.find(Presentation.class, presentation.getId())).isNotNull();
    assertThat(parentCatalogItem.getPresentationByLocale().get("fr_FR")).isNotNull();
    assertThat(parentCatalogItem.getPresentationByLocale().get("fr_FR").getLocale()).isEqualTo("fr_FR");
    // cleanup
    removePersistedTestData(parentCatalogItem, presentation);
}
Also used : CatalogItem(org.rembx.jeeshop.catalog.model.CatalogItem) Presentation(org.rembx.jeeshop.catalog.model.Presentation) Test(org.junit.jupiter.api.Test)

Example 2 with CatalogItem

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

the class PresentationResourceCT method deleteGivenPresentation_shouldRemoveIt.

@Test
public void deleteGivenPresentation_shouldRemoveIt() {
    CatalogItem parentCatalogItem = testCatalog.aCategoryWithoutPresentation();
    Presentation presentation = createTestPresentation();
    parentCatalogItem.getPresentationByLocale().put("fr_FR", presentation);
    service = new PresentationResource(entityManager, null).init(parentCatalogItem, "fr_FR", presentation);
    // wrap call in transaction as method is transactional
    entityManager.getTransaction().begin();
    service.delete();
    entityManager.getTransaction().commit();
    assertThat(entityManager.find(Presentation.class, presentation.getId())).isNull();
    assertThat(parentCatalogItem.getPresentationByLocale().get("fr_FR")).isNull();
}
Also used : CatalogItem(org.rembx.jeeshop.catalog.model.CatalogItem) Presentation(org.rembx.jeeshop.catalog.model.Presentation) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 CatalogItem (org.rembx.jeeshop.catalog.model.CatalogItem)2 Presentation (org.rembx.jeeshop.catalog.model.Presentation)2