### Question:
StackInfoMapper { public StackInfo map() { final StackInfo info = new StackInfo(); if (stack == null) { info.setStatus(HeatStatus.NOTFOUND); } else { info.setName(stack.getStackName()); info.setCanonicalName(stack.getStackName() + "/" + stack.getId()); info.setStatus(this.mapStatus(stack.getStackStatus())); info.setStatusMessage(stack.getStackStatusReason()); Optional<Map<String, Object>> result = this.mapOutputToMap(stack.getOutputs()); if (result.isPresent()) { info.setOutputs(result.get()); } info.setParameters(stack.getParameters()); } return info; } StackInfoMapper(Stack stack); StackInfo map();  }### Answer:
@Test public void nullStack() { StackInfoMapper mapper = new StackInfoMapper(null); assertEquals(HeatStatus.NOTFOUND, mapper.map().getStatus()); }
@Test public void checkOutputToMap() throws JsonParseException, JsonMappingException, IOException { ObjectMapper jacksonMapper = new ObjectMapper(); Stack sample = jacksonMapper.readValue(this.getJson("stack-example.json"), Stack.class); StackInfoMapper mapper = new StackInfoMapper(sample); StackInfo result = mapper.map(); Map<String, Object> map = result.getOutputs(); assertEquals(true, map.containsKey("key2")); assertEquals("value1", map.get("key1")); }
@Test public void mapRemainingFields() { Stack stack = new Stack(); stack.setStackName("name"); stack.setId("id"); stack.setStackStatusReason("message"); stack.setParameters(new HashMap<String, Object>()); StackInfoMapper mapper = new StackInfoMapper(stack); StackInfo info = mapper.map(); assertEquals("name", info.getName()); assertEquals("name/id", info.getCanonicalName()); assertEquals("message", info.getStatusMessage()); assertEquals(stack.getParameters(), info.getParameters()); }