File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 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+ 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 }} "
Original file line number Diff line number Diff 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 () {
You can’t perform that action at this time.
0 commit comments