Search in sources :

Example 11 with Profile

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;
}
Also used : Profile(com.icthh.xm.ms.entity.domain.Profile)

Example 12 with 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);
}
Also used : Profile(com.icthh.xm.ms.entity.domain.Profile) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with Profile

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());
}
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)

Example 14 with Profile

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());
    });
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Profile(com.icthh.xm.ms.entity.domain.Profile) BeforeTransaction(org.springframework.test.context.transaction.BeforeTransaction)

Example 15 with Profile

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());
}
Also used : Profile(com.icthh.xm.ms.entity.domain.Profile) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Profile (com.icthh.xm.ms.entity.domain.Profile)19 Test (org.junit.Test)12 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 XmEntity (com.icthh.xm.ms.entity.domain.XmEntity)6 XmEntityResourceIntTest (com.icthh.xm.ms.entity.web.rest.XmEntityResourceIntTest)3 Transactional (org.springframework.transaction.annotation.Transactional)3 LogicExtensionPoint (com.icthh.xm.commons.lep.LogicExtensionPoint)2 EntityNotFoundException (com.icthh.xm.commons.exceptions.EntityNotFoundException)1 XmAuthenticationContext (com.icthh.xm.commons.security.XmAuthenticationContext)1 BeforeTransaction (org.springframework.test.context.transaction.BeforeTransaction)1