Search in sources :

Example 66 with XmEntity

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

the class AttachmentResourceIntTest 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 Attachment createEntity(EntityManager em) {
    Attachment attachment = new Attachment().typeKey(DEFAULT_TYPE_KEY).name(DEFAULT_NAME).contentUrl(DEFAULT_CONTENT_URL).description(DEFAULT_DESCRIPTION).startDate(DEFAULT_START_DATE).endDate(DEFAULT_END_DATE).valueContentType(DEFAULT_VALUE_CONTENT_TYPE).valueContentSize(DEFAULT_VALUE_CONTENT_SIZE);
    // Add required entity
    XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
    em.persist(xmEntity);
    em.flush();
    attachment.setXmEntity(xmEntity);
    return attachment;
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Attachment(com.icthh.xm.ms.entity.domain.Attachment)

Example 67 with XmEntity

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

the class XmEntitySaveIntTest method createEntity.

public static XmEntity createEntity(String typeKey) {
    val data = new HashMap<String, Object>();
    data.put("runGeneralScript", 0);
    data.put("runGeneralScriptDELETE", 0);
    data.put("runSaveProceed", 0);
    data.put("runSaveRun", 0);
    data.put("runDeleteProceed", 0);
    data.put("runDeleteRun", 0);
    val entity = new XmEntity().key(UUID.randomUUID()).typeKey(typeKey).startDate(Instant.now()).stateKey("STATE1").name("DEFAULT_NAME").description("DEFAULT_DESCRIPTION");
    entity.setData(data);
    return entity;
}
Also used : lombok.val(lombok.val) HashMap(java.util.HashMap) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity)

Example 68 with XmEntity

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

the class XmEntitySaveIntTest method testLep.

@Test
@Transactional
public void testLep() throws Exception {
    initLeps();
    XmEntity runSaveProceed = createEntity("TEST_SAVE_AND_PROCEED");
    XmEntity runSave = createEntity("TEST_SAVE_RUN");
    XmEntity runGeneralScript = createEntity("TEST_NOT_RUN_SAVE");
    xmEntityServiceImpl.save(runSaveProceed);
    xmEntityServiceImpl.save(runSave);
    xmEntityServiceImpl.save(runGeneralScript);
    assertThat(runSaveProceed.getData().get("runGeneralScript")).isEqualTo(1);
    assertThat(runSaveProceed.getData().get("runSaveProceed")).isEqualTo(1);
    assertThat(runSaveProceed.getData().get("runSaveRun")).isEqualTo(0);
    assertThat(runSave.getData().get("runGeneralScript")).isEqualTo(0);
    assertThat(runSave.getData().get("runSaveProceed")).isEqualTo(0);
    assertThat(runSave.getData().get("runSaveRun")).isEqualTo(1);
    assertThat(runGeneralScript.getData().get("runGeneralScript")).isEqualTo(1);
    assertThat(runGeneralScript.getData().get("runSaveProceed")).isEqualTo(0);
    assertThat(runGeneralScript.getData().get("runSaveRun")).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 69 with XmEntity

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

the class EntityToExcelConverterUnitTest method buildXmEntity.

private XmEntity buildXmEntity() {
    XmEntity entity = new XmEntity();
    entity.setId(DEFAULT_LONG_VALUE);
    return entity.key(DEFAULT_STRING_VALUE).typeKey(DEFAULT_STRING_VALUE).stateKey(DEFAULT_STRING_VALUE).name(DEFAULT_STRING_VALUE).startDate(Instant.now()).updateDate(Instant.now()).endDate(Instant.now()).avatarUrl(DEFAULT_STRING_VALUE).description(DEFAULT_STRING_VALUE).createdBy(DEFAULT_STRING_VALUE).removed(false);
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity)

Example 70 with XmEntity

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

the class ProfileServiceUnitTest method getProfileByEntityId.

@Test
public void getProfileByEntityId() {
    Profile profile = new Profile();
    profile.setId(1L);
    profile.setUserKey(USER_KEY);
    XmEntity entity = XmEntityResourceIntTest.createEntity(null);
    entity.setId(2L);
    profile.setXmentity(entity);
    when(profileRepository.findOneByXmentityId(entity.getId())).thenReturn(profile);
    service.getByXmEntityId(entity.getId());
    verify(profileRepository).findOneByXmentityId(entity.getId());
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Profile(com.icthh.xm.ms.entity.domain.Profile) XmEntityResourceIntTest(com.icthh.xm.ms.entity.web.rest.XmEntityResourceIntTest) 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