From 36ed344a3a227a0a865fbbeacd40fa246ccc6f98 Mon Sep 17 00:00:00 2001
From: ZMai <zmai@slb.com>
Date: Wed, 28 Jun 2023 12:15:54 -0500
Subject: [PATCH] Add unit test

---
 .../osdu/indexer/service/SearchServiceImplTest.java    | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/SearchServiceImplTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/SearchServiceImplTest.java
index 2018809bf..93ee08260 100644
--- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/SearchServiceImplTest.java
+++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/SearchServiceImplTest.java
@@ -7,12 +7,15 @@ import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.opengroup.osdu.core.common.http.IUrlFetchService;
 import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
+import org.opengroup.osdu.core.common.model.http.AppException;
 import org.opengroup.osdu.core.common.model.http.HttpResponse;
 import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo;
 import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties;
 import org.opengroup.osdu.indexer.model.SearchRequest;
 import org.opengroup.osdu.indexer.model.SearchResponse;
 import org.powermock.modules.junit4.PowerMockRunner;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.ArgumentMatchers.any;
 
 import java.net.URISyntaxException;
@@ -143,4 +146,11 @@ public class SearchServiceImplTest {
         Assert.assertNotNull(searchResponse);
         Assert.assertNull(searchResponse.getResults());
     }
+
+    @Test
+    public void query_with_exception() throws URISyntaxException {
+        when(this.configurationProperties.getSearchHost()).thenReturn(searchHost);
+        when(this.urlFetchService.sendRequest(any())).thenThrow(new AppException(415, "upstream server responded with unsupported media type: text/plain", "Unsupported media type" ));
+        assertThrows(URISyntaxException.class, () -> sut.query(new SearchRequest()));
+    }
 }
-- 
GitLab