From 2797720e823c4312aac7b595ae2ce00079b66b8f Mon Sep 17 00:00:00 2001 From: FedericoRuzzier <49512050+FedericoRuzzier@users.noreply.github.com> Date: Fri, 25 Oct 2024 09:45:27 +0200 Subject: [PATCH] fix sonar issues PAGOPA-2316 --- .../service/DecouplerServiceTest.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/test/java/it/gov/pagopa/wispconverter/service/DecouplerServiceTest.java b/src/test/java/it/gov/pagopa/wispconverter/service/DecouplerServiceTest.java index 4aa9355a..0f6ee3b4 100644 --- a/src/test/java/it/gov/pagopa/wispconverter/service/DecouplerServiceTest.java +++ b/src/test/java/it/gov/pagopa/wispconverter/service/DecouplerServiceTest.java @@ -18,7 +18,6 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ActiveProfiles; -import static it.gov.pagopa.wispconverter.service.DecouplerService.MAP_CACHING_KEY_TEMPLATE; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.any; @@ -46,9 +45,9 @@ class DecouplerServiceTest { @MockBean private IdempotencyKeyRepositorySecondary idempotencyKeyRepositorySecondary; - private static final String domainId = "12345678910"; + private static final String DOMAIN_ID = "12345678910"; - private static final String nav = "350000000000000000"; + private static final String NAV = "350000000000000000"; @ParameterizedTest @CsvSource({"wisp_nav2iuv_123456IUVMOCK1,123456IUVMOCK1", "wisp_nav2iuv_123456IUVMOCK1_123456IUVMOCK2,123456IUVMOCK1_123456IUVMOCK2"}) @@ -58,7 +57,7 @@ void getCachedMappingFromNavToIuvTestOK(String nav2iuv, String iuv) { // mocking decoupler cached keys when(cacheRepository.read(anyString(), any())).thenReturn(nav2iuv); - CachedKeysMapping result = decouplerService.getCachedMappingFromNavToIuv(domainId, nav); + CachedKeysMapping result = decouplerService.getCachedMappingFromNavToIuv(DOMAIN_ID, NAV); Assertions.assertEquals(iuv, result.getIuv()); } @@ -67,16 +66,14 @@ void getCachedMappingFromNavToIuvTestOK(String nav2iuv, String iuv) { @SneakyThrows void getCachedMappingFromNavToIuvTestKONullKey() { - String mappingKey = String.format(MAP_CACHING_KEY_TEMPLATE, domainId, nav); - // mocking decoupler cached keys when(cacheRepository.read(anyString(), any())).thenReturn(null); try { - decouplerService.getCachedMappingFromNavToIuv(domainId, nav); + decouplerService.getCachedMappingFromNavToIuv(DOMAIN_ID, NAV); fail(); } catch (AppException e) { - assertEquals(e.getError(), AppErrorCodeMessageEnum.PERSISTENCE_REQUESTID_CACHING_ERROR); + assertEquals(AppErrorCodeMessageEnum.PERSISTENCE_REQUESTID_CACHING_ERROR, e.getError()); } } @@ -88,10 +85,10 @@ void getCachedMappingFromNavToIuvTestKOWrongKey() { when(cacheRepository.read(anyString(), any())).thenReturn("wrong_string"); try { - decouplerService.getCachedMappingFromNavToIuv(domainId, nav); + decouplerService.getCachedMappingFromNavToIuv(DOMAIN_ID, NAV); fail(); } catch (AppException e) { - assertEquals(e.getError(), AppErrorCodeMessageEnum.PERSISTENCE_MAPPING_NAV_TO_IUV_ERROR); + assertEquals(AppErrorCodeMessageEnum.PERSISTENCE_MAPPING_NAV_TO_IUV_ERROR, e.getError()); } } } \ No newline at end of file