InsertLine extends TransformationOperation<InsertLine> { public InsertLine setLineNumber(Integer lineNumber) { checkForNull("Line Number", lineNumber); if(lineNumber <= 0){ throw new TransformationDefinitionException("Line number cannot be negative or zero"); } this.lineNumber = lineNumber; setInsertionMode(InsertionMode.LINE_NUMBER); return this; } InsertLine();  InsertLine(String newLine);  InsertLine(String newLine, Integer lineNumber);  InsertLine(String newLine, String regex); InsertLine setInsertionMode(InsertionMode insertionMode); InsertLine setNewLine(String newLine); InsertLine setLineNumber(Integer lineNumber); InsertLine setRegex(String regex); @Override String getDescription();  }
@Test(expectedExceptions = TransformationDefinitionException.class, expectedExceptionsMessageRegExp = "Line number cannot be negative or zero") public void invalidLineNumberTest1() { InsertLine insertLine = new InsertLine(" color: yellow").relative("/src/main/resources/dogs.yaml"); insertLine.setLineNumber(-1); }
@Test(expectedExceptions = TransformationDefinitionException.class, expectedExceptionsMessageRegExp = "Line number cannot be negative or zero") public void invalidLineNumberTest2() { InsertLine insertLine = new InsertLine(" color: yellow").relative("/src/main/resources/dogs.yaml"); insertLine.setLineNumber(0); }