Skip to content

Commit

Permalink
Added a test exposing a bug in the generated serializers for enums im…
Browse files Browse the repository at this point in the history
…plementing interfaces with @JsonSubTypes. Issue #164
  • Loading branch information
Michael Mortensen authored and Michael Mortensen committed Dec 17, 2013
1 parent 2979498 commit f34ca3b
Showing 1 changed file with 22 additions and 0 deletions.
Expand Up @@ -1053,4 +1053,26 @@ public void testJsonSubTypesWithAnInterface() {
assertEquals(value, o1.getValue());
assertEquals(o1.getValue(), o2.getValue());
}


@JsonTypeInfo(use = Id.CLASS, include = As.PROPERTY, property = "@class")
@JsonSubTypes({ @Type(EnumOfSubTypeInterface.class) })
interface JsonSubTypesWithAnInterfaceForUseWithAnEnum {
@JsonProperty("name")
String name();
}

enum EnumOfSubTypeInterface implements JsonSubTypesWithAnInterfaceForUseWithAnEnum {
HELLO,
WORLD
}

static interface JsonSubTypesWithAnInterfaceForUseWithAnEnumCodec extends JsonEncoderDecoder<JsonSubTypesWithAnInterfaceForUseWithAnEnum> {}

public void testJsonSubTypesWithAnInterfaceImplementedByAnEnum() {
JsonSubTypesWithAnInterfaceForUseWithAnEnumCodec codec = GWT.create(JsonSubTypesWithAnInterfaceForUseWithAnEnumCodec.class);
JSONValue json = codec.encode(EnumOfSubTypeInterface.HELLO);
JsonSubTypesWithAnInterfaceForUseWithAnEnum useWithAnEnum = codec.decode(json);
assertEquals(useWithAnEnum.name(), EnumOfSubTypeInterface.HELLO.name());
}
}

0 comments on commit f34ca3b

Please sign in to comment.