use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class DeleteEntityTest method testDelete.
@Test
public void testDelete() {
XmEntity entity = xmEntityService.save(createXmEntity());
xmEntityService.delete(entity.getId());
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class EntityServiceImplIntTest method deleteSelfLinkTarget.
@Test
@Transactional
@WithMockUser(authorities = "SUPER-ADMIN")
public void deleteSelfLinkTarget() {
XmEntity targetEntity = xmEntityRepository.save(createEntity(2l, TARGET_TYPE_KEY));
Link link = createLink(self.getXmentity(), targetEntity);
linkRepository.save(link);
xmEntityService.deleteLinkTarget(IdOrKey.SELF, link.getId().toString());
assertThat(linkRepository.findAll()).hasSize(BigInteger.ZERO.intValue());
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class EntityServiceImplIntTest method createEntity.
private XmEntity createEntity(Long id, String typeKey) {
XmEntity entity = new XmEntity();
entity.setId(id);
entity.setName("Name");
entity.setTypeKey(typeKey);
entity.setStartDate(new Date().toInstant());
entity.setUpdateDate(new Date().toInstant());
entity.setKey("KEY-" + id);
entity.setStateKey("STATE1");
entity.setData(ImmutableMap.<String, Object>builder().put("AAAAAAAAAA", "BBBBBBBBBB").build());
return entity;
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class EntityServiceImplIntTest method beforeTransaction.
@BeforeTransaction
public void beforeTransaction() {
TenantContextUtils.setTenant(tenantContextHolder, "RESINTTEST");
MockitoAnnotations.initMocks(this);
when(authContextHolder.getContext()).thenReturn(context);
when(context.getRequiredUserKey()).thenReturn("userKey");
XmEntity sourceEntity = xmEntityRepository.save(createEntity(1l, TARGET_TYPE_KEY));
self = new Profile();
self.setXmentity(sourceEntity);
when(profileService.getSelfProfile()).thenReturn(self);
xmEntityService = new XmEntityServiceImpl(xmEntitySpecService, xmEntityRepository, xmEntitySearchRepository, lifecycleService, null, profileService, linkService, storageService, attachmentService, permittedSearchRepository, startUpdateDateGenerationStrategy, authContextHolder);
xmEntityService.setSelf(xmEntityService);
lepManager.beginThreadContext(ctx -> {
ctx.setValue(THREAD_CONTEXT_KEY_TENANT_CONTEXT, tenantContextHolder.getContext());
ctx.setValue(THREAD_CONTEXT_KEY_AUTH_CONTEXT, authContextHolder.getContext());
});
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class EntityServiceImplIntTest method saveSelfLinkTarget.
@Test
@Transactional
@WithMockUser(authorities = "SUPER-ADMIN")
public void saveSelfLinkTarget() throws Exception {
when(storageService.store(Mockito.any(MultipartFile.class), Mockito.any())).thenReturn("test.txt");
int databaseSizeBeforeCreate = linkRepository.findAll().size();
XmEntity targetEntity = xmEntityRepository.save(createEntity(2l, TARGET_TYPE_KEY));
Link link = createSelfLink(targetEntity);
// Create link with attachment
MockMultipartFile file = new MockMultipartFile("file", "test.txt", "text/plain", "TEST".getBytes());
xmEntityService.saveLinkTarget(IdOrKey.SELF, link, file);
// Validate the link in the database
List<Link> linkList = linkRepository.findAll();
assertThat(linkList).hasSize(databaseSizeBeforeCreate + BigInteger.ONE.intValue());
// validate attachment in database
List<Attachment> attachments = attachmentService.findAll(null);
assertThat(attachments).hasSize(BigInteger.ONE.intValue());
Attachment attachment = attachments.stream().findFirst().get();
assertThat(attachment.getContentUrl()).contains("test.txt");
}
Aggregations