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