-
-
Notifications
You must be signed in to change notification settings - Fork 344
Expand file tree
/
Copy pathJsonWrappedTest.java
More file actions
53 lines (44 loc) · 1.57 KB
/
Copy pathJsonWrappedTest.java
File metadata and controls
53 lines (44 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.fasterxml.jackson.annotation;
import java.lang.reflect.Constructor;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class JsonWrappedTest
extends AnnotationTestUtil
{
private static class BeanWithField {
@JsonWrapped("wrapper")
public String field;
}
private static class BeanWithMethod {
@JsonWrapped("wrapper")
public String getField() { return null; }
}
private static class BeanWithParam {
public BeanWithParam(@JsonWrapped("wrapper") String field) { }
}
@JsonWrapped("wrapper")
@JacksonAnnotationsInside
@interface BundleAnnotation { }
@Test
public void testRuntimeRetentionOnField() throws Exception {
JsonWrapped ann = BeanWithField.class.getField("field").getAnnotation(JsonWrapped.class);
assertNotNull(ann);
assertTrue(ann.enabled());
}
@Test
public void testRuntimeRetentionOnMethod() throws Exception {
JsonWrapped ann = BeanWithMethod.class.getMethod("getField").getAnnotation(JsonWrapped.class);
assertNotNull(ann);
}
@Test
public void testApplicableOnConstructorParameter() throws Exception {
Constructor<?> ctor = BeanWithParam.class.getDeclaredConstructor(String.class);
JsonWrapped ann = ctor.getParameters()[0].getAnnotation(JsonWrapped.class);
assertNotNull(ann);
}
@Test
public void testApplicableOnAnnotationType() {
JsonWrapped ann = BundleAnnotation.class.getAnnotation(JsonWrapped.class);
assertNotNull(ann);
}
}