Skip to content

Commit 4d0591d

Browse files
committed
Added more tests
1 parent bbe1266 commit 4d0591d

40 files changed

+3516
-604
lines changed

.vscode/cspell.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,6 +1382,16 @@
13821382
"gcch",
13831383
"updation" // current typo in a swagger
13841384
]
1385+
},
1386+
{
1387+
"filename": "sdk/ai/azure-ai-projects/**",
1388+
"words": [
1389+
"AISEARCH",
1390+
"AISERVICES",
1391+
"SUBSCRIPTIONID",
1392+
"RESOURCEGROUPNAME",
1393+
"PROJECTNAME"
1394+
]
13851395
}
13861396
],
13871397
"allowCompoundWords": true

sdk/ai/azure-ai-projects/customization/src/main/java/AIProjectsCustomizations.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void customize(LibraryCustomization customization, Logger logger) {
2121
connectionsImpl.getFileName(),
2222
"{endpoint}/agents/v1.0");
2323

24-
for (Range r : toReplace ) {
24+
for (Range r : toReplace) {
2525
logger.info("customizing");
2626
connectionsImpl.getEditor().replace(
2727
connectionsImpl.getFileName(),
@@ -30,5 +30,23 @@ public void customize(LibraryCustomization customization, Logger logger) {
3030
"{endpoint}"
3131
);
3232
}
33+
34+
ClassCustomization telemetriesImpl = customization.getClass(
35+
"com.azure.ai.projects.implementation",
36+
"TelemetriesImpl");
37+
38+
List<Range> toReplace = telemetriesImpl.getEditor().searchText(
39+
telemetriesImpl.getFileName(),
40+
"{endpoint}/agents/v1.0");
41+
42+
for (Range r : toReplace) {
43+
logger.info("customizing");
44+
telemetriesImpl.getEditor().replace(
45+
telemetriesImpl.getFileName(),
46+
r.getStart(),
47+
r.getEnd(),
48+
"{endpoint}"
49+
);
50+
}
3351
}
3452
}

sdk/ai/azure-ai-projects/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Code generated by Microsoft (R) TypeSpec Code Generator.
4646
<spotless.skip>false</spotless.skip>
4747

4848
<javaModulesSurefireArgLine>
49+
--add-exports com.azure.core/com.azure.core.implementation.util=ALL-UNNAMED
4950
--add-opens com.azure.core/com.azure.core.implementation.util=ALL-UNNAMED
5051
</javaModulesSurefireArgLine>
5152
</properties>

sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/AgentsClient.java

Lines changed: 196 additions & 127 deletions
Large diffs are not rendered by default.

sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/TelemetriesImpl.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public final class TelemetriesImpl {
4444

4545
/**
4646
* Initializes an instance of TelemetriesImpl.
47-
*
47+
*
4848
* @param client the instance of the service client containing this operation class.
4949
*/
5050
TelemetriesImpl(AIProjectClientImpl client) {
@@ -55,7 +55,7 @@ public final class TelemetriesImpl {
5555

5656
/**
5757
* Gets Service version.
58-
*
58+
*
5959
* @return the serviceVersion value.
6060
*/
6161
public ProjectsServiceVersion getServiceVersion() {
@@ -66,7 +66,7 @@ public ProjectsServiceVersion getServiceVersion() {
6666
* The interface defining all the services for AIProjectClientTelemetries to be used by the proxy service to perform
6767
* REST calls.
6868
*/
69-
@Host("{endpoint}/agents/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{projectName}")
69+
@Host("{endpoint}/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{projectName}")
7070
@ServiceInterface(name = "AIProjectClientTelem")
7171
public interface TelemetriesService {
7272
@Get("/{appInsightsResourceUrl}")
@@ -99,7 +99,7 @@ Response<BinaryData> getAppInsightsSync(@HostParam("endpoint") String endpoint,
9999
/**
100100
* Gets the properties of the specified Application Insights resource.
101101
* <p><strong>Response Body Schema</strong></p>
102-
*
102+
*
103103
* <pre>
104104
* {@code
105105
* {
@@ -111,16 +111,16 @@ Response<BinaryData> getAppInsightsSync(@HostParam("endpoint") String endpoint,
111111
* }
112112
* }
113113
* </pre>
114-
*
114+
*
115115
* @param appInsightsResourceUrl The AppInsights Azure resource Url. It should have the format:
116116
* '/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/microsoft.insights/components/{resourcename}'.
117117
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
118+
* @return the properties of the specified Application Insights resource along with {@link Response} on successful
119+
* completion of {@link Mono}.
118120
* @throws HttpResponseException thrown if the request is rejected by server.
119121
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
120122
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
121123
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
122-
* @return the properties of the specified Application Insights resource along with {@link Response} on successful
123-
* completion of {@link Mono}.
124124
*/
125125
@ServiceMethod(returns = ReturnType.SINGLE)
126126
public Mono<Response<BinaryData>> getAppInsightsWithResponseAsync(String appInsightsResourceUrl,
@@ -134,7 +134,7 @@ public Mono<Response<BinaryData>> getAppInsightsWithResponseAsync(String appInsi
134134
/**
135135
* Gets the properties of the specified Application Insights resource.
136136
* <p><strong>Response Body Schema</strong></p>
137-
*
137+
*
138138
* <pre>
139139
* {@code
140140
* {
@@ -146,15 +146,15 @@ public Mono<Response<BinaryData>> getAppInsightsWithResponseAsync(String appInsi
146146
* }
147147
* }
148148
* </pre>
149-
*
149+
*
150150
* @param appInsightsResourceUrl The AppInsights Azure resource Url. It should have the format:
151151
* '/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/microsoft.insights/components/{resourcename}'.
152152
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
153+
* @return the properties of the specified Application Insights resource along with {@link Response}.
153154
* @throws HttpResponseException thrown if the request is rejected by server.
154155
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
155156
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
156157
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
157-
* @return the properties of the specified Application Insights resource along with {@link Response}.
158158
*/
159159
@ServiceMethod(returns = ReturnType.SINGLE)
160160
public Response<BinaryData> getAppInsightsWithResponse(String appInsightsResourceUrl,

sdk/ai/azure-ai-projects/src/custom/java/com/azure/ai/projects/models/AgentServerSentEvents.java renamed to sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/AgentServerSentEvents.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.azure.ai.projects.models.streaming.StreamTypeFactory;
66
import com.azure.ai.projects.models.streaming.StreamUpdate;
77
import com.azure.core.util.BinaryData;
8+
import com.azure.core.util.logging.ClientLogger;
89
import reactor.core.publisher.Flux;
910
import reactor.core.scheduler.Schedulers;
1011

@@ -27,6 +28,8 @@ public final class AgentServerSentEvents {
2728
// Server sent events are divided by 2 CRLF or single LF character
2829
private static final int SSE_CHUNK_LINE_BREAK_COUNT_MARKER = 2;
2930

31+
private final ClientLogger logger = new ClientLogger(AgentServerSentEvents.class);
32+
3033
/**
3134
* A factory that determines into which type to deserialize the server sent events.
3235
*/
@@ -147,6 +150,8 @@ private boolean isByteCarriageReturn(byte character) {
147150
* @param currentEvent The current line of the server sent event.
148151
* @param outputValues The list of values to add the current line to.
149152
* @throws IllegalStateException If the current event contains a server side error.
153+
* @throws IllegalArgumentException If there's an error processing the event data.
154+
* @throws UncheckedIOException If there's an error deserializing the event data.
150155
*/
151156
public void handleCurrentEvent(String currentEvent, List<StreamUpdate> outputValues)
152157
throws IllegalArgumentException {
@@ -172,7 +177,7 @@ public void handleCurrentEvent(String currentEvent, List<StreamUpdate> outputVal
172177
return;
173178
}
174179
if (ERROR.equals(AgentStreamEvent.fromString(eventName))) {
175-
throw new IllegalArgumentException(eventJson);
180+
throw logger.logExceptionAsError(new IllegalArgumentException(eventJson));
176181
}
177182

178183
outputValues.add(this.eventDeserializer.deserializeEvent(eventName, BinaryData.fromString(eventJson)));

0 commit comments

Comments
 (0)