Skip to content

Commit 5b95834

Browse files
committed
Address comments
1 parent cb64f4f commit 5b95834

File tree

6 files changed

+39
-7
lines changed

6 files changed

+39
-7
lines changed

aws/client/aws-client-awsjson/src/main/java/software/amazon/smithy/java/aws/client/awsjson/AwsJson11Protocol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public final class AwsJson11Protocol extends AwsJsonProtocol {
2525
* discriminator of documents that use relative shape IDs.
2626
*/
2727
public AwsJson11Protocol(ShapeId service) {
28-
super(TRAIT_ID, service, ErrorTypeSanitizer::REMOVE_NAMESPACE_AND_URI);
28+
super(TRAIT_ID, service, ErrorTypeSanitizer::removeNamespaceAndUri);
2929
}
3030

3131
@Override

aws/client/aws-client-awsjson/src/main/java/software/amazon/smithy/java/aws/client/awsjson/AwsJson1Protocol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public final class AwsJson1Protocol extends AwsJsonProtocol {
2525
* discriminator of documents that use relative shape IDs.
2626
*/
2727
public AwsJson1Protocol(ShapeId service) {
28-
super(TRAIT_ID, service, ErrorTypeSanitizer::REMOVE_URI);
28+
super(TRAIT_ID, service, ErrorTypeSanitizer::removeUri);
2929
}
3030

3131
@Override

aws/client/aws-client-restjson/src/main/java/software/amazon/smithy/java/aws/client/restjson/RestJsonClientProtocol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public RestJsonClientProtocol(ShapeId service) {
5353
.useJsonName(true)
5454
.useTimestampFormat(true)
5555
.defaultNamespace(service.getNamespace())
56-
.errorTypeSanitizer(ErrorTypeSanitizer::REMOVE_NAMESPACE_AND_URI)
56+
.errorTypeSanitizer(ErrorTypeSanitizer::removeNamespaceAndUri)
5757
.build();
5858

5959
this.errorDeserializer = HttpErrorDeserializer.builder()

codecs/json-codec/src/main/java/software/amazon/smithy/java/json/ErrorTypeSanitizer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* sanitizers to remove trailing URIs or leading namespaces from {@code __type}.
1414
*/
1515
public class ErrorTypeSanitizer {
16-
public static String REMOVE_URI(String text) {
16+
public static String removeUri(String text) {
1717
if (text == null) {
1818
return null;
1919
}
@@ -24,14 +24,14 @@ public static String REMOVE_URI(String text) {
2424
return text;
2525
}
2626

27-
public static String REMOVE_NAMESPACE_AND_URI(String text) {
27+
public static String removeNamespaceAndUri(String text) {
2828
if (text == null) {
2929
return null;
3030
}
3131
var hash = text.indexOf('#');
3232
if (hash > 0) {
3333
text = text.substring(hash + 1);
3434
}
35-
return REMOVE_URI(text);
35+
return removeUri(text);
3636
}
3737
}

codecs/json-codec/src/main/java/software/amazon/smithy/java/json/JsonSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ Builder overrideSerdeProvider(JsonSerdeProvider provider) {
295295
* @param errorTypeSanitizer the sanitizer to use for error type.
296296
* @return the builder.
297297
*/
298-
Builder errorTypeSanitizer(Function<String, String> errorTypeSanitizer) {
298+
public Builder errorTypeSanitizer(Function<String, String> errorTypeSanitizer) {
299299
this.errorTypeSanitizer = errorTypeSanitizer;
300300
return this;
301301
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package software.amazon.smithy.java.json;
2+
3+
import java.util.List;
4+
import org.junit.jupiter.api.Test;
5+
6+
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
9+
public class ErrorTypeSanitizerTest {
10+
private static final String SIMPLE_TYPE = "FooError";
11+
private static final String TYPE_WITH_URI = "FooError:http://amazon.com/smithy/com.amazon.smithy.validate/";
12+
private static final String TYPE_WITH_NAMESPACE = "aws.protocoltests.restjson#FooError";
13+
private static final String TYPE_WITH_NAMESPACE_AND_URI = "aws.protocoltests.restjson#FooError:http://amazon.com/smithy/com.amazon.smithy.validate/";
14+
@Test
15+
public void testRemoveUri() {
16+
String expected = "FooError";
17+
String expectedWithNamespace = "aws.protocoltests.restjson#FooError";
18+
assertEquals(expected, ErrorTypeSanitizer.removeUri(SIMPLE_TYPE));
19+
assertEquals(expected, ErrorTypeSanitizer.removeUri(TYPE_WITH_URI));
20+
assertEquals(expectedWithNamespace, ErrorTypeSanitizer.removeUri(TYPE_WITH_NAMESPACE));
21+
assertEquals(expectedWithNamespace, ErrorTypeSanitizer.removeUri(TYPE_WITH_NAMESPACE_AND_URI));
22+
}
23+
24+
@Test
25+
public void testRemoveNameSpaceAndUri() {
26+
String expected = "FooError";
27+
assertEquals(expected, ErrorTypeSanitizer.removeNamespaceAndUri(SIMPLE_TYPE));
28+
assertEquals(expected, ErrorTypeSanitizer.removeNamespaceAndUri(TYPE_WITH_URI));
29+
assertEquals(expected, ErrorTypeSanitizer.removeNamespaceAndUri(TYPE_WITH_NAMESPACE));
30+
assertEquals(expected, ErrorTypeSanitizer.removeNamespaceAndUri(TYPE_WITH_NAMESPACE_AND_URI));
31+
}
32+
}

0 commit comments

Comments
 (0)