use of com.icthh.xm.ms.entity.domain.FunctionContext in project xm-ms-entity by xm-online.
the class StartUpdateDateGenerationStrategyUnitTest method testGenerateStartUpdateDate.
@Test
public void testGenerateStartUpdateDate() {
FunctionContext context = new FunctionContext();
assertThat(context.getStartDate()).isNull();
assertThat(context.getUpdateDate()).isNull();
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);
}
use of com.icthh.xm.ms.entity.domain.FunctionContext in project xm-ms-entity by xm-online.
the class FunctionContextServiceImpl method save.
/**
* Save a functionContext.
*
* @param functionContext the entity to save
* @return the persisted entity
*/
public FunctionContext save(FunctionContext functionContext) {
startUpdateDateGenerationStrategy.preProcessStartUpdateDates(functionContext, functionContext.getId(), functionContextRepository, FunctionContext::setStartDate, FunctionContext::getStartDate, FunctionContext::setUpdateDate);
FunctionContext result = functionContextRepository.save(functionContext);
functionContextSearchRepository.save(result);
return result;
}
use of com.icthh.xm.ms.entity.domain.FunctionContext in project xm-ms-entity by xm-online.
the class FunctionContextResourceExtendedIntTest method checkStartDateIsNotRequired.
@Test
@Transactional
public void checkStartDateIsNotRequired() throws Exception {
int databaseSizeBeforeTest = functionContextRepository.findAll().size();
// set the field null
functionContext.setStartDate(null);
// 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()));
List<FunctionContext> functionContextList = functionContextRepository.findAll();
assertThat(functionContextList).hasSize(databaseSizeBeforeTest + 1);
FunctionContext testFunctionContext = functionContextList.get(functionContextList.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 FunctionContextResourceIntTest method equalsVerifier.
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(FunctionContext.class);
FunctionContext functionContext1 = new FunctionContext();
functionContext1.setId(1L);
FunctionContext functionContext2 = new FunctionContext();
functionContext2.setId(functionContext1.getId());
assertThat(functionContext1).isEqualTo(functionContext2);
functionContext2.setId(2L);
assertThat(functionContext1).isNotEqualTo(functionContext2);
functionContext1.setId(null);
assertThat(functionContext1).isNotEqualTo(functionContext2);
}
use of com.icthh.xm.ms.entity.domain.FunctionContext in project xm-ms-entity by xm-online.
the class FunctionContextResourceIntTest method createEntity.
/**
* Create an entity for this test.
*
* 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 FunctionContext createEntity(EntityManager em) {
FunctionContext functionContext = new FunctionContext().key(DEFAULT_KEY).typeKey(DEFAULT_TYPE_KEY).description(DEFAULT_DESCRIPTION).startDate(DEFAULT_START_DATE).updateDate(DEFAULT_UPDATE_DATE).endDate(DEFAULT_END_DATE).data(DEFAULT_DATA);
// Add required entity
XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
em.persist(xmEntity);
em.flush();
functionContext.setXmEntity(xmEntity);
return functionContext;
}
Aggregations