private void initClusterEntities() throws Exception{
    String userName = "admin";

    ServiceConfigEntity oozieServiceConfigEntity = createServiceConfig("OOZIE", userName, 1L, 1L, System.currentTimeMillis(), null);
    ClusterEntity  clusterEntity = oozieServiceConfigEntity.getClusterEntity();

    Long clusterId = clusterEntity.getClusterId();

    if(null == clusterId){
      clusterId = 1L;
      clusterEntity.setClusterId(clusterId);
      clusterEntity = clusterDAO.merge(clusterEntity);
    }

    StackEntity stackEntityHDP01 = stackDAO.find(HDP_01.getStackName(),HDP_01.getStackVersion());
    StackEntity stackEntityHDP02 = stackDAO.find(HDP_02.getStackName(),HDP_02.getStackVersion());

    String oozieSite = "oozie-site";

    // create 5 Oozie Configs, with only the latest from HDP-0.2 being enabled
    int configsToCreate = 5;
    for (int i = 1; i <= configsToCreate; i++) {
      Thread.sleep(1);
      ClusterConfigEntity entity = new ClusterConfigEntity();
      entity.setClusterEntity(clusterEntity);
      entity.setClusterId(clusterEntity.getClusterId());
      entity.setType(oozieSite);
      entity.setVersion(Long.valueOf(i));
      entity.setTag("version"+i);
      entity.setTimestamp(new Date().getTime());

      // set selected to true to get the last selected timestamp populated
      entity.setSelected(true);

      // now set it to false
      entity.setSelected(false);

      entity.setStack(stackEntityHDP01);
      if (i >= 4) {
        entity.setStack(stackEntityHDP02);
        if (i == configsToCreate) {
          entity.setSelected(true);
        }
      }

      entity.setData("");
      clusterDAO.createConfig(entity);
      clusterEntity.getClusterConfigEntities().add(entity);
      clusterDAO.merge(clusterEntity);
    }
  }
Createa a cluster with 5 configurations for Oozie. Each configuration will
have a tag of "version" plus a count. 3 configs will be for
{@link #HDP_01}, and 2 will be for {@link #HDP_02}. Only the most recent
configuration, {@code version5}, will be enabled.

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