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);
}
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);
}
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);
}
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);
}
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();
}
Aggregations