Skip to content

Commit 43cb1e6

Browse files
Test for @JsonIgnore annotation (refs #251)
1 parent e4bf2ce commit 43cb1e6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

typescript-generator-core/src/test/java/cz/habarta/typescript/generator/Jackson2ParserTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,27 @@ private void testEnumByType(Class<? extends Enum<?>> type, Object... expectedVal
215215
Assert.assertEquals(expectedValues[i], enumModel.getMembers().get(i).getEnumValue());
216216
}
217217
}
218+
219+
@Test
220+
public void testIgnoredProperty() {
221+
final Settings settings = TestUtils.settings();
222+
final String output = new TypeScriptGenerator(settings).generateTypeScript(Input.from(ClassWithIgnoredProperty.class));
223+
Assert.assertTrue(output.contains("name1: string"));
224+
Assert.assertTrue(!output.contains("name2: string"));
225+
}
226+
227+
private static class ClassWithIgnoredProperty {
228+
public String name1;
229+
@JsonIgnore
230+
public String name2;
231+
}
232+
233+
// public static void main(String[] args) throws JsonProcessingException {
234+
// final ObjectMapper objectMapper = new ObjectMapper();
235+
// final ClassWithIgnoredProperty instance = new ClassWithIgnoredProperty();
236+
// instance.name1 = "xxx";
237+
// instance.name2 = "xxx";
238+
// System.out.println(objectMapper.writeValueAsString(instance));
239+
// }
240+
218241
}

0 commit comments

Comments
 (0)