Skip to content

Commit

Permalink
use OjectMapperProvider in unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickmann committed Oct 11, 2022
1 parent 93a12b1 commit 4ad38c5
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.MapType;
import com.fasterxml.jackson.datatype.joda.JodaModule;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import org.graylog2.shared.bindings.providers.ObjectMapperProvider;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.junit.Before;
Expand Down Expand Up @@ -91,12 +91,12 @@ public void testGetFields() throws Exception {

@Test
public void testJSONSerialization() throws Exception {
final ObjectMapper mapper = new ObjectMapper().registerModule(new JodaModule());
final ObjectMapper mapper = new ObjectMapperProvider().get();
final MapType valueType = mapper.getTypeFactory().constructMapType(HashMap.class, String.class, Object.class);

final Map<String, Object> map = mapper.readValue(mapper.writeValueAsBytes(messageSummary), valueType);

assertEquals(Sets.newHashSet("id", "timestamp", "message", "index", "source", "streamIds", "fields"), map.keySet());
assertEquals(Sets.newHashSet("id", "timestamp", "message", "index", "source", "stream_ids", "fields"), map.keySet());
}

@Test
Expand Down

0 comments on commit 4ad38c5

Please sign in to comment.