Search in sources :

Example 1 with FunctionContext

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);
}
Also used : FunctionContext(com.icthh.xm.ms.entity.domain.FunctionContext) Test(org.junit.Test)

Example 2 with FunctionContext

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;
}
Also used : FunctionContext(com.icthh.xm.ms.entity.domain.FunctionContext)

Example 3 with FunctionContext

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);
}
Also used : FunctionContext(com.icthh.xm.ms.entity.domain.FunctionContext) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with FunctionContext

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);
}
Also used : FunctionContext(com.icthh.xm.ms.entity.domain.FunctionContext) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with FunctionContext

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;
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) FunctionContext(com.icthh.xm.ms.entity.domain.FunctionContext)

Aggregations

FunctionContext (com.icthh.xm.ms.entity.domain.FunctionContext)17 Test (org.junit.Test)12 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 Transactional (org.springframework.transaction.annotation.Transactional)6 XmEntity (com.icthh.xm.ms.entity.domain.XmEntity)3 Instant (java.time.Instant)2 Timed (com.codahale.metrics.annotation.Timed)1 Attachment (com.icthh.xm.ms.entity.domain.Attachment)1 Calendar (com.icthh.xm.ms.entity.domain.Calendar)1 Comment (com.icthh.xm.ms.entity.domain.Comment)1 Event (com.icthh.xm.ms.entity.domain.Event)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 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1