Search in sources :

Example 36 with XmEntity

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

the class XmEntityResourceIntTest method createXmEntityTenantWithWhitespace.

@Test
@Transactional
public void createXmEntityTenantWithWhitespace() throws Exception {
    int databaseSizeBeforeCreate = xmEntityRepository.findAll().size();
    XmEntity tenant = createEntity(em);
    tenant.setTypeKey(Constants.TENANT_TYPE_KEY);
    tenant.setName("test name");
    // An entity with an existing ID cannot be created, so this API call must fail
    restXmEntityMockMvc.perform(post("/api/xm-entities").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(tenant))).andExpect(status().isBadRequest()).andExpect(jsonPath("$.error").value("error.validation")).andExpect(jsonPath("$.error_description").value(notNullValue()));
    // Validate the Alice in the database
    List<XmEntity> xmEntityList = xmEntityRepository.findAll();
    assertThat(xmEntityList).hasSize(databaseSizeBeforeCreate);
}
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 37 with XmEntity

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

the class TypeKeyValidatorIntTest method testStateKeyValidationIsNotValid.

@Test
public void testStateKeyValidationIsNotValid() {
    XmEntity entity = new XmEntity().key("TYPE1.SUBTYPE1-1").typeKey("TYPE1.SUBTYPE1").name("Entity name").startDate(Instant.now()).updateDate(Instant.now()).stateKey("UNVALIDSTATE");
    Set<ConstraintViolation<XmEntity>> constraintViolations = validator.validate(entity);
    assertEquals(1, constraintViolations.size());
    assertEquals("{xm.ms.entity.state.constraint}", constraintViolations.iterator().next().getMessageTemplate());
}
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 38 with XmEntity

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

the class TypeKeyValidatorIntTest method testDataValidation.

private void testDataValidation(Map data) {
    XmEntity entity = new XmEntity().key("TYPE1.SUBTYPE1-1").typeKey("TYPE1.SUBTYPE1").name("Entity name").startDate(Instant.now()).updateDate(Instant.now()).stateKey("STATE1").data(data);
    Set<ConstraintViolation<XmEntity>> constraintViolations = validator.validate(entity);
    assertEquals(1, constraintViolations.size());
    assertEquals("{xm.ms.entity.data.constraint}", constraintViolations.iterator().next().getMessageTemplate());
}
Also used : ConstraintViolation(javax.validation.ConstraintViolation) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity)

Example 39 with XmEntity

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

the class TypeKeyValidatorIntTest method testXmEntityDataValidationIsValid.

@Test
public void testXmEntityDataValidationIsValid() {
    Map data = of("booleanProperties", false, "numberProperties", 5, "stringProperties", "str");
    XmEntity entity = new XmEntity().key("TYPE1.SUBTYPE1-1").typeKey("TYPE1.SUBTYPE1").name("Entity name").startDate(Instant.now()).updateDate(Instant.now()).stateKey("STATE1").data(data);
    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) Map(java.util.Map) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 40 with XmEntity

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

the class TypeKeyValidatorIntTest method testTagTypeKeyValidationIsNotValid.

@Test
public void testTagTypeKeyValidationIsNotValid() {
    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("TAG2").name("Tag").startDate(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) Tag(com.icthh.xm.ms.entity.domain.Tag) 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