@Test(expected=IllegalArgumentException.class) public void testParseExceptionWithUnknownPrefix() { String exceptionCode = "XXX-0013"; AEF cut = new AEF(); CougarException ce = (CougarException)cut.parseException(ResponseCode.Forbidden, exceptionCode, null, null); }
@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);  }