@Test public void testParseException() { String exceptionCode = "DSC-0013"; AEF cut = new AEF(); String reason = "too weak"; CougarException ce = (CougarException)cut.parseException(ResponseCode.Forbidden, exceptionCode, reason, null); assertNotNull(ce); assertTrue(ce instanceof CougarClientException); assertEquals(exceptionCode, ce.getServerFaultCode().getDetail()); assertEquals(reason, ce.getMessage()); }
@Override public Exception parseException(ResponseCode responseCode, String prefix, String reason, List<String[]> params) { String exceptionPrefix = extractExceptionPrefix(prefix); if (!exceptionInstantiatorMap.containsKey(exceptionPrefix)) { throw new IllegalArgumentException("Unknown exception prefix [" + prefix + "] encountered!"); } return exceptionInstantiatorMap.get(exceptionPrefix).createException(responseCode, prefix, reason, parseExceptionParamList(params)); }
AbstractExceptionFactory implements ExceptionFactory { @Override public Exception parseException(ResponseCode responseCode, String prefix, String reason, List<String[]> params) { String exceptionPrefix = extractExceptionPrefix(prefix); if (!exceptionInstantiatorMap.containsKey(exceptionPrefix)) { throw new IllegalArgumentException("Unknown exception prefix [" + prefix + "] encountered!"); } return exceptionInstantiatorMap.get(exceptionPrefix).createException(responseCode, prefix, reason, parseExceptionParamList(params)); } }
AbstractExceptionFactory implements ExceptionFactory { @Override public Exception parseException(ResponseCode responseCode, String prefix, String reason, List<String[]> params) { String exceptionPrefix = extractExceptionPrefix(prefix); if (!exceptionInstantiatorMap.containsKey(exceptionPrefix)) { throw new IllegalArgumentException("Unknown exception prefix [" + prefix + "] encountered!"); } return exceptionInstantiatorMap.get(exceptionPrefix).createException(responseCode, prefix, reason, parseExceptionParamList(params)); } AbstractExceptionFactory(); }
AbstractExceptionFactory implements ExceptionFactory { @Override public Exception parseException(ResponseCode responseCode, String prefix, String reason, List<String[]> params) { String exceptionPrefix = extractExceptionPrefix(prefix); if (!exceptionInstantiatorMap.containsKey(exceptionPrefix)) { throw new IllegalArgumentException("Unknown exception prefix [" + prefix + "] encountered!"); } return exceptionInstantiatorMap.get(exceptionPrefix).createException(responseCode, prefix, reason, parseExceptionParamList(params)); } AbstractExceptionFactory(); void registerExceptionInstantiator(String exceptionPrefix, ExceptionInstantiator instantiator); @Override Exception parseException(ResponseCode responseCode, String prefix, String reason, List<String[]> params); String extractExceptionPrefix(String prefix); }
AbstractExceptionFactory implements ExceptionFactory { @Override public Exception parseException(ResponseCode responseCode, String prefix, String reason, List<String[]> params) { String exceptionPrefix = extractExceptionPrefix(prefix); if (!exceptionInstantiatorMap.containsKey(exceptionPrefix)) { throw new IllegalArgumentException("Unknown exception prefix [" + prefix + "] encountered!"); } return exceptionInstantiatorMap.get(exceptionPrefix).createException(responseCode, prefix, reason, parseExceptionParamList(params)); } AbstractExceptionFactory(); void registerExceptionInstantiator(String exceptionPrefix, ExceptionInstantiator instantiator); @Override Exception parseException(ResponseCode responseCode, String prefix, String reason, List<String[]> params); String extractExceptionPrefix(String prefix);  }