Skip to content

Commit

Permalink
Rewrote test for #380, to test expected behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 7, 2014
1 parent 9bff69f commit ad9a43f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 72 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.fasterxml.jackson.databind.deser;

import com.fasterxml.jackson.annotation.*;
import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.module.SimpleModule;

/**
* Test for [JACKSON-429]
Expand All @@ -27,6 +30,26 @@ static class NonIgnoredType
public IgnoredType ignored;
}

// // And test for mix-in annotations

@JsonIgnoreType
static class Person {
public String name;
public Person() { }
public Person(String name) {
this.name = name;
}
}

static class PersonWrapper {
public int value = 1;
public Person person = new Person("Foo");
}

@JsonIgnoreType
static abstract class PersonMixin {
}

/*
/**********************************************************
/* Unit tests
Expand All @@ -46,4 +69,25 @@ public void testIgnoredType() throws Exception
assertNotNull(bean);
assertEquals(9, bean.value);
}

public void testSingleWithMixins() throws Exception {
SimpleModule module = new SimpleModule();
module.setMixInAnnotation(Person.class, PersonMixin.class);
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(module);
PersonWrapper input = new PersonWrapper();
String json = mapper.writeValueAsString(input);
assertEquals("{\"value\":1}", json);
}

public void testListWithMixins() throws Exception {
SimpleModule module = new SimpleModule();
module.setMixInAnnotation(Person.class, PersonMixin.class);
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(module);
List<Person> persons = new ArrayList<Person>();
persons.add(new Person("Bob"));
String json = mapper.writeValueAsString(persons);
assertEquals("[{\"name\":\"Bob\"}]", json);
}
}

This file was deleted.

0 comments on commit ad9a43f

Please sign in to comment.