Search in sources :

Example 6 with FunctionContext

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);
}
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 7 with FunctionContext

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);
}
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 8 with FunctionContext

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);
}
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 9 with FunctionContext

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

Example 10 with FunctionContext

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

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