Skip to content

Commit 0101fef

Browse files
committed
re-introduce deleted code
1 parent 3d9c198 commit 0101fef

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

.github/workflows/e2e-test.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,19 @@ jobs:
9999
# print response body with headers to stdout. q:body only O:print -:stdout S:headers
100100
run: wget -qO- -S localhost:8080
101101

102+
- name: "Slack Notification"
103+
if: failure()
104+
uses: slackapi/[email protected]
105+
with:
106+
webhook: ${{ secrets.SLACK_WEBHOOK }}
107+
webhook-type: incoming-webhook
108+
payload: |
109+
blocks:
110+
- type: "section"
111+
text:
112+
type: "mrkdwn"
113+
text: "⚠️ End-to-end tests failed! 😬 Please inspect & fix by clicking <https://github.com/SAP/ai-sdk-java/actions/runs/${{ github.run_id }}|here>"
114+
- type: "section"
115+
text:
116+
type: "plain_text"
117+
text: "${{ steps.run_tests.outputs.error_message }} "

sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/OrchestrationTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,24 @@ void testImageInput() {
318318
assertThat(choices.get(0).getMessage().getContent()).isNotEmpty();
319319
}
320320

321+
@Test
322+
void testImageInputBase64() {
323+
String dataUrl = "";
324+
try {
325+
URL url = new URL("https://upload.wikimedia.org/wikipedia/commons/c/c9/Sap-logo-700x700.jpg");
326+
try (InputStream inputStream = url.openStream()) {
327+
byte[] imageBytes = inputStream.readAllBytes();
328+
byte[] encodedBytes = Base64.getEncoder().encode(imageBytes);
329+
String encodedString = new String(encodedBytes, StandardCharsets.UTF_8);
330+
dataUrl = "data:image/jpeg;base64," + encodedString;
331+
}
332+
} catch (Exception e) {
333+
System.out.println("Error fetching or reading the image from URL: " + e.getMessage());
334+
}
335+
val result = service.imageInput(dataUrl).getOriginalResponse();
336+
val choices = (result.getFinalResult()).getChoices();
337+
assertThat(choices.get(0).getMessage().getContent()).isNotEmpty();
338+
}
321339

322340
@Test
323341
void testMultiStringInput() {

0 commit comments

Comments
 (0)