### Question:
NetezzaProcedureFormator implements ICodeReformator { @Override public String reformat(String in) { StringBuilder result = new StringBuilder(); String newLinesStripped = in.replace("/n", " "); List<String> parts = breakApartNewLines(newLinesStripped.split("\\s+"), stmtSep); boolean foundAs = false; boolean inDeclaration = false; boolean inMainSection = false; boolean inCreateSection = true; for (String part : parts) { if (inCreateSection && !part.equalsIgnoreCase("AS")) { result.append(part); result.append(" "); continue; } if (part.equalsIgnoreCase("AS") && !foundAs) { foundAs = true; inCreateSection = false; result.append("AS\n"); continue; } if (part.equalsIgnoreCase("BEGIN_PROC") && !inMainSection) { result.append("BEGIN_PROC\n"); continue; } if (part.equalsIgnoreCase("DECLARE")) { result.append("DECLARE\n"); inDeclaration = true; continue; } if (inDeclaration && !part.equalsIgnoreCase("BEGIN")) { if (!part.endsWith(stmtSep)) { result.append("\t"); } result.append(part); if (part.endsWith(stmtSep)) { result.append("\n"); } else { result.append(" "); } continue; } if (inDeclaration && part.equalsIgnoreCase("BEGIN")) { result.append("BEGIN\n\t"); inDeclaration = false; inMainSection = true; continue; } if (inMainSection) { if (part.equalsIgnoreCase("END"+stmtSep) || part.equalsIgnoreCase("END")) { inMainSection = false; result.setLength(result.length() - 1); result.append(part); if (!part.endsWith(stmtSep)) { result.append(stmtSep); } result.append("\n"); } else { result.append(part); result.append(" "); if (part.endsWith(stmtSep)) { result.append("\n\t"); } } continue; } result.append(part); result.append(stmtSep); result.append("\n"); } return result.toString(); } NetezzaProcedureFormator(String stmtSep); @Override String reformat(String in);  }### Answer:
@Test public void testformat() { String newSql = classUnderTest.reformat(SQL); String[] parts = newSql.split("\n"); assertEquals(18, parts.length); }
@Test public void testformat2() { String newSql = classUnderTest.reformat(SQL2); String[] parts = newSql.split("\n"); assertEquals(20, parts.length); }