use of com.icthh.xm.ms.entity.domain.Calendar in project xm-ms-entity by xm-online.
the class CalendarResourceIntTest method createEntity.
/**
* Create an entity for this test.
* <p>
* This is a static method, as tests for other entities might also need it,
* if they test an entity which requires the current entity.
*/
public static Calendar createEntity(EntityManager em) {
// Create required entity
XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
em.persist(xmEntity);
em.flush();
return new Calendar().typeKey(DEFAULT_TYPE_KEY).name(DEFAULT_NAME).description(DEFAULT_DESCRIPTION).startDate(DEFAULT_START_DATE).endDate(DEFAULT_END_DATE).xmEntity(xmEntity);
}
use of com.icthh.xm.ms.entity.domain.Calendar in project xm-ms-entity by xm-online.
the class CalendarResourceIntTest method createCalendar.
@Test
@Transactional
public void createCalendar() throws Exception {
int databaseSizeBeforeCreate = calendarRepository.findAll().size();
// Create the Calendar
restCalendarMockMvc.perform(post("/api/calendars").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(calendar))).andExpect(status().isCreated());
// Validate the Calendar in the database
List<Calendar> calendarList = calendarRepository.findAll();
assertThat(calendarList).hasSize(databaseSizeBeforeCreate + 1);
Calendar testCalendar = calendarList.get(calendarList.size() - 1);
assertThat(testCalendar.getTypeKey()).isEqualTo(DEFAULT_TYPE_KEY);
assertThat(testCalendar.getName()).isEqualTo(DEFAULT_NAME);
assertThat(testCalendar.getDescription()).isEqualTo(DEFAULT_DESCRIPTION);
assertThat(testCalendar.getStartDate()).isEqualTo(DEFAULT_START_DATE);
assertThat(testCalendar.getEndDate()).isEqualTo(DEFAULT_END_DATE);
// Validate the Calendar in Elasticsearch
Calendar calendarEs = calendarSearchRepository.findOne(testCalendar.getId());
assertThat(calendarEs).isEqualToComparingFieldByField(testCalendar);
}
use of com.icthh.xm.ms.entity.domain.Calendar in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method prepareCalendar.
private int prepareCalendar() throws Exception {
// Create the XmEntity with tag
MvcResult result = performPost("/api/xm-entities", xmEntityIncoming).andExpect(status().isCreated()).andExpect(jsonPath("$.key").value(DEFAULT_KEY)).andReturn();
int id = JsonPath.read(result.getResponse().getContentAsString(), "$.id");
xmEntityIncoming.setId((long) id);
val calendar = new Calendar().name("name").typeKey("TYPEKEY").startDate(Instant.now()).xmEntity(xmEntityIncoming);
MvcResult resultSaveCalendar = performPost("/api/calendars", calendar).andExpect(status().is2xxSuccessful()).andReturn();
int calendarId = JsonPath.read(resultSaveCalendar.getResponse().getContentAsString(), "$.id");
calendar.setId((long) calendarId);
val event = new Event().typeKey("TYPEKEY").title("title").startDate(Instant.now()).calendar(calendar).assigned(xmEntityIncoming);
MvcResult resultSaveEvent = performPost("/api/events", event).andExpect(status().is2xxSuccessful()).andReturn();
List<XmEntity> xmEntityList = xmEntityRepository.findAll();
em.detach(xmEntityList.get(xmEntityList.size() - 1));
List<Calendar> calendarList = calendarService.findAll(null);
em.detach(calendarList.get(calendarList.size() - 1));
return id;
}
use of com.icthh.xm.ms.entity.domain.Calendar in project xm-ms-entity by xm-online.
the class CalendarResourceIntTest method updateCalendar.
@Test
@Transactional
public void updateCalendar() throws Exception {
// Initialize the database
calendarService.save(calendar);
int databaseSizeBeforeUpdate = calendarRepository.findAll().size();
// Update the calendar
Calendar updatedCalendar = calendarRepository.findOne(calendar.getId());
updatedCalendar.typeKey(UPDATED_TYPE_KEY).name(UPDATED_NAME).description(UPDATED_DESCRIPTION).startDate(UPDATED_START_DATE).endDate(UPDATED_END_DATE);
restCalendarMockMvc.perform(put("/api/calendars").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedCalendar))).andExpect(status().isOk());
// Validate the Calendar in the database
List<Calendar> calendarList = calendarRepository.findAll();
assertThat(calendarList).hasSize(databaseSizeBeforeUpdate);
Calendar testCalendar = calendarList.get(calendarList.size() - 1);
assertThat(testCalendar.getTypeKey()).isEqualTo(UPDATED_TYPE_KEY);
assertThat(testCalendar.getName()).isEqualTo(UPDATED_NAME);
assertThat(testCalendar.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
assertThat(testCalendar.getStartDate()).isEqualTo(UPDATED_START_DATE);
assertThat(testCalendar.getEndDate()).isEqualTo(UPDATED_END_DATE);
// Validate the Calendar in Elasticsearch
Calendar calendarEs = calendarSearchRepository.findOne(testCalendar.getId());
assertThat(calendarEs).isEqualToComparingFieldByField(testCalendar);
}
use of com.icthh.xm.ms.entity.domain.Calendar in project xm-ms-entity by xm-online.
the class DeleteEntityTest method createXmEntity.
private XmEntity createXmEntity() {
XmEntity xmEntity = new XmEntity().key(randomUUID().toString()).typeKey("TEST_DELETE");
xmEntity.name("name").functionContexts(asSet(new FunctionContext().key("1").typeKey("A").xmEntity(xmEntity), new FunctionContext().key("2").typeKey("A").xmEntity(xmEntity), new FunctionContext().key("3").typeKey("A").xmEntity(xmEntity))).attachments(asSet(new Attachment().typeKey("A").name("1"), new Attachment().typeKey("A").name("2"), new Attachment().typeKey("A").name("3"))).calendars(asSet(new Calendar().typeKey("A").name("1").events(asSet(new Event().typeKey("A").title("1"), new Event().typeKey("A").title("2"))), new Calendar().typeKey("A").name("2").events(asSet(new Event().typeKey("A").title("3"), new Event().typeKey("A").title("4"))))).locations(asSet(new Location().typeKey("A").name("1"), new Location().typeKey("A").name("2"))).ratings(asSet(new Rating().typeKey("A").votes(asSet(new Vote().message("1").value(1.1).userKey("1"), new Vote().message("2").value(2.1).userKey("2"))))).tags(asSet(new Tag().typeKey("A").name("1"), new Tag().typeKey("A").name("2"))).comments(asSet(new Comment().message("1").userKey("1"), new Comment().message("2").userKey("1")));
return xmEntity;
}
Aggregations