Skip to content

Commit

Permalink
Add failing test for #56
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatu Saloranta committed Aug 30, 2019
1 parent 2cfda73 commit 1184377
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.fasterxml.jackson.datatype.guava.failing;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.json.JsonMapper;

import com.google.common.collect.BoundType;
import com.google.common.collect.Range;

import com.fasterxml.jackson.datatype.guava.GuavaModule;
import com.fasterxml.jackson.datatype.guava.ModuleTestBase;

// [datatypes-collections#56]: support naming strategy
public class Range56Test extends ModuleTestBase
{

// [datatypes-collections#56]: support naming strategy
public void testSnakeCaseNamingStrategy() throws Exception
{
String json = "{\"lower_endpoint\": 12, \"lower_bound_type\": \"CLOSED\", \"upper_endpoint\": 33, \"upper_bound_type\": \"CLOSED\"}";

GuavaModule mod = new GuavaModule().defaultBoundType(BoundType.CLOSED);
ObjectMapper mapper = JsonMapper.builder()
.addModule(mod)
.propertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
.build();

@SuppressWarnings("unchecked")
Range<Integer> r = (Range<Integer>) mapper.readValue(json, Range.class);

assertEquals(Integer.valueOf(12), r.lowerEndpoint());
assertEquals(Integer.valueOf(33), r.upperEndpoint());

assertEquals(BoundType.CLOSED, r.lowerBoundType());
assertEquals(BoundType.CLOSED, r.upperBoundType());
}
}

0 comments on commit 1184377

Please sign in to comment.