Skip to content

Commit

Permalink
aggiunta step e test aggiunta sportelli CRDUD
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco-Meloni committed Apr 5, 2024
1 parent edc21ee commit 7c54d05
Show file tree
Hide file tree
Showing 2 changed files with 216 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import com.opencsv.CSVWriter;
import io.cucumber.java.After;
import io.cucumber.java.Transpose;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import it.pagopa.pn.client.b2b.pa.PnPaB2bUtils;
import it.pagopa.pn.client.b2b.pa.service.impl.PnExternalServiceClientImpl;
import it.pagopa.pn.client.b2b.pa.service.impl.PnRaddAlternativeClientImpl;
import it.pagopa.pn.client.b2b.radd.generated.openapi.clients.externalb2braddalt.model_AnagraficaCRUD.CreateRegistryRequest;
import it.pagopa.pn.client.b2b.radd.generated.openapi.clients.externalb2braddalt.model_AnagraficaCRUD.CreateRegistryResponse;
import it.pagopa.pn.client.b2b.radd.generated.openapi.clients.externalb2braddalt.model_AnagraficaCRUD.RegistriesResponse;
import it.pagopa.pn.client.b2b.radd.generated.openapi.clients.externalb2braddalt.model_AnagraficaCRUD.UpdateRegistryRequest;
import it.pagopa.pn.client.b2b.radd.generated.openapi.clients.externalb2braddalt.model_AnagraficaCsv.RegistryUploadRequest;
import it.pagopa.pn.client.b2b.radd.generated.openapi.clients.externalb2braddalt.model_AnagraficaCsv.RegistryUploadResponse;
Expand Down Expand Up @@ -47,6 +49,7 @@ public class AnagraficaRaddAltSteps {
private String filePathCsv;
private String shaCSV;
private String requestid;
private String registryId;
private CreateRegistryRequest sportelloRaddCrud;

private String uid = "1234556";
Expand Down Expand Up @@ -184,17 +187,39 @@ public void vieneGeneratoSportelloRadd(@Transpose CreateRegistryRequest dataSpor
}
}

@When("viene generato uno sportello Radd con restituzione errore con dati:")
public void vieneGeneratoConErroreSportelloRadd(@Transpose CreateRegistryRequest dataSportello) {

log.info("Request inserimento: {}", dataSportello);
try {
raddAltClient.addRegistry(this.uid, sportelloRaddCrud);
} catch (HttpStatusCodeException e) {
this.sharedSteps.setNotificationError(e);
}

}


