### Question:
AAIErrorFormatter { public String getMessage() { if (error.getRequestError() != null && error.getRequestError().getServiceException() != null) { ServiceException serviceException = error.getRequestError().getServiceException(); return this.fillInTemplate(serviceException.getText(), serviceException.getVariables()); } return "no parsable error message found"; } AAIErrorFormatter(AAIError error); String getMessage();  }### Answer:
@Test public void testGetMessage() { ServiceException svcException = new ServiceException(); svcException.setText("test %1 message - %2"); svcException.setVariables(Arrays.asList("error", "service exception %1 test")); RequestError requestError = new RequestError(); requestError.setServiceException(svcException); doReturn(requestError).when(errorObj).getRequestError(); AAIErrorFormatter formatter = new AAIErrorFormatter(errorObj); String result = formatter.getMessage(); assertEquals("equal", "test error message - service exception error test", result); }
@Test public void errorMessageOnPercentEncodedTest() { ServiceException svcException = new ServiceException(); svcException.setText("test my%20Test %1 message - %2"); svcException.setVariables(Arrays.asList("error", "service exception %1 test")); RequestError requestError = new RequestError(); requestError.setServiceException(svcException); doReturn(requestError).when(errorObj).getRequestError(); AAIErrorFormatter formatter = new AAIErrorFormatter(errorObj); String result = formatter.getMessage(); assertEquals("equal", "test my%20Test error message - service exception error test", result); }
@Test public void testGetMessageNoParsable() { errorObj.setRequestError(null); AAIErrorFormatter formatter = new AAIErrorFormatter(errorObj); String result = formatter.getMessage(); assertEquals("equal", "no parsable error message found", result); }