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