CielRequirement implements Requirement { protected static boolean checkCielVersions(String required, String found) { if (found == null) { return false; } DateFormat format = new SimpleDateFormat("yyyyMMdd"); try { Date requiredDate = format.parse(required); Date foundDate = format.parse(found); return foundDate.equals(requiredDate) || foundDate.after(requiredDate); } catch (Exception e) { return false; } }  @Override String getName(); @Override String getRequiredVersion(); void setRequiredVersion(String requiredVersion); @Override String getFoundVersion(); @Override boolean isSatisfied(); public String requiredVersion; }
@Test public void checkCielVersions_shouldReturnFalseIfVersionIsNotParseable() { Assert.assertFalse(CielRequirement.checkCielVersions("20130101", null)); Assert.assertFalse(CielRequirement.checkCielVersions("20130101", "x")); }
@Test public void checkCielVersions_shouldReturnTrueIfFoundVersionIsGreaterOrEqual() { Assert.assertFalse(CielRequirement.checkCielVersions("20130101", "20121201")); Assert.assertTrue(CielRequirement.checkCielVersions("20130101", "20130101")); Assert.assertTrue(CielRequirement.checkCielVersions("20130101", "20130102")); }