### Question:
Cuboid implements Comparable<Cuboid> { public static boolean isValid(CubeDesc cube, long cuboidID) { RowKeyDesc rowkey = cube.getRowkey(); if (cuboidID < 0) { throw new IllegalArgumentException("Cuboid " + cuboidID + " should be greater than 0"); } if (checkBaseCuboid(rowkey, cuboidID)) { return true; } if (checkMandatoryColumns(rowkey, cuboidID) == false) { return false; } if (checkAggregationGroup(rowkey, cuboidID) == false) { return false; } if (checkHierarchy(rowkey, cuboidID) == false) { return false; } return true; } private  Cuboid(CubeDesc cube, long originalID, long validID); static Cuboid findById(CubeDesc cube, byte[] cuboidID); static Cuboid findById(CubeDesc cube, long cuboidID); static boolean isValid(CubeDesc cube, long cuboidID); static long getBaseCuboidId(CubeDesc cube); CubeDesc getCube(); List<TblColRef> getColumns(); List<TblColRef> getAggregationColumns(); long getId(); byte[] getBytes(); long getInputID(); boolean useAncestor(); boolean requirePostAggregation(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(Cuboid o);  }### Answer:
@Test public void testIsValid() { CubeDesc cube = getTestKylinCubeWithSeller(); assertEquals(false, Cuboid.isValid(cube, 0)); assertEquals(true, Cuboid.isValid(cube, toLong("111111111"))); assertEquals(false, Cuboid.isValid(cube, toLong("011111110"))); assertEquals(false, Cuboid.isValid(cube, toLong("100000000"))); assertEquals(true, Cuboid.isValid(cube, toLong("111111000"))); assertEquals(true, Cuboid.isValid(cube, toLong("110000111"))); assertEquals(true, Cuboid.isValid(cube, toLong("110111000"))); assertEquals(true, Cuboid.isValid(cube, toLong("111110111"))); assertEquals(false, Cuboid.isValid(cube, toLong("111110001"))); assertEquals(false, Cuboid.isValid(cube, toLong("111110100"))); assertEquals(false, Cuboid.isValid(cube, toLong("110000100"))); }
@Test public void testIsValid2() { CubeDesc cube = getTestKylinCubeWithoutSeller(); try { assertEquals(false, Cuboid.isValid(cube, toLong("111111111"))); fail(); } catch (IllegalArgumentException ex) { } assertEquals(false, Cuboid.isValid(cube, 0)); assertEquals(true, Cuboid.isValid(cube, toLong("11111111"))); assertEquals(true, Cuboid.isValid(cube, toLong("10000111"))); assertEquals(false, Cuboid.isValid(cube, toLong("10001111"))); assertEquals(false, Cuboid.isValid(cube, toLong("11001111"))); assertEquals(true, Cuboid.isValid(cube, toLong("10000001"))); assertEquals(true, Cuboid.isValid(cube, toLong("10000101"))); assertEquals(true, Cuboid.isValid(cube, toLong("10100000"))); assertEquals(true, Cuboid.isValid(cube, toLong("10110000"))); assertEquals(true, Cuboid.isValid(cube, toLong("10111000"))); assertEquals(false, Cuboid.isValid(cube, toLong("10001000"))); assertEquals(false, Cuboid.isValid(cube, toLong("10011000"))); }