Cron { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Cron cron = (Cron) o; return Objects.equals(expression, cron.expression); } Cron(String expression); String getExpression(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void expressionEquals() { String expression1 = "* * 8 0 * *"; String expression2 = "* * 8 * 0 *"; String expression3 = "* * 8 0 * *"; Cron cron1 = new Cron(expression1); Cron cron2 = new Cron(expression2); Cron cron3 = new Cron(expression3); Cron cron4 = new Cron(null); assertTrue(cron1.equals(cron3)); assertFalse(cron1.equals(null)); assertFalse(cron4.equals(null)); assertFalse(cron1.equals(cron2)); assertTrue(cron1.equals(cron3)); }