Skip to content

Commit

Permalink
QA-5851: first version of test edits
Browse files Browse the repository at this point in the history
- modified [B2B_TIMELINE_ANALOG_GIACENZA_AR_3] by adding missing checks on deliveryDetailCode and attempts made
- introduced [B2B_TIMELINE_ANALOG_GIACENZA_AR_ERR_1]
  • Loading branch information
Vincenzo-Massaro committed Feb 12, 2025
1 parent 002af06 commit 1ea963d
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/test/java/it/pagopa/pn/cucumber/steps/SharedSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static it.pagopa.pn.cucumber.utils.NotificationValue.PAYMENT_PAGOPA_FORM;
import static it.pagopa.pn.cucumber.utils.NotificationValue.getDefaultValue;
import static it.pagopa.pn.cucumber.utils.NotificationValue.getValue;
import static java.util.Objects.nonNull;
import static org.awaitility.Awaitility.await;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -2242,6 +2243,18 @@ public List<TimelineElementV26> getTimelineElementsByEventId(String timelineEven
return timelineElementList.stream().filter(elem -> Objects.requireNonNull(elem.getCategory()).getValue().equals(timelineEventCategory)).toList();
}

/** Get all timeline elements having attempt index less or equal to the given one
* @param attemptIndex the index of the attempt (starting from 0)
* @return a list of timeline elements that match the given event category and data from test */
public List<TimelineElementV26> getTimelineElementsToAttempt(int attemptIndex) {
List<TimelineElementV26> timelineElementList = notificationResponseComplete.getTimeline();
return timelineElementList.stream()
.filter(elem -> nonNull(elem.getDetails()))
.filter(elem -> nonNull(elem.getDetails().getSentAttemptMade()))
.filter(elem -> elem.getDetails().getSentAttemptMade() <= attemptIndex)
.toList();
}

public TimelineElementV26 getTimelineElementByEventId(String timelineEventCategory, DataTest dataFromTest) {
return getTimelineElementsByEventId(timelineEventCategory, dataFromTest).stream()
.findAny()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,23 @@
import it.pagopa.pn.client.b2b.pa.mapper.model.PnTimelineLegalFactV26;
import it.pagopa.pn.client.b2b.pa.polling.design.PnPollingFactory;
import it.pagopa.pn.client.b2b.pa.polling.design.PnPollingStrategy;
import it.pagopa.pn.client.b2b.pa.polling.dto.*;
import it.pagopa.pn.client.b2b.pa.polling.impl.*;
import it.pagopa.pn.client.b2b.pa.polling.dto.PnPollingParameter;
import it.pagopa.pn.client.b2b.pa.polling.dto.PnPollingPredicate;
import it.pagopa.pn.client.b2b.pa.polling.dto.PnPollingResponseV1;
import it.pagopa.pn.client.b2b.pa.polling.dto.PnPollingResponseV20;
import it.pagopa.pn.client.b2b.pa.polling.dto.PnPollingResponseV21;
import it.pagopa.pn.client.b2b.pa.polling.dto.PnPollingResponseV23;
import it.pagopa.pn.client.b2b.pa.polling.dto.PnPollingResponseV26;
import it.pagopa.pn.client.b2b.pa.polling.impl.PnPollingServiceStatusRapidV1;
import it.pagopa.pn.client.b2b.pa.polling.impl.PnPollingServiceStatusRapidV26;
import it.pagopa.pn.client.b2b.pa.polling.impl.PnPollingServiceTimelineExtraRapidV26;
import it.pagopa.pn.client.b2b.pa.polling.impl.PnPollingServiceTimelineRapidV1;
import it.pagopa.pn.client.b2b.pa.polling.impl.PnPollingServiceTimelineRapidV20;
import it.pagopa.pn.client.b2b.pa.polling.impl.PnPollingServiceTimelineRapidV21;
import it.pagopa.pn.client.b2b.pa.polling.impl.PnPollingServiceTimelineRapidV23;
import it.pagopa.pn.client.b2b.pa.polling.impl.PnPollingServiceTimelineRapidV26;
import it.pagopa.pn.client.b2b.pa.polling.impl.PnPollingServiceTimelineSlowV1;
import it.pagopa.pn.client.b2b.pa.polling.impl.PnPollingServiceTimelineSlowV26;
import it.pagopa.pn.client.b2b.pa.service.IPnPaB2bClient;
import it.pagopa.pn.client.b2b.pa.service.IPnPrivateDeliveryPushExternalClient;
import it.pagopa.pn.client.b2b.pa.service.IPnWebRecipientClient;
Expand Down Expand Up @@ -73,6 +88,7 @@
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.IntStream;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.pdfbox.Loader;
Expand Down Expand Up @@ -2588,6 +2604,31 @@ public void vieneVerificatoElementoTimeline(String timelineEventCategory, @Trans
}
}

