Search in sources :

Example 11 with Catalog

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

the class CatalogsCT method create_shouldSetupOwner_for_admin.

@Test
public void create_shouldSetupOwner_for_admin() {
    tester.setAdminUser();
    Catalog catalog = new Catalog("Catalog");
    catalog.setOwner(TestCatalog.OWNER);
    Catalog actualCatalog = tester.test_create(catalog);
    assertThat(actualCatalog).isNotNull();
    assertThat(actualCatalog.getOwner()).isEqualTo(TestCatalog.OWNER);
}
Also used : Catalog(org.rembx.jeeshop.catalog.model.Catalog) TestCatalog(org.rembx.jeeshop.catalog.test.TestCatalog) Test(org.junit.jupiter.api.Test)

Example 12 with Catalog

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

the class CatalogsCT method delete_shouldRemove.

@Test
public void delete_shouldRemove() {
    tester.setStoreAdminUser();
    Catalog catalog = new Catalog("Test Catalog");
    catalog.setOwner(TestCatalog.OWNER);
    tester.test_delete(catalog);
    assertThat(tester.getEntityManager().find(Catalog.class, catalog.getId())).isNull();
}
Also used : Catalog(org.rembx.jeeshop.catalog.model.Catalog) TestCatalog(org.rembx.jeeshop.catalog.test.TestCatalog) Test(org.junit.jupiter.api.Test)

Example 13 with Catalog

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

the class Catalogs method delete.

@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed(ADMIN)
@Path("/{catalogId}")
public void delete(@PathParam("catalogId") Long catalogId) {
    Catalog catalog = entityManager.find(Catalog.class, catalogId);
    checkNotNull(catalog);
    entityManager.remove(catalog);
}
Also used : Catalog(org.rembx.jeeshop.catalog.model.Catalog) RolesAllowed(javax.annotation.security.RolesAllowed)

Example 14 with Catalog

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

the class CatalogsCT method create_shouldPersist.

@Test
public void create_shouldPersist() {
    Catalog catalog = new Catalog("New Test Catalog");
    entityManager.getTransaction().begin();
    service.create(catalog);
    entityManager.getTransaction().commit();
    assertThat(entityManager.find(Catalog.class, catalog.getId())).isNotNull();
    entityManager.remove(catalog);
}
Also used : Catalog(org.rembx.jeeshop.catalog.model.Catalog) TestCatalog(org.rembx.jeeshop.catalog.test.TestCatalog) Test(org.junit.Test)

Example 15 with Catalog

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

Aggregations

Catalog (org.rembx.jeeshop.catalog.model.Catalog)22 Test (org.junit.jupiter.api.Test)10 TestCatalog (org.rembx.jeeshop.catalog.test.TestCatalog)10 WebApplicationException (org.rembx.jeeshop.rest.WebApplicationException)9 RolesAllowed (javax.annotation.security.RolesAllowed)7 ArrayList (java.util.ArrayList)6 PermitAll (javax.annotation.security.PermitAll)4 Category (org.rembx.jeeshop.catalog.model.Category)4 Transactional (javax.transaction.Transactional)3 Store (org.rembx.jeeshop.catalog.model.Store)2 Test (org.junit.Test)1 Presentation (org.rembx.jeeshop.catalog.model.Presentation)1