Search in sources :

Example 1 with Event

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

the class EventService method save.

/**
 * Save a event.
 *
 * @param event the entity to save
 * @return the persisted entity
 */
public Event save(Event event) {
    Event result = eventRepository.save(event);
    eventSearchRepository.save(result);
    return result;
}
Also used : Event(com.icthh.xm.ms.entity.domain.Event)

Example 2 with Event

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

the class EventResourceIntTest method updateEvent.

@Test
@Transactional
public void updateEvent() throws Exception {
    // Initialize the database
    eventService.save(event);
    int databaseSizeBeforeUpdate = eventRepository.findAll().size();
    // Update the event
    Event updatedEvent = eventRepository.findOne(event.getId());
    updatedEvent.typeKey(UPDATED_TYPE_KEY).repeatRuleKey(UPDATED_REPEAT_RULE_KEY).title(UPDATED_TITLE).description(UPDATED_DESCRIPTION).startDate(UPDATED_START_DATE).endDate(UPDATED_END_DATE);
    restEventMockMvc.perform(put("/api/events").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedEvent))).andExpect(status().isOk());
    // Validate the Event in the database
    List<Event> eventList = eventRepository.findAll();
    assertThat(eventList).hasSize(databaseSizeBeforeUpdate);
    Event testEvent = eventList.get(eventList.size() - 1);
    assertThat(testEvent.getTypeKey()).isEqualTo(UPDATED_TYPE_KEY);
    assertThat(testEvent.getRepeatRuleKey()).isEqualTo(UPDATED_REPEAT_RULE_KEY);
    assertThat(testEvent.getTitle()).isEqualTo(UPDATED_TITLE);
    assertThat(testEvent.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
    assertThat(testEvent.getStartDate()).isEqualTo(UPDATED_START_DATE);
    assertThat(testEvent.getEndDate()).isEqualTo(UPDATED_END_DATE);
    // Validate the Event in Elasticsearch
    Event eventEs = eventSearchRepository.findOne(testEvent.getId());
    assertThat(eventEs).isEqualToComparingFieldByField(testEvent);
}
Also used : Event(com.icthh.xm.ms.entity.domain.Event) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Event

use of com.icthh.xm.ms.entity.domain.Event 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 4 with Event

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

the class EventResourceIntTest method createEvent.

@Test
@Transactional
public void createEvent() throws Exception {
    int databaseSizeBeforeCreate = eventRepository.findAll().size();
    // Create the Event
    restEventMockMvc.perform(post("/api/events").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(event))).andExpect(status().isCreated());
    // Validate the Event in the database
    List<Event> eventList = eventRepository.findAll();
    assertThat(eventList).hasSize(databaseSizeBeforeCreate + 1);
    Event testEvent = eventList.get(eventList.size() - 1);
    assertThat(testEvent.getTypeKey()).isEqualTo(DEFAULT_TYPE_KEY);
    assertThat(testEvent.getRepeatRuleKey()).isEqualTo(DEFAULT_REPEAT_RULE_KEY);
    assertThat(testEvent.getTitle()).isEqualTo(DEFAULT_TITLE);
    assertThat(testEvent.getDescription()).isEqualTo(DEFAULT_DESCRIPTION);
    assertThat(testEvent.getStartDate()).isEqualTo(DEFAULT_START_DATE);
    assertThat(testEvent.getEndDate()).isEqualTo(DEFAULT_END_DATE);
    // Validate the Event in Elasticsearch
    Event eventEs = eventSearchRepository.findOne(testEvent.getId());
    assertThat(eventEs).isEqualToComparingFieldByField(testEvent);
}
Also used : Event(com.icthh.xm.ms.entity.domain.Event) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Event

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

the class EventResourceIntTest method equalsVerifier.

@Test
@Transactional
public void equalsVerifier() throws Exception {
    TestUtil.equalsVerifier(Event.class);
    Event event1 = new Event();
    event1.setId(1L);
    Event event2 = new Event();
    event2.setId(event1.getId());
    assertThat(event1).isEqualTo(event2);
    event2.setId(2L);
    assertThat(event1).isNotEqualTo(event2);
    event1.setId(null);
    assertThat(event1).isNotEqualTo(event2);
}
Also used : Event(com.icthh.xm.ms.entity.domain.Event) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

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