Search in sources :

Example 16 with Profile

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

the class SystemQueueConsumerUnitTest method createProfile.

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

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

the class XmEntityResource method produceEvent.

private void produceEvent(XmEntity entity, String eventType) {
    if (entity == null) {
        return;
    }
    Profile profile = profileService.getByXmEntityId(entity.getId());
    if (profile == null) {
        return;
    }
    String content = this.profileEventProducer.createEventJson(profile, eventType);
    this.profileEventProducer.send(content);
}
Also used : Profile(com.icthh.xm.ms.entity.domain.Profile)

Example 18 with Profile

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

the class ProfileService method updateProfile.

@LogicExtensionPoint("UpdateProfile")
public XmEntity updateProfile(XmEntity entity) {
    Profile profile = getSelfProfile();
    XmEntity profileEntity = profile.getXmentity();
    // update profile data
    profileEntity.setData(entity.getData());
    save(profile);
    return profileEntity;
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Profile(com.icthh.xm.ms.entity.domain.Profile) LogicExtensionPoint(com.icthh.xm.commons.lep.LogicExtensionPoint)

Example 19 with Profile

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

the class ProfileService method getSelfProfile.

@LogicExtensionPoint("GetSelfProfile")
@Transactional(readOnly = true)
public Profile getSelfProfile() {
    XmAuthenticationContext context = authContextHolder.getContext();
    if (!context.isFullyAuthenticated()) {
        throw new EntityNotFoundException("Can't get profile for not fully authenticated user");
    }
    String userKey = context.getRequiredUserKey();
    log.debug("Get profile for user key {}", userKey);
    Profile profile = getProfile(userKey);
    if (profile == null) {
        throw new IllegalArgumentException("Profile not found for user key " + userKey);
    }
    return profile;
}
Also used : XmAuthenticationContext(com.icthh.xm.commons.security.XmAuthenticationContext) EntityNotFoundException(com.icthh.xm.commons.exceptions.EntityNotFoundException) Profile(com.icthh.xm.ms.entity.domain.Profile) LogicExtensionPoint(com.icthh.xm.commons.lep.LogicExtensionPoint) 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