mirror of
https://github.com/valitydev/org-manager.git
synced 2024-11-06 08:25:21 +00:00
fix party management (#33)
Co-authored-by: ggmaleva <ggmaleva@yandex.ru>
This commit is contained in:
parent
6ec707b77e
commit
75cb52d9e2
7
pom.xml
7
pom.xml
@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.vality</groupId>
|
<groupId>dev.vality</groupId>
|
||||||
<artifactId>service-parent-pom</artifactId>
|
<artifactId>service-parent-pom</artifactId>
|
||||||
<version>1.0.15</version>
|
<version>1.0.18</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>org-manager</artifactId>
|
<artifactId>org-manager</artifactId>
|
||||||
@ -46,12 +46,11 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.vality</groupId>
|
<groupId>dev.vality</groupId>
|
||||||
<artifactId>damsel</artifactId>
|
<artifactId>damsel</artifactId>
|
||||||
<version>1.558-3efe7df</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.vality</groupId>
|
<groupId>dev.vality</groupId>
|
||||||
<artifactId>org-management-proto</artifactId>
|
<artifactId>org-management-proto</artifactId>
|
||||||
<version>1.10-f433223</version>
|
<version>1.11-03a269d</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>dev.vality</groupId>
|
<groupId>dev.vality</groupId>
|
||||||
@ -62,7 +61,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.vality</groupId>
|
<groupId>dev.vality</groupId>
|
||||||
<artifactId>bouncer-proto</artifactId>
|
<artifactId>bouncer-proto</artifactId>
|
||||||
<version>1.39-633ba73</version>
|
<version>1.41-5628c61</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--spring-->
|
<!--spring-->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -18,6 +18,8 @@ public class MailMessageSender {
|
|||||||
|
|
||||||
@Value("${dashboard.url}")
|
@Value("${dashboard.url}")
|
||||||
private String dashboardUrl;
|
private String dashboardUrl;
|
||||||
|
@Value("${dudoser.mail-from}")
|
||||||
|
private String mailFrom;
|
||||||
|
|
||||||
private final MessageSenderSrv.Iface dudoserClient;
|
private final MessageSenderSrv.Iface dudoserClient;
|
||||||
|
|
||||||
@ -27,8 +29,8 @@ public class MailMessageSender {
|
|||||||
messageMail.setMailBody(new MailBody(dashboardUrl + body));
|
messageMail.setMailBody(new MailBody(dashboardUrl + body));
|
||||||
messageMail.setToEmails(List.of(email));
|
messageMail.setToEmails(List.of(email));
|
||||||
messageMail.setSubject("Подтверждение вступления в организацию");
|
messageMail.setSubject("Подтверждение вступления в организацию");
|
||||||
messageMail.setFromEmail("no-reply@rbkmoney.com");
|
messageMail.setFromEmail(mailFrom);
|
||||||
|
log.info("Try to send message to email: {}", email);
|
||||||
dudoserClient.send(Message.message_mail(messageMail));
|
dudoserClient.send(Message.message_mail(messageMail));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.warn("dudoserClient error", ex);
|
log.warn("dudoserClient error", ex);
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package dev.vality.orgmanager.service;
|
package dev.vality.orgmanager.service;
|
||||||
|
|
||||||
import dev.vality.damsel.domain.PartyContactInfo;
|
import dev.vality.damsel.domain.PartyContactInfo;
|
||||||
import dev.vality.damsel.payment_processing.ExternalUser;
|
|
||||||
import dev.vality.damsel.payment_processing.PartyExists;
|
import dev.vality.damsel.payment_processing.PartyExists;
|
||||||
import dev.vality.damsel.payment_processing.PartyManagementSrv;
|
import dev.vality.damsel.payment_processing.PartyManagementSrv;
|
||||||
import dev.vality.damsel.payment_processing.PartyParams;
|
import dev.vality.damsel.payment_processing.PartyParams;
|
||||||
import dev.vality.damsel.payment_processing.UserInfo;
|
|
||||||
import dev.vality.damsel.payment_processing.UserType;
|
|
||||||
import dev.vality.orgmanager.exception.PartyManagementException;
|
import dev.vality.orgmanager.exception.PartyManagementException;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -22,10 +19,9 @@ public class PartyManagementServiceImpl implements PartyManagementService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createParty(String partyId, String userId, String email) {
|
public void createParty(String partyId, String userId, String email) {
|
||||||
UserInfo userInfo = new UserInfo(userId, UserType.external_user(new ExternalUser()));
|
|
||||||
PartyParams partyParams = new PartyParams(new PartyContactInfo(email));
|
PartyParams partyParams = new PartyParams(new PartyContactInfo(email));
|
||||||
try {
|
try {
|
||||||
partyManagementClient.create(userInfo, partyId, partyParams);
|
partyManagementClient.create(partyId, partyParams);
|
||||||
} catch (PartyExists ex) {
|
} catch (PartyExists ex) {
|
||||||
log.warn("Party already exists. (partyId: {}, userId: {}, email: {})", partyId, userId, email);
|
log.warn("Party already exists. (partyId: {}, userId: {}, email: {})", partyId, userId, email);
|
||||||
} catch (TException ex) {
|
} catch (TException ex) {
|
||||||
|
@ -78,9 +78,10 @@ scheduler:
|
|||||||
dudoser:
|
dudoser:
|
||||||
url: http://dudoser:8022/dudos
|
url: http://dudoser:8022/dudos
|
||||||
networkTimeout: 10000
|
networkTimeout: 10000
|
||||||
|
mail-from: no-reply@vality.dev
|
||||||
|
|
||||||
party-management:
|
party-management:
|
||||||
url: http://party-management:8022/party/time
|
url: http://party-management:8022/processing/partymgmt
|
||||||
networkTimeout: 10000
|
networkTimeout: 10000
|
||||||
|
|
||||||
dashboard:
|
dashboard:
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package dev.vality.orgmanager.service;
|
package dev.vality.orgmanager.service;
|
||||||
|
|
||||||
import dev.vality.damsel.payment_processing.InvalidUser;
|
|
||||||
import dev.vality.damsel.payment_processing.PartyExists;
|
import dev.vality.damsel.payment_processing.PartyExists;
|
||||||
import dev.vality.damsel.payment_processing.PartyManagementSrv;
|
import dev.vality.damsel.payment_processing.PartyManagementSrv;
|
||||||
import dev.vality.damsel.payment_processing.PartyParams;
|
import dev.vality.damsel.payment_processing.PartyParams;
|
||||||
import dev.vality.damsel.payment_processing.UserInfo;
|
|
||||||
import dev.vality.orgmanager.exception.PartyManagementException;
|
import dev.vality.orgmanager.exception.PartyManagementException;
|
||||||
import org.apache.thrift.TException;
|
import org.apache.thrift.TException;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
@ -15,14 +13,10 @@ import org.mockito.Mock;
|
|||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
import static dev.vality.orgmanager.TestObjectFactory.randomString;
|
import static dev.vality.orgmanager.TestObjectFactory.randomString;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.doThrow;
|
import static org.mockito.Mockito.*;
|
||||||
import static org.mockito.Mockito.times;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
|
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
class PartyManagementServiceImplTest {
|
class PartyManagementServiceImplTest {
|
||||||
@ -39,26 +33,26 @@ class PartyManagementServiceImplTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldThrowPartyManagementExceptionOnCreateParty() throws TException {
|
void shouldThrowPartyManagementExceptionOnCreateParty() throws TException {
|
||||||
doThrow(new InvalidUser())
|
doThrow(new TException())
|
||||||
.when(partyManagementClient).create(any(UserInfo.class), anyString(), any(PartyParams.class));
|
.when(partyManagementClient).create(anyString(), any(PartyParams.class));
|
||||||
String partyId = randomString();
|
String partyId = randomString();
|
||||||
String userId = randomString();
|
String userId = randomString();
|
||||||
String email = randomString();
|
String email = randomString();
|
||||||
|
|
||||||
PartyManagementException partyManagementException =
|
var exception =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
PartyManagementException.class,
|
PartyManagementException.class,
|
||||||
() -> partyManagementService.createParty(partyId, userId, email)
|
() -> partyManagementService.createParty(partyId, userId, email)
|
||||||
);
|
);
|
||||||
|
|
||||||
assertTrue(partyManagementException.getMessage().contains(String.format(
|
assertTrue(exception.getMessage().contains(String.format(
|
||||||
"Exception during party creation. (partyId: %s, userId: %s, email: %s)", partyId, userId, email)));
|
"Exception during party creation. (partyId: %s, userId: %s, email: %s)", partyId, userId, email)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldCreatePartyIfPartyExistThrown() throws TException {
|
void shouldCreatePartyIfPartyExistThrown() throws TException {
|
||||||
doThrow(new PartyExists())
|
doThrow(new PartyExists())
|
||||||
.when(partyManagementClient).create(any(UserInfo.class), anyString(), any(PartyParams.class));
|
.when(partyManagementClient).create(anyString(), any(PartyParams.class));
|
||||||
String partyId = randomString();
|
String partyId = randomString();
|
||||||
String userId = randomString();
|
String userId = randomString();
|
||||||
String email = randomString();
|
String email = randomString();
|
||||||
@ -66,7 +60,7 @@ class PartyManagementServiceImplTest {
|
|||||||
partyManagementService.createParty(partyId, userId, email);
|
partyManagementService.createParty(partyId, userId, email);
|
||||||
|
|
||||||
verify(partyManagementClient, times(1))
|
verify(partyManagementClient, times(1))
|
||||||
.create(any(UserInfo.class), anyString(), any(PartyParams.class));
|
.create(anyString(), any(PartyParams.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -77,16 +71,11 @@ class PartyManagementServiceImplTest {
|
|||||||
|
|
||||||
partyManagementService.createParty(partyId, userId, email);
|
partyManagementService.createParty(partyId, userId, email);
|
||||||
|
|
||||||
ArgumentCaptor<UserInfo> userInfoCaptor = ArgumentCaptor.forClass(UserInfo.class);
|
|
||||||
ArgumentCaptor<String> partyIdCaptor = ArgumentCaptor.forClass(String.class);
|
ArgumentCaptor<String> partyIdCaptor = ArgumentCaptor.forClass(String.class);
|
||||||
ArgumentCaptor<PartyParams> partyParamsCaptor = ArgumentCaptor.forClass(PartyParams.class);
|
ArgumentCaptor<PartyParams> partyParamsCaptor = ArgumentCaptor.forClass(PartyParams.class);
|
||||||
|
|
||||||
verify(partyManagementClient, times(1))
|
verify(partyManagementClient, times(1))
|
||||||
.create(userInfoCaptor.capture(), partyIdCaptor.capture(), partyParamsCaptor.capture());
|
.create(partyIdCaptor.capture(), partyParamsCaptor.capture());
|
||||||
|
|
||||||
assertEquals(1, userInfoCaptor.getAllValues().size());
|
|
||||||
assertEquals(userId, userInfoCaptor.getValue().getId());
|
|
||||||
assertTrue(userInfoCaptor.getValue().getType().isSetExternalUser());
|
|
||||||
|
|
||||||
assertEquals(1, partyIdCaptor.getAllValues().size());
|
assertEquals(1, partyIdCaptor.getAllValues().size());
|
||||||
assertEquals(partyId, partyIdCaptor.getValue());
|
assertEquals(partyId, partyIdCaptor.getValue());
|
||||||
|
Loading…
Reference in New Issue
Block a user