@Test(expected=IllegalArgumentException.class) public void testPrefixExtractor() { AEF cut = new AEF(); assertEquals("DSC", cut.extractExceptionPrefix("DSC-0001")); cut.extractExceptionPrefix("XXX"); fail("Should have thrown an exception due to incorrect exception prefix string"); }
public String extractExceptionPrefix(String prefix) { String[] prefixLits = prefix.split("-"); if (prefixLits.length != 2) { throw new IllegalArgumentException("Invalid exception prefix [" + prefix + "] encountered"); } return prefixLits[0]; }
AbstractExceptionFactory implements ExceptionFactory { public String extractExceptionPrefix(String prefix) { String[] prefixLits = prefix.split("-"); if (prefixLits.length != 2) { throw new IllegalArgumentException("Invalid exception prefix [" + prefix + "] encountered"); } return prefixLits[0]; } }
AbstractExceptionFactory implements ExceptionFactory { public String extractExceptionPrefix(String prefix) { String[] prefixLits = prefix.split("-"); if (prefixLits.length != 2) { throw new IllegalArgumentException("Invalid exception prefix [" + prefix + "] encountered"); } return prefixLits[0]; } AbstractExceptionFactory(); }
AbstractExceptionFactory implements ExceptionFactory { public String extractExceptionPrefix(String prefix) { String[] prefixLits = prefix.split("-"); if (prefixLits.length != 2) { throw new IllegalArgumentException("Invalid exception prefix [" + prefix + "] encountered"); } return prefixLits[0]; } 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 { public String extractExceptionPrefix(String prefix) { String[] prefixLits = prefix.split("-"); if (prefixLits.length != 2) { throw new IllegalArgumentException("Invalid exception prefix [" + prefix + "] encountered"); } return prefixLits[0]; } AbstractExceptionFactory(); void registerExceptionInstantiator(String exceptionPrefix, ExceptionInstantiator instantiator); @Override Exception parseException(ResponseCode responseCode, String prefix, String reason, List<String[]> params); String extractExceptionPrefix(String prefix);  }