Fixing VerificationResultComponentTest and PaymentUpdateBySdf04Test.
This commit is contained in:
parent
3c31fc9d02
commit
de54b1c94a
2 changed files with 48 additions and 11 deletions
|
|
@ -46,6 +46,12 @@ class PaymentUpdateBySdf04Test extends AbstractClearingTest {
|
||||||
this.settingResult = ArgumentCaptor.forClass(PaymentInstruction.class);
|
this.settingResult = ArgumentCaptor.forClass(PaymentInstruction.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link PaymentUpdateBySdf04#updatePayments(Long)} ()} <br>
|
||||||
|
* Тест проверяет обновление сущности
|
||||||
|
* {@link PaymentInstruction}
|
||||||
|
* в Hazelcast при передаче из Apache Kafka.<br>
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
void updatePayments() throws NoSuchFieldException, IllegalAccessException {
|
void updatePayments() throws NoSuchFieldException, IllegalAccessException {
|
||||||
//ARRANGE
|
//ARRANGE
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import ru.clearing.classes.statics.data.sdf.SDf01;
|
||||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
||||||
import ru.spcex.platform.enumeration.AccountType;
|
import ru.spcex.platform.enumeration.AccountType;
|
||||||
|
import ru.spcex.platform.enumeration.ResultStatuses;
|
||||||
import ru.spcex.platform.enumeration.Task;
|
import ru.spcex.platform.enumeration.Task;
|
||||||
import ru.spcex.platform.imdg.api.Imdg;
|
import ru.spcex.platform.imdg.api.Imdg;
|
||||||
import ru.spcex.platform.imdg.iml.hazelcast.adapter.ImdgHazelcast;
|
import ru.spcex.platform.imdg.iml.hazelcast.adapter.ImdgHazelcast;
|
||||||
|
|
@ -23,15 +24,15 @@ import java.math.BigDecimal;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
import static ru.spcex.clearing.utils.TestUtils.addRecordToKafka;
|
import static ru.spcex.clearing.utils.TestUtils.*;
|
||||||
import static ru.spcex.clearing.utils.TestUtils.getJsonStringForUPDATE;
|
|
||||||
|
|
||||||
class VerificationResultComponentTest extends AbstractClearingTest {
|
class VerificationResultComponentTest extends AbstractClearingTest {
|
||||||
private static final int PARTITION = 0;
|
private static final int PARTITION = 0;
|
||||||
private static final AtomicInteger currentInteger = new AtomicInteger(1);
|
private static final AtomicInteger currentInteger = new AtomicInteger(1);
|
||||||
private static final String TOPIC_VERIFICATION = Task.getVerification.topic();
|
private static final String TOPIC_VERIFICATION = Task.getVerification.topic();
|
||||||
private final ArgumentCaptor<VerificationResult> settingResult = ArgumentCaptor.forClass(VerificationResult.class);
|
|
||||||
@Autowired
|
@Autowired
|
||||||
EventsReceiver eventsReceiver;
|
EventsReceiver eventsReceiver;
|
||||||
private Imdg<SDf01> sdf01Imdg;
|
private Imdg<SDf01> sdf01Imdg;
|
||||||
|
|
@ -53,8 +54,6 @@ class VerificationResultComponentTest extends AbstractClearingTest {
|
||||||
.serializable()
|
.serializable()
|
||||||
.spiedInstance(verificationResultImdg)
|
.spiedInstance(verificationResultImdg)
|
||||||
.defaultAnswer(CALLS_REAL_METHODS));
|
.defaultAnswer(CALLS_REAL_METHODS));
|
||||||
|
|
||||||
//setting imdg for been VerificationResultComponent
|
|
||||||
Field dbServiceField = null;
|
Field dbServiceField = null;
|
||||||
try {
|
try {
|
||||||
dbServiceField = VerificationResultComponent.class.getDeclaredField("verificationResultImdg");
|
dbServiceField = VerificationResultComponent.class.getDeclaredField("verificationResultImdg");
|
||||||
|
|
@ -67,10 +66,15 @@ class VerificationResultComponentTest extends AbstractClearingTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link VerificationResultComponent#executeRevision()} ()} <br>
|
||||||
|
* Тест проверяет создание сущностей
|
||||||
|
* {@link VerificationResult}
|
||||||
|
* в Hazelcast при передаче из Apache Kafka.<br>
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
void executeRevision() {
|
void executeRevision() {
|
||||||
//ARRANGE
|
//ARRANGE
|
||||||
int times = currentInteger.getAndIncrement();
|
|
||||||
Long companyId = 10L;
|
Long companyId = 10L;
|
||||||
String acc = "15444876546";
|
String acc = "15444876546";
|
||||||
String remainder = "15";
|
String remainder = "15";
|
||||||
|
|
@ -97,15 +101,42 @@ class VerificationResultComponentTest extends AbstractClearingTest {
|
||||||
company.setClearingCode("codeTest");
|
company.setClearingCode("codeTest");
|
||||||
companyImdg.insert(company);
|
companyImdg.insert(company);
|
||||||
|
|
||||||
|
//ACT & ASSERT
|
||||||
|
checkVerificationResults(ResultStatuses.success.getKey());
|
||||||
|
|
||||||
|
// сравнить remainder==balance
|
||||||
|
sDf01.setRemainder(remainder + "1");
|
||||||
|
sdf01Imdg.insert(sDf01);
|
||||||
|
//ACT & ASSERT
|
||||||
|
checkVerificationResults(ResultStatuses.notSuccess.getKey());
|
||||||
|
|
||||||
|
// 2.1 Номера торговых/клиринговых счетов, соответствующие загруженным в КС
|
||||||
|
sDf01.setRemainder(remainder);
|
||||||
|
sDf01.setDeal(acc + "1");
|
||||||
|
sdf01Imdg.insert(sDf01);
|
||||||
|
//ACT & ASSERT
|
||||||
|
checkVerificationResults(ResultStatuses.notSuccess.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkVerificationResults(String resultStatuses) {
|
||||||
|
int times = currentInteger.getAndIncrement();
|
||||||
//ACT
|
//ACT
|
||||||
addRecordToKafka((MockConsumer) eventsReceiver.getConsumer(), TOPIC_VERIFICATION,
|
addRecordToKafka((MockConsumer) eventsReceiver.getConsumer(), TOPIC_VERIFICATION,
|
||||||
PARTITION, times, getJsonStringForUPDATE(new LauncherCommandRequest(), 1L));
|
PARTITION, times, getJsonStringForUPDATE(new LauncherCommandRequest(), 1L));
|
||||||
|
|
||||||
//waiting for kafka producer send message
|
ArgumentCaptor<VerificationResult> settingResult = ArgumentCaptor.forClass(VerificationResult.class);
|
||||||
verify(verificationResultImdgMock, timeout(30_000L).times(4))
|
verify(verificationResultImdgMock, timeout(30_000L).times(4 * times))
|
||||||
.insert(settingResult.capture());
|
.insert(settingResult.capture());
|
||||||
settingResult.getValue();
|
Collection<VerificationResult> results = verificationResultImdg.getAllValues();
|
||||||
Collection<VerificationResult> result = verificationResultImdg.getAllValues();
|
|
||||||
result.size();
|
Long generationId = null;
|
||||||
|
|
||||||
|
//ASSERT
|
||||||
|
for (VerificationResult verificationResult : results) {
|
||||||
|
if (generationId == null) generationId = verificationResult.getGenerationId();
|
||||||
|
assertEquals(resultStatuses, verificationResult.getGenerationStatus());
|
||||||
|
assertEquals(generationId, verificationResult.getGenerationId());
|
||||||
|
}
|
||||||
|
clearAllInImdg(verificationResultImdg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue