Search in sources :

Example 61 with XmEntity

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

the class LinkResourceIntTest 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 Link createEntity(EntityManager em) {
    Link link = new Link().typeKey(DEFAULT_TYPE_KEY).name(DEFAULT_NAME).description(DEFAULT_DESCRIPTION).startDate(DEFAULT_START_DATE).endDate(DEFAULT_END_DATE);
    // Add required entity
    XmEntity target = XmEntityResourceIntTest.createEntity(em);
    em.persist(target);
    em.flush();
    link.setTarget(target);
    // Add required entity
    XmEntity source = XmEntityResourceIntTest.createEntity(em);
    em.persist(source);
    em.flush();
    link.setSource(source);
    return link;
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Link(com.icthh.xm.ms.entity.domain.Link)

Example 62 with XmEntity

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

the class LocationResourceIntTest 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 Location createEntity(EntityManager em) {
    Location location = new Location().typeKey(DEFAULT_TYPE_KEY).countryKey(DEFAULT_COUNTRY_KEY).longitude(DEFAULT_LONGITUDE).latitude(DEFAULT_LATITUDE).name(DEFAULT_NAME).addressLine1(DEFAULT_ADDRESS_LINE_1).addressLine2(DEFAULT_ADDRESS_LINE_2).city(DEFAULT_CITY).region(DEFAULT_REGION).zip(DEFAULT_ZIP);
    // Add required entity
    XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
    em.persist(xmEntity);
    em.flush();
    location.setXmEntity(xmEntity);
    return location;
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Location(com.icthh.xm.ms.entity.domain.Location)

Example 63 with XmEntity

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

the class TypeKeyValidatorIntTest method testEntityTypeKeyValidationIsNotValid.

@Test
public void testEntityTypeKeyValidationIsNotValid() {
    XmEntity entity = new XmEntity().key("TYPE1.SUBTYPE2-1").typeKey("TYPE1.SUBTYPE2").name("Entity name").startDate(Instant.now()).updateDate(Instant.now());
    Set<ConstraintViolation<XmEntity>> constraintViolations = validator.validate(entity);
    assertEquals(1, 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 64 with XmEntity

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

the class TypeKeyValidatorIntTest method testTagTypeKeyValidationIsValid.

@Test
public void testTagTypeKeyValidationIsValid() {
    XmEntity entity = new XmEntity().key("TYPE1.SUBTYPE1-1").typeKey("TYPE1.SUBTYPE1").name("Entity name").startDate(Instant.now()).updateDate(Instant.now()).stateKey("STATE1").addTags(new Tag().typeKey("TAG1").name("Tag").startDate(Instant.now()));
    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) Tag(com.icthh.xm.ms.entity.domain.Tag) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 65 with XmEntity

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

the class TypeKeyValidatorIntTest method testStateKeyValidationIsValid.

@Test
public void testStateKeyValidationIsValid() {
    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)

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