Search in sources :

Example 1 with Store

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

the class Stores method findPresentationsLocales.

@GET
@Path("/{storeId}/presentationslocales")
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({ ADMIN, STORE_ADMIN, ADMIN_READONLY })
public Set<String> findPresentationsLocales(@Context SecurityContext securityContext, @PathParam("storeId") @NotNull Long storeId) {
    Store loadedStore = entityManager.find(Store.class, storeId);
    checkNotNull(loadedStore);
    if (!isAdminUser(securityContext) && !isOwner(securityContext, loadedStore.getOwner()))
        throw new WebApplicationException(Response.Status.FORBIDDEN);
    return loadedStore.getPresentationByLocale().keySet();
}
Also used : WebApplicationException(org.rembx.jeeshop.rest.WebApplicationException) Store(org.rembx.jeeshop.catalog.model.Store) RolesAllowed(javax.annotation.security.RolesAllowed)

Example 2 with Store

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

the class StoresCT method modify_shouldModify_for_admin.

@Test
public void modify_shouldModify_for_admin() {
    tester.setAdminUser();
    Store store = new Store(1L, "Superstore 2");
    store.setOwner(TestCatalog.OWNER);
    tester.test_modify(store);
    Store actual = tester.getEntityManager().find(Store.class, store.getId());
    assertThat(actual).isNotNull();
    assertThat(actual.getName()).isEqualTo("Superstore 2");
}
Also used : Store(org.rembx.jeeshop.catalog.model.Store) Test(org.junit.jupiter.api.Test)

Example 3 with Store

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

the class StoresCT method find_shouldLoadSchedules.

@Test
public void find_shouldLoadSchedules() {
    tester.setAdminUser();
    Store store = localService.find(tester.getSecurityContext(), 2L, null);
    assertThat(store).isNotNull();
    assertThat(store.getPremisses()).isNotEmpty();
    assertThat(store.getPremisses().get(0).getSchedules()).isNotEmpty();
    assertThat(store.getPremisses().get(0).getSchedules().get(0).getDayOfWeek()).isEqualTo(DayOfWeek.MONDAY);
}
Also used : Store(org.rembx.jeeshop.catalog.model.Store) Test(org.junit.jupiter.api.Test)

Example 4 with Store

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

the class StoresCT method delete_shouldRemove_for_store_admin.

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

Example 5 with Store

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

the class StoresCT method modify_shouldThrowForbidden_for_store_admin.

@Test
public void modify_shouldThrowForbidden_for_store_admin() {
    try {
        tester.setSAnotherStoreAdminUser();
        Store store = new Store(1L, "Superstore");
        tester.test_modify(store);
        fail("Should have throw an exception");
    } catch (WebApplicationException e) {
        assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.FORBIDDEN);
    }
}
Also used : WebApplicationException(org.rembx.jeeshop.rest.WebApplicationException) Store(org.rembx.jeeshop.catalog.model.Store) Test(org.junit.jupiter.api.Test)

Aggregations

Store (org.rembx.jeeshop.catalog.model.Store)18 Test (org.junit.jupiter.api.Test)13 WebApplicationException (org.rembx.jeeshop.rest.WebApplicationException)7 RolesAllowed (javax.annotation.security.RolesAllowed)3 ArrayList (java.util.ArrayList)2 PermitAll (javax.annotation.security.PermitAll)2 Transactional (javax.transaction.Transactional)2 Catalog (org.rembx.jeeshop.catalog.model.Catalog)2 Presentation (org.rembx.jeeshop.catalog.model.Presentation)1