Skip to content

Commit

Permalink
chore(test): cover meta annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
CarstenWickner committed Nov 11, 2024
1 parent b704550 commit ba8594d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
package com.github.victools.jsonschema.module.jackson;

import com.fasterxml.classmate.ResolvedType;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.github.victools.jsonschema.generator.FieldScope;
import com.github.victools.jsonschema.generator.SchemaVersion;
import com.github.victools.jsonschema.generator.TypeContext;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Stream;
Expand Down Expand Up @@ -127,11 +130,16 @@ private static class TestTypeWithReferences {
private static class TestTypeReferencedAsInteger {
}

@JsonIdentityInfo(generator = ObjectIdGenerators.StringIdGenerator.class)
@JsonIdentityReference(alwaysAsId = true)
@StringIdentity
private static class TestTypeReferencedAsString {
}

@JsonIdentityInfo(generator = ObjectIdGenerators.StringIdGenerator.class)
@JsonIdentityReference(alwaysAsId = true)
@JacksonAnnotationsInside
@Retention(RetentionPolicy.RUNTIME)
@interface StringIdentity {}

@JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class)
@JsonIdentityReference(alwaysAsId = true)
private static class TestTypeReferencedAsUuid {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.github.victools.jsonschema.module.jackson;

import com.fasterxml.classmate.ResolvedType;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
Expand All @@ -25,6 +26,8 @@
import com.github.victools.jsonschema.generator.MemberScope;
import com.github.victools.jsonschema.generator.MethodScope;
import com.github.victools.jsonschema.generator.SchemaVersion;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.stream.Stream;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -188,7 +191,7 @@ private static class TestClassWithSuperTypeReferences {
public TestSuperClassWithNameProperty superTypeWithAnnotationOnGetter;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.WRAPPER_ARRAY)
public TestSuperClassWithNameProperty superTypeWithAnnotationOnFieldAndGetter;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "fullClass", include = JsonTypeInfo.As.PROPERTY)
@FullClassProperty
public TestSuperInterface superInterfaceWithAnnotationOnField;

public TestSuperClassWithNameProperty getSuperTypeNoAnnotation() {
Expand All @@ -210,6 +213,11 @@ public TestSuperClassWithNameProperty getSuperTypeWithAnnotationOnFieldAndGetter
}
}

@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "fullClass", include = JsonTypeInfo.As.PROPERTY)
@JacksonAnnotationsInside
@Retention(RetentionPolicy.RUNTIME)
@interface FullClassProperty {}

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
@JsonSubTypes({
@JsonSubTypes.Type(TestSubClass1.class),
Expand Down

0 comments on commit ba8594d

Please sign in to comment.