@@ -0,0 +1,1725 @@
+package uk.org.taverna.scufl2.api.core;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.Collections;%0Aimport java.util.List;%0A%0Aimport org.junit.Test;%0A%0Aimport uk.org.taverna.scufl2.api.common.Named;%0Aimport uk.org.taverna.scufl2.api.port.InputWorkflowPort;%0Aimport uk.org.taverna.scufl2.api.port.OutputWorkflowPort;%0Aimport uk.org.taverna.scufl2.api.port.Port;%0A%0Aimport static org.junit.Assert.*;%0A%0Apublic class PortOrderTest %7B%0A%09List%3CPort%3E ports = new ArrayList%3CPort%3E();%0A%09%0A%09Workflow wf = new Workflow();%0A%0A%09@Test%0A%09public void orderedByName() throws Exception %7B%0A%09%09ports.add(new InputWorkflowPort(wf, %22p3%22));%0A%09%09ports.add(new InputWorkflowPort(wf, %22p1%22));%0A%09%09ports.add(new InputWorkflowPort(wf, %22p2%22));%0A%09%09Collections.sort(ports);%0A%09%09assertNamesEqual(ports, %22p1%22, %22p2%22, %22p3%22);%0A%09%7D%0A%09%0A%09@Test%0A%09public void ignoringNull() throws Exception %7B%0A%09%09ports.add(new InputWorkflowPort(null, %22p3%22));%0A%09%09ports.add(new InputWorkflowPort(null, %22p1%22));%0A%09%09ports.add(new InputWorkflowPort(wf, %22p2%22));%0A%09%09Collections.sort(ports);%0A%09%09assertNamesEqual(ports, %22p1%22, %22p2%22, %22p3%22);%0A%09%7D%0A%09%0A%09@Test%0A%09public void orderedByClassName() throws Exception %7B%0A%09%09ports.add(new InputWorkflowPort(wf, %22p3%22));%0A%09%09ports.add(new OutputWorkflowPort(wf, %22p1%22));%0A%09%09ports.add(new InputWorkflowPort(wf, %22p2%22));%0A%09%09Collections.sort(ports);%0A%09%09assertNamesEqual(ports, %22p2%22, %22p3%22, %22p1%22);%0A%09%7D%0A%0A%0A%09public static void assertNamesEqual(List%3C? extends Named%3E named, String... expectedNames) %7B%0A%09%09List%3CString%3E names = namesOf(named);%09%0A%09%09assertEquals(Arrays.asList(expectedNames), names);%09%09%0A%09%7D%0A%0A%09public static List%3CString%3E namesOf(List%3C? extends Named%3E named) %7B%0A%09%09List%3CString%3E names = new ArrayList%3CString%3E();%0A%09%09for (Named n : named) %7B%0A%09%09%09names.add(n.getName());%0A%09%09%7D%0A%09%09return names;%0A%09%7D%0A%0A%7D%0A

Test ordering of ports