Search in sources :

Example 1 with Profile

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

the class ProfileService method save.

/**
 * Save a profile.
 *
 * @param profile the entity to save
 * @return the persisted entity
 */
public Profile save(Profile profile) {
    Profile result = profileRepository.save(profile);
    profileSearchRepository.save(result);
    entitySearchRepository.save(result.getXmentity());
    return result;
}
Also used : Profile(com.icthh.xm.ms.entity.domain.Profile)

Example 2 with Profile

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

the class SystemEventMapperUnitTest method testMap.

@Test
public void testMap() {
    Profile profile = new Profile();
    SystemEventMapper.toProfile(createEvent(), profile);
    assertNotNull(profile.getXmentity());
    assertEquals(DEFAULT_FIRST_NAME + " " + DEFAULT_LAST_NAME, profile.getXmentity().getName());
    assertEquals(Constants.ACCOUNT_TYPE_KEY + "-" + DEFAULT_ID, profile.getXmentity().getKey());
    assertEquals(DEFAULT_IMAGE_URL, profile.getXmentity().getAvatarUrl());
    assertEquals(EntityState.NEW.name(), profile.getXmentity().getStateKey());
    assertEquals(DEFAULT_CREATED_DATE, profile.getXmentity().getStartDate());
    assertEquals(DEFAULT_LAST_MODIFIED_DATE, profile.getXmentity().getUpdateDate());
    assertEquals(DEFAULT_USER_KEY, profile.getUserKey());
}
Also used : Profile(com.icthh.xm.ms.entity.domain.Profile) Test(org.junit.Test)

Example 3 with Profile

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

the class SystemEventMapperUnitTest method testMapWithoutDate.

@Test
public void testMapWithoutDate() {
    Profile profile = new Profile();
    SystemEventMapper.toProfile(createEventWithoutDates(), profile);
    assertNotNull(profile.getXmentity());
    assertEquals(DEFAULT_FIRST_NAME + " " + DEFAULT_LAST_NAME, profile.getXmentity().getName());
    assertEquals(Constants.ACCOUNT_TYPE_KEY + "-" + DEFAULT_ID, profile.getXmentity().getKey());
    assertEquals(DEFAULT_IMAGE_URL, profile.getXmentity().getAvatarUrl());
    assertEquals(EntityState.NEW.name(), profile.getXmentity().getStateKey());
    assertNotNull(profile.getXmentity().getStartDate());
    assertNotNull(profile.getXmentity().getUpdateDate());
    assertEquals(DEFAULT_USER_KEY, profile.getUserKey());
}
Also used : Profile(com.icthh.xm.ms.entity.domain.Profile) Test(org.junit.Test)

Example 4 with Profile

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

the class SystemEventMapperUnitTest method testMapProfileAlreadyExists.

@Test
public void testMapProfileAlreadyExists() {
    Long id = 1L;
    Profile profile = new Profile();
    profile.setId(id);
    profile.setXmentity(new XmEntity());
    profile.getXmentity().setStateKey(EntityState.ACTIVE.name());
    profile.getXmentity().setId(id);
    SystemEventMapper.toProfile(createEvent(), profile);
    assertNotNull(profile.getXmentity());
    assertEquals(id, profile.getId());
    assertEquals(id, profile.getXmentity().getId());
    assertEquals(DEFAULT_FIRST_NAME + " " + DEFAULT_LAST_NAME, profile.getXmentity().getName());
    assertEquals(Constants.ACCOUNT_TYPE_KEY + "-" + DEFAULT_ID, profile.getXmentity().getKey());
    assertEquals(DEFAULT_IMAGE_URL, profile.getXmentity().getAvatarUrl());
    assertEquals(EntityState.ACTIVE.name(), profile.getXmentity().getStateKey());
    assertNotNull(profile.getXmentity().getStartDate());
    assertNotNull(profile.getXmentity().getUpdateDate());
    assertEquals(DEFAULT_USER_KEY, profile.getUserKey());
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Profile(com.icthh.xm.ms.entity.domain.Profile) Test(org.junit.Test)

Example 5 with Profile

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

the class ProfileServiceUnitTest method saveProfile.

@Test
public void saveProfile() {
    Profile profile = new Profile();
    profile.setId(ID);
    XmEntity xmEntity = new XmEntity();
    xmEntity.setId(ID);
    profile.setXmentity(xmEntity);
    when(profileRepository.save(profile)).thenReturn(profile);
    when(profileSearchRepository.save(profile)).thenReturn(profile);
    when(entitySearchRepository.save(profile.getXmentity())).thenReturn(profile.getXmentity());
    service.save(profile);
    verify(profileRepository).save(profile);
    verify(profileSearchRepository).save(profile);
    verify(entitySearchRepository).save(profile.getXmentity());
}
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)

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