@Test
  public void testGetLatestClusterConfigsByStack() throws Exception {
    initClusterEntities();

    ClusterEntity clusterEntity = clusterDAO.findByName("c1");

    // there should be 3 configs in HDP-0.1 for this cluster, none selected
    List<ClusterConfigEntity> clusterConfigEntities = clusterDAO.getLatestConfigurations(clusterEntity.getClusterId(), HDP_01);
    Assert.assertEquals(1, clusterConfigEntities.size());

    ClusterConfigEntity entity = clusterConfigEntities.get(0);
    Assert.assertEquals("version3", entity.getTag());
    Assert.assertEquals("oozie-site", entity.getType());
    Assert.assertFalse(entity.isSelected());

    // there should be 2 configs in HDP-0.2 for this cluster, the latest being
    // selected
    clusterConfigEntities = clusterDAO.getLatestConfigurations(clusterEntity.getClusterId(), HDP_02);
    Assert.assertEquals(1, clusterConfigEntities.size());

    entity = clusterConfigEntities.get(0);
    Assert.assertEquals("version5", entity.getTag());
    Assert.assertEquals("oozie-site", entity.getType());
    Assert.assertTrue(entity.isSelected());
  }
Tests the ability to find the latest configuration by stack, regardless of
whether that configuration is enabled.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/orm/dao/ServiceConfigDAOTest.java