Search in sources :

Example 6 with Profile

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

the class ProfileServiceUnitTest method getProfile.

@Test
public void getProfile() {
    Profile profile = new Profile();
    profile.setId(1L);
    profile.setUserKey(USER_KEY);
    when(profileRepository.findOneByUserKey(USER_KEY)).thenReturn(profile);
    service.getProfile(USER_KEY);
    verify(profileRepository).findOneByUserKey(USER_KEY);
}
Also used : 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 7 with Profile

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

the class SystemQueueConsumerUnitTest method updateNotExistsProfile.

@Test
public void updateNotExistsProfile() {
    when(profileService.getProfile(USER_KEY)).thenReturn(null);
    when(profileService.save(anyObject())).thenReturn(new Profile());
    consumer.consumeEvent(new ConsumerRecord<>("test", 0, 0, "", UPDATE_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)

Example 8 with Profile

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

the class SystemQueueConsumerUnitTest method updateProfile.

@Test
public void updateProfile() {
    when(profileService.getProfile(USER_KEY)).thenReturn(new Profile());
    when(profileService.save(anyObject())).thenReturn(new Profile());
    consumer.consumeEvent(new ConsumerRecord<>("test", 0, 0, "", UPDATE_PROFILE_EVENT));
    verify(profileService).getProfile(USER_KEY);
    verify(profileService).save(anyObject());
}
Also used : Profile(com.icthh.xm.ms.entity.domain.Profile) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with Profile

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

the class TenantDatabaseService method buildProfileForDefaultUser.

private Profile buildProfileForDefaultUser(String tenantKey) {
    XmEntity entity = new XmEntity();
    entity.setTypeKey("ACCOUNT.USER");
    entity.setKey("ACCOUNT.USER-1");
    entity.setName("Administrator");
    entity.setStateKey(EntityState.NEW.name());
    entity.setStartDate(Instant.now());
    entity.setUpdateDate(Instant.now());
    entity.setCreatedBy(Constants.SYSTEM_ACCOUNT);
    Profile profile = new Profile();
    profile.setXmentity(entity);
    profile.setUserKey(tenantKey.toLowerCase());
    return profile;
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Profile(com.icthh.xm.ms.entity.domain.Profile)

Example 10 with Profile

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

the class ProfileResourceIntTest method getProfileByXmEntityId.

@Test
@Transactional
public void getProfileByXmEntityId() throws Exception {
    profileService.save(profile);
    Profile profileByEntityId = profileService.getByXmEntityId(profile.getXmentity().getId());
    Assert.assertNotNull(profileByEntityId);
    Assert.assertEquals(profile.getId(), profileByEntityId.getId());
    Assert.assertEquals(profile.getXmentity().getId(), profileByEntityId.getXmentity().getId());
}
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)

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