CmUtils { public static String distroVersionOfHadoopStack(HadoopStack stack) { try { String[] versionInfo = stack.getDistro().split("-"); return (versionInfo[1]); } catch (Exception e) { return Constants.VERSION_UNBOUNDED; } }  static String distroVersionOfHadoopStack(HadoopStack stack); static boolean isValidRack(String rack); static String getConfDir();  }
@Test public void testMajorVersionOfStack() { HadoopStack stack = new HadoopStack(); stack.setDistro("CDH-5.0.1"); Assert.assertEquals(CmUtils.distroVersionOfHadoopStack(stack), "5.0.1"); stack.setDistro("CDH"); Assert.assertEquals(CmUtils.distroVersionOfHadoopStack(stack), "-1"); stack.setDistro(null); Assert.assertEquals(CmUtils.distroVersionOfHadoopStack(stack), "-1"); }