Skip to content

Commit

Permalink
Merge pull request #160 from frascu/fix/parsing-fields-with-annotations
Browse files Browse the repository at this point in the history
Fix build error by parsing fields having annotations
  • Loading branch information
minborg authored Jul 26, 2021
2 parents 22420a7 + d622e09 commit d5f3e74
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
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);
}

}

0 comments on commit d5f3e74

Please sign in to comment.