Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build error by parsing fields having annotations #160

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ private Type render(Node node) {
}

private Node parseNode(String s) {
// Remove annotations in the type
if (s.startsWith("@")) {
s = s.substring(s.indexOf(' ') + 1);
}
// Base case returns leaf without children
if (!(s.contains("<") || s.contains(","))) {
return new Node(SimpleType.create(s));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,38 @@ void renderMapOfMapOfListOfSetOfDoubleAndIntegerAndLong() {
assertEquals(expected, actual);
}

@Test
void renderStringWithAnnotations() {
String type = "@javax.validation.constraints.Email,@javax.validation.constraints.Size(max=255) java.lang.String";
SimpleType expected = SimpleType.create("java.lang.String");
Type actual = typeParser.render(type);
assertEquals(expected, actual);
}

@Test
void renderStringWithAnnotation() {
String type = "@javax.validation.constraints.Size(max=255) java.lang.String";
SimpleType expected = SimpleType.create("java.lang.String");
Type actual = typeParser.render(type);
assertEquals(expected, actual);
}

@Test
void renderMapOfStringWithAnnotations() {
String type = "@javax.validation.constraints.Email,@javax.validation.constraints.Size(max=255) java.util.Map<java.lang.String>";
SimpleParameterizedType expected = SimpleParameterizedType.create(
SimpleType.create("java.util.Map"), SimpleType.create("java.lang.String"));
Type actual = typeParser.render(type);
assertEquals(expected, actual);
}

@Test
void renderMapOfStringWithAnnotation() {
String type = "@javax.validation.constraints.Size(max=255) java.util.Map<java.lang.String>";
SimpleParameterizedType expected = SimpleParameterizedType.create(
SimpleType.create("java.util.Map"), SimpleType.create("java.lang.String"));
Type actual = typeParser.render(type);
assertEquals(expected, actual);
}

}