### Question:
MsoCommonUtils { protected MsoException heatExceptionToMsoException(OpenStackBaseException e, String context) { MsoException me = null; if (e instanceof OpenStackResponseException) { OpenStackResponseException re = (OpenStackResponseException) e; try { Explanation explanation = re.getResponse().getErrorEntity(Explanation.class); logger.error("Exception - Openstack Error on {} : {}", context, explanation); String fullError = explanation.getExplanation() + ", error.type=" + explanation.getError().getType() + ", error.message=" + explanation.getError().getMessage(); logger.error(fullError); me = new MsoOpenstackException(explanation.getCode(), explanation.getTitle(), fullError); } catch (Exception e2) { logger.error("{} {} Exception - HTTP Error on {}: {}, ", MessageEnum.RA_CONNECTION_EXCEPTION, ErrorCode.DataError.getValue(), context, re.getStatus(), e.getMessage(), e2); me = new MsoOpenstackException(re.getStatus(), re.getMessage(), re.getMessage()); } me.addContext(context); } else if (e instanceof OpenStackConnectException) { OpenStackConnectException ce = (OpenStackConnectException) e; me = new MsoIOException(ce.getMessage()); me.addContext(context); logger.error("{} {} Openstack Heat connection error on {}: ", MessageEnum.RA_CONNECTION_EXCEPTION, ErrorCode.DataError.getValue(), context, e); } return me; }  T executeAndRecordOpenstackRequest(OpenStackRequest<T> request); MsoException keystoneErrorToMsoException(OpenStackBaseException e, String context); boolean isNullOrEmpty(String s);  }### Answer:
@Test public final void testHeatExceptionToMsoException() throws JsonParseException, JsonMappingException, IOException { OpenStackBaseException openStackConnectException = new OpenStackConnectException("connect"); OpenStackBaseException openStackResponseException = new OpenStackResponseException("response", 1); MsoException me = commonUtils.heatExceptionToMsoException(openStackConnectException, "ContextError"); assertTrue(me instanceof MsoIOException); assertTrue("connect".equals(me.getMessage())); MsoException me2 = commonUtils.heatExceptionToMsoException(openStackResponseException, "ContextError"); assertTrue(me2 instanceof MsoOpenstackException); assertTrue("ContextError".equals(me2.getContext())); assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory())); OpenStackResponse openStackResponse = Mockito.mock(OpenStackResponse.class); Explanation explanation = mapper.readValue(new File(RESOURCE_PATH + "Explanation.json"), Explanation.class); doReturn(explanation).when(openStackResponse).getErrorEntity(eq(Explanation.class)); openStackResponseException = new OpenStackResponseException("response", 501, openStackResponse); MsoException me3 = commonUtils.heatExceptionToMsoException(openStackResponseException, "ContextError"); assertTrue(me3 instanceof MsoOpenstackException); assertEquals("1 title: explanation, error.type=null, error.message=null", me3.toString()); }