Version { @Override public String toString() { if (StringUtils.isBlank(customName)) { if (lowNumber == 0) { return String.format("%s.%s", bigNumber, intermediateNumber); } return String.format("%s.%s.%s", bigNumber, intermediateNumber, lowNumber); } else { if (lowNumber == 0) { return String.format("%s.%s-%s", bigNumber, intermediateNumber, customName); } return String.format("%s.%s.%s-%s", bigNumber, intermediateNumber, lowNumber, customName); } } Version(String completeVersionAsString); int getBigNumber(); int getIntermediateNumber(); int getLowNumber(); String getCustomName(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testVersionToStringGivesRightOutput() { Version version = new Version("4.1.9"); assertEquals("4.1.9", version.toString()); }
@Test public void testToStringPaddingZero() { Version version1 = new Version("4.1.0"); assertEquals("4.1", version1.toString()); }
@Test public void tesToStringWithCodeName() { Version version1 = new Version("4-dev"); assertEquals("4.0-dev", version1.toString()); }