@Test
public void testGetLastServiceConfig() throws Exception {

  createServiceConfig("HDFS", "admin", 1L, 1L, 1111L, null);
  createServiceConfig("HDFS", "admin", 2L, 2L, 2222L, null);
  createServiceConfig("YARN", "admin", 1L, 3L, 3333L, null);
  Long clusterId = clusterDAO.findByName("c1").getClusterId();
  ServiceConfigEntity serviceConfigEntity =
    serviceConfigDAO.getLastServiceConfig(clusterId, "HDFS");
  Assert.assertNotNull(serviceConfigEntity);
  Assert.assertEquals("c1", serviceConfigEntity.getClusterEntity().getClusterName());
  Assert.assertEquals(clusterId, serviceConfigEntity.getClusterEntity()
    .getClusterId());
  Assert.assertEquals("HDFS", serviceConfigEntity.getServiceName());
  Assert.assertEquals(Long.valueOf(2222L), serviceConfigEntity.getCreateTimestamp());
  Assert.assertEquals("admin", serviceConfigEntity.getUser());
  Assert.assertEquals(Long.valueOf(2), serviceConfigEntity.getVersion());
  Assert.assertTrue(serviceConfigEntity.getClusterConfigEntities().isEmpty());
  Assert.assertNotNull(serviceConfigEntity.getServiceConfigId());
}