if (getChildCount() == 1) { for (int i = 0; i < getChildCount(); i++) perInputCache.add(new HashSet<Job>()); ownerToCache.put(newJob.getOwningProcess(), perInputCache); workingSet.add(newJob); for (int i = 1; i < getChildCount(); i++) { Set<Job> thisSet = perInputCache.get(i); if (i == inputIndex) {
@Test public void addCrossProductMany() { crossProduct1.insert(dotProduct1); crossProduct1.insert(dotProduct2); crossProduct1.insert(input1); crossProduct1.insert(input2); crossProduct1.insert(crossProduct2); assertEquals(5, crossProduct1.getChildCount()); assertEquals(Arrays.asList(dotProduct1, dotProduct2, input1, input2, crossProduct2), crossProduct1.getChildren()); Enumeration<IterationStrategyNode> enumeration = crossProduct1 .children(); assertTrue(enumeration.hasMoreElements()); assertEquals(dotProduct1, enumeration.nextElement()); assertEquals(dotProduct2, enumeration.nextElement()); assertEquals(input1, enumeration.nextElement()); assertEquals(input2, enumeration.nextElement()); assertEquals(crossProduct2, enumeration.nextElement()); assertFalse(enumeration.hasMoreElements()); }
@Test public void addCrossProduct() throws Exception { assertNull(crossProduct1.getParent()); crossProduct1.setParent(root); assertEquals(root, crossProduct1.getParent()); assertEquals(1, root.getChildCount()); assertEquals(crossProduct1, root.getChildAt(0)); assertEquals(Arrays.asList(crossProduct1), root.getChildren()); assertEquals(0, crossProduct1.getChildCount()); crossProduct1.insert(input1); assertEquals(input1, crossProduct1.getChildAt(0)); crossProduct1.insert(input2, 0); assertEquals(input2, crossProduct1.getChildAt(0)); assertEquals(input1, crossProduct1.getChildAt(1)); assertEquals(2, crossProduct1.getChildCount()); assertEquals(Arrays.asList(input2, input1), crossProduct1.getChildren()); // A re-insert should move it crossProduct1.insert(input2, 2); assertEquals(2, crossProduct1.getChildCount()); assertEquals(Arrays.asList(input1, input2), crossProduct1.getChildren()); crossProduct1.insert(input2, 0); assertEquals(Arrays.asList(input2, input1), crossProduct1.getChildren()); crossProduct1.insert(input1, 1); assertEquals(Arrays.asList(input2, input1), crossProduct1.getChildren()); }