Search in sources :

Example 1 with CalendarSpec

use of com.icthh.xm.ms.entity.domain.spec.CalendarSpec in project xm-ms-entity by xm-online.

the class EventResourceIntTest method updateEventReadOnlyCalendar.

@Test
@Transactional
public void updateEventReadOnlyCalendar() throws Exception {
    CalendarSpec calendarSpec = new CalendarSpec();
    calendarSpec.setReadonly(true);
    when(xmEntitySpecService.findCalendar(eq(XmEntityResourceIntTest.DEFAULT_TYPE_KEY), eq(CalendarResourceIntTest.DEFAULT_TYPE_KEY))).thenReturn(Optional.of(calendarSpec));
    Calendar calendar = CalendarResourceIntTest.createEntity(em);
    em.persist(calendar);
    event.setCalendar(calendar);
    em.persist(event);
    em.detach(event);
    em.detach(event.getEventDataRef());
    event.typeKey(UPDATED_TYPE_KEY).repeatRuleKey(UPDATED_REPEAT_RULE_KEY).title(UPDATED_TITLE).description(UPDATED_DESCRIPTION).startDate(UPDATED_START_DATE).endDate(UPDATED_END_DATE).color(UPDATED_COLOR).calendar(calendar).getEventDataRef().setData(UPDATED_EVENT_DATA_REF_DATA);
    restEventMockMvc.perform(put("/api/events").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(event))).andExpect(status().isBadRequest()).andExpect(jsonPath("$.error").value("error.read.only.calendar")).andExpect(jsonPath("$.error_description").value(notNullValue()));
}
Also used : Calendar(com.icthh.xm.ms.entity.domain.Calendar) CalendarSpec(com.icthh.xm.ms.entity.domain.spec.CalendarSpec) AbstractSpringBootTest(com.icthh.xm.ms.entity.AbstractSpringBootTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with CalendarSpec

use of com.icthh.xm.ms.entity.domain.spec.CalendarSpec in project xm-ms-entity by xm-online.

the class EventResourceIntTest method createEventReadOnlyCalendar.

@Test
@Transactional
public void createEventReadOnlyCalendar() throws Exception {
    CalendarSpec calendarSpec = new CalendarSpec();
    calendarSpec.setReadonly(true);
    when(xmEntitySpecService.findCalendar(eq(XmEntityResourceIntTest.DEFAULT_TYPE_KEY), eq(CalendarResourceIntTest.DEFAULT_TYPE_KEY))).thenReturn(Optional.of(calendarSpec));
    Calendar calendar = CalendarResourceIntTest.createEntity(em);
    em.persist(calendar);
    event.setCalendar(calendar);
    restEventMockMvc.perform(post("/api/events").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(event))).andExpect(status().isBadRequest()).andExpect(jsonPath("$.error").value("error.read.only.calendar")).andExpect(jsonPath("$.error_description").value(notNullValue()));
}
Also used : Calendar(com.icthh.xm.ms.entity.domain.Calendar) CalendarSpec(com.icthh.xm.ms.entity.domain.spec.CalendarSpec) AbstractSpringBootTest(com.icthh.xm.ms.entity.AbstractSpringBootTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with CalendarSpec

use of com.icthh.xm.ms.entity.domain.spec.CalendarSpec in project xm-ms-entity by xm-online.

the class XmEntitySpecService method getAllKeys.

/**
 * Transforms all XmEntity Specification keys into the thin structure based
 * in maps and sets.
 *
 * @return thin structure based in maps and sets
 */
@IgnoreLogginAspect
public Map<String, Map<String, Set<String>>> getAllKeys() {
    Map<String, Map<String, Set<String>>> result = Maps.newHashMap();
    for (TypeSpec typeSpec : findAllTypes()) {
        Map<String, Set<String>> subKeys = Maps.newHashMap();
        getKeys(subKeys, AttachmentSpec.class, typeSpec.getAttachments(), AttachmentSpec::getKey);
        getKeys(subKeys, CalendarSpec.class, typeSpec.getCalendars(), CalendarSpec::getKey);
        getKeys(subKeys, LinkSpec.class, typeSpec.getLinks(), LinkSpec::getKey);
        getKeys(subKeys, LocationSpec.class, typeSpec.getLocations(), LocationSpec::getKey);
        getKeys(subKeys, RatingSpec.class, typeSpec.getRatings(), RatingSpec::getKey);
        getKeys(subKeys, StateSpec.class, typeSpec.getStates(), StateSpec::getKey);
        getKeys(subKeys, TagSpec.class, typeSpec.getTags(), TagSpec::getKey);
        result.put(typeSpec.getKey(), subKeys);
    }
    return result;
}
Also used : AttachmentSpec(com.icthh.xm.ms.entity.domain.spec.AttachmentSpec) LocationSpec(com.icthh.xm.ms.entity.domain.spec.LocationSpec) Set(java.util.Set) RatingSpec(com.icthh.xm.ms.entity.domain.spec.RatingSpec) StateSpec(com.icthh.xm.ms.entity.domain.spec.StateSpec) TagSpec(com.icthh.xm.ms.entity.domain.spec.TagSpec) LinkSpec(com.icthh.xm.ms.entity.domain.spec.LinkSpec) CalendarSpec(com.icthh.xm.ms.entity.domain.spec.CalendarSpec) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TypeSpec(com.icthh.xm.ms.entity.domain.spec.TypeSpec) IgnoreLogginAspect(com.icthh.xm.commons.logging.aop.IgnoreLogginAspect)

Example 4 with CalendarSpec

use of com.icthh.xm.ms.entity.domain.spec.CalendarSpec in project xm-ms-entity by xm-online.

the class CalendarResourceIntTest method createReadOnlyCalendar.

@Test
@Transactional
public void createReadOnlyCalendar() throws Exception {
    CalendarSpec calendarSpec = new CalendarSpec();
    calendarSpec.setReadonly(true);
    when(xmEntitySpecService.findCalendar(eq(XmEntityResourceIntTest.DEFAULT_TYPE_KEY), eq(DEFAULT_TYPE_KEY))).thenReturn(Optional.of(calendarSpec));
    createCalendar();
}
Also used : CalendarSpec(com.icthh.xm.ms.entity.domain.spec.CalendarSpec) AbstractSpringBootTest(com.icthh.xm.ms.entity.AbstractSpringBootTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with CalendarSpec

use of com.icthh.xm.ms.entity.domain.spec.CalendarSpec in project xm-ms-entity by xm-online.

the class CalendarResourceIntTest method updateReadOnlyCalendar.

@Test
@Transactional
public void updateReadOnlyCalendar() throws Exception {
    CalendarSpec calendarSpec = new CalendarSpec();
    calendarSpec.setReadonly(true);
    when(xmEntitySpecService.findCalendar(eq(XmEntityResourceIntTest.DEFAULT_TYPE_KEY), eq(DEFAULT_TYPE_KEY))).thenReturn(Optional.of(calendarSpec));
    when(xmEntitySpecService.findCalendar(eq(XmEntityResourceIntTest.DEFAULT_TYPE_KEY), eq(UPDATED_TYPE_KEY))).thenReturn(Optional.of(calendarSpec));
    calendarService.save(calendar);
    Calendar updatedCalendar = calendarRepository.findById(calendar.getId()).get();
    updatedCalendar.typeKey(UPDATED_TYPE_KEY).name(UPDATED_NAME).description(UPDATED_DESCRIPTION).startDate(UPDATED_START_DATE).endDate(UPDATED_END_DATE).setTimeZoneId(UPDATED_TIMEZONE_ID);
    restCalendarMockMvc.perform(put("/api/calendars").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedCalendar))).andExpect(status().isBadRequest()).andExpect(jsonPath("$.error").value("error.read.only.calendar")).andExpect(jsonPath("$.error_description").value(notNullValue()));
}
Also used : Calendar(com.icthh.xm.ms.entity.domain.Calendar) CalendarSpec(com.icthh.xm.ms.entity.domain.spec.CalendarSpec) AbstractSpringBootTest(com.icthh.xm.ms.entity.AbstractSpringBootTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

CalendarSpec (com.icthh.xm.ms.entity.domain.spec.CalendarSpec)5 AbstractSpringBootTest (com.icthh.xm.ms.entity.AbstractSpringBootTest)4 Test (org.junit.Test)4 Transactional (org.springframework.transaction.annotation.Transactional)4 Calendar (com.icthh.xm.ms.entity.domain.Calendar)3 IgnoreLogginAspect (com.icthh.xm.commons.logging.aop.IgnoreLogginAspect)1 AttachmentSpec (com.icthh.xm.ms.entity.domain.spec.AttachmentSpec)1 LinkSpec (com.icthh.xm.ms.entity.domain.spec.LinkSpec)1 LocationSpec (com.icthh.xm.ms.entity.domain.spec.LocationSpec)1 RatingSpec (com.icthh.xm.ms.entity.domain.spec.RatingSpec)1 StateSpec (com.icthh.xm.ms.entity.domain.spec.StateSpec)1 TagSpec (com.icthh.xm.ms.entity.domain.spec.TagSpec)1 TypeSpec (com.icthh.xm.ms.entity.domain.spec.TypeSpec)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1