Skip to content

Commit

Permalink
Removed sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Mar 4, 2025
1 parent 6ad499a commit adf5ec9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
package it.pagopa.selfcare.party.registry_proxy.web.config;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import com.fasterxml.jackson.databind.ObjectMapper;
import it.pagopa.selfcare.commons.web.config.SecurityConfig;
import it.pagopa.selfcare.party.registry_proxy.connector.api.GeoTaxonomiesConnector;
import it.pagopa.selfcare.party.registry_proxy.connector.api.NationalRegistriesConnector;
import it.pagopa.selfcare.party.registry_proxy.connector.rest.GeoTaxonomiesConnectorImpl;
import it.pagopa.selfcare.party.registry_proxy.connector.rest.IvassConnectorImpl;
import it.pagopa.selfcare.party.registry_proxy.connector.rest.config.GeoTaxonomiesRestClientConfig;
import it.pagopa.selfcare.party.registry_proxy.connector.rest.config.NationalRegistriesRestClientConfig;
import it.pagopa.selfcare.party.registry_proxy.core.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.MediaType;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;

@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT)
@ComponentScan(basePackages = {"it.pagopa.selfcare.party.registry_proxy.web.controller", "it.pagopa.selfcare.party.registry_proxy.web.model.mapper"})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package it.pagopa.selfcare.party.registry_proxy.connector.rest.client;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

import it.pagopa.selfcare.party.registry_proxy.connector.model.nationalregistries.Businesses;
import it.pagopa.selfcare.party.registry_proxy.connector.model.nationalregistries.LegalAddressRequest;
import it.pagopa.selfcare.party.registry_proxy.connector.rest.config.GeoTaxonomiesRestClientConfig;
import it.pagopa.selfcare.party.registry_proxy.connector.rest.config.NationalRegistriesRestClientConfig;
import it.pagopa.selfcare.party.registry_proxy.connector.rest.model.AdELegalOKDto;
import it.pagopa.selfcare.party.registry_proxy.connector.rest.model.AdELegalRequestBodyDto;
Expand All @@ -13,8 +14,6 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

@FeignClient(name = "${rest-client.national-registries.serviceCode}", url = "${rest-client.national-registries.base-url}", configuration = NationalRegistriesRestClientConfig.class)
public interface NationalRegistriesRestClient {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@ void apply_nullAuthentication() {
assertEquals("api-key-value", headerValue.get());
}

@Test
void applyWithDuplicatedKey() {
// given
RequestTemplate requestTemplate = new RequestTemplate();
requestTemplate.header("x-api-key", "test");

// when
interceptor.apply(requestTemplate);

// then
Map<String, Collection<String>> headers = requestTemplate.headers();
assertNotNull(headers);
Collection<String> headerValues = headers.get("x-api-key");
assertNotNull(headerValues);
assertEquals(1, headerValues.size());
Optional<String> headerValue = headerValues.stream().findAny();
assertTrue(headerValue.isPresent());
assertEquals("test", headerValue.get());
}

}


Expand Down

0 comments on commit adf5ec9

Please sign in to comment.