Skip to content

Commit ad9a43f

Browse files
committed
Rewrote test for #380, to test expected behavior
1 parent 9bff69f commit ad9a43f

File tree

2 files changed

+45
-72
lines changed

2 files changed

+45
-72
lines changed

src/test/java/com/fasterxml/jackson/databind/deser/TestIgnoredTypes.java

+45-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package com.fasterxml.jackson.databind.deser;
22

3-
import com.fasterxml.jackson.annotation.*;
3+
import java.util.ArrayList;
4+
import java.util.List;
45

6+
import com.fasterxml.jackson.annotation.*;
57
import com.fasterxml.jackson.databind.*;
8+
import com.fasterxml.jackson.databind.module.SimpleModule;
69

710
/**
811
* Test for [JACKSON-429]
@@ -27,6 +30,26 @@ static class NonIgnoredType
2730
public IgnoredType ignored;
2831
}
2932

33+
// // And test for mix-in annotations
34+
35+
@JsonIgnoreType
36+
static class Person {
37+
public String name;
38+
public Person() { }
39+
public Person(String name) {
40+
this.name = name;
41+
}
42+
}
43+
44+
static class PersonWrapper {
45+
public int value = 1;
46+
public Person person = new Person("Foo");
47+
}
48+
49+
@JsonIgnoreType
50+
static abstract class PersonMixin {
51+
}
52+
3053
/*
3154
/**********************************************************
3255
/* Unit tests
@@ -46,4 +69,25 @@ public void testIgnoredType() throws Exception
4669
assertNotNull(bean);
4770
assertEquals(9, bean.value);
4871
}
72+
73+
public void testSingleWithMixins() throws Exception {
74+
SimpleModule module = new SimpleModule();
75+
module.setMixInAnnotation(Person.class, PersonMixin.class);
76+
ObjectMapper mapper = new ObjectMapper();
77+
mapper.registerModule(module);
78+
PersonWrapper input = new PersonWrapper();
79+
String json = mapper.writeValueAsString(input);
80+
assertEquals("{\"value\":1}", json);
81+
}
82+
83+
public void testListWithMixins() throws Exception {
84+
SimpleModule module = new SimpleModule();
85+
module.setMixInAnnotation(Person.class, PersonMixin.class);
86+
ObjectMapper mapper = new ObjectMapper();
87+
mapper.registerModule(module);
88+
List<Person> persons = new ArrayList<Person>();
89+
persons.add(new Person("Bob"));
90+
String json = mapper.writeValueAsString(persons);
91+
assertEquals("[{\"name\":\"Bob\"}]", json);
92+
}
4993
}

src/test/java/com/fasterxml/jackson/failing/TestJsonIgnoreTypeWithMixIn.java

-71
This file was deleted.

0 commit comments

Comments
 (0)