From 1e1b2d9ae80a3aef17e67a7b81a3b82293e5d071 Mon Sep 17 00:00:00 2001 From: Azad Abbasi Date: Mon, 26 Oct 2020 15:18:44 -0700 Subject: [PATCH] Rename EventRoute to DigitalTwinsEventRoute (#16824) --- .../core/DigitalTwinsAsyncClient.java | 40 +++++++++---------- .../digitaltwins/core/DigitalTwinsClient.java | 22 +++++----- .../converters/EventRouteConverter.java | 14 +++---- .../converters/OptionsConverter.java | 4 +- .../core/models/CreateEventRouteOptions.java | 3 +- ...Route.java => DigitalTwinsEventRoute.java} | 8 ++-- ... => GetDigitalTwinsEventRouteOptions.java} | 13 +++--- ...> ListDigitalTwinsEventRoutesOptions.java} | 13 +++--- .../src/samples/README.md | 16 ++++---- .../core/EventRoutesSyncSamples.java | 10 ++--- ...alTwinsAsyncClientJavaDocCodeSnippets.java | 18 ++++----- ...DigitalTwinsClientJavaDocCodeSnippets.java | 24 +++++------ .../core/EventRoutesAsyncTest.java | 12 +++--- .../digitaltwins/core/EventRoutesTest.java | 24 +++++------ .../core/EventRoutesTestBase.java | 8 ++-- 15 files changed, 113 insertions(+), 116 deletions(-) rename sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/{EventRoute.java => DigitalTwinsEventRoute.java} (90%) rename sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/{GetEventRouteOptions.java => GetDigitalTwinsEventRouteOptions.java} (81%) rename sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/{ListEventRoutesOptions.java => ListDigitalTwinsEventRoutesOptions.java} (86%) diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java index ef5461c716e93..c7cd66f49938e 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java @@ -1249,9 +1249,9 @@ Mono> queryNextPage(String nextLink, Class clazz, QueryO * @return An empty mono. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createOrReplaceEventRoute(String eventRouteId, EventRoute eventRoute) + public Mono createOrReplaceEventRoute(String eventRouteId, DigitalTwinsEventRoute eventRoute) { - return createEventRouteWithResponse(eventRouteId, eventRoute, null) + return createOrReplaceEventRouteWithResponse(eventRouteId, eventRoute, null) .flatMap(voidResponse -> Mono.empty()); } @@ -1269,12 +1269,12 @@ public Mono createOrReplaceEventRoute(String eventRouteId, EventRoute even * @return A {@link Response} containing an empty mono. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createEventRouteWithResponse(String eventRouteId, EventRoute eventRoute, CreateEventRouteOptions options) + public Mono> createOrReplaceEventRouteWithResponse(String eventRouteId, DigitalTwinsEventRoute eventRoute, CreateEventRouteOptions options) { - return withContext(context -> createEventRouteWithResponse(eventRouteId, eventRoute, options, context)); + return withContext(context -> createOrReplaceEventRouteWithResponse(eventRouteId, eventRoute, options, context)); } - Mono> createEventRouteWithResponse(String eventRouteId, EventRoute eventRoute, CreateEventRouteOptions options, Context context) + Mono> createOrReplaceEventRouteWithResponse(String eventRouteId, DigitalTwinsEventRoute eventRoute, CreateEventRouteOptions options, Context context) { return this.protocolLayer.getEventRoutes().addWithResponseAsync(eventRouteId, EventRouteConverter.map(eventRoute), OptionsConverter.toProtocolLayerOptions(options), context); } @@ -1290,7 +1290,7 @@ Mono> createEventRouteWithResponse(String eventRouteId, EventRout * @return The retrieved event route. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getEventRoute(String eventRouteId) + public Mono getEventRoute(String eventRouteId) { return getEventRouteWithResponse(eventRouteId, null) .map(Response::getValue); @@ -1308,12 +1308,12 @@ public Mono getEventRoute(String eventRouteId) * @return A {@link Response} containing the retrieved event route. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getEventRouteWithResponse(String eventRouteId, GetEventRouteOptions options) + public Mono> getEventRouteWithResponse(String eventRouteId, GetDigitalTwinsEventRouteOptions options) { return withContext(context -> getEventRouteWithResponse(eventRouteId, options, context)); } - Mono> getEventRouteWithResponse(String eventRouteId, GetEventRouteOptions options, Context context) + Mono> getEventRouteWithResponse(String eventRouteId, GetDigitalTwinsEventRouteOptions options, Context context) { return this.protocolLayer.getEventRoutes().getByIdWithResponseAsync(eventRouteId, OptionsConverter.toProtocolLayerOptions(options), context) .map(eventRouteResponse -> new SimpleResponse<>( @@ -1373,7 +1373,7 @@ Mono> deleteEventRouteWithResponse(String eventRouteId, DeleteEve * This PagedFlux may take multiple service requests to iterate over all event routes. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listEventRoutes() + public PagedFlux listEventRoutes() { return listEventRoutes(null); } @@ -1385,42 +1385,42 @@ public PagedFlux listEventRoutes() * * {@codesnippet com.azure.digitaltwins.core.asyncClient.listEventRoutes#Options} * - * @param options The optional parameters to use when listing event routes. See {@link ListEventRoutesOptions} for more details + * @param options The optional parameters to use when listing event routes. See {@link ListDigitalTwinsEventRoutesOptions} for more details * on what optional parameters can be set. * @return A {@link PagedFlux} that contains all the event routes that exist in your digital twins instance. * This PagedFlux may take multiple service requests to iterate over all event routes. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listEventRoutes(ListEventRoutesOptions options) + public PagedFlux listEventRoutes(ListDigitalTwinsEventRoutesOptions options) { return new PagedFlux<>( () -> withContext(context -> listEventRoutesFirstPage(options, context)), nextLink -> withContext(context -> listEventRoutesNextPage(nextLink, options, context))); } - PagedFlux listEventRoutes(ListEventRoutesOptions options, Context context) + PagedFlux listEventRoutes(ListDigitalTwinsEventRoutesOptions options, Context context) { return new PagedFlux<>( () -> listEventRoutesFirstPage(options, context), nextLink -> listEventRoutesNextPage(nextLink, options, context)); } - Mono> listEventRoutesFirstPage(ListEventRoutesOptions options, Context context) { + Mono> listEventRoutesFirstPage(ListDigitalTwinsEventRoutesOptions options, Context context) { return protocolLayer .getEventRoutes() .listSinglePageAsync(OptionsConverter.toProtocolLayerOptions(options), context) .map(pagedEventRouteMappingFunction); } - Mono> listEventRoutesNextPage(String nextLink, ListEventRoutesOptions options, Context context) { + Mono> listEventRoutesNextPage(String nextLink, ListDigitalTwinsEventRoutesOptions options, Context context) { return protocolLayer .getEventRoutes() .listNextSinglePageAsync(nextLink, OptionsConverter.toProtocolLayerOptions(options), context) .map(pagedEventRouteMappingFunction); } - private Function, PagedResponse> pagedEventRouteMappingFunction = (pagedEventRouteResponse) -> { - List convertedList = pagedEventRouteResponse.getValue().stream() + private Function, PagedResponse> pagedEventRouteMappingFunction = (pagedEventRouteResponse) -> { + List convertedList = pagedEventRouteResponse.getValue().stream() .map(EventRouteConverter::map) .filter(Objects::nonNull) .collect(Collectors.toList()); @@ -1451,7 +1451,7 @@ Mono> listEventRoutesNextPage(String nextLink, ListEve * * {@codesnippet com.azure.digitaltwins.core.asyncClient.publishTelemetry#String-String-Object#String} * - * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link DigitalTwinsEventRoute} * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. * @param digitalTwinId The Id of the digital twin. * @param messageId A unique message identifier (within the scope of the digital twin id) that is commonly used for de-duplicating messages. Defaults to a random UUID if argument is null. @@ -1477,7 +1477,7 @@ public Mono publishTelemetry(String digitalTwinId, String messageId, Objec * * {@codesnippet com.azure.digitaltwins.core.asyncClient.publishTelemetryWithResponse#String-String-Object-Options#String} * - * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link DigitalTwinsEventRoute} * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. * @param digitalTwinId The Id of the digital twin. * @param messageId A unique message identifier (within the scope of the digital twin id) that is commonly used for de-duplicating messages. Defaults to a random UUID if argument is null. @@ -1528,7 +1528,7 @@ Mono> publishTelemetryWithResponse(String digitalTwinId, String m * * {@codesnippet com.azure.digitaltwins.core.asyncClient.publishComponentTelemetry#String-String-String-Object#String} * - * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link DigitalTwinsEventRoute} * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. * @param digitalTwinId The Id of the digital twin. * @param componentName The name of the DTDL component. @@ -1555,7 +1555,7 @@ public Mono publishComponentTelemetry(String digitalTwinId, String compone * * {@codesnippet com.azure.digitaltwins.core.asyncClient.publishComponentTelemetryWithResponse#String-String-String-Object-Options#String} * - * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link DigitalTwinsEventRoute} * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. * @param digitalTwinId The Id of the digital twin. * @param componentName The name of the DTDL component. diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java index 56407773d227b..ed6e7a97ce846 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java @@ -814,7 +814,7 @@ public PagedIterable query(String query, Class clazz, QueryOptions opt * @param eventRoute The event route to create. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void createOrReplaceEventRoute(String eventRouteId, EventRoute eventRoute) { + public void createOrReplaceEventRoute(String eventRouteId, DigitalTwinsEventRoute eventRoute) { createOrReplaceEventRouteWithResponse(eventRouteId, eventRoute, null, Context.NONE); } @@ -833,8 +833,8 @@ public void createOrReplaceEventRoute(String eventRouteId, EventRoute eventRoute * @return A {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createOrReplaceEventRouteWithResponse(String eventRouteId, EventRoute eventRoute, CreateEventRouteOptions options, Context context) { - return this.digitalTwinsAsyncClient.createEventRouteWithResponse(eventRouteId, eventRoute, options, context).block(); + public Response createOrReplaceEventRouteWithResponse(String eventRouteId, DigitalTwinsEventRoute eventRoute, CreateEventRouteOptions options, Context context) { + return this.digitalTwinsAsyncClient.createOrReplaceEventRouteWithResponse(eventRouteId, eventRoute, options, context).block(); } /** @@ -848,7 +848,7 @@ public Response createOrReplaceEventRouteWithResponse(String eventRouteId, * @return The retrieved event route. */ @ServiceMethod(returns = ReturnType.SINGLE) - public EventRoute getEventRoute(String eventRouteId) { + public DigitalTwinsEventRoute getEventRoute(String eventRouteId) { return getEventRouteWithResponse(eventRouteId, null, Context.NONE).getValue(); } @@ -865,7 +865,7 @@ public EventRoute getEventRoute(String eventRouteId) { * @return A {@link Response} containing the retrieved event route. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getEventRouteWithResponse(String eventRouteId, GetEventRouteOptions options, Context context) { + public Response getEventRouteWithResponse(String eventRouteId, GetDigitalTwinsEventRouteOptions options, Context context) { return this.digitalTwinsAsyncClient.getEventRouteWithResponse(eventRouteId, options, context).block(); } @@ -913,7 +913,7 @@ public Response deleteEventRouteWithResponse(String eventRouteId, DeleteEv * This PagedIterable may take multiple service requests to iterate over all event routes. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listEventRoutes() { + public PagedIterable listEventRoutes() { return listEventRoutes(null, Context.NONE); } @@ -930,7 +930,7 @@ public PagedIterable listEventRoutes() { * This PagedIterable may take multiple service requests to iterate over all event routes. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listEventRoutes(ListEventRoutesOptions options, Context context) { + public PagedIterable listEventRoutes(ListDigitalTwinsEventRoutesOptions options, Context context) { return new PagedIterable<>(this.digitalTwinsAsyncClient.listEventRoutes(options, context)); } @@ -951,7 +951,7 @@ public PagedIterable listEventRoutes(ListEventRoutesOptions options, * * {@codesnippet com.azure.digitaltwins.core.syncClient.publishTelemetry#String-String-Object#String} * - * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link DigitalTwinsEventRoute} * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. * @param digitalTwinId The Id of the digital twin. * @param messageId A unique message identifier (within the scope of the digital twin id) that is commonly used for de-duplicating messages. Defaults to a random UUID if argument is null. @@ -975,7 +975,7 @@ public void publishTelemetry(String digitalTwinId, String messageId, Object payl * * {@codesnippet com.azure.digitaltwins.core.syncClient.publishTelemetryWithResponse#String-String-Object-Options-Context#String} * - * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link DigitalTwinsEventRoute} * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. * @param digitalTwinId The Id of the digital twin. * @param messageId A unique message identifier (within the scope of the digital twin id) that is commonly used for de-duplicating messages. Defaults to a random UUID if argument is null. @@ -1002,7 +1002,7 @@ public Response publishTelemetryWithResponse(String digitalTwinId, String * * {@codesnippet com.azure.digitaltwins.core.syncClient.publishComponentTelemetry#String-String-String-Object#String} * - * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link DigitalTwinsEventRoute} * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. * @param digitalTwinId The Id of the digital twin. * @param componentName The name of the DTDL component. @@ -1027,7 +1027,7 @@ public void publishComponentTelemetry(String digitalTwinId, String componentName * * {@codesnippet com.azure.digitaltwins.core.syncClient.publishComponentTelemetryWithResponse#String-String-String-Object-Options-Context#String} * - * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link DigitalTwinsEventRoute} * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. * @param digitalTwinId The Id of the digital twin. * @param componentName The name of the DTDL component. diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/implementation/converters/EventRouteConverter.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/implementation/converters/EventRouteConverter.java index 58b151938dd20..8b222d488c141 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/implementation/converters/EventRouteConverter.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/implementation/converters/EventRouteConverter.java @@ -3,34 +3,34 @@ package com.azure.digitaltwins.core.implementation.converters; -import com.azure.digitaltwins.core.models.EventRoute; +import com.azure.digitaltwins.core.models.DigitalTwinsEventRoute; /** * A converter between {@link com.azure.digitaltwins.core.implementation.models.EventRoute} and - * {@link com.azure.digitaltwins.core.models.EventRoute}. + * {@link DigitalTwinsEventRoute}. */ public final class EventRouteConverter { /** * Maps from {@link com.azure.digitaltwins.core.implementation.models.EventRoute} to - * {@link com.azure.digitaltwins.core.models.EventRoute}. If the input is null, then the output will be null as well. + * {@link DigitalTwinsEventRoute}. If the input is null, then the output will be null as well. */ - public static com.azure.digitaltwins.core.models.EventRoute map(com.azure.digitaltwins.core.implementation.models.EventRoute input) { + public static DigitalTwinsEventRoute map(com.azure.digitaltwins.core.implementation.models.EventRoute input) { if (input == null) { return null; } - EventRoute mappedEventRoute = new EventRoute(input.getEndpointName()); + DigitalTwinsEventRoute mappedEventRoute = new DigitalTwinsEventRoute(input.getEndpointName()); mappedEventRoute.setFilter(input.getFilter()); mappedEventRoute.setEventRouteId(input.getId()); return mappedEventRoute; } /** - * Maps from {@link com.azure.digitaltwins.core.models.EventRoute} to + * Maps from {@link DigitalTwinsEventRoute} to * {@link com.azure.digitaltwins.core.implementation.models.EventRoute}. If the input is null, then the output will be null as well. */ - public static com.azure.digitaltwins.core.implementation.models.EventRoute map(com.azure.digitaltwins.core.models.EventRoute input) { + public static com.azure.digitaltwins.core.implementation.models.EventRoute map(DigitalTwinsEventRoute input) { if (input == null) { return null; } diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/implementation/converters/OptionsConverter.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/implementation/converters/OptionsConverter.java index a70f833c53b40..223c50b46187a 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/implementation/converters/OptionsConverter.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/implementation/converters/OptionsConverter.java @@ -84,7 +84,7 @@ public static EventRoutesAddOptions toProtocolLayerOptions(CreateEventRouteOptio return new EventRoutesAddOptions().setTraceparent(options.getTraceParent()).setTracestate(options.getTraceState()); } - public static EventRoutesListOptions toProtocolLayerOptions(ListEventRoutesOptions options) { + public static EventRoutesListOptions toProtocolLayerOptions(ListDigitalTwinsEventRoutesOptions options) { if (options == null) { return null; } @@ -95,7 +95,7 @@ public static EventRoutesListOptions toProtocolLayerOptions(ListEventRoutesOptio .setMaxItemsPerPage(options.getMaxItemsPerPage()); } - public static EventRoutesGetByIdOptions toProtocolLayerOptions(GetEventRouteOptions options) { + public static EventRoutesGetByIdOptions toProtocolLayerOptions(GetDigitalTwinsEventRouteOptions options) { if (options == null) { return null; } diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/CreateEventRouteOptions.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/CreateEventRouteOptions.java index 1f16f3fea95e5..fc745028f86a6 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/CreateEventRouteOptions.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/CreateEventRouteOptions.java @@ -9,8 +9,7 @@ /** * The optional parameters for - * {@link com.azure.digitaltwins.core.DigitalTwinsClient#createOrReplaceEventRouteWithResponse(String, EventRoute, CreateEventRouteOptions, Context)} and - * {@link com.azure.digitaltwins.core.DigitalTwinsAsyncClient#createEventRouteWithResponse(String, EventRoute, CreateEventRouteOptions)} + * {@link com.azure.digitaltwins.core.DigitalTwinsClient#createOrReplaceEventRouteWithResponse(String, DigitalTwinsEventRoute, CreateEventRouteOptions, Context)} and */ @Fluent public final class CreateEventRouteOptions { diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/EventRoute.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/DigitalTwinsEventRoute.java similarity index 90% rename from sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/EventRoute.java rename to sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/DigitalTwinsEventRoute.java index 4a555ea8d7866..9d6252789ecb8 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/EventRoute.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/DigitalTwinsEventRoute.java @@ -15,7 +15,7 @@ * event route can point towards an Azure EventHub as a consumer of published telemetry. */ @Fluent -public final class EventRoute { +public final class DigitalTwinsEventRoute { /* * The id of the event route. */ @@ -40,7 +40,7 @@ public final class EventRoute { * @param endpointName the name of the endpoint that this event route connects to. */ @JsonCreator - public EventRoute(@JsonProperty(value = "endpointName", required = true) String endpointName) { + public DigitalTwinsEventRoute(@JsonProperty(value = "endpointName", required = true) String endpointName) { this.endpointName = endpointName; } @@ -77,7 +77,7 @@ public String getFilter() { * @param filter the filter value to set. * @return the EventRoute object itself. */ - public EventRoute setFilter(String filter) { + public DigitalTwinsEventRoute setFilter(String filter) { this.filter = filter; return this; } @@ -88,7 +88,7 @@ public EventRoute setFilter(String filter) { * @param id The event route's Id to set. * @return the EventRoute object itself. */ - public EventRoute setEventRouteId(String id) { + public DigitalTwinsEventRoute setEventRouteId(String id) { this.id = id; return this; } diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/GetEventRouteOptions.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/GetDigitalTwinsEventRouteOptions.java similarity index 81% rename from sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/GetEventRouteOptions.java rename to sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/GetDigitalTwinsEventRouteOptions.java index d66fe35d5dc08..521c1c798d31e 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/GetEventRouteOptions.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/GetDigitalTwinsEventRouteOptions.java @@ -5,16 +5,15 @@ import com.azure.core.annotation.Fluent; import com.azure.core.util.Context; -import com.azure.digitaltwins.core.implementation.models.EventRoutesGetByIdOptions; import com.fasterxml.jackson.annotation.JsonProperty; /** * The optional parameters for - * {@link com.azure.digitaltwins.core.DigitalTwinsClient#getEventRouteWithResponse(String, GetEventRouteOptions, Context)} and - * {@link com.azure.digitaltwins.core.DigitalTwinsAsyncClient#getEventRouteWithResponse(String, GetEventRouteOptions)} + * {@link com.azure.digitaltwins.core.DigitalTwinsClient#getEventRouteWithResponse(String, GetDigitalTwinsEventRouteOptions, Context)} and + * {@link com.azure.digitaltwins.core.DigitalTwinsAsyncClient#getEventRouteWithResponse(String, GetDigitalTwinsEventRouteOptions)} */ @Fluent -public final class GetEventRouteOptions { +public final class GetDigitalTwinsEventRouteOptions { /* * Identifies the request in a distributed tracing system. */ @@ -41,9 +40,9 @@ public String getTraceParent() { * Set the traceparent property: Identifies the request in a distributed tracing system. * * @param traceparent the traceparent value to set. - * @return the GetEventRouteOptions object itself. + * @return the GetDigitalTwinsEventRouteOptions object itself. */ - public GetEventRouteOptions setTraceParent(String traceparent) { + public GetDigitalTwinsEventRouteOptions setTraceParent(String traceparent) { this.traceparent = traceparent; return this; } @@ -65,7 +64,7 @@ public String getTraceState() { * @param tracestate the tracestate value to set. * @return the GetEventRouteOptions object itself. */ - public GetEventRouteOptions setTraceState(String tracestate) { + public GetDigitalTwinsEventRouteOptions setTraceState(String tracestate) { this.tracestate = tracestate; return this; } diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/ListEventRoutesOptions.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/ListDigitalTwinsEventRoutesOptions.java similarity index 86% rename from sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/ListEventRoutesOptions.java rename to sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/ListDigitalTwinsEventRoutesOptions.java index 17919e9a3bc3d..089d41607e00a 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/ListEventRoutesOptions.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/models/ListDigitalTwinsEventRoutesOptions.java @@ -5,16 +5,15 @@ import com.azure.core.annotation.Fluent; import com.azure.core.util.Context; -import com.azure.digitaltwins.core.implementation.models.EventRoutesListOptions; import com.fasterxml.jackson.annotation.JsonProperty; /** * The optional parameters for - * {@link com.azure.digitaltwins.core.DigitalTwinsClient#listEventRoutes(ListEventRoutesOptions, Context)} and - * {@link com.azure.digitaltwins.core.DigitalTwinsAsyncClient#listEventRoutes(ListEventRoutesOptions)} + * {@link com.azure.digitaltwins.core.DigitalTwinsClient#listEventRoutes(ListDigitalTwinsEventRoutesOptions, Context)} and + * {@link com.azure.digitaltwins.core.DigitalTwinsAsyncClient#listEventRoutes(ListDigitalTwinsEventRoutesOptions)} */ @Fluent -public final class ListEventRoutesOptions { +public final class ListDigitalTwinsEventRoutesOptions { /* * Identifies the request in a distributed tracing system. */ @@ -50,7 +49,7 @@ public String getTraceParent() { * @param traceparent the traceparent value to set. * @return the ListEventRoutesOptions object itself. */ - public ListEventRoutesOptions setTraceParent(String traceparent) { + public ListDigitalTwinsEventRoutesOptions setTraceParent(String traceparent) { this.traceparent = traceparent; return this; } @@ -72,7 +71,7 @@ public String getTraceState() { * @param tracestate the tracestate value to set. * @return the ListEventRoutesOptions object itself. */ - public ListEventRoutesOptions setTraceState(String tracestate) { + public ListDigitalTwinsEventRoutesOptions setTraceState(String tracestate) { this.tracestate = tracestate; return this; } @@ -94,7 +93,7 @@ public Integer getMaxItemsPerPage() { * @param maxItemsPerPage the maxItemsPerPage value to set. * @return the ListEventRoutesOptions object itself. */ - public ListEventRoutesOptions setMaxItemsPerPage(Integer maxItemsPerPage) { + public ListDigitalTwinsEventRoutesOptions setMaxItemsPerPage(Integer maxItemsPerPage) { this.maxItemsPerPage = maxItemsPerPage; return this; } diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/samples/README.md b/sdk/digitaltwins/azure-digitaltwins-core/src/samples/README.md index 6a800b036b15b..16547e9f73dcf 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/samples/README.md +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/samples/README.md @@ -163,7 +163,7 @@ asynClient.listModels() Use `getModel` with model's unique identifier to get a specific model. ```java -asyncClient.createDigitalTwin(twinId, twinContent) +asyncClient.createOrReplaceDigitalTwin(twinId, twinContent) .subscribe( twin -> System.out.println("Created digital twin: " + twinId + "\n\t Body: " + twin), throwable -> System.out.println("Could not create digital twin " + twinId + " due to " + throwable) @@ -212,7 +212,7 @@ BasicDigitalTwin basicTwin = new BasicDigitalTwin() .addroperty("ComponentProp2", 123) ); -BasicDigitalTwin basicTwinResponse = syncClient.createDigitalTwin(basicDtId, basicTwin, BasicDigitalTwin.class); +BasicDigitalTwin basicTwinResponse = syncClient.createOrReplaceDigitalTwin(basicDtId, basicTwin, BasicDigitalTwin.class); ``` Alternatively, you can create your own custom data types to serialize and deserialize your digital twins. @@ -222,7 +222,7 @@ You can also retrieve the application/json string payload from disk and pass it ```java String payload = ; -String digitalTwinCreateResponse = syncClient.createDigitalTwin(twinId, payload, String.class); +String digitalTwinCreateResponse = syncClient.createOrReplaceDigitalTwin(twinId, payload, String.class); ``` ### Get and deserialize a digital twin @@ -315,7 +315,7 @@ BasicRelationship buildingFloorRelationshipPayload = new BasicRelationship() .addProperty("Prop1", "Prop1 value") .addProperty("Prop2", 6); -client.createRelationship(buildingTwinId, buildingFloorRelationshipId, buildingFloorRelationshipPayload, BasicRelationship.class); +client.createOrReplaceRelationship(buildingTwinId, buildingFloorRelationshipId, buildingFloorRelationshipPayload, BasicRelationship.class); ``` ### Get and deserialize a digital twin relationship @@ -385,11 +385,11 @@ To create an event route, provide an Id of an event route such as "sampleEventRo ```java String filter = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycleNotification'"; -EventRoute eventRoute = new EventRoute(); +DigitalTwinsEventRoute eventRoute = new EventRoute(); eventRoute.setEndpointName(eventRouteEndpointName); eventRoute.setFilter(filter); -client.createEventRoute(eventRouteId, eventRoute); +client.createOrReplaceEventRoute(eventRouteId, eventRoute); ``` For more information on the event route filter language, see the "how to manage routes" [filter events documentation](https://docs.microsoft.com/azure/digital-twins/how-to-manage-routes-apis-cli#filter-events). @@ -399,9 +399,9 @@ For more information on the event route filter language, see the "how to manage List a specific event route given event route Id or all event routes setting options with `GetEventRouteAsync` and `GetEventRoutesAsync`. ```java -PagedIterable eventRoutes = client.listEventRoutes(); +PagedIterable eventRoutes = client.listEventRoutes(); -for (EventRoute eventRoute : eventRoutes) { +for (DigitalTwinsEventRoute eventRoute : eventRoutes) { existingEventRouteId = eventRoute.getId(); System.out.println(String.format("\tEventRouteId: %s", eventRoute.getId())); System.out.println(String.format("\tEventRouteEndpointName: %s", eventRoute.getEndpointName())); diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/samples/java/com/azure/digitaltwins/core/EventRoutesSyncSamples.java b/sdk/digitaltwins/azure-digitaltwins-core/src/samples/java/com/azure/digitaltwins/core/EventRoutesSyncSamples.java index 28f5da38f7d5f..ae130713cd225 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/samples/java/com/azure/digitaltwins/core/EventRoutesSyncSamples.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/samples/java/com/azure/digitaltwins/core/EventRoutesSyncSamples.java @@ -5,7 +5,7 @@ import com.azure.digitaltwins.core.helpers.ConsoleLogger; import com.azure.digitaltwins.core.helpers.SamplesArguments; import com.azure.digitaltwins.core.implementation.models.ErrorResponseException; -import com.azure.digitaltwins.core.models.EventRoute; +import com.azure.digitaltwins.core.models.DigitalTwinsEventRoute; import com.azure.identity.ClientSecretCredentialBuilder; import java.util.UUID; @@ -38,7 +38,7 @@ public static void main(String[] args) { ConsoleLogger.printHeader("List event routes"); ConsoleLogger.print("Listing all current event routes in your Azure Digital Twins instance"); - PagedIterable eventRoutes = null; + PagedIterable eventRoutes = null; try { eventRoutes = client.listEventRoutes(); } catch (ErrorResponseException ex) { @@ -48,7 +48,7 @@ public static void main(String[] args) { } String existingEventRouteId = null; - for (EventRoute eventRoute : eventRoutes) { + for (DigitalTwinsEventRoute eventRoute : eventRoutes) { existingEventRouteId = eventRoute.getEventRouteId(); ConsoleLogger.print(String.format("\tEventRouteId: %s", eventRoute.getEventRouteId())); ConsoleLogger.print(String.format("\tEventRouteEndpointName: %s", eventRoute.getEndpointName())); @@ -63,7 +63,7 @@ public static void main(String[] args) { ConsoleLogger.printHeader("Get event route"); ConsoleLogger.print(String.format("Getting a single event route with Id %s", existingEventRouteId)); try { - EventRoute existingEventRoute = client.getEventRoute(existingEventRouteId); + DigitalTwinsEventRoute existingEventRoute = client.getEventRoute(existingEventRouteId); ConsoleLogger.print(String.format("Successfully retrieved event route with Id %s", existingEventRouteId)); ConsoleLogger.print(String.format("\tEventRouteId: %s", existingEventRoute.getEventRouteId())); ConsoleLogger.print(String.format("\tEventRouteEndpointName: %s", existingEventRoute.getEndpointName())); @@ -87,7 +87,7 @@ public static void main(String[] args) { String eventRouteId = "SomeEventRoute-" + UUID.randomUUID(); String eventRouteEndpointName = parsedArguments.getEventRouteEndpointName(); String filter = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycleNotification'"; - EventRoute eventRoute = new EventRoute(eventRouteEndpointName); + DigitalTwinsEventRoute eventRoute = new DigitalTwinsEventRoute(eventRouteEndpointName); eventRoute.setFilter(filter); try { diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/samples/java/com/azure/digitaltwins/core/snippets/DigitalTwinsAsyncClientJavaDocCodeSnippets.java b/sdk/digitaltwins/azure-digitaltwins-core/src/samples/java/com/azure/digitaltwins/core/snippets/DigitalTwinsAsyncClientJavaDocCodeSnippets.java index 1b763f0efe526..0fb4519f57d22 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/samples/java/com/azure/digitaltwins/core/snippets/DigitalTwinsAsyncClientJavaDocCodeSnippets.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/samples/java/com/azure/digitaltwins/core/snippets/DigitalTwinsAsyncClientJavaDocCodeSnippets.java @@ -799,7 +799,7 @@ public void query() { //region EventRouteSnippets /** - * Generates code samples for using {@link DigitalTwinsAsyncClient#createOrReplaceEventRoute(String, EventRoute)} + * Generates code samples for using {@link DigitalTwinsAsyncClient#createOrReplaceEventRoute(String, DigitalTwinsEventRoute)} */ @Override public void createEventRoute() { @@ -807,14 +807,14 @@ public void createEventRoute() { String filter = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycleNotification'"; - EventRoute eventRoute = new EventRoute("myEndpointName").setFilter(filter); + DigitalTwinsEventRoute eventRoute = new DigitalTwinsEventRoute("myEndpointName").setFilter(filter); digitalTwinsAsyncClient.createOrReplaceEventRoute("myEventRouteId", eventRoute).subscribe(); // END: com.azure.digitaltwins.core.asyncClient.createOrReplaceEventRoute#String-EventRoute } /** * Generates code samples for using - * {@link DigitalTwinsAsyncClient#createEventRouteWithResponse(String, EventRoute, CreateEventRouteOptions)} + * {@link DigitalTwinsAsyncClient#createOrReplaceEventRouteWithResponse(String, DigitalTwinsEventRoute, CreateEventRouteOptions)} */ @Override public void createEventRouteWithResponse() { @@ -822,8 +822,8 @@ public void createEventRouteWithResponse() { String filter = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycleNotification'"; - EventRoute eventRoute = new EventRoute("myEndpointName").setFilter(filter); - digitalTwinsAsyncClient.createEventRouteWithResponse( + DigitalTwinsEventRoute eventRoute = new DigitalTwinsEventRoute("myEndpointName").setFilter(filter); + digitalTwinsAsyncClient.createOrReplaceEventRouteWithResponse( "myEventRouteId", eventRoute, new CreateEventRouteOptions()) @@ -845,14 +845,14 @@ public void getEventRoute() { /** * Generates code samples for using - * {@link DigitalTwinsAsyncClient#getEventRouteWithResponse(String, GetEventRouteOptions)} + * {@link DigitalTwinsAsyncClient#getEventRouteWithResponse(String, GetDigitalTwinsEventRouteOptions)} */ @Override public void getEventRouteWithResponse() { // BEGIN: com.azure.digitaltwins.core.asyncClient.getEventRouteWithResponse#String-Options digitalTwinsAsyncClient.getEventRouteWithResponse( "myEventRouteId", - new GetEventRouteOptions()) + new GetDigitalTwinsEventRouteOptions()) .subscribe(eventRouteWithResponse -> { System.out.println( "Received get event route operation response with HTTP status code: " + @@ -895,7 +895,7 @@ public void deleteEventRouteWithResponse() { /** * Generates code samples for using * {@link DigitalTwinsAsyncClient#listEventRoutes()} and - * {@link DigitalTwinsAsyncClient#listEventRoutes(ListEventRoutesOptions)} + * {@link DigitalTwinsAsyncClient#listEventRoutes(ListDigitalTwinsEventRoutesOptions)} */ @Override public void listEventRoutes() { @@ -906,7 +906,7 @@ public void listEventRoutes() { // END: com.azure.digitaltwins.core.asyncClient.listEventRoutes // BEGIN: com.azure.digitaltwins.core.asyncClient.listEventRoutes#Options - digitalTwinsAsyncClient.listEventRoutes(new ListEventRoutesOptions().setMaxItemsPerPage(5)) + digitalTwinsAsyncClient.listEventRoutes(new ListDigitalTwinsEventRoutesOptions().setMaxItemsPerPage(5)) .doOnNext(eventRoute -> System.out.println("Retrieved event route with Id: " + eventRoute.getEventRouteId())) .subscribe(); // END: com.azure.digitaltwins.core.asyncClient.listEventRoutes#Options diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/samples/java/com/azure/digitaltwins/core/snippets/DigitalTwinsClientJavaDocCodeSnippets.java b/sdk/digitaltwins/azure-digitaltwins-core/src/samples/java/com/azure/digitaltwins/core/snippets/DigitalTwinsClientJavaDocCodeSnippets.java index 8112dd147b513..2cdb2d953f551 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/samples/java/com/azure/digitaltwins/core/snippets/DigitalTwinsClientJavaDocCodeSnippets.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/samples/java/com/azure/digitaltwins/core/snippets/DigitalTwinsClientJavaDocCodeSnippets.java @@ -862,7 +862,7 @@ public void query() { //region EventRouteSnippets /** - * Generates code samples for using {@link DigitalTwinsClient#createOrReplaceEventRoute(String, EventRoute)} + * Generates code samples for using {@link DigitalTwinsClient#createOrReplaceEventRoute(String, DigitalTwinsEventRoute)} */ @Override public void createEventRoute() { @@ -870,14 +870,14 @@ public void createEventRoute() { String filter = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycleNotification'"; - EventRoute eventRoute = new EventRoute("myEndpointName").setFilter(filter); + DigitalTwinsEventRoute eventRoute = new DigitalTwinsEventRoute("myEndpointName").setFilter(filter); digitalTwinsSyncClient.createOrReplaceEventRoute("myEventRouteId", eventRoute); // END: com.azure.digitaltwins.core.syncClient.createOrReplaceEventRoute#String-EventRoute } /** * Generates code samples for using - * {@link DigitalTwinsClient#createOrReplaceEventRouteWithResponse(String, EventRoute, CreateEventRouteOptions, Context)} + * {@link DigitalTwinsClient#createOrReplaceEventRouteWithResponse(String, DigitalTwinsEventRoute, CreateEventRouteOptions, Context)} */ @Override public void createEventRouteWithResponse() { @@ -885,7 +885,7 @@ public void createEventRouteWithResponse() { String filter = "$eventType = 'DigitalTwinTelemetryMessages' or $eventType = 'DigitalTwinLifecycleNotification'"; - EventRoute eventRoute = new EventRoute("myEndpointName").setFilter(filter); + DigitalTwinsEventRoute eventRoute = new DigitalTwinsEventRoute("myEndpointName").setFilter(filter); Response response = digitalTwinsSyncClient.createOrReplaceEventRouteWithResponse( "myEventRouteId", eventRoute, @@ -902,7 +902,7 @@ public void createEventRouteWithResponse() { @Override public void getEventRoute() { // BEGIN: com.azure.digitaltwins.core.syncClient.getEventRoute#String - EventRoute eventRoute = digitalTwinsSyncClient.getEventRoute("myEventRouteId"); + DigitalTwinsEventRoute eventRoute = digitalTwinsSyncClient.getEventRoute("myEventRouteId"); System.out.println("Retrieved event route with Id: " + eventRoute.getEventRouteId()); // END: com.azure.digitaltwins.core.syncClient.getEventRoute#String @@ -910,14 +910,14 @@ public void getEventRoute() { /** * Generates code samples for using - * {@link DigitalTwinsClient#getEventRouteWithResponse(String, GetEventRouteOptions, Context)} + * {@link DigitalTwinsClient#getEventRouteWithResponse(String, GetDigitalTwinsEventRouteOptions, Context)} */ @Override public void getEventRouteWithResponse() { // BEGIN: com.azure.digitaltwins.core.syncClient.getEventRouteWithResponse#String-Options-Context - Response eventRouteWithResponse = digitalTwinsSyncClient.getEventRouteWithResponse( + Response eventRouteWithResponse = digitalTwinsSyncClient.getEventRouteWithResponse( "myEventRouteId", - new GetEventRouteOptions(), + new GetDigitalTwinsEventRouteOptions(), new Context("key", "value")); System.out.println( @@ -957,20 +957,20 @@ public void deleteEventRouteWithResponse() { /** * Generates code samples for using {@link DigitalTwinsClient#listEventRoutes()} and - * {@link DigitalTwinsClient#listEventRoutes(ListEventRoutesOptions, Context)} + * {@link DigitalTwinsClient#listEventRoutes(ListDigitalTwinsEventRoutesOptions, Context)} */ @Override public void listEventRoutes() { // BEGIN: com.azure.digitaltwins.core.syncClient.listEventRoutes - PagedIterable listResponse = digitalTwinsSyncClient.listEventRoutes(); + PagedIterable listResponse = digitalTwinsSyncClient.listEventRoutes(); listResponse.forEach( eventRoute -> System.out.println("Retrieved event route with Id: " + eventRoute.getEventRouteId())); // END: com.azure.digitaltwins.core.syncClient.listEventRoutes // BEGIN: com.azure.digitaltwins.core.syncClient.listEventRoutes#Options-Context - PagedIterable listResponseWithOptions = digitalTwinsSyncClient.listEventRoutes( - new ListEventRoutesOptions().setMaxItemsPerPage(5), + PagedIterable listResponseWithOptions = digitalTwinsSyncClient.listEventRoutes( + new ListDigitalTwinsEventRoutesOptions().setMaxItemsPerPage(5), new Context("key", "value")); listResponseWithOptions diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/EventRoutesAsyncTest.java b/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/EventRoutesAsyncTest.java index 0bd7aa7394cb3..d392238195302 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/EventRoutesAsyncTest.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/EventRoutesAsyncTest.java @@ -2,8 +2,8 @@ import com.azure.core.http.HttpClient; import com.azure.core.util.logging.ClientLogger; -import com.azure.digitaltwins.core.models.EventRoute; -import com.azure.digitaltwins.core.models.ListEventRoutesOptions; +import com.azure.digitaltwins.core.models.DigitalTwinsEventRoute; +import com.azure.digitaltwins.core.models.ListDigitalTwinsEventRoutesOptions; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import reactor.test.StepVerifier; @@ -31,7 +31,7 @@ public void eventRouteLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVe String eventRouteId = testResourceNamer.randomUuid(); // CREATE - EventRoute eventRouteToCreate = new EventRoute(EVENT_ROUTE_ENDPOINT_NAME); + DigitalTwinsEventRoute eventRouteToCreate = new DigitalTwinsEventRoute(EVENT_ROUTE_ENDPOINT_NAME); eventRouteToCreate.setFilter(FILTER); StepVerifier.create(asyncClient.createOrReplaceEventRoute(eventRouteId, eventRouteToCreate)) .verifyComplete(); @@ -79,7 +79,7 @@ public void getEventRouteThrowsIfEventRouteDoesNotExist(HttpClient httpClient, D public void createEventRouteThrowsIfFilterIsMalformed(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) { DigitalTwinsAsyncClient asyncClient = getAsyncClient(httpClient, serviceVersion); String eventRouteId = testResourceNamer.randomUuid(); - EventRoute eventRouteToCreate = new EventRoute(EVENT_ROUTE_ENDPOINT_NAME); + DigitalTwinsEventRoute eventRouteToCreate = new DigitalTwinsEventRoute(EVENT_ROUTE_ENDPOINT_NAME); eventRouteToCreate.setFilter("this is not a valid filter"); StepVerifier.create(asyncClient.createOrReplaceEventRoute(eventRouteId, eventRouteToCreate)) @@ -97,7 +97,7 @@ public void listEventRoutesPaginationWorks(HttpClient httpClient, DigitalTwinsSe // create enough event routes so that the list API can have multiple pages for (int i = 0; i < eventRouteCountToCreate; i++) { String eventRouteId = testResourceNamer.randomUuid(); - EventRoute eventRouteToCreate = new EventRoute(EVENT_ROUTE_ENDPOINT_NAME); + DigitalTwinsEventRoute eventRouteToCreate = new DigitalTwinsEventRoute(EVENT_ROUTE_ENDPOINT_NAME); eventRouteToCreate.setFilter(FILTER); StepVerifier.create(asyncClient.createOrReplaceEventRoute(eventRouteId, eventRouteToCreate)) .verifyComplete(); @@ -105,7 +105,7 @@ public void listEventRoutesPaginationWorks(HttpClient httpClient, DigitalTwinsSe // list event routes by page, make sure that all non-final pages have the expected page size AtomicInteger pageCount = new AtomicInteger(0); - ListEventRoutesOptions listEventRoutesOptions = (new ListEventRoutesOptions()).setMaxItemsPerPage(expectedPageSize); + ListDigitalTwinsEventRoutesOptions listEventRoutesOptions = (new ListDigitalTwinsEventRoutesOptions()).setMaxItemsPerPage(expectedPageSize); StepVerifier.create(asyncClient.listEventRoutes(listEventRoutesOptions).byPage()) .thenConsumeWhile( (pagedResponseOfEventRoute) -> pagedResponseOfEventRoute != null, diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/EventRoutesTest.java b/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/EventRoutesTest.java index e37cc2bbff09c..b073fc868640c 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/EventRoutesTest.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/EventRoutesTest.java @@ -5,8 +5,8 @@ import com.azure.core.http.rest.PagedResponse; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; -import com.azure.digitaltwins.core.models.EventRoute; -import com.azure.digitaltwins.core.models.ListEventRoutesOptions; +import com.azure.digitaltwins.core.models.DigitalTwinsEventRoute; +import com.azure.digitaltwins.core.models.ListDigitalTwinsEventRoutesOptions; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -33,18 +33,18 @@ public void eventRouteLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVe String eventRouteId = testResourceNamer.randomUuid(); // CREATE - EventRoute eventRouteToCreate = new EventRoute(EVENT_ROUTE_ENDPOINT_NAME); + DigitalTwinsEventRoute eventRouteToCreate = new DigitalTwinsEventRoute(EVENT_ROUTE_ENDPOINT_NAME); eventRouteToCreate.setFilter(FILTER); client.createOrReplaceEventRoute(eventRouteId, eventRouteToCreate); try { // GET - EventRoute retrievedEventRoute = client.getEventRoute(eventRouteId); + DigitalTwinsEventRoute retrievedEventRoute = client.getEventRoute(eventRouteId); assertEventRoutesEqual(eventRouteToCreate, eventRouteId, retrievedEventRoute); // LIST - PagedIterable listedEventRoutes = client.listEventRoutes(); - for (EventRoute listedEventRoute : listedEventRoutes) { + PagedIterable listedEventRoutes = client.listEventRoutes(); + for (DigitalTwinsEventRoute listedEventRoute : listedEventRoutes) { // There may be other event routes in place, so ignore them if they aren't the event route // that was just created. We only need to see that the newly created event route is present in the // list of all event routes. @@ -75,7 +75,7 @@ public void getEventRouteThrowsIfEventRouteDoesNotExist(HttpClient httpClient, D public void createEventRouteThrowsIfFilterIsMalformed(HttpClient httpClient, DigitalTwinsServiceVersion serviceVersion) { DigitalTwinsClient client = getClient(httpClient, serviceVersion); String eventRouteId = testResourceNamer.randomUuid(); - EventRoute eventRouteToCreate = new EventRoute(EVENT_ROUTE_ENDPOINT_NAME); + DigitalTwinsEventRoute eventRouteToCreate = new DigitalTwinsEventRoute(EVENT_ROUTE_ENDPOINT_NAME); eventRouteToCreate.setFilter("this is not a valid filter"); assertRestException(() -> client.createOrReplaceEventRoute(eventRouteId, eventRouteToCreate), HttpURLConnection.HTTP_BAD_REQUEST); @@ -92,17 +92,17 @@ public void listEventRoutesPaginationWorks(HttpClient httpClient, DigitalTwinsSe // create enough event routes so that the list API can have multiple pages for (int i = 0; i < eventRouteCountToCreate; i++) { String eventRouteId = testResourceNamer.randomUuid(); - EventRoute eventRouteToCreate = new EventRoute(EVENT_ROUTE_ENDPOINT_NAME); + DigitalTwinsEventRoute eventRouteToCreate = new DigitalTwinsEventRoute(EVENT_ROUTE_ENDPOINT_NAME); eventRouteToCreate.setFilter(FILTER); client.createOrReplaceEventRoute(eventRouteId, eventRouteToCreate); } // list event routes by page, make sure that all non-final pages have the expected page size - ListEventRoutesOptions listEventRoutesOptions = (new ListEventRoutesOptions()).setMaxItemsPerPage(expectedPageSize); - PagedIterable eventRoutes = client.listEventRoutes(listEventRoutesOptions, Context.NONE); - Iterable> eventRoutePages = eventRoutes.iterableByPage(); + ListDigitalTwinsEventRoutesOptions listEventRoutesOptions = (new ListDigitalTwinsEventRoutesOptions()).setMaxItemsPerPage(expectedPageSize); + PagedIterable eventRoutes = client.listEventRoutes(listEventRoutesOptions, Context.NONE); + Iterable> eventRoutePages = eventRoutes.iterableByPage(); int pageCount = 0; - for (PagedResponse eventRoutePagedResponse : eventRoutePages) { + for (PagedResponse eventRoutePagedResponse : eventRoutePages) { pageCount++; // Any page of results with a continuation token should be a non-final page, and should have the exact page size that we specified above diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/EventRoutesTestBase.java b/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/EventRoutesTestBase.java index f40dac14dd098..7912353740f55 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/EventRoutesTestBase.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/EventRoutesTestBase.java @@ -3,7 +3,7 @@ import com.azure.core.http.HttpClient; import com.azure.core.http.rest.PagedIterable; import com.azure.core.util.logging.ClientLogger; -import com.azure.digitaltwins.core.models.EventRoute; +import com.azure.digitaltwins.core.models.DigitalTwinsEventRoute; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -41,9 +41,9 @@ public abstract class EventRoutesTestBase extends DigitalTwinsTestBase { public void removeAllEventRoutes() { // Using sync client for simplicity. This function isn't testing the clients, so no need to use both sync and async clients for cleanup DigitalTwinsClient client = getDigitalTwinsClientBuilder(null, DigitalTwinsServiceVersion.getLatest()).buildClient(); - PagedIterable listedEventRoutes = client.listEventRoutes(); + PagedIterable listedEventRoutes = client.listEventRoutes(); List currentEventRouteIds = new ArrayList<>(); - for (EventRoute listedEventRoute : listedEventRoutes) { + for (DigitalTwinsEventRoute listedEventRoute : listedEventRoutes) { currentEventRouteIds.add(listedEventRoute.getEventRouteId()); } @@ -55,7 +55,7 @@ public void removeAllEventRoutes() { // Note that only service returned eventRoute instances have their Id field set. When a user builds an instance locally, // there is no way to assign an Id to it. - protected static void assertEventRoutesEqual(EventRoute expected, String expectedId, EventRoute actual) { + protected static void assertEventRoutesEqual(DigitalTwinsEventRoute expected, String expectedId, DigitalTwinsEventRoute actual) { assertEquals(expectedId, actual.getEventRouteId()); assertEquals(expected.getEndpointName(), actual.getEndpointName()); assertEquals(expected.getFilter(), actual.getFilter());