@Override public void visitBlockingControlLink(BlockingControlLink bean) { // Also checks from Child Workflow parent = bean.getParent(); Processor block = bean.getBlock(); Processor untilFinished = bean.getUntilFinished(); // Check the block and untilFinished processors are in the same workflow if (block != null) { Workflow blockParent = block.getParent(); if ((parent == null) || !parent.equals(blockParent)) listener.outOfScopeValue(bean, "block", block); } if (untilFinished != null) { Workflow untilFinishedParent = untilFinished.getParent(); if ((parent == null) || !parent.equals(untilFinishedParent)) listener.outOfScopeValue(bean, "untilFinished", untilFinished); } // Check the block and untilFinished processors are specified if (checkComplete) { if (block == null) listener.nullField(bean, "block"); if (untilFinished == null) listener.nullField(bean, "untilFinished"); } }
Workflow sendsToWorkflow = findAncestral((Child<?>) sendsTo, Workflow.class); if ((parent == null) || !parent.equals(sendsToWorkflow)) listener.outOfScopeValue(bean, "sendsTo", sendsTo); Workflow receivesFromWorkflow = findAncestral((Child<?>) receivesFrom, Workflow.class); if ((parent == null) || !parent.equals(receivesFromWorkflow)) listener.outOfScopeValue(bean, "receivesFrom", receivesFrom);
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; BlockingControlLink other = (BlockingControlLink) obj; if (getUntilFinished() == null) { if (other.getUntilFinished() != null) return false; } else if (!getUntilFinished().equals(other.getUntilFinished())) return false; if (getParent() == null) { if (other.getParent() != null) return false; } else if (!getParent().equals(other.getParent())) return false; if (getBlock() == null) { if (other.getBlock() != null) return false; } else if (!getBlock().equals(other.getBlock())) return false; return true; }
@Test public void workflowsNotEqualsUnlessOrphans() { Workflow wf1 = new Workflow(); Workflow wf2 = new Workflow(); wf1.setName("fred"); wf2.setName("fred"); // No parents, so they are equal assertEquals(wf1, wf2); WorkflowBundle wb1 = new WorkflowBundle(); WorkflowBundle wb2 = new WorkflowBundle(); // Make them look "equal" wb2.setName(wb1.getName()); wb2.setGlobalBaseURI(wb1.getGlobalBaseURI()); assertFalse(wb1.equals(wb2)); wf1.setParent(wb1); wf2.setParent(wb2); assertFalse(wf1.equals(wf2)); wf1.setParent(null); assertFalse(wf1.equals(wf2)); assertFalse(wf2.equals(wf1)); wf2.setParent(null); assertTrue(wf1.equals(wf2)); }