use of com.icthh.xm.ms.entity.domain.FunctionContext in project xm-ms-entity by xm-online.
the class FunctionContextResourceIntTest method updateFunctionContext.
@Test
@Transactional
public void updateFunctionContext() throws Exception {
// Initialize the database
functionContextService.save(functionContext);
int databaseSizeBeforeUpdate = functionContextRepository.findAll().size();
// Update the functionContext
FunctionContext updatedFunctionContext = functionContextRepository.findOne(functionContext.getId());
em.detach(updatedFunctionContext);
updatedFunctionContext.key(UPDATED_KEY).typeKey(UPDATED_TYPE_KEY).description(UPDATED_DESCRIPTION).startDate(UPDATED_START_DATE).updateDate(UPDATED_UPDATE_DATE).endDate(UPDATED_END_DATE).data(UPDATED_DATA);
restFunctionContextMockMvc.perform(put("/api/function-contexts").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedFunctionContext))).andExpect(status().isOk());
// Validate the FunctionContext in the database
List<FunctionContext> functionContextList = functionContextRepository.findAll();
assertThat(functionContextList).hasSize(databaseSizeBeforeUpdate);
FunctionContext testFunctionContext = functionContextList.get(functionContextList.size() - 1);
assertThat(testFunctionContext.getKey()).isEqualTo(UPDATED_KEY);
assertThat(testFunctionContext.getTypeKey()).isEqualTo(UPDATED_TYPE_KEY);
assertThat(testFunctionContext.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
assertThat(testFunctionContext.getStartDate()).isEqualTo(DEFAULT_START_DATE);
assertThat(testFunctionContext.getUpdateDate()).isEqualTo(DEFAULT_UPDATE_DATE);
assertThat(testFunctionContext.getEndDate()).isEqualTo(UPDATED_END_DATE);
assertThat(testFunctionContext.getData()).isEqualTo(UPDATED_DATA);
// Validate the FunctionContext in Elasticsearch
FunctionContext functionContextEs = functionContextSearchRepository.findOne(testFunctionContext.getId());
assertThat(functionContextEs).isEqualToComparingFieldByField(testFunctionContext);
}
use of com.icthh.xm.ms.entity.domain.FunctionContext in project xm-ms-entity by xm-online.
the class FunctionContextResourceIntTest method createFunctionContext.
@Test
@Transactional
public void createFunctionContext() throws Exception {
int databaseSizeBeforeCreate = functionContextRepository.findAll().size();
// Create the FunctionContext
restFunctionContextMockMvc.perform(post("/api/function-contexts").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(functionContext))).andExpect(status().isCreated());
// Validate the FunctionContext in the database
List<FunctionContext> functionContextList = functionContextRepository.findAll();
assertThat(functionContextList).hasSize(databaseSizeBeforeCreate + 1);
FunctionContext testFunctionContext = functionContextList.get(functionContextList.size() - 1);
assertThat(testFunctionContext.getKey()).isEqualTo(DEFAULT_KEY);
assertThat(testFunctionContext.getTypeKey()).isEqualTo(DEFAULT_TYPE_KEY);
assertThat(testFunctionContext.getDescription()).isEqualTo(DEFAULT_DESCRIPTION);
assertThat(testFunctionContext.getStartDate()).isEqualTo(DEFAULT_START_DATE);
assertThat(testFunctionContext.getUpdateDate()).isEqualTo(DEFAULT_UPDATE_DATE);
assertThat(testFunctionContext.getEndDate()).isEqualTo(DEFAULT_END_DATE);
assertThat(testFunctionContext.getData()).isEqualTo(DEFAULT_DATA);
// Validate the FunctionContext in Elasticsearch
FunctionContext functionContextEs = functionContextSearchRepository.findOne(testFunctionContext.getId());
assertThat(functionContextEs).isEqualToComparingFieldByField(testFunctionContext);
}
use of com.icthh.xm.ms.entity.domain.FunctionContext in project xm-ms-entity by xm-online.
the class FunctionContextResourceExtendedIntTest method createFunctionContextWithEntryDate.
@Test
@Transactional
public void createFunctionContextWithEntryDate() throws Exception {
int databaseSizeBeforeCreate = functionContextRepository.findAll().size();
// Create the FunctionContext
restFunctionContextMockMvc.perform(post("/api/function-contexts").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(functionContext))).andExpect(status().isCreated()).andExpect(jsonPath("$.startDate").value(MOCKED_START_DATE.toString())).andExpect(jsonPath("$.updateDate").value(MOCKED_UPDATE_DATE.toString()));
// Validate the FunctionContext in the database
List<FunctionContext> voteList = functionContextRepository.findAll();
assertThat(voteList).hasSize(databaseSizeBeforeCreate + 1);
FunctionContext testFunctionContext = voteList.get(voteList.size() - 1);
assertThat(testFunctionContext.getStartDate()).isEqualTo(MOCKED_START_DATE);
assertThat(testFunctionContext.getUpdateDate()).isEqualTo(MOCKED_UPDATE_DATE);
// Validate the FunctionContext in Elasticsearch
FunctionContext functionContextEs = functionContextSearchRepository.findOne(testFunctionContext.getId());
assertThat(functionContextEs).isEqualToComparingFieldByField(testFunctionContext);
}
use of com.icthh.xm.ms.entity.domain.FunctionContext in project xm-ms-entity by xm-online.
the class FunctionContextResourceExtendedIntTest method checkStartDateIsRequiredInDb.
@Test
@Transactional
public void checkStartDateIsRequiredInDb() throws Exception {
FunctionContext o = functionContextService.save(functionContext);
// set the field null
when(startUpdateDateGenerationStrategy.generateStartDate()).thenReturn(null);
o.setStartDate(null);
functionContextService.save(o);
try {
functionContextRepository.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.FunctionContext in project xm-ms-entity by xm-online.
the class StartUpdateDateGenerationStrategyUnitTest method testOverrideInputDates.
@Test
public void testOverrideInputDates() {
FunctionContext context = new FunctionContext();
context.setStartDate(UPDATED_START_DATE);
context.setUpdateDate(UPDATED_UPDATE_DATE);
assertThat(context.getStartDate()).isEqualTo(UPDATED_START_DATE);
assertThat(context.getUpdateDate()).isEqualTo(UPDATED_UPDATE_DATE);
strategy.preProcessStartUpdateDates(context, context.getId(), repository, FunctionContext::setStartDate, FunctionContext::getStartDate, FunctionContext::setUpdateDate);
assertThat(context.getStartDate()).isEqualTo(MOCK_START_DATE);
assertThat(context.getUpdateDate()).isEqualTo(MOCK_UPDATE_DATE);
}
Aggregations