generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 16
feat: [Grounding] Added GroundingClient.withHeader()
#767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,10 @@ | ||
| package com.sap.ai.sdk.grounding; | ||
|
|
||
| import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl; | ||
| import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; | ||
| import static com.github.tomakehurst.wiremock.client.WireMock.get; | ||
| import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; | ||
| import static com.github.tomakehurst.wiremock.client.WireMock.okJson; | ||
| import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
|
|
@@ -36,7 +41,7 @@ class GroundingClientTest { | |
| void testPipelines() { | ||
| final PipelinesApi api = new GroundingClient(SERVICE).pipelines(); | ||
|
|
||
| final GetPipelines allPipelines = api.getAllPipelines("reosurceGroup"); | ||
| final GetPipelines allPipelines = api.getAllPipelines("resourceGroup"); | ||
|
Comment on lines
-39
to
+44
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🥳 |
||
| assertThat(allPipelines).isNotNull(); | ||
| assertThat(allPipelines.getResources()).isEmpty(); | ||
| } | ||
|
|
@@ -45,7 +50,7 @@ void testPipelines() { | |
| void testVector() { | ||
| final VectorApi api = new GroundingClient(SERVICE).vector(); | ||
|
|
||
| final CollectionsListResponse collections = api.getAllCollections("reosurceGroup"); | ||
| final CollectionsListResponse collections = api.getAllCollections("resourceGroup"); | ||
| assertThat(collections).isNotNull(); | ||
| assertThat(collections.getResources()) | ||
| .isNotNull() | ||
|
|
@@ -63,7 +68,7 @@ void testVector() { | |
| }); | ||
|
|
||
| final UUID collectionId = collections.getResources().get(0).getId(); | ||
| final Documents documents = api.getAllDocuments("reosurceGroup", collectionId); | ||
| final Documents documents = api.getAllDocuments("resourceGroup", collectionId); | ||
| assertThat(documents).isNotNull(); | ||
| final var documentMeta = | ||
| VectorDocumentKeyValueListPair.create() | ||
|
|
@@ -82,7 +87,7 @@ void testVector() { | |
|
|
||
| final UUID documentId = documents.getResources().get(0).getId(); | ||
| final DocumentResponse document = | ||
| api.getDocumentById("reosurceGroup", collectionId, documentId); | ||
| api.getDocumentById("resourceGroup", collectionId, documentId); | ||
| assertThat(document).isNotNull(); | ||
| assertThat(document.getId()).isEqualTo(documentId); | ||
| assertThat(document.getMetadata()).isNotNull().containsExactly(documentMeta); | ||
|
|
@@ -115,7 +120,7 @@ void testVector() { | |
| void testRetrieval() { | ||
| final RetrievalApi api = new GroundingClient(SERVICE).retrieval(); | ||
|
|
||
| DataRepositories repositories = api.getDataRepositories("reosurceGroup"); | ||
| DataRepositories repositories = api.getDataRepositories("resourceGroup"); | ||
| assertThat(repositories).isNotNull(); | ||
| assertThat(repositories.getResources()) | ||
| .isNotEmpty() | ||
|
|
@@ -137,4 +142,26 @@ void testRetrieval() { | |
| assertThat(r2.getMetadata()).isNotNull().isEmpty(); | ||
| }); | ||
| } | ||
|
|
||
| @Test | ||
| void testCustomHeaders() { | ||
| WM.stubFor( | ||
| get(anyUrl()) | ||
| .withHeader("x-test-header", equalTo("test-value")) | ||
| .willReturn( | ||
| okJson( | ||
| """ | ||
| { | ||
| "count": 0, | ||
| "resources": [] | ||
| } | ||
| """))); | ||
|
|
||
| new GroundingClient(SERVICE) | ||
| .withHeader("x-test-header", "test-value") | ||
| .pipelines() | ||
| .getAllPipelines("resourceGroup"); | ||
|
|
||
| WM.verify(getRequestedFor(anyUrl()).withHeader("x-test-header", equalTo("test-value"))); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |
|
|
||
| ### ✨ New Functionality | ||
|
|
||
| - | ||
| - [Grounding] Added `GroundingClient.withHeader()`. | ||
|
|
||
| ### 📈 Improvements | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caused by
if (header.getValue() != null) {. I'm not testing the value to null because it will never be null and I prefer having theifrather that an IDE warning.