@When("viene modificato uno sportello Radd con dati:")
public void vieneModificatoSportelloRadd(Map<String, String> dataSportello) {
public void vieneModificatoSportelloRadd(@Transpose UpdateRegistryRequest dataSportello) {
log.info("Upload Request: {}", dataSportello);
try {
Assertions.assertDoesNotThrow(() -> raddAltClient.updateRegistry(this.uid, this.registryId, dataSportello));
} catch (HttpStatusCodeException e) {
this.sharedSteps.setNotificationError(e);
}
}

UpdateRegistryRequest aggiornamentoSportelloRadd = dataTableTypeRaddAlt.convertUpdateRegistryRequest(dataSportello);

@When("viene modificato uno sportello Radd con dati errati:")
public void vieneModificatoSportelloRadd(Map<String,String> dataSportello) {
log.info("Upload Request: {}", dataSportello);
UpdateRegistryRequest aggiornamentoSportelloRadd = dataTableTypeRaddAlt.convertUpdateRegistryRequest(dataSportello);
try {
Assertions.assertDoesNotThrow(() -> raddAltClient.updateRegistry(uid, this.requestid, aggiornamentoSportelloRadd));
Assertions.assertDoesNotThrow(() -> raddAltClient.updateRegistry(this.uid, this.registryId, aggiornamentoSportelloRadd));
} catch (AssertionFailedError assertionFailedError) {
String message = assertionFailedError.getMessage() +
"{Update Request: " + (aggiornamentoSportelloRadd == null ? "NULL" : aggiornamentoSportelloRadd) + " }";
"{Update Request: " + (dataSportello == null ? "NULL" : dataSportello) + " }";
throw new AssertionFailedError(message, assertionFailedError.getExpected(), assertionFailedError.getActual(), assertionFailedError.getCause());
}
}
Expand All @@ -212,7 +237,7 @@ public void vieneCancellatoSportelloRadd(String tipoDate) {
}

try {
raddAltClient.deleteRegistry(uid, this.requestid, endDate);
raddAltClient.deleteRegistry(uid, this.registryId, endDate);
} catch (AssertionFailedError assertionFailedError) {
String message = assertionFailedError.getMessage() +
"{endDate: " + (endDate == null ? "NULL" : endDate) + " }";
Expand All @@ -224,16 +249,17 @@ public void vieneCancellatoSportelloRadd(String tipoDate) {
@When("viene richiesta la lista degli sportelli con dati:")
public void vieneRichiestolaListaDeiSportelliRadd(Map<String, String> dataSportello) {

try {
raddAltClient.retrieveRegistries(
uid
, getValue(dataSportello, RADD_FILTER_LIMIT.key) == null ? null : Integer.parseInt(getValue(dataSportello, RADD_FILTER_FILEKEY.key))
, getValue(dataSportello, RADD_FILTER_FILEKEY.key) == null ? null : getValue(dataSportello, RADD_FILTER_FILEKEY.key)
, getValue(dataSportello, ADDRESS_RADD_CAP.key) == null ? null : getValue(dataSportello, ADDRESS_RADD_CAP.key)
, getValue(dataSportello, ADDRESS_RADD_CITY.key) == null ? null : getValue(dataSportello, ADDRESS_RADD_CITY.key)
, getValue(dataSportello, ADDRESS_RADD_PROVINCE.key) == null ? null : getValue(dataSportello, ADDRESS_RADD_PROVINCE.key)
, getValue(dataSportello, RADD_EXTERNAL_CODE.key) == null ? null : getValue(dataSportello, RADD_EXTERNAL_CODE.key)); //TODO vedere meglio la gestione del externalCode
RegistriesResponse sportello= raddAltClient.retrieveRegistries(
this.uid
, getValue(dataSportello, RADD_FILTER_LIMIT.key) == null ? null : Integer.parseInt(getValue(dataSportello, RADD_FILTER_FILEKEY.key))
, getValue(dataSportello, RADD_FILTER_FILEKEY.key) == null ? null : getValue(dataSportello, RADD_FILTER_FILEKEY.key)
, getValue(dataSportello, ADDRESS_RADD_CAP.key) == null ? null : getValue(dataSportello, ADDRESS_RADD_CAP.key)
, getValue(dataSportello, ADDRESS_RADD_CITY.key) == null ? null : getValue(dataSportello, ADDRESS_RADD_CITY.key)
, getValue(dataSportello, ADDRESS_RADD_PROVINCE.key) == null ? null : getValue(dataSportello, ADDRESS_RADD_PROVINCE.key)
, getValue(dataSportello, RADD_EXTERNAL_CODE.key) == null ? null : getValue(dataSportello, RADD_EXTERNAL_CODE.key)); //TODO vedere meglio la gestione del externalCode

try {
Assertions.assertNotNull(sportello);
} catch (AssertionFailedError assertionFailedError) {
String message = assertionFailedError.getMessage() +
"{endDate: " + (this.requestid == null ? "NULL" : this.requestid) + " }";
Expand All @@ -249,7 +275,7 @@ public void creazioneCsv(List<CreateRegistryRequest> csvData) throws IOException

//TODO inserire tutti campi da mettere nel csv
List<String[]> data = new ArrayList<>();
data.add(new String[]{"addressRow", "cap", "city"});
data.add(new String[]{"addressRow", "cap", "city","pr","country","startValidity","endValidity","openingTime","description",});

for (int i = 0; i < csvData.size(); i++) {
data.add(new String[]{csvData.get(i).getAddress().getAddressRow(),
Expand Down
Loading

0 comments on commit 7c54d05

Please sign in to comment.