FromInstruction { @Override public String toString() { StringBuilder stringBuilder = new StringBuilder(NAME); stringBuilder.append(" "); stringBuilder.append(baseImageName); if (hasTag()) { stringBuilder.append(String.format(":%s", tag.trim())); } for (String part : additionalParts) { if (StringUtils.isNotBlank(part)) { stringBuilder.append(String.format(" %s", part.trim())); } } if (hasComments()) { stringBuilder.append(String.format(" %s", comments)); } return stringBuilder.toString(); } FromInstruction(String fromInstructionLine); private  FromInstruction(String baseImageName, String tag, List<String> additionalParts, String comments); static boolean isFromInstructionWithThisImageAndOlderTag(String lineInFile, String imageName, String imageTag); FromInstruction getFromInstructionWithNewTag(String newTag); static boolean isFromInstruction(String dockerFileLine); @Override String toString(); String getBaseImageName(); boolean hasBaseImage(String imageToFind); boolean hasTag(); boolean hasADifferentTag(String expectedTag); String getTag(); List<String> getAdditionalParts(); boolean hasComments(); String getComments();  }
@Test(dataProvider = "inputFromInstructionData") public void testStringResult(String fromInstruction, String expectedResult) { assertEquals(new FromInstruction(fromInstruction).toString(), expectedResult); }