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