Search in sources :

Example 46 with XmEntity

use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.

the class XmEntityResourceIntTest method createXmEntity.

@Test
@Transactional
public void createXmEntity() throws Exception {
    int databaseSizeBeforeCreate = xmEntityRepository.findAll().size();
    // Create the XmEntity
    restXmEntityMockMvc.perform(post("/api/xm-entities").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(xmEntity))).andExpect(status().isCreated());
    // Validate the XmEntity in the database
    List<XmEntity> xmEntityList = xmEntityRepository.findAll();
    assertThat(xmEntityList).hasSize(databaseSizeBeforeCreate + 1);
    XmEntity testXmEntity = xmEntityList.get(xmEntityList.size() - 1);
    assertThat(testXmEntity.getKey()).isEqualTo(DEFAULT_KEY);
    assertThat(testXmEntity.getTypeKey()).isEqualTo(DEFAULT_TYPE_KEY);
    assertThat(testXmEntity.getStateKey()).isEqualTo(DEFAULT_STATE_KEY);
    assertThat(testXmEntity.getName()).isEqualTo(DEFAULT_NAME);
    assertThat(testXmEntity.getStartDate()).isEqualTo(MOCKED_START_DATE);
    assertThat(testXmEntity.getUpdateDate()).isEqualTo(MOCKED_UPDATE_DATE);
    assertThat(testXmEntity.getEndDate()).isEqualTo(DEFAULT_END_DATE);
    assertThat(testXmEntity.getAvatarUrl()).contains("aaaaa.jpg");
    assertThat(testXmEntity.getDescription()).isEqualTo(DEFAULT_DESCRIPTION);
    assertThat(testXmEntity.getData()).isEqualTo(DEFAULT_DATA);
    assertThat(testXmEntity.isRemoved()).isEqualTo(DEFAULT_REMOVED);
    // Validate the XmEntity in Elasticsearch
    XmEntity xmEntityEs = xmEntitySearchRepository.findOne(testXmEntity.getId());
    assertThat(xmEntityEs).isEqualToComparingFieldByField(testXmEntity);
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 47 with XmEntity

use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.

the class XmEntityResourceIntTest method equalsVerifier.

@Test
@Transactional
public void equalsVerifier() throws Exception {
    TestUtil.equalsVerifier(XmEntity.class);
    XmEntity xmEntity1 = new XmEntity();
    xmEntity1.setId(1L);
    XmEntity xmEntity2 = new XmEntity();
    xmEntity2.setId(xmEntity1.getId());
    assertThat(xmEntity1).isEqualTo(xmEntity2);
    xmEntity2.setId(2L);
    assertThat(xmEntity1).isNotEqualTo(xmEntity2);
    xmEntity1.setId(null);
    assertThat(xmEntity1).isNotEqualTo(xmEntity2);
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 48 with XmEntity

use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.

the class XmEntitySaveIntTest method testDeleteLep.

@Test
@Transactional
public void testDeleteLep() throws Exception {
    initLeps();
    XmEntity runSaveProceed = createEntity("TEST_DELETE_AND_PROCEED");
    XmEntity runSave = createEntity("TEST_DELETE_RUN");
    XmEntity runGeneralScript = createEntity("TEST_NOT_RUN_DELETE");
    xmEntityServiceImpl.save(runSaveProceed);
    xmEntityServiceImpl.save(runSave);
    xmEntityServiceImpl.save(runGeneralScript);
    xmEntityServiceImpl.delete(runSaveProceed.getId());
    xmEntityServiceImpl.delete(runSave.getId());
    xmEntityServiceImpl.delete(runGeneralScript.getId());
    assertThat(runSaveProceed.getData().get("runGeneralScriptDELETE")).isEqualTo(1);
    assertThat(runSaveProceed.getData().get("runDeleteProceed")).isEqualTo(1);
    assertThat(runSaveProceed.getData().get("runDeleteRun")).isEqualTo(0);
    assertThat(runSave.getData().get("runGeneralScriptDELETE")).isEqualTo(0);
    assertThat(runSave.getData().get("runDeleteProceed")).isEqualTo(0);
    assertThat(runSave.getData().get("runDeleteRun")).isEqualTo(1);
    assertThat(runGeneralScript.getData().get("runGeneralScriptDELETE")).isEqualTo(1);
    assertThat(runGeneralScript.getData().get("runDeleteProceed")).isEqualTo(0);
    assertThat(runGeneralScript.getData().get("runDeleteRun")).isEqualTo(0);
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 49 with XmEntity

use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.

the class TagResourceIntTest method createEntity.

/**
 * Create an entity for this test.
 * <p>
 * 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 Tag createEntity(EntityManager em) {
    Tag tag = new Tag().typeKey(DEFAULT_TYPE_KEY).name(DEFAULT_NAME).startDate(DEFAULT_START_DATE);
    // Add required entity
    XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
    em.persist(xmEntity);
    em.flush();
    tag.setXmEntity(xmEntity);
    return tag;
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Tag(com.icthh.xm.ms.entity.domain.Tag)

Example 50 with XmEntity

use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.

the class VoteResourceIntTest 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 Vote createEntity(EntityManager em) {
    Vote vote = new Vote().userKey(DEFAULT_USER_KEY).value(DEFAULT_VALUE).message(DEFAULT_MESSAGE).entryDate(DEFAULT_ENTRY_DATE);
    // Add required entity
    XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
    em.persist(xmEntity);
    em.flush();
    vote.setXmEntity(xmEntity);
    Rating rating = RatingResourceIntTest.createEntity(em);
    em.persist(rating);
    em.flush();
    vote.setRating(rating);
    return vote;
}
Also used : Vote(com.icthh.xm.ms.entity.domain.Vote) Rating(com.icthh.xm.ms.entity.domain.Rating) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity)

Aggregations

XmEntity (com.icthh.xm.ms.entity.domain.XmEntity)102 Test (org.junit.Test)60 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)46 Transactional (org.springframework.transaction.annotation.Transactional)32 Link (com.icthh.xm.ms.entity.domain.Link)22 Tag (com.icthh.xm.ms.entity.domain.Tag)10 ConstraintViolation (javax.validation.ConstraintViolation)9 WithMockUser (org.springframework.security.test.context.support.WithMockUser)9 MvcResult (org.springframework.test.web.servlet.MvcResult)9 HashMap (java.util.HashMap)8 Map (java.util.Map)8 SneakyThrows (lombok.SneakyThrows)8 Attachment (com.icthh.xm.ms.entity.domain.Attachment)7 Location (com.icthh.xm.ms.entity.domain.Location)7 lombok.val (lombok.val)7 Calendar (com.icthh.xm.ms.entity.domain.Calendar)6 Profile (com.icthh.xm.ms.entity.domain.Profile)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 Rating (com.icthh.xm.ms.entity.domain.Rating)5 Timed (com.codahale.metrics.annotation.Timed)4