mirror of
https://github.com/valitydev/org-manager.git
synced 2024-11-06 00:15:23 +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>
|
||||
<groupId>dev.vality</groupId>
|
||||
<artifactId>service-parent-pom</artifactId>
|
||||
<version>1.0.15</version>
|
||||
<version>1.0.18</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>org-manager</artifactId>
|
||||
@ -46,12 +46,11 @@
|
||||
<dependency>
|
||||
<groupId>dev.vality</groupId>
|
||||
<artifactId>damsel</artifactId>
|
||||
<version>1.558-3efe7df</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.vality</groupId>
|
||||
<artifactId>org-management-proto</artifactId>
|
||||
<version>1.10-f433223</version>
|
||||
<version>1.11-03a269d</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>dev.vality</groupId>
|
||||
@ -62,7 +61,7 @@
|
||||
<dependency>
|
||||
<groupId>dev.vality</groupId>
|
||||
<artifactId>bouncer-proto</artifactId>
|
||||
<version>1.39-633ba73</version>
|
||||
<version>1.41-5628c61</version>
|
||||
</dependency>
|
||||
<!--spring-->
|
||||
<dependency>
|
||||
|
@ -18,6 +18,8 @@ public class MailMessageSender {
|
||||
|
||||
@Value("${dashboard.url}")
|
||||
private String dashboardUrl;
|
||||
@Value("${dudoser.mail-from}")
|
||||
private String mailFrom;
|
||||
|
||||
private final MessageSenderSrv.Iface dudoserClient;
|
||||
|
||||
@ -27,8 +29,8 @@ public class MailMessageSender {
|
||||
messageMail.setMailBody(new MailBody(dashboardUrl + body));
|
||||
messageMail.setToEmails(List.of(email));
|
||||
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));
|
||||
} catch (Exception ex) {
|
||||
log.warn("dudoserClient error", ex);
|
||||
|
@ -1,12 +1,9 @@
|
||||
package dev.vality.orgmanager.service;
|
||||
|
||||
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.PartyManagementSrv;
|
||||
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 lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -22,10 +19,9 @@ public class PartyManagementServiceImpl implements PartyManagementService {
|
||||
|
||||
@Override
|
||||
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));
|
||||
try {
|
||||
partyManagementClient.create(userInfo, partyId, partyParams);
|
||||
partyManagementClient.create(partyId, partyParams);
|
||||
} catch (PartyExists ex) {
|
||||
log.warn("Party already exists. (partyId: {}, userId: {}, email: {})", partyId, userId, email);
|
||||
} catch (TException ex) {
|
||||
|
@ -78,9 +78,10 @@ scheduler:
|
||||
dudoser:
|
||||
url: http://dudoser:8022/dudos
|
||||
networkTimeout: 10000
|
||||
mail-from: no-reply@vality.dev
|
||||
|
||||
party-management:
|
||||
url: http://party-management:8022/party/time
|
||||
url: http://party-management:8022/processing/partymgmt
|
||||
networkTimeout: 10000
|
||||
|
||||
dashboard:
|
||||
|
@ -1,10 +1,8 @@
|
||||
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.PartyManagementSrv;
|
||||
import dev.vality.damsel.payment_processing.PartyParams;
|
||||
import dev.vality.damsel.payment_processing.UserInfo;
|
||||
import dev.vality.orgmanager.exception.PartyManagementException;
|
||||
import org.apache.thrift.TException;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@ -15,14 +13,10 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import static dev.vality.orgmanager.TestObjectFactory.randomString;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class PartyManagementServiceImplTest {
|
||||
@ -39,26 +33,26 @@ class PartyManagementServiceImplTest {
|
||||
|
||||
@Test
|
||||
void shouldThrowPartyManagementExceptionOnCreateParty() throws TException {
|
||||
doThrow(new InvalidUser())
|
||||
.when(partyManagementClient).create(any(UserInfo.class), anyString(), any(PartyParams.class));
|
||||
doThrow(new TException())
|
||||
.when(partyManagementClient).create(anyString(), any(PartyParams.class));
|
||||
String partyId = randomString();
|
||||
String userId = randomString();
|
||||
String email = randomString();
|
||||
|
||||
PartyManagementException partyManagementException =
|
||||
var exception =
|
||||
assertThrows(
|
||||
PartyManagementException.class,
|
||||
() -> 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)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldCreatePartyIfPartyExistThrown() throws TException {
|
||||
doThrow(new PartyExists())
|
||||
.when(partyManagementClient).create(any(UserInfo.class), anyString(), any(PartyParams.class));
|
||||
.when(partyManagementClient).create(anyString(), any(PartyParams.class));
|
||||
String partyId = randomString();
|
||||
String userId = randomString();
|
||||
String email = randomString();
|
||||
@ -66,7 +60,7 @@ class PartyManagementServiceImplTest {
|
||||
partyManagementService.createParty(partyId, userId, email);
|
||||
|
||||
verify(partyManagementClient, times(1))
|
||||
.create(any(UserInfo.class), anyString(), any(PartyParams.class));
|
||||
.create(anyString(), any(PartyParams.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -77,16 +71,11 @@ class PartyManagementServiceImplTest {
|
||||
|
||||
partyManagementService.createParty(partyId, userId, email);
|
||||
|
||||
ArgumentCaptor<UserInfo> userInfoCaptor = ArgumentCaptor.forClass(UserInfo.class);
|
||||
ArgumentCaptor<String> partyIdCaptor = ArgumentCaptor.forClass(String.class);
|
||||
ArgumentCaptor<PartyParams> partyParamsCaptor = ArgumentCaptor.forClass(PartyParams.class);
|
||||
|
||||
verify(partyManagementClient, times(1))
|
||||
.create(userInfoCaptor.capture(), partyIdCaptor.capture(), partyParamsCaptor.capture());
|
||||
|
||||
assertEquals(1, userInfoCaptor.getAllValues().size());
|
||||
assertEquals(userId, userInfoCaptor.getValue().getId());
|
||||
assertTrue(userInfoCaptor.getValue().getType().isSetExternalUser());
|
||||
.create(partyIdCaptor.capture(), partyParamsCaptor.capture());
|
||||
|
||||
assertEquals(1, partyIdCaptor.getAllValues().size());
|
||||
assertEquals(partyId, partyIdCaptor.getValue());
|
||||
|
Loading…
Reference in New Issue
Block a user