Search in sources :

Example 1 with Presentation

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

the class PresentationResourceCT method modifyLocalizedPresentation_shouldUpdateGivenPresentation.

@Test
public void modifyLocalizedPresentation_shouldUpdateGivenPresentation() {
    Presentation presentation = createTestPresentation();
    service = new PresentationResource(entityManager, null).init(null, "fr_FR", presentation);
    UUID uuid = UUID.randomUUID();
    presentation.setShortDescription(uuid.toString());
    // wrap call in transaction as method is transactional
    entityManager.getTransaction().begin();
    service.modifyLocalizedPresentation(presentation);
    entityManager.getTransaction().commit();
    assertThat(entityManager.find(Presentation.class, presentation.getId()).getShortDescription()).isEqualTo(uuid.toString());
    // cleanup
    removePersistedTestData(null, presentation);
}
Also used : Presentation(org.rembx.jeeshop.catalog.model.Presentation) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 2 with Presentation

use of org.rembx.jeeshop.catalog.model.Presentation 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 3 with Presentation

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

the class Catalogs method findPresentationByLocale.

@Path("/{catalogId}/presentations/{locale}")
@PermitAll
public PresentationResource findPresentationByLocale(@PathParam("catalogId") @NotNull Long catalogId, @NotNull @PathParam("locale") String locale) {
    Catalog catalog = entityManager.find(Catalog.class, catalogId);
    checkNotNull(catalog);
    Presentation presentation = catalog.getPresentationByLocale().get(locale);
    return presentationResource.init(catalog, locale, presentation);
}
Also used : Presentation(org.rembx.jeeshop.catalog.model.Presentation) Catalog(org.rembx.jeeshop.catalog.model.Catalog) PermitAll(javax.annotation.security.PermitAll)

Example 4 with Presentation

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

the class Stores method findPresentationByLocale.

@Path("/{storeId}/presentations/{locale}")
@PermitAll
public PresentationResource findPresentationByLocale(@PathParam("storedId") @NotNull Long storeId, @NotNull @PathParam("locale") String locale) {
    Store store = entityManager.find(Store.class, storeId);
    checkNotNull(store);
    Presentation presentation = store.getPresentationByLocale().get(locale);
    return presentationResource.init(store, locale, presentation);
}
Also used : Store(org.rembx.jeeshop.catalog.model.Store) Presentation(org.rembx.jeeshop.catalog.model.Presentation) PermitAll(javax.annotation.security.PermitAll)

Example 5 with Presentation

use of org.rembx.jeeshop.catalog.model.Presentation 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

Presentation (org.rembx.jeeshop.catalog.model.Presentation)7 Test (org.junit.jupiter.api.Test)4 PermitAll (javax.annotation.security.PermitAll)2 CatalogItem (org.rembx.jeeshop.catalog.model.CatalogItem)2 UUID (java.util.UUID)1 Catalog (org.rembx.jeeshop.catalog.model.Catalog)1 Store (org.rembx.jeeshop.catalog.model.Store)1