1 package org.kuali.common.devops.archive.test; 2 3 import static java.lang.String.format; 4 import static java.util.Arrays.asList; 5 import static org.kuali.common.devops.archive.evaluate.ListEvaluators.listSizeEvaluator; 6 import static org.kuali.common.devops.archive.evaluate.ListUtils.distribute; 7 import static org.kuali.common.util.log.Loggers.newLogger; 8 9 import java.util.List; 10 11 import org.junit.Test; 12 import org.kuali.common.devops.archive.evaluate.ListEvaluator; 13 import org.slf4j.Logger; 14 15 public class ListUtilsTest { 16 17 private static final Logger logger = newLogger(); 18 19 @Test 20 public void test1() { 21 List<Integer> list = asList(100, 2, 3, 4, 5, 6, 7); 22 ListEvaluator<Integer> evaluator = listSizeEvaluator(); 23 List<List<Integer>> lol = distribute(list, 3, evaluator); 24 logger.info(format("size: %s", lol.size())); 25 logger.info(format("size 0: %s", lol.get(0).size())); 26 logger.info(format("size 1: %s", lol.get(1).size())); 27 logger.info(format("size 2: %s", lol.get(2).size())); 28 } 29 30 @Test 31 public void test2() { 32 List<Integer> list = asList(1, 2, 3, 4, 5, 6, 7); 33 for (int i = 0; i < list.size(); i++) { 34 logger.info("--"); 35 for (List<Integer> element : distribute(list, i + 1)) { 36 logger.info(format("size: %s", element.size())); 37 } 38 } 39 } 40 41 }