Skip to content

Commit

Permalink
Remove ErrorOptions (Azure#25338)
Browse files Browse the repository at this point in the history
* Remove ErrorOptions

* revapi exclusion

* fix unit tests in WPS

* fix checkstyle
  • Loading branch information
srnagar authored and XiaofeiCao committed Nov 18, 2021
1 parent 8ab8399 commit 283b02e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
10 changes: 10 additions & 0 deletions eng/code-quality-reports/src/main/resources/revapi/revapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,16 @@
"code": "java.method.added",
"new": "method java.lang.Class<T> com.azure.core.util.serializer.TypeReference<T>::getJavaClass()",
"justification": "New method added to TypeReference in azure-core."
},
{
"code": "java.method.visibilityReduced",
"new": "method com.azure.core.http.rest.RequestOptions com.azure.core.http.rest.RequestOptions::setErrorOptions(java.util.EnumSet<com.azure.core.http.rest.ErrorOptions>)",
"justification": "The use case for ErrorOptions is not yet clear. It will be added later if there are enough data points to suggest this is needed."
},
{
"code": "java.class.visibilityReduced",
"new": "enum com.azure.core.http.rest.ErrorOptions",
"justification": "The use case for ErrorOptions is not yet clear. It will be added later if there are enough data points to suggest this is needed."
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Determines how errors are handled by requests using {@link RequestOptions}.
*/
public enum ErrorOptions {
enum ErrorOptions {
/**
* Throw exceptions when an HTTP response with a status code indicating an error (400 or above) is received.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public RequestOptions setBody(BinaryData requestBody) {
* @throws IllegalArgumentException If both {@link ErrorOptions#THROW} and {@link ErrorOptions#NO_THROW} are
* included in {@code errorOptions}.
*/
public RequestOptions setErrorOptions(EnumSet<ErrorOptions> errorOptions) {
RequestOptions setErrorOptions(EnumSet<ErrorOptions> errorOptions) {
Objects.requireNonNull(errorOptions, "'errorOptions' cannot be null.");

if (errorOptions.contains(ErrorOptions.THROW) && errorOptions.contains(ErrorOptions.NO_THROW)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.azure.core.http.HttpClient;
import com.azure.core.http.policy.HttpLogDetailLevel;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.rest.ErrorOptions;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.test.TestBase;
Expand All @@ -25,11 +24,11 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;

import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.util.EnumSet;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand Down Expand Up @@ -243,12 +242,14 @@ public void testAadCredential() {
}

@Test
@DisabledIfEnvironmentVariable(named = "AZURE_TEST_MODE", matches = "LIVE", disabledReason = "This requires real "
+ "connection id that is created when a client connects to Web PubSub service. So, run this in PLAYBACK "
+ "mode only.")
public void testCheckPermission() {
RequestOptions requestOptions = new RequestOptions()
.addQueryParam("targetName", "group_name")
.setErrorOptions(EnumSet.of(ErrorOptions.NO_THROW));
boolean permission = client.checkPermissionWithResponse(WebPubSubPermission.JOIN_LEAVE_GROUP, "connection_id",
.addQueryParam("targetName", "java");
boolean permission = client.checkPermissionWithResponse(WebPubSubPermission.SEND_TO_GROUP, "71xtjgThROOJ6DsVY3xbBw2ef45fd11",
requestOptions).getValue();
Assertions.assertFalse(permission);
Assertions.assertTrue(permission);
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{
"networkCallRecords" : [ {
"Method" : "HEAD",
"Uri" : "https://REDACTED.webpubsub.azure.com/api/hubs/test/permissions/joinLeaveGroup/connections/connection_id?api-version=2021-10-01&targetName=group_name",
"Uri" : "https://REDACTED.webpubsub.azure.com/api/hubs/test/permissions/sendToGroup/connections/71xtjgThROOJ6DsVY3xbBw2ef45fd11?api-version=2021-10-01&targetName=java",
"Headers" : {
"User-Agent" : "azsdk-java-azure-messaging-webpubsub/1.0.0-beta.6 (17; Windows 10; 10.0)"
"User-Agent" : "azsdk-java-azure-messaging-webpubsub/1.0.0-beta.6 (14.0.2; Windows 10; 10.0)"
},
"Response" : {
"Server" : "nginx",
"Strict-Transport-Security" : "max-age=15724800; includeSubDomains",
"api-supported-versions" : "2021-10-01",
"Connection" : "keep-alive",
"Vary" : "Accept-Encoding,Accept-Encoding",
"retry-after" : "0",
"StatusCode" : "404",
"Body" : "",
"Date" : "Wed, 03 Nov 2021 18:51:07 GMT",
"Content-Type" : "text/plain; charset=utf-8"
"StatusCode" : "200",
"Date" : "Fri, 12 Nov 2021 01:49:48 GMT"
},
"Exception" : null
} ],
Expand Down

0 comments on commit 283b02e

Please sign in to comment.