@SuppressWarnings("serial")
@Test
public void testIsApplicableMinimumStackVersion() throws Exception {

  final Cluster cluster = Mockito.mock(Cluster.class);
  Mockito.when(cluster.getClusterId()).thenReturn(1L);
  Mockito.when(cluster.getServices()).thenReturn(new HashMap<String, Service>() {
    {
      put("YARN", null);
    }
  });
  Mockito.when(cluster.getCurrentStackVersion()).thenReturn(new StackId("MYSTACK-12.2"));
  ClusterVersionEntity clusterVersionEntity = Mockito.mock(ClusterVersionEntity.class);
  Mockito.when(cluster.getCurrentClusterVersion()).thenReturn(clusterVersionEntity);
  RepositoryVersionEntity repositoryVersionEntity = Mockito.mock(RepositoryVersionEntity.class);
  Mockito.when(clusterVersionEntity.getRepositoryVersion()).thenReturn(repositoryVersionEntity);
  Mockito.when(m_clusters.getCluster("c1")).thenReturn(cluster);
  Map<String, String> checkProperties = new HashMap<String, String>();
  checkProperties.put("min-applicable-stack-version", "HDP-2.2.4.2");
  PrerequisiteCheckConfig prerequisiteCheckConfig = Mockito.mock(PrerequisiteCheckConfig.class);
  Mockito.when(prerequisiteCheckConfig.getCheckProperties(
      m_check.getClass().getName())).thenReturn(checkProperties);
  PrereqCheckRequest request = new PrereqCheckRequest("c1");
  request.setPrerequisiteCheckConfig(prerequisiteCheckConfig);
  Mockito.when(repositoryVersionEntity.getVersion()).thenReturn("2.3.0.1");
  boolean isApplicable = m_check.isApplicable(request);
  Assert.assertTrue(isApplicable);
}