Search in sources :

Example 81 with XmEntity

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

the class EntityServiceImplIntTest method testGetLinkTargetsSelfKey.

@Test
@Transactional
public void testGetLinkTargetsSelfKey() throws Exception {
    XmEntity targetEntity = xmEntityRepository.save(createEntity(2l, TARGET_TYPE_KEY));
    Link link = createSelfLink(targetEntity);
    linkRepository.save(link);
    List<Link> result = xmEntityService.getLinkTargets(IdOrKey.SELF, TARGET_TYPE_KEY);
    assertThat(result).isNotNull();
    assertThat(result.size()).isEqualTo(BigInteger.ONE.intValue());
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Link(com.icthh.xm.ms.entity.domain.Link) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 82 with XmEntity

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

the class EntityServiceImplIntTest method deleteForeignLinkTarget.

@Test(expected = BusinessException.class)
@Transactional
@WithMockUser(authorities = "SUPER-ADMIN")
public void deleteForeignLinkTarget() {
    XmEntity sourceEntity = xmEntityRepository.save(createEntity(25l, "ACCOUNT.USER"));
    XmEntity targetEntity = xmEntityRepository.save(createEntity(2l, TARGET_TYPE_KEY));
    Link link = createLink(sourceEntity, targetEntity);
    linkRepository.save(link);
    xmEntityService.deleteLinkTarget(IdOrKey.SELF, link.getId().toString());
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Link(com.icthh.xm.ms.entity.domain.Link) WithMockUser(org.springframework.security.test.context.support.WithMockUser) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 83 with XmEntity

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

the class EntityServiceImplIntTest method testGetLinkTargetsByEntityId.

@Test
@Transactional
public void testGetLinkTargetsByEntityId() throws Exception {
    XmEntity sourceEntity = xmEntityRepository.save(createEntity(null, "ACCOUNT"));
    XmEntity targetEntity = xmEntityRepository.save(createEntity(2l, TARGET_TYPE_KEY));
    Link link = createLink(sourceEntity, targetEntity);
    linkRepository.save(link);
    List<Link> targetsLinks = xmEntityService.getLinkTargets(IdOrKey.of(sourceEntity.getId()), TARGET_TYPE_KEY);
    assertThat(targetsLinks).isNotEmpty();
    assertThat(targetsLinks.size()).isEqualTo(BigInteger.ONE.intValue());
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Link(com.icthh.xm.ms.entity.domain.Link) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 84 with XmEntity

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

the class AvatarUrlListenerUnitTest method testPostLoadSuccess.

@Ignore
@Test
public void testPostLoadSuccess() {
    XmEntity entity = new XmEntity().avatarUrl("hello.jpg");
    target.postLoad(entity);
    assertEquals("http://hello.rgw.icthh.test/hello.jpg", entity.getAvatarUrl());
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 85 with XmEntity

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

the class AvatarUrlListenerUnitTest method testPrePersistEmpty.

@Test
public void testPrePersistEmpty() {
    XmEntity entity = new XmEntity().avatarUrl(null);
    target.prePersist(entity);
    assertEquals(null, entity.getAvatarUrl());
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Test(org.junit.Test)

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