Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
Indexer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSDU
OSDU Data Platform
System
Indexer
Commits
36ed344a
Commit
36ed344a
authored
1 year ago
by
Zhibin Mai
Browse files
Options
Downloads
Patches
Plain Diff
Add unit test
parent
5df40bab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!571
Catch the generic exception that might be thrown from FetchServiceHttpRequest.sendRequest(...) API
Pipeline
#195403
failed
1 year ago
Stage: review
Pipeline: Indexer
#195404
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indexer-core/src/test/java/org/opengroup/osdu/indexer/service/SearchServiceImplTest.java
+10
-0
10 additions, 0 deletions
...opengroup/osdu/indexer/service/SearchServiceImplTest.java
with
10 additions
and
0 deletions
indexer-core/src/test/java/org/opengroup/osdu/indexer/service/SearchServiceImplTest.java
+
10
−
0
View file @
36ed344a
...
...
@@ -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
()));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment