Pipeline { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } Pipeline other = (Pipeline) obj; if(other.getStageGroups().size()==getStageGroups().size()) { for(StageGroup g : other.getStageGroups()) { if(!hasGroup(g.getName()) || !g.equals(getGroup(g.getName()))) { return false; } } return true; } return false; } Pipeline(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); Set<StageGroup> getStageGroups(); boolean hasGroup(String groupName); StageGroup getGroup(String groupName); void removeGroup(String group); void addGroup(StageGroup g); Set<Stage> getStages(); Stage getStage(String name); StageGroup getGroupForStage(String name); boolean hasStage(String name);  }
@Test public void testEquals() { Pipeline p = new Pipeline(); assertTrue(p.equals(p)); assertTrue(p.equals(new Pipeline())); Pipeline p2 = new Pipeline(); p2.addGroup(new StageGroup("group")); assertFalse(p.equals(p2)); assertFalse(p2.equals(p)); p.addGroup(new StageGroup("group")); assertTrue(p.equals(p2)); DatabaseFile df = new DatabaseFile(); p2.getGroup("group").addStage(new Stage("stage", df)); assertFalse(p.equals(p2)); p.getGroup("group").addStage(new Stage("stage2", df)); assertFalse(p.equals(p2)); p2.getGroup("group").addStage(new Stage("stage2", df)); p.getGroup("group").addStage(new Stage("stage", df)); assertTrue(p.equals(p2)); }