@Then("viene verificato che l'ultimo tentativo effettuato abbia indice {int}")
public void vieneVerificatoCheUltimoTentativoEffettuatoAbbiaIndice(Integer index) {
try {
List<TimelineElementV26> actualTimelineElements = sharedSteps.getTimelineElementsToAttempt(
index);
List<Integer> actualAttemptsMade = actualTimelineElements.stream()
.map(TimelineElementV26::getDetails)
.filter(Objects::nonNull)
.map(TimelineElementDetailsV26::getSentAttemptMade)
.distinct()
.toList();
List<Integer> expectedAttemptsMade = IntStream.range(0, index + 1)
.boxed()
.toList();

assertThat(actualAttemptsMade)
.withFailMessage("Non è stato trovato alcun elemento di timeline corrispondente a un tentativo di indice minore o uguale a '%d'.".formatted(index))
.isNotEmpty()
.as("I tentativi effettuati non corrispondono a quelli attesi.")
.hasSameElementsAs(expectedAttemptsMade);
} catch (AssertionError assertionFailedError) {
sharedSteps.throwAssertFailerWithIUN(assertionFailedError);
}
}

/** Checks that a certain timeline element has a field with a text value compatible with the specified regular expression.
* @param timelineEventCategory the category of the timeline element, e.g. "SEND_ANALOG_PROGRESS"
* @param eventId the event id of the timeline element, e.g. "CON020"
Expand Down Expand Up @@ -2690,6 +2731,20 @@ public void vieneVerificatoCheElementoTimelineNonEsista(String timelineEventCate
}
}

/* TODO 12/02/2025 Accorpare con vieneVerificatoCheElementoTimelineNonEsista(String timelineEventCategory, @Transpose DataTest dataFromTest)
* parametrizzando il load della timeline.
*/
@And("viene verificato che l'elemento di timeline {string} non esista nella timeline caricata")
public void vieneVerificatoCheElementoTimelineNonEsistaNotLoadTimeline(String timelineEventCategory, @Transpose DataTest dataFromTest) {
TimelineElementV26 timelineElement = sharedSteps.getTimelineElementByEventId(timelineEventCategory, dataFromTest);
try {
log.info("TIMELINE_ELEMENT: " + timelineElement);
Assertions.assertNull(timelineElement);
} catch (AssertionFailedError assertionFailedError) {
sharedSteps.throwAssertFailerWithIUN(assertionFailedError);
}
}

