new HostComponentStateEntityPK();
primaryKey.setClusterId(clusters.getCluster("C1").getClusterId());
primaryKey.setServiceName("HDFS");
primaryKey.setComponentName("DATANODE");
primaryKey.setHostName("h1");
HostComponentStateEntity entity =
hostComponentStateDAO.findByPK(primaryKey);
Collection<HostComponentConfigMappingEntity> entities =
entity.getHostComponentConfigMappingEntities();
Assert.assertEquals(0, entities.size());
impl.setConfigs(oldConfigs);
impl.persist();
Assert.assertEquals(3, impl.getConfigVersions().size());
entity = hostComponentStateDAO.findByPK(primaryKey);
entities = entity.getHostComponentConfigMappingEntities();
Assert.assertEquals(3, entities.size());
Map<String, String> newConfigs = new HashMap<String, String>();
newConfigs.put("type1", "v1");
newConfigs.put("type2", "v3");
newConfigs.put("type4", "v5");
ServiceComponentHostStartEvent startEvent =
new ServiceComponentHostStartEvent("DATANODE", "h1", 1, newConfigs);
impl.handleEvent(startEvent);
Assert.assertEquals(newConfigs.size(),
impl.getConfigVersions().size());
entity = hostComponentStateDAO.findByPK(primaryKey);
entities = entity.getHostComponentConfigMappingEntities();
Assert.assertEquals(3, entities.size());
for (HostComponentConfigMappingEntity e : entities) {
LOG.debug("Found live config "
+ e.getConfigType() + ":" + e.getVersionTag());