Skip to content

Commit

Permalink
minor test cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 29, 2018
1 parent 6188e2d commit 73e0067
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 49 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,26 +1,56 @@
package com.fasterxml.jackson.databind.deser.creators.jdk8;

import static org.assertj.core.api.BDDAssertions.then;

import java.io.IOException;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;

public class PersonTest
public class PersonTest extends BaseMapTest
{
@Test
public void shouldBeAbleToDeserializePerson() throws IOException
static class Person {

// mandatory fields
private final String name;
private final String surname;

// optional fields
private String nickname;

// 29-Jan-2018, tatu: Should (apparently?! nice) work without annotation, as long as
// parameter names exist
// @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public Person(String name, String surname) {

this.name = name;
this.surname = surname;
}

public String getName() {
return name;
}

public String getSurname() {
return surname;
}

public String getNickname() {

return nickname;
}

public void setNickname(String nickname) {

this.nickname = nickname;
}
}
public void testPersonDeserialization() throws IOException
{
final ObjectMapper mapper = new ObjectMapper();

// when
Person actual = mapper.readValue("{\"name\":\"joe\",\"surname\":\"smith\",\"nickname\":\"joey\"}", Person.class);

// then
Person expected = new Person("joe", "smith");
expected.setNickname("joey");
then(actual).isEqualToComparingFieldByField(expected);

assertEquals("joe", actual.getName());
assertEquals("smith", actual.getSurname());
assertEquals("joey", actual.getNickname());
}
}

0 comments on commit 73e0067

Please sign in to comment.