ColumnPatternUtil { public ColumnPatternContainer findColNamesForColNamePattern(QueryableLongColumnShardResolver lengthColResolver, String pattern) throws LengthColumnMissingException { return findColNamesForColNamePattern(lengthColResolver, Arrays.asList(pattern)); }  ColumnPatternContainer findColNamesForColNamePattern(QueryableLongColumnShardResolver lengthColResolver,
      String pattern); ColumnPatternContainer findColNamesForColNamePattern(QueryableLongColumnShardResolver lengthColResolver,
      List<String> patterns);  }
@Test public void singlePatternSimple() { simulateLengths(new Triple<>("a.b", 5L, 2L)); ColumnPatternContainer patterns = colPatternUtil.findColNamesForColNamePattern(env, "a.b[*].c"); Set<List<String>> res = patterns.getColumnPatterns(1L); Set<List<String>> expected = new HashSet<>(Arrays.asList(Arrays.asList("a.b[0].c"), Arrays.asList("a.b[1].c"))); Assert.assertEquals(res, expected, "Expected correct final colNames"); }
@Test public void singlePatternSimple2() { simulateLengths(new Triple<>("a.b", 3L, 2L), new Triple<>("a.b[0].c", 7L, 1L), new Triple<>("a.b[1].c", 3L, 3L), new Triple<>("a.b[2].c", 1L, 0L)); ColumnPatternContainer patterns = colPatternUtil.findColNamesForColNamePattern(env, "a.b[*].c[*]"); Set<List<String>> res = patterns.getColumnPatterns(1L); Set<List<String>> expected = new HashSet<>(Arrays.asList( Arrays.asList("a.b[0].c[0]"), Arrays.asList("a.b[1].c[0]"), Arrays.asList("a.b[1].c[1]"), Arrays.asList("a.b[1].c[2]"))); Assert.assertEquals(res, expected, "Expected correct final colNames"); }
@Test(expectedExceptions = PatternException.class) public void singlePatternNone() { colPatternUtil.findColNamesForColNamePattern(env, "a.b[1].c[0]"); }
@Test public void multiplePatternSimple() { simulateLengths(new Triple<>("a.b", 5L, 2L)); ColumnPatternContainer patterns = colPatternUtil.findColNamesForColNamePattern(env, Arrays.asList("a.b[*].c", "a.b[*].d")); Set<List<String>> res = patterns.getColumnPatterns(1L); Set<List<String>> expected = new HashSet<>(Arrays.asList(Arrays.asList("a.b[0].c", "a.b[0].d"), Arrays.asList("a.b[1].c", "a.b[1].d"))); Assert.assertEquals(res, expected, "Expected correct final colNames"); }
@Test(expectedExceptions = PatternException.class) public void multiplePatternWrongRepetition() { colPatternUtil.findColNamesForColNamePattern(env, Arrays.asList("a.b[*].c", "a.c[*].d[*]")); }
@Test public void multiplePatternTwoLevel() { simulateLengths(new Triple<>("a.b", 3L, 3L), new Triple<>("a.b[0].d", 7L, 3L), new Triple<>("a.b[1].d", 2L, 1L), new Triple<>("a.b[2].d", 1L, 0L)); ColumnPatternContainer patterns = colPatternUtil.findColNamesForColNamePattern(env, Arrays.asList("a.b[*].c", "a.b[*].d[*].e")); Set<List<String>> res = patterns.getColumnPatterns(1L); Set<List<String>> expected = new HashSet<>(Arrays.asList( Arrays.asList("a.b[0].c", "a.b[0].d[0].e"), Arrays.asList("a.b[0].c", "a.b[0].d[1].e"), Arrays.asList("a.b[0].c", "a.b[0].d[2].e"), Arrays.asList("a.b[1].c", "a.b[1].d[0].e") )); Assert.assertEquals(res, expected, "Expected correct final colNames"); }
@Test public void multiplePatternTwoLevel2() { simulateLengths(new Triple<>("a", 3L, 2L), new Triple<>("a[0].b.c", 3L, 2L), new Triple<>("a[1].b.c", 3L, 1L), new Triple<>("a[2].b.c", 1L, 1L) ); ColumnPatternContainer patterns = colPatternUtil.findColNamesForColNamePattern(env, Arrays.asList("a[*].b.c[*]", "a[*].b.d")); Set<List<String>> res = patterns.getColumnPatterns(1L); Set<List<String>> expected = new HashSet<>(Arrays.asList( Arrays.asList("a[0].b.c[0]", "a[0].b.d"), Arrays.asList("a[0].b.c[1]", "a[0].b.d"), Arrays.asList("a[1].b.c[0]", "a[1].b.d") )); Assert.assertEquals(res, expected, "Expected correct final colNames"); }
@Test public void multiplePatternTwoLevel3() { simulateLengths(new Triple<>("a", 3L, 2L), new Triple<>("a[0].b.c", 3L, 2L), new Triple<>("a[1].b.c", 3L, 1L), new Triple<>("a[2].b.c", 3L, 2L) ); ColumnPatternContainer patterns = colPatternUtil.findColNamesForColNamePattern(env, Arrays.asList("a[*].b.c[*]", "a[*].b.c[*]")); Set<List<String>> res = patterns.getColumnPatterns(1L); Set<List<String>> expected = new HashSet<>(Arrays.asList( Arrays.asList("a[0].b.c[0]", "a[0].b.c[0]"), Arrays.asList("a[0].b.c[1]", "a[0].b.c[1]"), Arrays.asList("a[1].b.c[0]", "a[1].b.c[0]"))); Assert.assertEquals(res, expected, "Expected correct final colNames"); }
@Test public void multiplePatternTwoAndNone() { simulateLengths(new Triple<>("a", 3L, 2L), new Triple<>("a[0].b.c", 3L, 2L), new Triple<>("a[1].b.c", 3L, 1L), new Triple<>("a[2].b.c", 3L, 2L) ); ColumnPatternContainer patterns = colPatternUtil.findColNamesForColNamePattern(env, Arrays.asList("a[*].b.c[*]", "a.x")); Set<List<String>> res = patterns.getColumnPatterns(1L); Set<List<String>> expected = new HashSet<>(Arrays.asList( Arrays.asList("a[0].b.c[0]", "a.x"), Arrays.asList("a[0].b.c[1]", "a.x"), Arrays.asList("a[1].b.c[0]", "a.x"))); Assert.assertEquals(res, expected, "Expected correct final colNames"); }