@Test
public void testConjureUnionTypeDeprecation() {

    ConjureSourceFile conjure = ConjureParser.parse(new File("src/test/resources/example-deprecation.yml"));
    UnionTypeDefinition union = conjure.types()
            .definitions()
            .objects()
            .get(TypeName.of("UnionWithDeprecatedTypes"))
            .visit(new TypeDefinitionVisitor<UnionTypeDefinition>() {
                @Override
                public UnionTypeDefinition visit(AliasTypeDefinition _def) {
                    throw new SafeIllegalArgumentException("Expected EnumTypeDefinition");
                }
                @Override
                public UnionTypeDefinition visit(EnumTypeDefinition _def) {
                    throw new SafeIllegalArgumentException("Expected EnumTypeDefinition");
                }
                @Override
                public UnionTypeDefinition visit(ObjectTypeDefinition _def) {
                    throw new SafeIllegalArgumentException("Expected EnumTypeDefinition");
                }
                @Override
                public UnionTypeDefinition visit(UnionTypeDefinition def) {
                    return def;
                }
            });
    assertThat(union.union().get(FieldName.of("first")).deprecated()).isNotPresent();
    assertThat(union.union().get(FieldName.of("second")).deprecated()).hasValue("Use 'first'.");
}