use of com.icthh.xm.ms.entity.domain.Profile in project xm-ms-entity by xm-online.
the class ProfileResourceIntTest 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 Profile createEntity(EntityManager em, XmEntity xmEntity) {
Profile profile = new Profile().userKey(DEFAULT_USER_KEY);
// Add required entity
em.persist(xmEntity);
em.flush();
profile.setXmentity(xmEntity);
return profile;
}
use of com.icthh.xm.ms.entity.domain.Profile in project xm-ms-entity by xm-online.
the class ProfileResourceIntTest method equalsVerifier.
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(Profile.class);
Profile profile1 = new Profile();
profile1.setId(1L);
Profile profile2 = new Profile();
profile2.setId(profile1.getId());
assertThat(profile1).isEqualTo(profile2);
profile2.setId(2L);
assertThat(profile1).isNotEqualTo(profile2);
profile1.setId(null);
assertThat(profile1).isNotEqualTo(profile2);
}
use of com.icthh.xm.ms.entity.domain.Profile 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());
}
use of com.icthh.xm.ms.entity.domain.Profile 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.Profile in project xm-ms-entity by xm-online.
the class SystemQueueConsumerUnitTest method createExistsProfile.
@Test
public void createExistsProfile() {
when(profileService.getProfile(USER_KEY)).thenReturn(new Profile());
when(profileService.save(anyObject())).thenReturn(new Profile());
consumer.consumeEvent(new ConsumerRecord<>("test", 0, 0, "", CREATE_PROFILE_EVENT));
verify(profileService).getProfile(USER_KEY);
verify(profileService, times(0)).save(anyObject());
}
Aggregations