From dc40148b2c7bbabc92cbcecbb37b5f6175e2353d Mon Sep 17 00:00:00 2001
From: t-muskans <t-muskans@microsoft.com>
Date: Tue, 1 Jun 2021 17:46:30 +0530
Subject: [PATCH] fixed UTs

---
 .../osdu/indexer/azure/service/RetryPolicy.java          | 4 +++-
 .../osdu/indexer/azure/service/RetryPolicyTest.java      | 9 ++++++---
 .../azure/service/UrlFetchServiceAzureImplTest.java      | 8 +++++++-
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/service/RetryPolicy.java b/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/service/RetryPolicy.java
index 9fcf09a89..47d906c9a 100644
--- a/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/service/RetryPolicy.java
+++ b/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/service/RetryPolicy.java
@@ -20,6 +20,7 @@ import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
 import io.github.resilience4j.retry.RetryConfig;
 import lombok.Data;
+import lombok.extern.java.Log;
 import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
 import org.opengroup.osdu.core.common.model.http.HttpResponse;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,6 +34,7 @@ import java.time.Duration;
  * to resolve intermittent CosmosDb Not found issue
  */
 
+@Log
 @Component
 @Data
 @ConfigurationProperties(prefix = "azure.storage.client.retry")
@@ -73,7 +75,7 @@ public class RetryPolicy {
                 notFoundElement.getAsJsonArray().isJsonNull()) {
             return false;
         }
-        logger.info("Retry is set true");
+        log.info("Retry is set true");
         return true;
     }
 }
diff --git a/provider/indexer-azure/src/test/java/org/opengroup/osdu/indexer/azure/service/RetryPolicyTest.java b/provider/indexer-azure/src/test/java/org/opengroup/osdu/indexer/azure/service/RetryPolicyTest.java
index da0e03240..70a7fcb9e 100644
--- a/provider/indexer-azure/src/test/java/org/opengroup/osdu/indexer/azure/service/RetryPolicyTest.java
+++ b/provider/indexer-azure/src/test/java/org/opengroup/osdu/indexer/azure/service/RetryPolicyTest.java
@@ -23,6 +23,7 @@ import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opengroup.osdu.core.common.http.FetchServiceHttpRequest;
 import org.opengroup.osdu.core.common.http.UrlFetchServiceImpl;
+import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
 import org.opengroup.osdu.core.common.model.http.HttpResponse;
 
 import java.util.function.Predicate;
@@ -124,10 +125,12 @@ public class RetryPolicyTest {
     private HttpResponse response;
     @InjectMocks
     private RetryPolicy retryPolicy;
+    @Mock
+    private JaxRsDpsLog logger;
 
 
     @Test
-    public void retry_should_be_true_for_json1() {
+    public void retry_should_be_true_for_jsonResponseWithNotFound() {
         RetryConfig config = this.retryPolicy.retryConfig();
         Predicate<HttpResponse> retry = config.getResultPredicate();
         response.setBody(JSON_RESPONSE_WITH_NOT_FOUND);
@@ -138,7 +141,7 @@ public class RetryPolicyTest {
     }
 
     @Test
-    public void retry_should_be_false_for_json2() {
+    public void retry_should_be_false_for_jsonResponse1WithOut_NotFound() {
         RetryConfig config = this.retryPolicy.retryConfig();
         Predicate<HttpResponse> retry = config.getResultPredicate();
         response.setBody(JSON_RESPONSE1_WITHOUT_NOT_FOUND);
@@ -148,7 +151,7 @@ public class RetryPolicyTest {
     }
 
     @Test
-    public void retry_should_be_false_for_json3() {
+    public void retry_should_be_false_for_jsonResponse2WithOut_NotFound() {
         RetryConfig config = this.retryPolicy.retryConfig();
         Predicate<HttpResponse> retry = config.getResultPredicate();
         response.setBody(JSON_RESPONSE2_WITHOUT_NOT_FOUND);
diff --git a/provider/indexer-azure/src/test/java/org/opengroup/osdu/indexer/azure/service/UrlFetchServiceAzureImplTest.java b/provider/indexer-azure/src/test/java/org/opengroup/osdu/indexer/azure/service/UrlFetchServiceAzureImplTest.java
index db880e27d..916c5b8bc 100644
--- a/provider/indexer-azure/src/test/java/org/opengroup/osdu/indexer/azure/service/UrlFetchServiceAzureImplTest.java
+++ b/provider/indexer-azure/src/test/java/org/opengroup/osdu/indexer/azure/service/UrlFetchServiceAzureImplTest.java
@@ -14,6 +14,7 @@
 
 package org.opengroup.osdu.indexer.azure.service;
 
+import io.github.resilience4j.retry.RetryConfig;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -22,8 +23,11 @@ import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opengroup.osdu.core.common.http.FetchServiceHttpRequest;
 import org.opengroup.osdu.core.common.http.UrlFetchServiceImpl;
+import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
 import org.opengroup.osdu.core.common.model.http.HttpResponse;
 
+import java.time.Duration;
+
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.atMost;
 import static org.mockito.Mockito.times;
@@ -34,13 +38,15 @@ import static org.mockito.Mockito.when;
 public class UrlFetchServiceAzureImplTest {
 
     @Mock
-    private RetryPolicy retryPolicy;
+    private JaxRsDpsLog logger;
     @Mock
     private UrlFetchServiceImpl urlFetchService;
     @InjectMocks
     private FetchServiceHttpRequest httpRequest;
     @InjectMocks
     private HttpResponse response;
+    @Mock
+    private RetryPolicy retryPolicy;
     @InjectMocks
     private UrlFetchServiceAzureImpl urlFetchServiceAzure;
 
-- 
GitLab