@Test public void shouldTransformConcreteBodyToMap() { testSliEntity = new TestSliEntity(); Map<String, Object> body = testSliEntity.createBody(); Assert.assertEquals("Body should contain 2 elements", 2, body.size()); Assert.assertEquals("Incorrect map element", "1", body.get("fieldOne")); @SuppressWarnings("unchecked") Map<String, Object> subObjectMap = (Map<String, Object>) body.get("testSubObject"); Assert.assertNotNull("SubObject map null", subObjectMap); Assert.assertEquals("subObject should contain 2 elements", 2, subObjectMap.size()); Assert.assertEquals("Incorrect map element", "A", subObjectMap.get("subFieldA")); Assert.assertEquals("Incorrect map element", "B", subObjectMap.get("subFieldB")); }
public Map<String, Object> createBody() { Map<String, Object> body = null; try { body = MAPPER. readValue(this.json(), new TypeReference<Map<String, Object>>() { }); clearNullValueKeys(body); } catch (JsonParseException e) { LOG.error("Entity map conversion error: ", e); } catch (JsonMappingException e) { LOG.error("Entity map conversion error: ", e); } catch (IOException e) { LOG.error("Entity map conversion error: ", e); } return body; }
SliEntity { public Map<String, Object> createBody() { Map<String, Object> body = null; try { body = MAPPER. readValue(this.json(), new TypeReference<Map<String, Object>>() { }); clearNullValueKeys(body); } catch (JsonParseException e) { LOG.error("Entity map conversion error: ", e); } catch (JsonMappingException e) { LOG.error("Entity map conversion error: ", e); } catch (IOException e) { LOG.error("Entity map conversion error: ", e); } return body; } }
SliEntity { public Map<String, Object> createBody() { Map<String, Object> body = null; try { body = MAPPER. readValue(this.json(), new TypeReference<Map<String, Object>>() { }); clearNullValueKeys(body); } catch (JsonParseException e) { LOG.error("Entity map conversion error: ", e); } catch (JsonMappingException e) { LOG.error("Entity map conversion error: ", e); } catch (IOException e) { LOG.error("Entity map conversion error: ", e); } return body; } SliEntity(); }
SliEntity { public Map<String, Object> createBody() { Map<String, Object> body = null; try { body = MAPPER. readValue(this.json(), new TypeReference<Map<String, Object>>() { }); clearNullValueKeys(body); } catch (JsonParseException e) { LOG.error("Entity map conversion error: ", e); } catch (JsonMappingException e) { LOG.error("Entity map conversion error: ", e); } catch (IOException e) { LOG.error("Entity map conversion error: ", e); } return body; } SliEntity(); abstract String entityType(); GenericEntity createGenericEntity(); Map<String, Object> createBody(); JsonNode json(); @JsonIgnore boolean isCreatedByOthers(); @JsonIgnore String getCreatorRefId(); @JsonIgnore void setCreatorRefId(String creatorRefId); @JsonIgnore String getZoneId(); @JsonIgnore void setZoneId(String zoneId); @JsonIgnore String getOtherSifRefId(); @JsonIgnore void setOtherSifRefId(String otherSifRefId); @JsonIgnore boolean hasOtherSifRefId(); @Override String toString(); }
SliEntity { public Map<String, Object> createBody() { Map<String, Object> body = null; try { body = MAPPER. readValue(this.json(), new TypeReference<Map<String, Object>>() { }); clearNullValueKeys(body); } catch (JsonParseException e) { LOG.error("Entity map conversion error: ", e); } catch (JsonMappingException e) { LOG.error("Entity map conversion error: ", e); } catch (IOException e) { LOG.error("Entity map conversion error: ", e); } return body; } SliEntity(); abstract String entityType(); GenericEntity createGenericEntity(); Map<String, Object> createBody(); JsonNode json(); @JsonIgnore boolean isCreatedByOthers(); @JsonIgnore String getCreatorRefId(); @JsonIgnore void setCreatorRefId(String creatorRefId); @JsonIgnore String getZoneId(); @JsonIgnore void setZoneId(String zoneId); @JsonIgnore String getOtherSifRefId(); @JsonIgnore void setOtherSifRefId(String otherSifRefId); @JsonIgnore boolean hasOtherSifRefId(); @Override String toString();  }