Skip to content

Commit

Permalink
fix test deleghe
Browse files Browse the repository at this point in the history
  • Loading branch information
angelominisci committed Nov 7, 2024
1 parent a5030e9 commit d4ab45b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/main/java/it/pn/frontend/e2e/config/CustomHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

@Slf4j
@Component
Expand Down Expand Up @@ -98,7 +99,7 @@ public static <R, S> CustomHttpClient<R, S> getInstance() {
return (CustomHttpClient<R, S>) instance;
}
**/

/**
public static <R, S> CustomHttpClient<R, S> getInstanceWithApiKey(String apiKey) {
if (instance == null) {
synchronized (CustomHttpClient.class) {
Expand All @@ -109,10 +110,9 @@ public static <R, S> CustomHttpClient<R, S> getInstanceWithApiKey(String apiKey
}
return (CustomHttpClient<R, S>) instance;
}

**/
public ResponseType sendHttpPostRequest(String endpoint, Map<String, String> headers, RequestType requestObject, Class<ResponseType> responseType) throws IOException {
String apiUrl = baseUrlApi + endpoint;

try (CloseableHttpClient client = HttpClients.createDefault()) {
ObjectMapper objectMapper = new ObjectMapper();
String jsonBody = objectMapper.writeValueAsString(requestObject);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/it/pn/frontend/e2e/rest/RestContact.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class RestContact {
private final Map<String, String> headers = new HashMap<>();

// Carica il token all'avvio della classe
@Autowired
private WebDriverConfig webDriverConfig;

@Autowired
Expand All @@ -45,7 +44,7 @@ public class RestContact {
public RestContact(WebDriverConfig webDriverConfig, CustomHttpClient<?, String> httpClient) {
this.httpClient = httpClient;
this.webDriverConfig = webDriverConfig;
this.httpClient.setBaseUrlApi("https://webapi." + webDriverConfig.getEnvironment() + ".notifichedigitali.it");
this.httpClient.setBaseUrlApi("https://webapi." + this.webDriverConfig.getEnvironment() + ".notifichedigitali.it");

String token = System.getProperty("token");
if (token != null) {
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/it/pn/frontend/e2e/rest/RestDelegation.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import java.io.IOException;
Expand All @@ -31,8 +32,8 @@ public class RestDelegation {
private static final Logger logger = LoggerFactory.getLogger(RestDelegation.class);


@Value("${environment}")
private String environment;

private WebDriverConfig webDriverConfig;

private final Map<String, String> headers = new HashMap<>();

Expand All @@ -42,9 +43,10 @@ public class RestDelegation {


@Autowired
public RestDelegation(CustomHttpClient<DelegateRequestPF, DelegateResponsePF> httpClientPF, CustomHttpClient<DelegateRequestPG, DelegateResponsePG> httpClientPG) {
public RestDelegation( WebDriverConfig webDriverConfig, CustomHttpClient<DelegateRequestPF, DelegateResponsePF> httpClientPF, CustomHttpClient<DelegateRequestPG, DelegateResponsePG> httpClientPG) {
this.httpClientPF = httpClientPF;
this.httpClientPG = httpClientPG;
this.webDriverConfig = webDriverConfig;
initializeHeaders();
setupHttpClients();
}
Expand All @@ -59,7 +61,7 @@ private void initializeHeaders() {
}

private void setupHttpClients() {
String baseUrl = "https://webapi." + environment + ".notifichedigitali.it";
String baseUrl = "https://webapi." + webDriverConfig.getEnvironment() + ".notifichedigitali.it";
httpClientPF.setBaseUrlApi(baseUrl);
httpClientPG.setBaseUrlApi(baseUrl);
}
Expand Down

0 comments on commit d4ab45b

Please sign in to comment.