TeradataTimePeriod extends DbStruct { @Override public boolean equals(Object other) { if (other == null) { return false; } if (!(other instanceof TeradataTimePeriod)) { return false; } TeradataTimePeriod odp = (TeradataTimePeriod) other; Object[] thisAtts = null; Object[] otherAtts = null; try { otherAtts = odp.getAttributes(); thisAtts = this.getAttributes(); } catch (SQLException e) { System.out.println("TeradataTimePeriod: equals: caught exception"); } if (!(thisAtts[0].equals(otherAtts[0]))) { return false; } if (!(thisAtts[1].equals(otherAtts[1]))) { return false; } return true; } TeradataTimePeriod(Object[] dates); @Override String toString(); @Override boolean equals(Object other);  }
@Test public void equalsTest() { String fromStr = "01:23:45"; String toStr = "12:13:14"; Time fromTime = null; Time toTime = null; fromTime = Time.valueOf(fromStr); toTime = Time.valueOf(toStr); Time[] range = {fromTime, toTime}; TeradataTimePeriod tdp = new TeradataTimePeriod(range); TeradataTimePeriod tdp2 = new TeradataTimePeriod(range); assertTrue("Time periods are not equal", tdp.equals(tdp2)); }
@Test public void notEqualsTest() { String fromStr = "01:23:45"; String toStr = "12:13:14"; Time fromTime = null; Time toTime = null; fromTime = Time.valueOf(fromStr); toTime = Time.valueOf(toStr); Time[] range = {fromTime, toTime}; TeradataTimePeriod tdp = new TeradataTimePeriod(range); Time[] range2 = {fromTime, fromTime}; TeradataTimePeriod tdp2 = new TeradataTimePeriod(range2); assertFalse("Time periods are equal", tdp.equals(tdp2)); }