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