Search in sources :

Example 1 with Calendar

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

the class CalendarService method save.

/**
 * Save a calendar.
 *
 * @param calendar the entity to save
 * @return the persisted entity
 */
public Calendar save(Calendar calendar) {
    startUpdateDateGenerationStrategy.preProcessStartDate(calendar, calendar.getId(), calendarRepository, Calendar::setStartDate, Calendar::getStartDate);
    Calendar result = calendarRepository.save(calendar);
    calendarSearchRepository.save(result);
    return result;
}
Also used : Calendar(com.icthh.xm.ms.entity.domain.Calendar)

Example 2 with Calendar

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

the class CalendarResourceExtendedIntTest method checkStartDateIsNotRequired.

@Test
@Transactional
public void checkStartDateIsNotRequired() throws Exception {
    int databaseSizeBeforeTest = calendarRepository.findAll().size();
    // set the field null
    calendar.setStartDate(null);
    // Create the Calendar.
    restCalendarMockMvc.perform(post("/api/calendars").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(calendar))).andExpect(status().isCreated()).andExpect(jsonPath("$.startDate").value(MOCKED_START_DATE.toString()));
    List<Calendar> calendarList = calendarRepository.findAll();
    assertThat(calendarList).hasSize(databaseSizeBeforeTest + 1);
    Calendar testCalendar = calendarList.get(calendarList.size() - 1);
    assertThat(testCalendar.getStartDate()).isEqualTo(MOCKED_START_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 3 with Calendar

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

the class CalendarResourceExtendedIntTest method createCalendarWithEntryDate.

@Test
@Transactional
public void createCalendarWithEntryDate() 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()).andExpect(jsonPath("$.startDate").value(MOCKED_START_DATE.toString()));
    // Validate the Calendar in the database
    List<Calendar> voteList = calendarRepository.findAll();
    assertThat(voteList).hasSize(databaseSizeBeforeCreate + 1);
    Calendar testCalendar = voteList.get(voteList.size() - 1);
    assertThat(testCalendar.getStartDate()).isEqualTo(MOCKED_START_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 4 with Calendar

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

the class CalendarResourceExtendedIntTest method checkStartDateIsRequiredInDb.

@Test
@Transactional
public void checkStartDateIsRequiredInDb() throws Exception {
    Calendar cal = calendarService.save(calendar);
    // set the field null
    when(startUpdateDateGenerationStrategy.generateStartDate()).thenReturn(null);
    cal.setStartDate(null);
    calendarService.save(cal);
    try {
        calendarRepository.flush();
        fail("DataIntegrityViolationException exception was expected!");
    } catch (DataIntegrityViolationException e) {
        assertThat(e.getMostSpecificCause().getMessage()).containsIgnoringCase("NULL not allowed for column \"START_DATE\"");
    }
}
Also used : Calendar(com.icthh.xm.ms.entity.domain.Calendar) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Calendar

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

the class CalendarResourceIntTest method equalsVerifier.

@Test
@Transactional
public void equalsVerifier() throws Exception {
    TestUtil.equalsVerifier(Calendar.class);
    Calendar calendar1 = new Calendar();
    calendar1.setId(1L);
    Calendar calendar2 = new Calendar();
    calendar2.setId(calendar1.getId());
    assertThat(calendar1).isEqualTo(calendar2);
    calendar2.setId(2L);
    assertThat(calendar1).isNotEqualTo(calendar2);
    calendar1.setId(null);
    assertThat(calendar1).isNotEqualTo(calendar2);
}
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)

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