ClusterDefinition { public Integer getMajorStackVersion() { if(StringUtils.isNotEmpty(versionId)) { String majorVersion = StringUtils.substring(versionId, 4, 5); if(StringUtils.isNotEmpty(majorVersion)) { return Integer.parseInt(majorVersion); } } return null; } ClusterDefinition(StateProvider stateProvider,
                           ClusterDefinitionProvider definitionProvider,
                           HostInfoProvider hostInfoProvider); Integer getMajorStackVersion(); Integer getMinorStackVersion(); String getClusterName(); String getVersionId(); Set<String> getServices(); Set<String> getHosts(); HostInfoProvider getHostInfoProvider(); Set<String> getComponents(String service); Set<String> getHostComponents(String service, String host); String getHostState(String hostName); String getServiceState(String serviceName); int setServiceState(String serviceName, String state); String getComponentState(String serviceName, String componentName); int setComponentState(String serviceName, String componentName, String state); String getHostComponentState(String hostName, String componentName); int setHostComponentState(String hostName, String componentName, String state); StateProvider.Process getProcess(Integer id); Set<Resource> getRequestResources(); Set<Resource> getTaskResources();  }
@Test public void testGetMajorStackVersion() { TestClusterDefinitionProvider testClusterDefinitionProvider = new TestClusterDefinitionProvider("clusterproperties_HDP2.txt", "myCluster", "HDP-2.0.6"); ClusterDefinition clusterDefinition = new ClusterDefinition(new TestStateProvider(), testClusterDefinitionProvider, new TestHostInfoProvider()); Integer majorVersion = clusterDefinition.getMajorStackVersion(); Integer minorVersion = clusterDefinition.getMinorStackVersion(); Assert.assertTrue(2 == majorVersion); Assert.assertTrue(0 == minorVersion); }