Skip to content

Commit fcbd6fa

Browse files
fix tests
1 parent 09bf293 commit fcbd6fa

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

core/src/main/java/com/sap/ai/sdk/core/AiCoreServiceKeyAccessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class AiCoreServiceKeyAccessor implements ServiceBindingAccessor {
2929

3030
private final Lazy<Dotenv> dotenv;
3131

32-
private static List<ServiceBinding> serviceBindings;
32+
static List<ServiceBinding> serviceBindings;
3333

3434
AiCoreServiceKeyAccessor() {
3535
this(Dotenv.configure().ignoreIfMissing().ignoreIfMalformed());

core/src/main/java/com/sap/ai/sdk/core/common/ClientResponseHandler.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ private T parseSuccess(@Nonnull final ClassicHttpResponse response) throws E {
8888
.getOrElseThrow(e -> exceptionFactory.build(message, e).setHttpResponse(response));
8989
try {
9090
final T value = objectMapper.readValue(content, successType);
91-
log.info(
92-
"LLM request success with duration:{}",
93-
response.getHeaders("x-upstream-service-time")[0].getValue());
91+
val timeHeaders = response.getHeaders("x-upstream-service-time");
92+
if (timeHeaders.length > 0) {
93+
log.info("LLM request success with duration:{}", timeHeaders[0].getValue());
94+
}
9495
return value;
9596
} catch (final JsonProcessingException e) {
9697
log.error("Failed to parse response to type {}", successType);

core/src/test/java/com/sap/ai/sdk/core/AiCoreServiceKeyAccessorTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@
99
import com.sap.cloud.environment.servicebinding.api.exception.ServiceBindingAccessException;
1010
import io.github.cdimascio.dotenv.Dotenv;
1111
import java.util.Map;
12+
import org.junit.jupiter.api.BeforeEach;
1213
import org.junit.jupiter.api.Test;
1314

1415
class AiCoreServiceKeyAccessorTest {
1516

17+
@BeforeEach
18+
void resetServiceBindings() {
19+
AiCoreServiceKeyAccessor.serviceBindings = null;
20+
}
21+
1622
@Test
1723
void testValidDotenv() {
1824
var dotenv = spy(Dotenv.configure().filename("valid.testenv"));

0 commit comments

Comments
 (0)