Search in sources :

Example 41 with XmEntity

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

the class TypeKeyValidatorIntTest method testEntityTypeKeyValidationIsValid.

@Test
public void testEntityTypeKeyValidationIsValid() {
    XmEntity entity = new XmEntity().key("TYPE1.SUBTYPE1-1").typeKey("TYPE1.SUBTYPE1").name("Entity name").startDate(Instant.now()).updateDate(Instant.now()).stateKey("STATE1");
    Set<ConstraintViolation<XmEntity>> constraintViolations = validator.validate(entity);
    assertEquals(0, constraintViolations.size());
}
Also used : ConstraintViolation(javax.validation.ConstraintViolation) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 42 with XmEntity

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

the class CalendarResourceIntTest 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 Calendar createEntity(EntityManager em) {
    // Create required entity
    XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
    em.persist(xmEntity);
    em.flush();
    return new Calendar().typeKey(DEFAULT_TYPE_KEY).name(DEFAULT_NAME).description(DEFAULT_DESCRIPTION).startDate(DEFAULT_START_DATE).endDate(DEFAULT_END_DATE).xmEntity(xmEntity);
}
Also used : Calendar(com.icthh.xm.ms.entity.domain.Calendar) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity)

Example 43 with XmEntity

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

the class CommentResourceIntTest 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 Comment createEntity(EntityManager em) {
    Comment comment = new Comment().userKey(DEFAULT_USER_KEY).message(DEFAULT_MESSAGE).entryDate(DEFAULT_ENTRY_DATE);
    // Add required entity
    XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
    em.persist(xmEntity);
    em.flush();
    comment.setXmEntity(xmEntity);
    return comment;
}
Also used : Comment(com.icthh.xm.ms.entity.domain.Comment) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity)

Example 44 with XmEntity

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

the class RatingResourceIntTest 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 Rating createEntity(EntityManager em) {
    Rating rating = new Rating().typeKey(DEFAULT_TYPE_KEY).value(DEFAULT_VALUE).startDate(DEFAULT_START_DATE).endDate(DEFAULT_END_DATE);
    // Add required entity
    XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
    em.persist(xmEntity);
    em.flush();
    rating.setXmEntity(xmEntity);
    return rating;
}
Also used : Rating(com.icthh.xm.ms.entity.domain.Rating) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity)

Example 45 with XmEntity

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

the class XmEntityResourceIntTest method updateXmEntity.

@Test
@Transactional
public void updateXmEntity() throws Exception {
    // Initialize the database
    xmEntityServiceImpl.save(xmEntity);
    int databaseSizeBeforeUpdate = xmEntityRepository.findAll().size();
    // Update the xmEntity
    XmEntity updatedXmEntity = xmEntityRepository.findOne(xmEntity.getId());
    em.detach(updatedXmEntity);
    updatedXmEntity.key(UPDATED_KEY).typeKey(UPDATED_TYPE_KEY).stateKey(UPDATED_STATE_KEY).name(UPDATED_NAME).startDate(UPDATED_START_DATE).updateDate(UPDATED_UPDATE_DATE).endDate(UPDATED_END_DATE).avatarUrl(UPDATED_AVATAR_URL).description(UPDATED_DESCRIPTION).data(UPDATED_DATA).removed(UPDATED_REMOVED);
    restXmEntityMockMvc.perform(put("/api/xm-entities").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedXmEntity))).andExpect(status().isOk());
    // Validate the XmEntity in the database
    List<XmEntity> xmEntityList = xmEntityRepository.findAll();
    assertThat(xmEntityList).hasSize(databaseSizeBeforeUpdate);
    XmEntity testXmEntity = xmEntityList.get(xmEntityList.size() - 1);
    assertThat(testXmEntity.getKey()).isEqualTo(UPDATED_KEY);
    assertThat(testXmEntity.getTypeKey()).isEqualTo(UPDATED_TYPE_KEY);
    assertThat(testXmEntity.getStateKey()).isEqualTo(UPDATED_STATE_KEY);
    assertThat(testXmEntity.getName()).isEqualTo(UPDATED_NAME);
    assertThat(testXmEntity.getStartDate()).isEqualTo(MOCKED_START_DATE);
    assertThat(testXmEntity.getUpdateDate()).isEqualTo(MOCKED_UPDATE_DATE);
    assertThat(testXmEntity.getEndDate()).isEqualTo(UPDATED_END_DATE);
    assertThat(testXmEntity.getAvatarUrl()).contains("bbbbb.jpg");
    assertThat(testXmEntity.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
    assertThat(testXmEntity.getData()).isEqualTo(UPDATED_DATA);
    assertThat(testXmEntity.isRemoved()).isEqualTo(UPDATED_REMOVED);
    // Validate the XmEntity in Elasticsearch
    XmEntity xmEntityEs = xmEntitySearchRepository.findOne(testXmEntity.getId());
    assertThat(xmEntityEs).isEqualToIgnoringGivenFields(testXmEntity, "avatarUrl", "attachments", "calendars", "locations", "ratings", "tags", "comments", "targets", "functionContexts");
}
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)

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