@And("viene schedulato il perfezionamento per decorrenza termini per il caso {string}")
public void vieneSchedulatoIlPerfezionamento(String timelineCategory, @Transpose DataTest dataFromTest) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,61 @@ Feature: avanzamento notifiche b2b con workflow cartaceo giacenza AR
| digitalDomicile | NULL |
| physicalAddress_address | Via@FAIL-CompiutaGiacenza_AR |
When la notifica viene inviata tramite api b2b dal "Comune_Multi" e si attende che lo stato diventi ACCEPTED
And vengono letti gli eventi fino all'elemento di timeline della notifica "REFINEMENT"
And viene verificato che l'elemento di timeline "SEND_ANALOG_PROGRESS" esista
| details | NOT_NULL |
| details_deliveryDetailCode | CON080 |
| details_recIndex | 0 |
| details_sentAttemptMade | 0 |
And viene verificato che l'elemento di timeline "SEND_ANALOG_PROGRESS" esista
| details | NOT_NULL |
| details_deliveryDetailCode | CON020 |
| details_recIndex | 0 |
| details_sentAttemptMade | 0 |
And viene verificato che l'elemento di timeline "SEND_ANALOG_PROGRESS" esista
| details | NOT_NULL |
| details_deliveryDetailCode | RECRN011 |
| details_recIndex | 0 |
| details_sentAttemptMade | 0 |
And viene verificato che l'elemento di timeline "SEND_ANALOG_PROGRESS" esista
| details | NOT_NULL |
| details_deliveryDetailCode | RECRN005B |
| details_recIndex | 0 |
| details_sentAttemptMade | 0 |
| details_attachments | [{"documentType": "Plico"}] |
And viene verificato che l'elemento di timeline "SEND_ANALOG_PROGRESS" esista
| details | NOT_NULL |
| details_deliveryDetailCode | RECRN005C |
| details_recIndex | 0 |
| details_sentAttemptMade | 0 |
And viene verificato che l'elemento di timeline "SEND_ANALOG_FEEDBACK" esista
| details | NOT_NULL |
| details_deliveryDetailCode | PNRN012 |
| details_recIndex | 0 |
| details_sentAttemptMade | 0 |
And viene verificato che l'ultimo tentativo effettuato abbia indice 1

# FIXME 12/02/2025 attualmente non si ha certezza della sequenza corretta, rivedere il test una volta ottenuta
@dev @workflowAnalogico
Scenario: [B2B_TIMELINE_ANALOG_GIACENZA_AR_ERR_1] Invio Notifica Mono destinatario workflow cartaceo - Caso FAIL-CompiutaGiacenza_AR_ERR
Given viene generata una nuova notifica
| subject | notifica analogica con cucumber |
| senderDenomination | Comune di palermo |
And destinatario Mario Gherkin e:
| digitalDomicile | NULL |
| physicalAddress_address | Via@FAIL_CompiutaGiacenza_AR_ERR |
When la notifica viene inviata tramite api b2b dal "Comune_Multi" e si attende che lo stato diventi ACCEPTED
And vengono letti gli eventi fino all'elemento di timeline della notifica "SEND_ANALOG_PROGRESS" con deliveryDetailCode "RECRN005C"
And viene verificato che l'elemento di timeline "SEND_ANALOG_PROGRESS" esista
| details | NOT_NULL |
| details_deliveryDetailCode | CON080 |
| details_recIndex | 0 |
| details_sentAttemptMade | 0 |
And viene verificato che l'elemento di timeline "SEND_ANALOG_PROGRESS" esista
| details | NOT_NULL |
| details_deliveryDetailCode | CON020 |
| details_recIndex | 0 |
| details_sentAttemptMade | 0 |
And viene verificato che l'elemento di timeline "SEND_ANALOG_PROGRESS" esista
| details | NOT_NULL |
| details_deliveryDetailCode | RECRN011 |
Expand All @@ -92,6 +141,12 @@ Feature: avanzamento notifiche b2b con workflow cartaceo giacenza AR
| details_recIndex | 0 |
| details_sentAttemptMade | 0 |
| details_attachments | [{"documentType": "Plico"}] |
And viene verificato che l'elemento di timeline "SEND_ANALOG_FEEDBACK" non esista nella timeline caricata
| details | NOT_NULL |
| details_deliveryDetailCode | PNRN012 |
| details_recIndex | 0 |
| details_sentAttemptMade | 0 |
And viene verificato che l'ultimo tentativo effettuato abbia indice 0

@dev @workflowAnalogico
Scenario: [B2B_TIMELINE_ANALOG_GIACENZA_AR_4] Invio Notifica Mono destinatario workflow cartaceo - Caso OK-Giacenza-gt10_AR PN-5927
Expand Down

0 comments on commit 1ea963d

Please sign in to comment.