diff --git a/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/KafkaReceiverTest.java b/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/KafkaReceiverTest.java index 1f260e2..929c1f1 100644 --- a/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/KafkaReceiverTest.java +++ b/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/KafkaReceiverTest.java @@ -21,6 +21,7 @@ import java.util.List; import java.util.Map; +import it.finanze.sanita.fse2.ms.gtw.statusmanager.service.impl.ConfigSRV; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.common.TopicPartition; import org.junit.jupiter.api.Test; @@ -34,7 +35,6 @@ import org.springframework.messaging.MessageHeaders; import org.springframework.test.context.ActiveProfiles; -import it.finanze.sanita.fse2.ms.gtw.statusmanager.client.IConfigClient; import it.finanze.sanita.fse2.ms.gtw.statusmanager.config.Constants; import it.finanze.sanita.fse2.ms.gtw.statusmanager.exceptions.BusinessException; import it.finanze.sanita.fse2.ms.gtw.statusmanager.service.IKafkaReceiverSRV; @@ -53,14 +53,14 @@ class KafkaReceiverTest { @Value("${kafka.statusmanager.topic}") String topic; - + @MockBean - private IConfigClient configClient; + private ConfigSRV config; @Test @Description("Generic error test on status manager listener - wrong json") void kafkaReceiverErrorTest() { - given(configClient.getExpirationDate()).willReturn(0); + given(config.getExpirationDate()).willReturn(0); Map map = new HashMap<>(); MessageHeaders headers = new MessageHeaders(map); diff --git a/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/RepoTest.java b/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/RepoTest.java index 06deddd..930e4de 100644 --- a/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/RepoTest.java +++ b/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/RepoTest.java @@ -14,13 +14,13 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.BDDMockito.given; +import it.finanze.sanita.fse2.ms.gtw.statusmanager.service.impl.ConfigSRV; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ActiveProfiles; -import it.finanze.sanita.fse2.ms.gtw.statusmanager.client.IConfigClient; import it.finanze.sanita.fse2.ms.gtw.statusmanager.config.Constants; import it.finanze.sanita.fse2.ms.gtw.statusmanager.exceptions.BusinessException; import it.finanze.sanita.fse2.ms.gtw.statusmanager.repository.mongo.impl.TransactionEventsRepo; @@ -30,14 +30,14 @@ class RepoTest { @MockBean - private IConfigClient configClient; + private ConfigSRV config; @Test @DisplayName("transaction Events Repo test Ko ") void transactionEvTestKo() { TransactionEventsRepo transEvRep = new TransactionEventsRepo(); - given(configClient.getExpirationDate()).willReturn(0); + given(config.getExpirationDate()).willReturn(0); assertThrows(BusinessException.class, () -> transEvRep.saveEvent(null, null)); } diff --git a/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/TxExecutorTest.java b/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/TxExecutorTest.java index 8e69eea..7b12909 100644 --- a/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/TxExecutorTest.java +++ b/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/TxExecutorTest.java @@ -17,6 +17,7 @@ import java.util.ArrayList; +import it.finanze.sanita.fse2.ms.gtw.statusmanager.service.impl.ConfigSRV; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -32,7 +33,6 @@ import org.springframework.web.client.ResourceAccessException; import org.springframework.web.client.RestTemplate; -import it.finanze.sanita.fse2.ms.gtw.statusmanager.client.IConfigClient; import it.finanze.sanita.fse2.ms.gtw.statusmanager.config.Constants; import it.finanze.sanita.fse2.ms.gtw.statusmanager.dto.client.processor.res.tx.DeleteTxResDTO; import it.finanze.sanita.fse2.ms.gtw.statusmanager.dto.client.processor.res.tx.GetTxResDTO; @@ -48,7 +48,7 @@ class TxExecutorTest { private TxExecutor txExecutor; @MockBean - private IConfigClient configClient; + private ConfigSRV config; @Autowired private MongoTemplate mongoTemplate; @@ -67,7 +67,7 @@ void executorSuccessTest() { GetTxResDTO last = TestUtility.createLastTxLinksMock(); DeleteTxResDTO deleted = TestUtility.createDeletedTransactionMock(); - Mockito.when(configClient.getExpirationDate()).thenReturn(5); + Mockito.when(config.getExpirationDate()).thenReturn(5); Mockito.when(restTemplate.getForEntity(anyString(), eq(GetTxResDTO.class))) .thenReturn(new ResponseEntity<>(first, HttpStatus.OK)) @@ -81,7 +81,7 @@ void executorSuccessTest() { @Test void executorFailureTestOnInit() { - Mockito.when(configClient.getExpirationDate()).thenReturn(5); + Mockito.when(config.getExpirationDate()).thenReturn(5); Mockito.when(restTemplate.getForEntity(anyString(), eq(GetTxResDTO.class))) .thenThrow(ResourceAccessException.class); Assertions.assertEquals(ActionRes.KO, txExecutor.execute()); @@ -91,7 +91,7 @@ void executorFailureTestOnInit() { void executorFailureTestOnVerify() { GetTxResDTO first = TestUtility.createFirstTxLinksMock(); first.setWif(new ArrayList<>()); - Mockito.when(configClient.getExpirationDate()).thenReturn(5); + Mockito.when(config.getExpirationDate()).thenReturn(5); Mockito.when(restTemplate.getForEntity(anyString(), eq(GetTxResDTO.class))) .thenReturn(new ResponseEntity<>(first, HttpStatus.OK)); Assertions.assertEquals(ActionRes.EMPTY, txExecutor.execute()); @@ -101,7 +101,7 @@ void executorFailureTestOnVerify() { void executorFailureTestOnProcess() { GetTxResDTO first = TestUtility.createFirstTxLinksMock(); - Mockito.when(configClient.getExpirationDate()).thenReturn(5); + Mockito.when(config.getExpirationDate()).thenReturn(5); Mockito.when(restTemplate.getForEntity(anyString(), eq(GetTxResDTO.class))) .thenReturn(new ResponseEntity<>(first, HttpStatus.OK)) @@ -115,7 +115,7 @@ void executorFailureTestOnDelete() { GetTxResDTO first = TestUtility.createFirstTxLinksMock(); GetTxResDTO last = TestUtility.createLastTxLinksMock(); - Mockito.when(configClient.getExpirationDate()).thenReturn(5); + Mockito.when(config.getExpirationDate()).thenReturn(5); Mockito.when(restTemplate.getForEntity(anyString(), eq(GetTxResDTO.class))) .thenReturn(new ResponseEntity<>(first, HttpStatus.OK))