package de.juplo.facebook.exceptions;
import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
import de.juplo.facebook.exceptions.GraphApiException.FacebookErrorMessage;
+import static de.juplo.facebook.exceptions.GraphApiException.OBJECT_MAPPER;
import java.io.IOException;
-import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
"}" +
"}";
- ObjectMapper mapper;
-
-
- @Before
- public void setUp()
- {
- mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
- }
-
@Test
public void testSerialize() throws JsonProcessingException
error.userMessage = "A message";
error.traceId = "EJplcsCHuLu";
- assertEquals(example, mapper.writeValueAsString(error));
+ assertEquals(example, OBJECT_MAPPER.writeValueAsString(error));
}
@Test
public void testDeserialize() throws IOException
{
FacebookErrorMessage error =
- mapper.readValue(example, FacebookErrorMessage.class);
+ OBJECT_MAPPER.readValue(example, FacebookErrorMessage.class);
assertEquals("Message describing the error", error.message);
assertEquals("OAuthException", error.type);