### Question:
AbstractPolicyAdminUIService implements PolicyAdminUIService { public Throwable getErrorAsThrowable (String responseName, Response response) { if (response == null) return null; ErrorResponse errorResponse = ErrorResponse.fromJSON(response.getText()); JsArray<RemoteError> errors = errorResponse.getErrors(); if (errors == null || errors.length()==0) errors = errorResponse.getServiceErrors(responseName); if (errors == null) return new Throwable(PolicyAdminUIUtil.constants.error()+" "+response.getStatusCode()); String s = ""; for (int i=0;i<errors.length();i++) { RemoteError re = errors.get(i); s += re.getCategory()+":"+re.getSeverity()+":"+re.getMessage()+" "; } if (!"".equals(s)) return new Throwable(s); return new Throwable(PolicyAdminUIUtil.messages.badRequestData()); }  String getPartialUrl(String operation, Map<String,String> namespaces, RequestFormat format); void setSecurityHeaders(RequestBuilder requestBuilder); Throwable getErrorAsThrowable(String responseName, Response response); Throwable getErrorAsThrowable(Response response); static final String SECURITY_NAMESPACE; static final String OASIS_NAMESPACE; static final String COMMON_NAMESPACE; }### Answer:
@Test public void testNoError() { response = null; try { abstractPolicyAdminUIService.getErrorAsThrowable(response); } catch (Throwable t) { fail("an exception was thrown"); } }
@Test (expected=Throwable.class) public void testErrorResponseNull() { String errorJSONMsg_1 = "{\"jsonns.ns2\":\"urn:oasis:names:tc:xacml:2.0:policy:schema:os\",\"jsonns.ns1\":\"http: expect(response.getText()).andReturn(errorJSONMsg_1); expect(ErrorResponse.fromJSON(errorJSONMsg_1)).andReturn(errorResponse); replay(response); PowerMock.replay(ErrorResponse.class); AbstractPolicyAdminUIService policyAdminUIService = new AbstractPolicyAdminUIService(); policyAdminUIService.getErrorAsThrowable(response); EasyMock.verify(response); }