public void testFlattening() throws Exception { List<List<String>> list = makeDeepList(0); List result = runFlattener(getLocalWorker(), list); assertEquals("incorrect number of entries in the list", 10, result.size()); for (int i = 1; i <= 10; i++) { String testVal = String.valueOf(i); assertEquals("incorrect value in list", testVal, result.get(i - 1)); } }
public void testDefaultDepth() { assertEquals("Default value should be 2", 2, getLocalWorker().getDepth()); }
public void testNotTooDeep() throws TaskExecutionException { List<List<List<String>>> deeperList = makeDeeperList(); // Should only flatten 2 levels by default! FlattenList l = getLocalWorker(); List result = runFlattener(l, deeperList); assertEquals("incorrect number of entries in the list", 3*4, result.size()); }
public void testXMLImport() { FlattenList flattener = getLocalWorker(); flattener.setDepth(1337); Element e = flattener.provideXML(); FlattenList flattener2 = getLocalWorker(); flattener2.consumeXML(e); assertEquals("Did not consume XML correctly", 1337, flattener2.getDepth()); }
public void testFlatteningDeeper() throws TaskExecutionException { List<List<List<String>>> deeperList = makeDeeperList(); FlattenList l = getLocalWorker(); l.setDepth(3); List result = runFlattener(l, deeperList); assertEquals("incorrect number of entries in the list", 4*10, result.size()); for (int i = 1; i <= 4*10; i++) { String testVal = String.valueOf(i); assertEquals("incorrect value in list", testVal, result.get(i - 1)); } }
public void testTooNarrow() throws TaskExecutionException { List<List<String>> deepList = makeDeepList(0); FlattenList l = getLocalWorker(); l.setDepth(3); // Should still manage, even if list is not that deep List result = runFlattener(l, deepList); assertEquals("incorrect number of entries in the list", 10, result.size()); for (int i = 1; i <= 10; i++) { String testVal = String.valueOf(i); assertEquals("incorrect value in list", testVal, result.get(i - 1)); } }
public void testXMLExport() throws DataConversionException { Element e = getLocalWorker().provideXML(); assertEquals(XScufl.XScuflNS, e.getNamespace()); assertEquals("extensions", e.getName()); Element flattenlist = e.getChild("flattenlist", XScufl.XScuflNS); assertNotNull("Element <flattenlist> not found", flattenlist); Attribute depth = flattenlist.getAttribute("depth", XScufl.XScuflNS); assertNotNull("Attribute depth='' not found", depth); assertEquals(2, depth.getIntValue()); }
public void testSettingDepth() { FlattenList l = getLocalWorker(); l.setDepth(3); assertEquals(3, l.getDepth()); l.setDepth(1337); assertEquals(1337, l.getDepth()); // Below 2 should not work, should limit to 2 l.setDepth(1); assertEquals(2, l.getDepth()); l.setDepth(0); assertEquals(2, l.getDepth()); l.setDepth(-1); assertEquals(2, l.getDepth()); l.setDepth(-20); assertEquals(2, l.getDepth()); // But setting to 2 should work l.setDepth(3); l.setDepth(2); assertEquals(2, l.getDepth()); }