ScaleCategory { @Override public boolean equals(Object o) { if(o == null) return false; if(!o.getClass().equals(this.getClass())) return false; ScaleCategory category = (ScaleCategory)o; return this.minValue == category.minValue && this.maxValue == category.maxValue; } ScaleCategory(String name, int minValue, int maxValue, String sensorStateValue, int sensorValue); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean fallsIntoCategory(int rawValue); String getName(); int getMinValue(); int getMaxValue(); String getSensorStateValue(); int getSensorValue();  }
@Test public void testEquals() throws Exception { ScaleCategory cat1 = new ScaleCategory("Category 1", 0, 49, "CAT1", 1); ScaleCategory cat2 = new ScaleCategory("Category 1", 0, 49, "CAT1", 1); ScaleCategory cat3 = new ScaleCategory("Category 2", 50, 99, "CAT1", 2); Assert.assertTrue(cat1.equals(cat2)); Assert.assertTrue(cat2.equals(cat1)); Assert.assertFalse(cat1.equals(cat3)); Assert.assertFalse(cat3.equals(cat1)); Assert.assertFalse(cat1.equals(null)); Assert.assertFalse(cat1.equals(new Object())); }