UPCEANLogicImpl { protected static int getSupplementalLength(String msg) { final String supp = retrieveSupplemental(msg); if (supp == null) { return 0; } else if (supp.length() == 2) { return 2; } else if (supp.length() == 5) { return 5; } else { throw new IllegalArgumentException( "Illegal supplemental length (valid: 2 or 5): " + supp); } } UPCEANLogicImpl(ChecksumMode mode); ChecksumMode getChecksumMode(); void validateMessage(String msg); char calcChecksum(String msg); abstract void generateBarcodeLogic(ClassicBarcodeLogicHandler logic, String msg);  }
@Test public void testGetSupplementalLength() throws Exception { assertEquals(0, UPCEANLogicImpl.getSupplementalLength("1234")); assertEquals(2, UPCEANLogicImpl.getSupplementalLength("1234+12")); assertEquals(5, UPCEANLogicImpl.getSupplementalLength("1234+12345")); try { UPCEANLogicImpl.getSupplementalLength("1234+123"); } catch (IllegalArgumentException iae) { } }