Skip to content

Commit 2cb7721

Browse files
Updated AI Core unit tests (#131)
1 parent 5d43a55 commit 2cb7721

File tree

5 files changed

+48
-40
lines changed

5 files changed

+48
-40
lines changed

core/src/test/java/com/sap/ai/sdk/core/client/ArtifactUnitTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Test that queries are on the right URL, with the right headers. Also check that the received
2020
* response is parsed correctly in the generated client.
2121
*/
22-
public class ArtifactUnitTest extends WireMockTestServer {
22+
class ArtifactUnitTest extends WireMockTestServer {
2323
@Test
2424
void getArtifacts() {
2525
wireMockServer.stubFor(

core/src/test/java/com/sap/ai/sdk/core/client/ConfigurationUnitTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Test that queries are on the right URL, with the right headers. Also check that the received
2222
* response is parsed correctly in the generated client.
2323
*/
24-
public class ConfigurationUnitTest extends WireMockTestServer {
24+
class ConfigurationUnitTest extends WireMockTestServer {
2525
@Test
2626
void getConfigurations() {
2727
wireMockServer.stubFor(

core/src/test/java/com/sap/ai/sdk/core/client/DeploymentUnitTest.java

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* Test that queries are on the right URL, with the right headers. Also check that the received
3333
* response is parsed correctly in the generated client.
3434
*/
35-
public class DeploymentUnitTest extends WireMockTestServer {
35+
class DeploymentUnitTest extends WireMockTestServer {
3636
@Test
3737
void getDeployments() {
3838
wireMockServer.stubFor(
@@ -48,32 +48,43 @@ void getDeployments() {
4848
"count": 1,
4949
"resources": [
5050
{
51+
"id": "d889e3a61050c085",
52+
"deploymentUrl": "https://api.ai.intprod-eu12.eu-central-1.aws.ml.hana.ondemand.com/v2/inference/deployments/d889e3a61050c085",
5153
"configurationId": "7652a231-ba9b-4fcc-b473-2c355cb21b61",
5254
"configurationName": "gpt-4-32k",
53-
"createdAt": "2024-04-17T15:19:53Z",
54-
"deploymentUrl": "https://api.ai.intprod-eu12.eu-central-1.aws.ml.hana.ondemand.com/v2/inference/deployments/d19b998f347341aa",
55+
"executableId": null,
56+
"scenarioId": "foundation-models",
57+
"status": "RUNNING",
58+
"statusMessage": null,
59+
"targetStatus": "RUNNING",
60+
"lastOperation": "CREATE",
61+
"latestRunningConfigurationId": "7652a231-ba9b-4fcc-b473-2c355cb21b61",
62+
"ttl": null,
5563
"details": {
64+
"scaling": {
65+
"backendDetails": {},
66+
"backend_details": {}
67+
},
5668
"resources": {
69+
"backendDetails": {
70+
"model": {
71+
"name": "gpt-4-32k",
72+
"version": "latest"
73+
}
74+
},
5775
"backend_details": {
5876
"model": {
5977
"name": "gpt-4-32k",
6078
"version": "latest"
6179
}
6280
}
63-
},
64-
"scaling": {
65-
"backend_details": {}
6681
}
6782
},
68-
"id": "d19b998f347341aa",
69-
"lastOperation": "CREATE",
70-
"latestRunningConfigurationId": "7652a231-ba9b-4fcc-b473-2c355cb21b61",
71-
"modifiedAt": "2024-05-07T13:05:45Z",
72-
"scenarioId": "foundation-models",
73-
"startTime": "2024-04-17T15:21:15Z",
74-
"status": "RUNNING",
75-
"submissionTime": "2024-04-17T15:20:11Z",
76-
"targetStatus": "RUNNING"
83+
"createdAt": "2024-09-20T11:31:24Z",
84+
"modifiedAt": "2024-10-30T13:36:38Z",
85+
"submissionTime": "2024-09-20T11:31:38Z",
86+
"startTime": "2024-09-20T11:32:42Z",
87+
"completionTime": null
7788
}
7889
]
7990
}
@@ -89,24 +100,22 @@ void getDeployments() {
89100

90101
assertThat(deployment.getConfigurationId()).isEqualTo("7652a231-ba9b-4fcc-b473-2c355cb21b61");
91102
assertThat(deployment.getConfigurationName()).isEqualTo("gpt-4-32k");
92-
assertThat(deployment.getCreatedAt()).isEqualTo("2024-04-17T15:19:53Z");
103+
assertThat(deployment.getCreatedAt()).isEqualTo("2024-09-20T11:31:24Z");
93104
assertThat(deployment.getDeploymentUrl())
94105
.isEqualTo(
95-
"https://api.ai.intprod-eu12.eu-central-1.aws.ml.hana.ondemand.com/v2/inference/deployments/d19b998f347341aa");
106+
"https://api.ai.intprod-eu12.eu-central-1.aws.ml.hana.ondemand.com/v2/inference/deployments/d889e3a61050c085");
96107
// Response contains key "backend_details" while spec (mistakenly) defines key "backendDetails".
97108
val expected = Map.of("model", Map.of("name", "gpt-4-32k", "version", "latest"));
98-
assertThat(deployment.getDetails().getResources().getCustomField("backend_details"))
99-
.isEqualTo(expected);
100-
assertThat(deployment.getDetails().getScaling().getCustomFieldNames())
101-
.contains("backend_details");
102-
assertThat(deployment.getId()).isEqualTo("d19b998f347341aa");
109+
assertThat(deployment.getDetails().getResources().getBackendDetails()).isEqualTo(expected);
110+
assertThat(deployment.getDetails().getScaling().getBackendDetails()).isEqualTo(Map.of());
111+
assertThat(deployment.getId()).isEqualTo("d889e3a61050c085");
103112
assertThat(deployment.getLastOperation()).isEqualTo(AiDeployment.LastOperationEnum.CREATE);
104113
assertThat(deployment.getLatestRunningConfigurationId())
105114
.isEqualTo("7652a231-ba9b-4fcc-b473-2c355cb21b61");
106-
assertThat(deployment.getModifiedAt()).isEqualTo("2024-05-07T13:05:45Z");
107-
assertThat(deployment.getStartTime()).isEqualTo("2024-04-17T15:21:15Z");
115+
assertThat(deployment.getModifiedAt()).isEqualTo("2024-10-30T13:36:38Z");
116+
assertThat(deployment.getStartTime()).isEqualTo("2024-09-20T11:32:42Z");
108117
assertThat(deployment.getStatus()).isEqualTo(AiDeploymentStatus.RUNNING);
109-
assertThat(deployment.getSubmissionTime()).isEqualTo("2024-04-17T15:20:11Z");
118+
assertThat(deployment.getSubmissionTime()).isEqualTo("2024-09-20T11:31:38Z");
110119
assertThat(deployment.getTargetStatus()).isEqualTo(AiDeployment.TargetStatusEnum.RUNNING);
111120
}
112121

@@ -234,10 +243,12 @@ void getDeploymentById() {
234243
"deploymentUrl": "https://api.ai.intprod-eu12.eu-central-1.aws.ml.hana.ondemand.com/v2/inference/deployments/db1d64d9f06be467",
235244
"details": {
236245
"resources": {
237-
"backend_details": {}
246+
"backend_details": {},
247+
"backendDetails": {}
238248
},
239249
"scaling": {
240-
"backend_details": {}
250+
"backend_details": {},
251+
"backendDetails": {}
241252
}
242253
},
243254
"id": "db1d64d9f06be467",
@@ -261,11 +272,8 @@ void getDeploymentById() {
261272
assertThat(deployment.getDeploymentUrl())
262273
.isEqualTo(
263274
"https://api.ai.intprod-eu12.eu-central-1.aws.ml.hana.ondemand.com/v2/inference/deployments/db1d64d9f06be467");
264-
// Response contains key "backend_details" while spec (mistakenly) defines key "backendDetails".
265-
assertThat(deployment.getDetails().getResources().getCustomFieldNames())
266-
.contains("backend_details");
267-
assertThat(deployment.getDetails().getScaling().getCustomFieldNames())
268-
.contains("backend_details");
275+
assertThat(deployment.getDetails().getResources().getBackendDetails()).isNotNull();
276+
assertThat(deployment.getDetails().getScaling().getBackendDetails()).isNotNull();
269277
assertThat(deployment.getId()).isEqualTo("db1d64d9f06be467");
270278
assertThat(deployment.getLastOperation())
271279
.isEqualTo(AiDeploymentResponseWithDetails.LastOperationEnum.CREATE);

core/src/test/java/com/sap/ai/sdk/core/client/ExecutionUnitTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* Test that queries are on the right URL, with the right headers. Also check that the received
3232
* response is parsed correctly in the generated client.
3333
*/
34-
public class ExecutionUnitTest extends WireMockTestServer {
34+
class ExecutionUnitTest extends WireMockTestServer {
3535
@Test
3636
void getExecutions() {
3737
wireMockServer.stubFor(
@@ -100,7 +100,7 @@ void getExecutions() {
100100
val aiArtifact = execution.getOutputArtifacts().get(0);
101101

102102
assertThat(aiArtifact.getCreatedAt()).isEqualTo("2023-08-05T14:10:05Z");
103-
assertThat(aiArtifact.getDescription()).isEqualTo("");
103+
assertThat(aiArtifact.getDescription()).isEmpty();
104104
assertThat(aiArtifact.getExecutionId()).isEqualTo("eab289226fe981da");
105105
assertThat(aiArtifact.getId()).isEqualTo("be0d728f-1cb2-4ff4-97ad-45c54ac592f6");
106106
assertThat(aiArtifact.getKind()).isEqualTo(AiArtifact.KindEnum.MODEL);
@@ -211,7 +211,7 @@ void getExecutionById() {
211211
val aiArtifact = execution.getOutputArtifacts().get(0);
212212

213213
assertThat(aiArtifact.getCreatedAt()).isEqualTo("2024-09-09T19:10:48Z");
214-
assertThat(aiArtifact.getDescription()).isEqualTo("");
214+
assertThat(aiArtifact.getDescription()).isEmpty();
215215
assertThat(aiArtifact.getExecutionId()).isEqualTo("e529e8bd58740bc9");
216216
assertThat(aiArtifact.getId()).isEqualTo("c4792df8-da67-44fe-ad99-b5ea74bbb248");
217217
assertThat(aiArtifact.getKind()).isEqualTo(AiArtifact.KindEnum.MODEL);

core/src/test/java/com/sap/ai/sdk/core/client/ScenarioUnitTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Test that queries are on the right URL, with the right headers. Also check that the received
1717
* response is parsed correctly in the generated client.
1818
*/
19-
public class ScenarioUnitTest extends WireMockTestServer {
19+
class ScenarioUnitTest extends WireMockTestServer {
2020
@Test
2121
void getScenarios() {
2222
wireMockServer.stubFor(
@@ -186,7 +186,7 @@ void getScenarioModels() {
186186
AiModelVersion aiModelVersion = scenario.getVersions().get(0);
187187
assertThat(aiModelVersion.getName()).isEqualTo("202407");
188188
assertThat(aiModelVersion.isIsLatest()).isTrue();
189-
assertThat(aiModelVersion.isDeprecated()).isEqualTo(false);
190-
assertThat(aiModelVersion.getRetirementDate()).isEqualTo("");
189+
assertThat(aiModelVersion.isDeprecated()).isFalse();
190+
assertThat(aiModelVersion.getRetirementDate()).isEmpty();
191191
}
192192
}

0 commit comments

Comments
 (0)