Search in sources :

Example 6 with Calendar

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);
}
Also used : Calendar(com.icthh.xm.ms.entity.domain.Calendar) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity)

Example 7 with Calendar

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);
}
Also used : Calendar(com.icthh.xm.ms.entity.domain.Calendar) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with Calendar

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;
}
Also used : lombok.val(lombok.val) Calendar(com.icthh.xm.ms.entity.domain.Calendar) Event(com.icthh.xm.ms.entity.domain.Event) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) MvcResult(org.springframework.test.web.servlet.MvcResult)

Example 9 with Calendar

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);
}
Also used : Calendar(com.icthh.xm.ms.entity.domain.Calendar) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with Calendar

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;
}
Also used : Comment(com.icthh.xm.ms.entity.domain.Comment) Vote(com.icthh.xm.ms.entity.domain.Vote) Calendar(com.icthh.xm.ms.entity.domain.Calendar) Rating(com.icthh.xm.ms.entity.domain.Rating) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Event(com.icthh.xm.ms.entity.domain.Event) Attachment(com.icthh.xm.ms.entity.domain.Attachment) Tag(com.icthh.xm.ms.entity.domain.Tag) FunctionContext(com.icthh.xm.ms.entity.domain.FunctionContext) Location(com.icthh.xm.ms.entity.domain.Location)

Aggregations

Calendar (com.icthh.xm.ms.entity.domain.Calendar)11 Test (org.junit.Test)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 Transactional (org.springframework.transaction.annotation.Transactional)6 XmEntity (com.icthh.xm.ms.entity.domain.XmEntity)4 Attachment (com.icthh.xm.ms.entity.domain.Attachment)2 Comment (com.icthh.xm.ms.entity.domain.Comment)2 Event (com.icthh.xm.ms.entity.domain.Event)2 Location (com.icthh.xm.ms.entity.domain.Location)2 Rating (com.icthh.xm.ms.entity.domain.Rating)2 Tag (com.icthh.xm.ms.entity.domain.Tag)2 Vote (com.icthh.xm.ms.entity.domain.Vote)2 LogicExtensionPoint (com.icthh.xm.commons.lep.LogicExtensionPoint)1 FunctionContext (com.icthh.xm.ms.entity.domain.FunctionContext)1 Link (com.icthh.xm.ms.entity.domain.Link)1 lombok.val (lombok.val)1 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1