Moved objectmapper to class level, one per class (#1558)

* Solr w Apache SolrJ

* Solr w Apache SolrJ

* updated test names and moved add to @before method

* create apache-solrj module, moved code from spring-data-solr

* More examples for indexing,delete,and query for solrj

* More examples for indexing,delete,and query for solrj

* Jackson Map Serialize/Deserialize

* Jackson Map Serialize/Deserialize

* Jackson version update

* keydeserializer code added

* keydeserializer code added

* remove explicit types from map instantion

* one objectmapper per class
This commit is contained in:
Nancy Bosecker 2017-04-01 10:26:50 -07:00 committed by Grzegorz Piwowarek
parent 2c50b4f1b7
commit 87be4ede27
2 changed files with 3 additions and 6 deletions

View File

@ -18,13 +18,13 @@ public class JacksonMapDeserializeTest {
private Map<MyPair, String> map;
private Map<MyPair, MyPair> cmap;
final ObjectMapper mapper = new ObjectMapper();
@Test
public void whenSimpleMapDeserialize_thenCorrect()
throws JsonParseException, JsonMappingException, IOException {
final String jsonInput = "{\"key\": \"value\"}";
final ObjectMapper mapper = new ObjectMapper();
TypeReference<HashMap<String, String>> typeRef = new TypeReference<HashMap<String, String>>() {
};
@ -38,7 +38,6 @@ public class JacksonMapDeserializeTest {
throws JsonParseException, JsonMappingException, IOException {
final String jsonInput = "{\"Abbott and Costello\":\"Comedy\"}";
final ObjectMapper mapper = new ObjectMapper();
TypeReference<HashMap<MyPair, String>> typeRef = new TypeReference<HashMap<MyPair, String>>() {
};
@ -59,7 +58,6 @@ public class JacksonMapDeserializeTest {
throws JsonParseException, JsonMappingException, IOException {
final String jsonInput = "{\"Abbott and Costello\" : \"Comedy and 1940s\"}";
final ObjectMapper mapper = new ObjectMapper();
TypeReference<HashMap<MyPair, MyPair>> typeRef = new TypeReference<HashMap<MyPair, MyPair>>() {
};

View File

@ -26,6 +26,8 @@ public class JacksonMapSerializeTest {
@JsonSerialize(keyUsing = MyPairSerializer.class)
private MyPair mapValue;
final ObjectMapper mapper = new ObjectMapper();
@Test
public void whenSimpleMapSerialize_thenCorrect()
throws JsonProcessingException {
@ -33,7 +35,6 @@ public class JacksonMapSerializeTest {
Map<String, String> map = new HashMap<>();
map.put("key", "value");
final ObjectMapper mapper = new ObjectMapper();
final String jsonResult = mapper.writeValueAsString(map);
Assert.assertEquals("{\"key\":\"value\"}", jsonResult);
@ -47,7 +48,6 @@ public class JacksonMapSerializeTest {
MyPair key = new MyPair("Abbott", "Costello");
map.put(key, "Comedy");
final ObjectMapper mapper = new ObjectMapper();
final String jsonResult = mapper.writeValueAsString(map);
Assert.assertEquals("{\"Abbott and Costello\":\"Comedy\"}", jsonResult);
@ -62,7 +62,6 @@ public class JacksonMapSerializeTest {
mapValue = new MyPair("Comedy", "1940's");
cmap.put(mapKey, mapValue);
final ObjectMapper mapper = new ObjectMapper();
final String jsonResult = mapper.writeValueAsString(cmap);
Assert.assertEquals("{\"Abbott and Costello\":\"Comedy and 1940's\"}",