Skip to content
Permalink
Browse files

SCUFL2-81 Tests for control link null compare

git-svn-id: https://taverna.googlecode.com/svn/scufl2/trunk@15054 bf327186-88b3-11dd-a302-d386e5130c1c
  • Loading branch information
stian@mygrid.org.uk
stian@mygrid.org.uk committed Jul 9, 2012
1 parent 0d28856 commit 53c1146647ed0e4bc7f8ad827859633b3a78da40
@@ -0,0 +1,84 @@
package uk.org.taverna.scufl2.api.core;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.junit.Test;

import uk.org.taverna.scufl2.api.port.InputWorkflowPort;
import uk.org.taverna.scufl2.api.port.OutputWorkflowPort;

public class ControlLinkCompareTest {
@SuppressWarnings("unchecked")
@Test
public void expectedOrder() throws Exception {

Workflow wf = new Workflow();
wf.setName("wf");

Processor a = new Processor(wf, "a");
Processor b = new Processor(wf, "b");
Processor c = new Processor(wf, "c");
Processor d = new Processor(wf, "d");

BlockingControlLink b_blocks_c = new BlockingControlLink(c, b);
BlockingControlLink a_blocks_c = new BlockingControlLink(c, a);
BlockingControlLink a_blocks_b = new BlockingControlLink(b, a);
BlockingControlLink b_blocks_d = new BlockingControlLink(d, b);
BlockingControlLink a_blocks_d = new BlockingControlLink(d, a);

ArrayList<ControlLink> links = new ArrayList<ControlLink>(wf.getControlLinks());
assertEquals(Arrays.asList(a_blocks_b, a_blocks_c, a_blocks_d, b_blocks_c, b_blocks_d), links);
Collections.shuffle(links);
Collections.sort(links);
assertEquals(Arrays.asList(a_blocks_b, a_blocks_c, a_blocks_d, b_blocks_c, b_blocks_d), links);
}

@SuppressWarnings("unchecked")
@Test
public void nullSupport() throws Exception {
Workflow wf = new Workflow();
wf.setName("wf");



Processor a = new Processor(wf, "a");
Processor b = new Processor(wf, "b");
Processor c = new Processor(wf, "c");
Processor d = new Processor(wf, "d");

BlockingControlLink b_blocks_c = new BlockingControlLink(c, b);
BlockingControlLink null_blocks_c = new BlockingControlLink();
null_blocks_c.setBlock(c);
null_blocks_c.setParent(wf);
BlockingControlLink a_blocks_b = new BlockingControlLink(b, a);
BlockingControlLink b_blocks_null = new BlockingControlLink();
b_blocks_null.setUntilFinished(b);
b_blocks_null.setParent(wf);

BlockingControlLink null_blocks_null = new BlockingControlLink();
null_blocks_null.setParent(wf);


ArrayList<ControlLink> links = new ArrayList<ControlLink>(wf.getControlLinks());
assertEquals(Arrays.asList(null_blocks_null, null_blocks_c, a_blocks_b, b_blocks_null, b_blocks_c), links);

Collections.shuffle(links);
Collections.sort(links);

BlockingControlLink a_blocks_d_no_parent = new BlockingControlLink();
a_blocks_d_no_parent.setBlock(d);
a_blocks_d_no_parent.setUntilFinished(a);
// no setParent
links.add(a_blocks_d_no_parent);
Collections.shuffle(links);
Collections.sort(links);

assertEquals(Arrays.asList(null_blocks_null, null_blocks_c, a_blocks_b, a_blocks_d_no_parent, b_blocks_null, b_blocks_c), links);
}

}

0 comments on commit 53c1146

Please sign in to comment.
You can’t perform that action at this time.