Skip to content

Commit 676aae0

Browse files
author
dalilaacqua
committed
Fix junit
1 parent c871cd9 commit 676aae0

File tree

3 files changed

+117
-455
lines changed

3 files changed

+117
-455
lines changed

src/test/java/it/gov/pagopa/idpay/transactions/repository/RewardBatchSpecificRepositoryImplTest.java

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -894,119 +894,6 @@ void findPreviousEmptyBatches_shouldReturnOnlyEmptyBatchesBeforeCurrentMonth_sor
894894
assertEquals("old-empty-2", result.get(1).getId());
895895
}
896896

897-
@Test
898-
void moveSuspendToNewBatch_ok_shouldMoveCountersAndAmounts() {
899-
long accrued = 150L;
900-
901-
RewardBatch oldBatch = rewardBatchRepository.findById("batch1").block();
902-
RewardBatch newBatch = rewardBatchRepository.findById("batch2").block();
903-
assertNotNull(oldBatch);
904-
assertNotNull(newBatch);
905-
906-
oldBatch.setInitialAmountCents(accrued);
907-
oldBatch.setSuspendedAmountCents(accrued);
908-
oldBatch.setNumberOfTransactions(ONE_LONG);
909-
oldBatch.setNumberOfTransactionsSuspended(ONE_LONG);
910-
oldBatch.setNumberOfTransactionsElaborated(ONE_LONG);
911-
912-
newBatch.setInitialAmountCents(ZERO_LONG);
913-
newBatch.setSuspendedAmountCents(ZERO_LONG);
914-
newBatch.setNumberOfTransactions(ZERO_LONG);
915-
newBatch.setNumberOfTransactionsSuspended(ZERO_LONG);
916-
newBatch.setNumberOfTransactionsElaborated(ZERO_LONG);
917-
918-
rewardBatchRepository.saveAll(List.of(oldBatch, newBatch)).collectList().block();
919-
920-
LocalDateTime oldUpdateBefore = oldBatch.getUpdateDate();
921-
LocalDateTime newUpdateBefore = newBatch.getUpdateDate();
922-
923-
Mono<RewardBatch> result = rewardBatchSpecificRepository
924-
.moveSuspendFromEvaluatingBatch("batch1", "batch2", accrued);
925-
926-
StepVerifier.create(result)
927-
.assertNext(updatedNew -> {
928-
assertEquals("batch2", updatedNew.getId());
929-
930-
assertEquals(accrued, updatedNew.getInitialAmountCents());
931-
assertEquals(accrued, updatedNew.getSuspendedAmountCents());
932-
assertEquals(ONE_LONG, updatedNew.getNumberOfTransactions());
933-
assertEquals(ONE_LONG, updatedNew.getNumberOfTransactionsSuspended());
934-
assertEquals(ONE_LONG, updatedNew.getNumberOfTransactionsElaborated());
935-
936-
assertNotNull(updatedNew.getUpdateDate());
937-
if (newUpdateBefore != null) {
938-
assertNotEquals(newUpdateBefore, updatedNew.getUpdateDate());
939-
}
940-
})
941-
.verifyComplete();
942-
943-
RewardBatch oldAfter = rewardBatchRepository.findById("batch1").block();
944-
RewardBatch newAfter = rewardBatchRepository.findById("batch2").block();
945-
assertNotNull(oldAfter);
946-
assertNotNull(newAfter);
947-
948-
assertEquals(150L, oldAfter.getInitialAmountCents());
949-
assertEquals(0, oldAfter.getSuspendedAmountCents());
950-
assertEquals(ZERO_LONG, oldAfter.getNumberOfTransactions());
951-
assertEquals(ZERO_LONG, oldAfter.getNumberOfTransactionsSuspended());
952-
assertEquals(ZERO_LONG, oldAfter.getNumberOfTransactionsElaborated());
953-
954-
assertNotNull(oldAfter.getUpdateDate());
955-
if (oldUpdateBefore != null) {
956-
assertNotEquals(oldUpdateBefore, oldAfter.getUpdateDate());
957-
}
958-
}
959-
960-
@Test
961-
void moveSuspendFromEvaluatingBatch_oldBatchNotFound_returnsBadRequest() {
962-
Mono<RewardBatch> result = rewardBatchSpecificRepository
963-
.moveSuspendFromEvaluatingBatch("NOT_EXISTING", "batch2", 150L);
964-
965-
StepVerifier.create(result)
966-
.expectErrorSatisfies(ex -> {
967-
assertInstanceOf(ClientExceptionNoBody.class, ex);
968-
assertEquals(org.springframework.http.HttpStatus.BAD_REQUEST,
969-
((ClientExceptionNoBody) ex).getHttpStatus());
970-
})
971-
.verify();
972-
}
973-
974-
975-
@Test
976-
void moveSuspendFromEvaluatingBatchNotFound_returnsBadRequest_andOldWasDecremented() {
977-
long accrued = 150L;
978-
979-
RewardBatch oldBatch = rewardBatchRepository.findById("batch1").block();
980-
assertNotNull(oldBatch);
981-
982-
oldBatch.setInitialAmountCents(ONE_LONG);
983-
oldBatch.setSuspendedAmountCents(accrued);
984-
oldBatch.setNumberOfTransactions(ONE_LONG);
985-
oldBatch.setNumberOfTransactionsSuspended(ONE_LONG);
986-
oldBatch.setNumberOfTransactionsElaborated(ONE_LONG);
987-
rewardBatchRepository.save(oldBatch).block();
988-
989-
Mono<RewardBatch> result = rewardBatchSpecificRepository
990-
.moveSuspendFromEvaluatingBatch("batch1", "NOT_EXISTING", accrued);
991-
992-
StepVerifier.create(result)
993-
.expectErrorSatisfies(ex -> {
994-
assertInstanceOf(ClientExceptionNoBody.class, ex);
995-
assertEquals(org.springframework.http.HttpStatus.BAD_REQUEST,
996-
((ClientExceptionNoBody) ex).getHttpStatus());
997-
})
998-
.verify();
999-
1000-
RewardBatch oldAfter = rewardBatchRepository.findById("batch1").block();
1001-
assertNotNull(oldAfter);
1002-
1003-
assertEquals(ONE_LONG, oldAfter.getInitialAmountCents());
1004-
assertEquals(ZERO_LONG, oldAfter.getSuspendedAmountCents());
1005-
assertEquals(ZERO_LONG, oldAfter.getNumberOfTransactions());
1006-
assertEquals(ZERO_LONG, oldAfter.getNumberOfTransactionsSuspended());
1007-
assertEquals(ZERO_LONG, oldAfter.getNumberOfTransactionsElaborated());
1008-
}
1009-
1010897
@Test
1011898
void moveTrxToNewBatch_notSuspended_updatesBothBatchesCorrectly() {
1012899

0 commit comments

Comments
 (0)