ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [2/8] ambari git commit: Merge branch 'branch-feature-AMBARI-18456' into trunk
Date Wed, 19 Oct 2016 19:06:06 GMT
http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
index 84f8124..f99b5ff 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
@@ -18,6 +18,31 @@
 
 package org.apache.ambari.server.controller.internal;
 
+import static org.easymock.EasyMock.anyBoolean;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isNull;
+import static org.easymock.EasyMock.newCapture;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+import java.lang.reflect.Field;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.RoleCommand;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
@@ -57,31 +82,6 @@ import org.junit.Test;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
 
-import java.lang.reflect.Field;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.easymock.EasyMock.anyBoolean;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.isNull;
-import static org.easymock.EasyMock.newCapture;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
 /**
  * ServiceResourceProvider tests.
  */
@@ -117,9 +117,8 @@ public class ServiceResourceProviderTest {
 
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
     expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo);
-    expect(managementController.getServiceFactory()).andReturn(serviceFactory);
 
-    expect(serviceFactory.createNew(cluster, "Service100")).andReturn(service);
+    expect(cluster.addService("Service100")).andReturn(service);
 
     expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
 
@@ -202,7 +201,6 @@ public class ServiceResourceProviderTest {
     // set expectations
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
     expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
-    expect(managementController.getServiceFactory()).andReturn(serviceFactory).anyTimes();
     expect(managementController.getHostComponents(EasyMock.<Set<ServiceComponentHostRequest>>anyObject())).
         andReturn(Collections.<ServiceComponentHostResponse>emptySet()).anyTimes();
 
@@ -321,7 +319,6 @@ public class ServiceResourceProviderTest {
     // set expectations
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
     expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
-    expect(managementController.getServiceFactory()).andReturn(serviceFactory).anyTimes();
     expect(managementController.getHostComponents(EasyMock.<Set<ServiceComponentHostRequest>>anyObject())).
         andReturn(Collections.<ServiceComponentHostResponse>emptySet()).anyTimes();
 
@@ -390,7 +387,6 @@ public class ServiceResourceProviderTest {
     // set expectations
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
     expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
-    expect(managementController.getServiceFactory()).andReturn(serviceFactory).anyTimes();
     expect(managementController.getHostComponents(EasyMock.<Set<ServiceComponentHostRequest>>anyObject())).
         andReturn(Collections.<ServiceComponentHostResponse>emptySet()).anyTimes();
 
@@ -458,7 +454,6 @@ public class ServiceResourceProviderTest {
     // set expectations
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
     expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
-    expect(managementController.getServiceFactory()).andReturn(serviceFactory).anyTimes();
     expect(managementController.getHostComponents(EasyMock.<Set<ServiceComponentHostRequest>>anyObject())).
         andReturn(Collections.<ServiceComponentHostResponse>emptySet()).anyTimes();
 
@@ -528,7 +523,6 @@ public class ServiceResourceProviderTest {
     // set expectations
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
     expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
-    expect(managementController.getServiceFactory()).andReturn(serviceFactory).anyTimes();
     expect(managementController.getHostComponents((Set<ServiceComponentHostRequest>) anyObject())).
         andReturn(Collections.<ServiceComponentHostResponse>emptySet()).anyTimes();
 
@@ -612,7 +606,6 @@ public class ServiceResourceProviderTest {
     // set expectations
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
     expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
-    expect(managementController.getServiceFactory()).andReturn(serviceFactory).anyTimes();
 
     expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
 
@@ -824,7 +817,7 @@ public class ServiceResourceProviderTest {
     Clusters clusters = createNiceMock(Clusters.class);
     Cluster cluster = createNiceMock(Cluster.class);
     Service service = createNiceMock(Service.class);
-    
+
     String serviceName = "Service100";
 
     // set expectations
@@ -912,7 +905,7 @@ public class ServiceResourceProviderTest {
 
     // verify
     verify(managementController, clusters, cluster, service);
-  }  
+  }
 
   @Test
   public void testDeleteResourcesBadComponentState() throws Exception{

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java
index 2721731..958957b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java
@@ -146,7 +146,6 @@ public class StackDefinedPropertyProviderTest {
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "6.3");
     host.setHostAttributes(hostAttributes);
-    host.persist();
 
     clusters.mapHostToCluster("h1", "c2");
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java
index 139702c..96810cf 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java
@@ -174,14 +174,12 @@ public class UpgradeResourceProviderHDP22Test {
     hostAttributes.put("os_release_version", "6.3");
     host.setHostAttributes(hostAttributes);
     host.setState(HostState.HEALTHY);
-    host.persist();
 
     clusters.mapHostToCluster("h1", "c1");
 
     // add a single HIVE server
     Service service = cluster.addService("HIVE");
     service.setDesiredStackVersion(cluster.getDesiredStackVersion());
-    service.persist();
 
     ServiceComponent component = service.addServiceComponent("HIVE_SERVER");
     ServiceComponentHost sch = component.addServiceComponentHost("h1");

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
index 63892cf..0649191 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
@@ -232,14 +232,12 @@ public class UpgradeResourceProviderTest {
     hostAttributes.put("os_release_version", "6.3");
     host.setHostAttributes(hostAttributes);
     host.setState(HostState.HEALTHY);
-    host.persist();
 
     clusters.mapHostToCluster("h1", "c1");
 
     // add a single ZK server
     Service service = cluster.addService("ZOOKEEPER");
     service.setDesiredStackVersion(cluster.getDesiredStackVersion());
-    service.persist();
 
     ServiceComponent component = service.addServiceComponent("ZOOKEEPER_SERVER");
     ServiceComponentHost sch = component.addServiceComponentHost("h1");
@@ -590,7 +588,6 @@ public class UpgradeResourceProviderTest {
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "6.3");
     host.setHostAttributes(hostAttributes);
-    host.persist();
 
     clusters.mapHostToCluster("h2", "c1");
     Cluster cluster = clusters.getCluster("c1");
@@ -736,7 +733,6 @@ public class UpgradeResourceProviderTest {
     // add additional service for the test
     Service service = cluster.addService("HIVE");
     service.setDesiredStackVersion(cluster.getDesiredStackVersion());
-    service.persist();
 
     ServiceComponent component = service.addServiceComponent("HIVE_SERVER");
     ServiceComponentHost sch = component.addServiceComponentHost("h1");

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java
index eccc1ed..baec7df 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java
@@ -17,15 +17,21 @@
  */
 package org.apache.ambari.server.controller.internal;
 
-import com.google.inject.Binder;
-import com.google.inject.Guice;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-import com.google.inject.persist.PersistService;
-import com.google.inject.persist.Transactional;
-import com.google.inject.util.Modules;
-import junit.framework.Assert;
+import static org.easymock.EasyMock.anyLong;
+import static org.easymock.EasyMock.anyString;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.Role;
 import org.apache.ambari.server.RoleCommand;
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
@@ -74,20 +80,16 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
+import com.google.inject.Binder;
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.persist.PersistService;
+import com.google.inject.persist.Transactional;
+import com.google.inject.util.Modules;
 
-import static org.easymock.EasyMock.anyLong;
-import static org.easymock.EasyMock.anyString;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import junit.framework.Assert;
 
 /**
  * UpgradeSummaryResourceProvider tests.
@@ -170,14 +172,12 @@ public class UpgradeSummaryResourceProviderTest {
     hostAttributes.put("os_release_version", "6.4");
     host.setHostAttributes(hostAttributes);
     host.setState(HostState.HEALTHY);
-    host.persist();
 
     clusters.mapHostToCluster("h1", "c1");
 
     // add a single ZOOKEEPER server
     Service service = cluster.addService("ZOOKEEPER");
     service.setDesiredStackVersion(cluster.getDesiredStackVersion());
-    service.persist();
 
     ServiceComponent component = service.addServiceComponent("ZOOKEEPER_SERVER");
     ServiceComponentHost sch = component.addServiceComponentHost("h1");

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/DefaultServiceCalculatedStateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/DefaultServiceCalculatedStateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/DefaultServiceCalculatedStateTest.java
index 0d7fc67..3b2460a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/DefaultServiceCalculatedStateTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/DefaultServiceCalculatedStateTest.java
@@ -19,14 +19,15 @@
 package org.apache.ambari.server.controller.utilities.state;
 
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.State;
 import org.junit.Assert;
-import java.util.HashMap;
-import java.util.Map;
 
 public final class DefaultServiceCalculatedStateTest extends GeneralServiceCalculatedStateTest {
 
@@ -54,7 +55,6 @@ public final class DefaultServiceCalculatedStateTest extends GeneralServiceCalcu
       hostAttributes.put("os_release_version", "6.3");
       host.setHostAttributes(hostAttributes);
       host.setState(HostState.HEALTHY);
-      host.persist();
       clusters.mapHostToCluster(hostName, clusterName);
 
       ServiceComponentHost sch = masterComponent.addServiceComponentHost(hostName);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/FlumeServiceCalculatedStateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/FlumeServiceCalculatedStateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/FlumeServiceCalculatedStateTest.java
index 1bc4214..fccc5e7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/FlumeServiceCalculatedStateTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/FlumeServiceCalculatedStateTest.java
@@ -18,6 +18,9 @@
 
 package org.apache.ambari.server.controller.utilities.state;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.ServiceComponent;
@@ -25,9 +28,6 @@ import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.State;
 import org.junit.Assert;
 
-import java.util.HashMap;
-import java.util.Map;
-
 public class FlumeServiceCalculatedStateTest extends GeneralServiceCalculatedStateTest{
   @Override
   protected String getServiceName() {
@@ -53,7 +53,6 @@ public class FlumeServiceCalculatedStateTest extends GeneralServiceCalculatedSta
       hostAttributes.put("os_release_version", "6.3");
       host.setHostAttributes(hostAttributes);
       host.setState(HostState.HEALTHY);
-      host.persist();
       clusters.mapHostToCluster(hostName, clusterName);
 
       ServiceComponentHost sch = masterComponent.addServiceComponentHost(hostName);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/GeneralServiceCalculatedStateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/GeneralServiceCalculatedStateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/GeneralServiceCalculatedStateTest.java
index 710c723..6374be0 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/GeneralServiceCalculatedStateTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/GeneralServiceCalculatedStateTest.java
@@ -18,30 +18,32 @@
 
 package org.apache.ambari.server.controller.utilities.state;
 
-  import com.google.inject.Binder;
-  import com.google.inject.Guice;
-  import com.google.inject.Inject;
-  import com.google.inject.Injector;
-  import com.google.inject.Module;
-  import com.google.inject.persist.PersistService;
-  import com.google.inject.util.Modules;
-  import org.apache.ambari.server.actionmanager.ActionManager;
-  import org.apache.ambari.server.orm.GuiceJpaInitializer;
-  import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
-  import org.apache.ambari.server.state.Cluster;
-  import org.apache.ambari.server.state.Clusters;
-  import org.apache.ambari.server.state.Service;
-  import org.apache.ambari.server.state.ServiceComponent;
-  import org.apache.ambari.server.state.ServiceComponentHost;
-  import org.apache.ambari.server.state.StackId;
-  import org.apache.ambari.server.state.State;
-  import org.apache.ambari.server.topology.TopologyManager;
-  import org.apache.ambari.server.utils.StageUtils;
-  import org.junit.After;
-  import org.junit.Before;
-  import org.junit.Test;
   import java.util.Map;
 
+import org.apache.ambari.server.actionmanager.ActionManager;
+import org.apache.ambari.server.orm.GuiceJpaInitializer;
+import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.ServiceComponent;
+import org.apache.ambari.server.state.ServiceComponentHost;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.State;
+import org.apache.ambari.server.topology.TopologyManager;
+import org.apache.ambari.server.utils.StageUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.inject.Binder;
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.persist.PersistService;
+import com.google.inject.util.Modules;
+
 public abstract class GeneralServiceCalculatedStateTest {
 
   final protected String[] hosts = {"h1", "h2"};
@@ -76,7 +78,6 @@ public abstract class GeneralServiceCalculatedStateTest {
 
     service = cluster.addService(getServiceName());
     service.setDesiredStackVersion(cluster.getDesiredStackVersion());
-    service.persist();
 
     createComponentsAndHosts();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HBaseServiceCalculatedStateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HBaseServiceCalculatedStateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HBaseServiceCalculatedStateTest.java
index 35a7b67..378f51e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HBaseServiceCalculatedStateTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HBaseServiceCalculatedStateTest.java
@@ -18,6 +18,9 @@
 
 package org.apache.ambari.server.controller.utilities.state;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.ServiceComponent;
@@ -25,9 +28,6 @@ import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.State;
 import org.junit.Assert;
 
-import java.util.HashMap;
-import java.util.Map;
-
 public class HBaseServiceCalculatedStateTest extends GeneralServiceCalculatedStateTest{
   @Override
   protected String getServiceName() {
@@ -54,7 +54,6 @@ public class HBaseServiceCalculatedStateTest extends GeneralServiceCalculatedSta
       hostAttributes.put("os_release_version", "6.3");
       host.setHostAttributes(hostAttributes);
       host.setState(HostState.HEALTHY);
-      host.persist();
       clusters.mapHostToCluster(hostName, clusterName);
 
       ServiceComponentHost sch = clientComponent.addServiceComponentHost(hostName);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HDFSServiceCalculatedStateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HDFSServiceCalculatedStateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HDFSServiceCalculatedStateTest.java
index a562962..99c90cf 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HDFSServiceCalculatedStateTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HDFSServiceCalculatedStateTest.java
@@ -19,6 +19,9 @@
 package org.apache.ambari.server.controller.utilities.state;
 
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.ServiceComponent;
@@ -26,9 +29,6 @@ import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.State;
 import org.junit.Assert;
 
-import java.util.HashMap;
-import java.util.Map;
-
 public class HDFSServiceCalculatedStateTest extends GeneralServiceCalculatedStateTest{
   @Override
   protected String getServiceName() {
@@ -55,7 +55,6 @@ public class HDFSServiceCalculatedStateTest extends GeneralServiceCalculatedStat
       hostAttributes.put("os_release_version", "6.3");
       host.setHostAttributes(hostAttributes);
       host.setState(HostState.HEALTHY);
-      host.persist();
       clusters.mapHostToCluster(hostName, clusterName);
 
       ServiceComponentHost sch = masterComponent.addServiceComponentHost(hostName);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HiveServiceCalculatedStateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HiveServiceCalculatedStateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HiveServiceCalculatedStateTest.java
index ddf1503..2c4dec6 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HiveServiceCalculatedStateTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HiveServiceCalculatedStateTest.java
@@ -19,6 +19,9 @@
 package org.apache.ambari.server.controller.utilities.state;
 
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.ServiceComponent;
@@ -26,9 +29,6 @@ import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.State;
 import org.junit.Assert;
 
-import java.util.HashMap;
-import java.util.Map;
-
 public class HiveServiceCalculatedStateTest extends GeneralServiceCalculatedStateTest{
   @Override
   protected String getServiceName() {
@@ -57,7 +57,6 @@ public class HiveServiceCalculatedStateTest extends GeneralServiceCalculatedStat
       hostAttributes.put("os_release_version", "6.3");
       host.setHostAttributes(hostAttributes);
       host.setState(HostState.HEALTHY);
-      host.persist();
       clusters.mapHostToCluster(hostName, clusterName);
 
       ServiceComponentHost sch = clientComponent.addServiceComponentHost(hostName);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/OozieServiceCalculatedStateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/OozieServiceCalculatedStateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/OozieServiceCalculatedStateTest.java
index 7e1595e..f6bc2cb 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/OozieServiceCalculatedStateTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/OozieServiceCalculatedStateTest.java
@@ -18,6 +18,9 @@
 
 package org.apache.ambari.server.controller.utilities.state;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.ServiceComponent;
@@ -25,9 +28,6 @@ import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.State;
 import org.junit.Assert;
 
-import java.util.HashMap;
-import java.util.Map;
-
 public class OozieServiceCalculatedStateTest extends GeneralServiceCalculatedStateTest{
   @Override
   protected String getServiceName() {
@@ -53,7 +53,6 @@ public class OozieServiceCalculatedStateTest extends GeneralServiceCalculatedSta
       hostAttributes.put("os_release_version", "6.3");
       host.setHostAttributes(hostAttributes);
       host.setState(HostState.HEALTHY);
-      host.persist();
       clusters.mapHostToCluster(hostName, clusterName);
 
       ServiceComponentHost sch = clientComponent.addServiceComponentHost(hostName);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/YarnServiceCalculatedStateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/YarnServiceCalculatedStateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/YarnServiceCalculatedStateTest.java
index b5cce0e..996ce69 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/YarnServiceCalculatedStateTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/YarnServiceCalculatedStateTest.java
@@ -19,6 +19,9 @@
 package org.apache.ambari.server.controller.utilities.state;
 
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.ServiceComponent;
@@ -26,9 +29,6 @@ import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.State;
 import org.junit.Assert;
 
-import java.util.HashMap;
-import java.util.Map;
-
 public class YarnServiceCalculatedStateTest extends GeneralServiceCalculatedStateTest {
   @Override
   protected String getServiceName() {
@@ -55,7 +55,6 @@ public class YarnServiceCalculatedStateTest extends GeneralServiceCalculatedStat
       hostAttributes.put("os_release_version", "6.3");
       host.setHostAttributes(hostAttributes);
       host.setState(HostState.HEALTHY);
-      host.persist();
       clusters.mapHostToCluster(hostName, clusterName);
 
       ServiceComponentHost sch = secondMasterComponent.addServiceComponentHost(hostName);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/events/EventsTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/events/EventsTest.java b/ambari-server/src/test/java/org/apache/ambari/server/events/EventsTest.java
index ce86f83..79d5569 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/events/EventsTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/events/EventsTest.java
@@ -110,7 +110,6 @@ public class EventsTest {
     hostAttributes.put("os_release_version", "6.4");
     host.setHostAttributes(hostAttributes);
     host.setState(HostState.HEALTHY);
-    host.persist();
 
     m_cluster = m_clusters.getCluster(m_clusterName);
     Assert.assertNotNull(m_cluster);
@@ -382,14 +381,12 @@ public class EventsTest {
   private void installHdfsService() throws Exception {
     String serviceName = "HDFS";
     Service service = m_serviceFactory.createNew(m_cluster, serviceName);
-    service.persist();
     service = m_cluster.getService(serviceName);
     Assert.assertNotNull(service);
 
     ServiceComponent component = m_componentFactory.createNew(service, "DATANODE");
     service.addServiceComponent(component);
     component.setDesiredState(State.INSTALLED);
-    component.persist();
 
     ServiceComponentHost sch = m_schFactory.createNew(component, HOSTNAME);
 
@@ -398,7 +395,5 @@ public class EventsTest {
     sch.setState(State.INSTALLED);
     sch.setDesiredStackVersion(new StackId("HDP-2.0.6"));
     sch.setStackVersion(new StackId("HDP-2.0.6"));
-
-    sch.persist();
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java
index 9135732..9a5802d 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java
@@ -387,7 +387,6 @@ public class HostVersionOutOfSyncListenerTest {
     addHost("h2");
     clusters.mapHostToCluster("h2", "c1");
     clusters.getHost("h2").setState(HostState.HEALTHY);
-    clusters.getHost("h2").persist();
 
     StackId stackId = new StackId(this.stackId);
     RepositoryVersionEntity repositoryVersionEntity = helper.getOrCreateRepositoryVersion(stackId,
@@ -445,8 +444,6 @@ public class HostVersionOutOfSyncListenerTest {
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "6.4");
     host1.setHostAttributes(hostAttributes);
-
-    host1.persist();
   }
 
   private void addService(Cluster cl, List<String> hostList,

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
index de2d292..15e81c5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
@@ -18,12 +18,11 @@
 
 package org.apache.ambari.server.orm;
 
-import javax.persistence.EntityManager;
-import junit.framework.Assert;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.lang.reflect.Method;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -35,6 +34,8 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
+import javax.persistence.EntityManager;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.Role;
 import org.apache.ambari.server.RoleCommand;
@@ -88,6 +89,7 @@ import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.State;
 import org.apache.ambari.server.state.alert.Scope;
 import org.apache.ambari.server.state.alert.SourceType;
+import org.apache.ambari.server.state.cluster.ClustersImpl;
 import org.springframework.security.crypto.password.PasswordEncoder;
 
 import com.google.inject.Inject;
@@ -96,6 +98,8 @@ import com.google.inject.Provider;
 import com.google.inject.Singleton;
 import com.google.inject.persist.Transactional;
 
+import junit.framework.Assert;
+
 @Singleton
 public class OrmTestHelper {
 
@@ -308,7 +312,7 @@ public class OrmTestHelper {
    * @return the cluster ID.
    */
   @Transactional
-  public Long createCluster() {
+  public Long createCluster() throws Exception {
     return createCluster(CLUSTER_NAME);
   }
 
@@ -318,7 +322,7 @@ public class OrmTestHelper {
    * @return the cluster ID.
    */
   @Transactional
-  public Long createCluster(String clusterName) {
+  public Long createCluster(String clusterName) throws Exception {
     // required to populate the database with stacks
     injector.getInstance(AmbariMetaInfo.class);
 
@@ -354,6 +358,15 @@ public class OrmTestHelper {
     clusterEntity = clusterDAO.findByName(clusterEntity.getClusterName());
     assertNotNull(clusterEntity);
     assertTrue(clusterEntity.getClusterId() > 0);
+
+    // because this test method goes around the Clusters business object, we
+    // forcefully will refresh the internal state so that any tests which
+    // incorrect use Clusters after calling this won't be affected
+    Clusters clusters = injector.getInstance(Clusters.class);
+    Method method = ClustersImpl.class.getDeclaredMethod("loadClustersAndHosts");
+    method.setAccessible(true);
+    method.invoke(clusters);
+
     return clusterEntity.getClusterId();
   }
 
@@ -397,7 +410,6 @@ public class OrmTestHelper {
     hostAttributes.put("os_release_version", "6.4");
     host.setHostAttributes(hostAttributes);
     host.setState(HostState.HEALTHY);
-    host.persist();
 
     clusters.mapHostToCluster(hostName, cluster.getClusterName());
   }
@@ -407,7 +419,6 @@ public class OrmTestHelper {
     ServiceComponent serviceComponent = service.getServiceComponent(componentName);
     ServiceComponentHost serviceComponentHost = serviceComponent.addServiceComponentHost(hostName);
     serviceComponentHost.setDesiredState(State.INSTALLED);
-    serviceComponentHost.persist();
   }
 
   /**
@@ -419,7 +430,6 @@ public class OrmTestHelper {
       ServiceComponentHostFactory schFactory, String hostName) throws Exception {
     String serviceName = "HDFS";
     Service service = serviceFactory.createNew(cluster, serviceName);
-    service.persist();
     service = cluster.getService(serviceName);
     assertNotNull(service);
 
@@ -427,7 +437,6 @@ public class OrmTestHelper {
 
     service.addServiceComponent(datanode);
     datanode.setDesiredState(State.INSTALLED);
-    datanode.persist();
 
     ServiceComponentHost sch = schFactory.createNew(datanode, hostName);
 
@@ -437,13 +446,10 @@ public class OrmTestHelper {
     sch.setDesiredStackVersion(new StackId("HDP-2.0.6"));
     sch.setStackVersion(new StackId("HDP-2.0.6"));
 
-    sch.persist();
-
     ServiceComponent namenode = componentFactory.createNew(service, "NAMENODE");
 
     service.addServiceComponent(namenode);
     namenode.setDesiredState(State.INSTALLED);
-    namenode.persist();
 
     sch = schFactory.createNew(namenode, hostName);
     namenode.addServiceComponentHost(sch);
@@ -451,8 +457,6 @@ public class OrmTestHelper {
     sch.setState(State.INSTALLED);
     sch.setDesiredStackVersion(new StackId("HDP-2.0.6"));
     sch.setStackVersion(new StackId("HDP-2.0.6"));
-
-    sch.persist();
   }
 
   /**
@@ -464,7 +468,6 @@ public class OrmTestHelper {
       ServiceComponentHostFactory schFactory, String hostName) throws Exception {
     String serviceName = "YARN";
     Service service = serviceFactory.createNew(cluster, serviceName);
-    service.persist();
     service = cluster.getService(serviceName);
     assertNotNull(service);
 
@@ -473,7 +476,6 @@ public class OrmTestHelper {
 
     service.addServiceComponent(resourceManager);
     resourceManager.setDesiredState(State.INSTALLED);
-    resourceManager.persist();
 
     ServiceComponentHost sch = schFactory.createNew(resourceManager, hostName);
 
@@ -482,8 +484,6 @@ public class OrmTestHelper {
     sch.setState(State.INSTALLED);
     sch.setDesiredStackVersion(new StackId("HDP-2.0.6"));
     sch.setStackVersion(new StackId("HDP-2.0.6"));
-
-    sch.persist();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/ClusterVersionDAOTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/ClusterVersionDAOTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/ClusterVersionDAOTest.java
index 4edfdcb..2e0c232 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/ClusterVersionDAOTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/ClusterVersionDAOTest.java
@@ -73,7 +73,7 @@ public class ClusterVersionDAOTest {
    * Helper function to transition the cluster through several cluster versions.
    * @param currStep Step to go to is a value from 1 - 7, inclusive.
    */
-  private void createRecordsUntilStep(int currStep) {
+  private void createRecordsUntilStep(int currStep) throws Exception {
     // Fresh install on A
     if (currStep >= 1 && lastStep <= 0) {
       clusterId = helper.createCluster();
@@ -147,7 +147,7 @@ public class ClusterVersionDAOTest {
   }
 
   @Test
-  public void testFindByStackAndVersion() {
+  public void testFindByStackAndVersion() throws Exception {
     createRecordsUntilStep(1);
     Assert.assertEquals(
         0,
@@ -161,14 +161,14 @@ public class ClusterVersionDAOTest {
   }
 
   @Test
-  public void testFindByCluster() {
+  public void testFindByCluster() throws Exception {
     createRecordsUntilStep(1);
     Assert.assertEquals(0, clusterVersionDAO.findByCluster("non existing").size());
     Assert.assertEquals(1, clusterVersionDAO.findByCluster(cluster.getClusterName()).size());
   }
 
   @Test
-  public void testFindByClusterAndStackAndVersion() {
+  public void testFindByClusterAndStackAndVersion() throws Exception {
     createRecordsUntilStep(1);
     Assert.assertNull(clusterVersionDAO.findByClusterAndStackAndVersion(
         cluster.getClusterName(), BAD_STACK, "non existing"));
@@ -181,7 +181,7 @@ public class ClusterVersionDAOTest {
    * At all times the cluster should have a cluster version whose state is {@link org.apache.ambari.server.state.RepositoryVersionState#CURRENT}
    */
   @Test
-  public void testFindByClusterAndStateCurrent() {
+  public void testFindByClusterAndStateCurrent() throws Exception {
     createRecordsUntilStep(1);
     Assert.assertNotNull(clusterVersionDAO.findByClusterAndStateCurrent(cluster.getClusterName()));
 
@@ -208,7 +208,7 @@ public class ClusterVersionDAOTest {
    * Test the state of certain cluster versions.
    */
   @Test
-  public void testFindByClusterAndState() {
+  public void testFindByClusterAndState() throws Exception {
     createRecordsUntilStep(1);
     Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.CURRENT).size());
     Assert.assertEquals(0, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLED).size());

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/ConfigGroupDAOTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/ConfigGroupDAOTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/ConfigGroupDAOTest.java
index 33e2636..c73843f 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/ConfigGroupDAOTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/ConfigGroupDAOTest.java
@@ -22,9 +22,6 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
 
-import com.google.inject.assistedinject.AssistedInject;
-import junit.framework.Assert;
-
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
@@ -36,10 +33,9 @@ import org.apache.ambari.server.orm.entities.ConfigGroupConfigMappingEntity;
 import org.apache.ambari.server.orm.entities.ConfigGroupEntity;
 import org.apache.ambari.server.orm.entities.ConfigGroupHostMappingEntity;
 import org.apache.ambari.server.orm.entities.HostEntity;
-import org.apache.ambari.server.orm.entities.ResourceEntity;
-import org.apache.ambari.server.orm.entities.ResourceTypeEntity;
 import org.apache.ambari.server.orm.entities.StackEntity;
-import org.apache.ambari.server.security.authorization.ResourceType;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.host.HostFactory;
 import org.junit.After;
 import org.junit.Before;
@@ -49,6 +45,8 @@ import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
 
+import junit.framework.Assert;
+
 public class ConfigGroupDAOTest {
   private Injector injector;
   private ConfigGroupDAO configGroupDAO;
@@ -88,28 +86,13 @@ public class ConfigGroupDAOTest {
   private ConfigGroupEntity createConfigGroup(String clusterName,
          String groupName, String tag, String desc, List<HostEntity> hosts,
          List<ClusterConfigEntity> configs) throws Exception {
-    ConfigGroupEntity configGroupEntity = new ConfigGroupEntity();
-
-    // create an admin resource to represent this cluster
-    ResourceTypeEntity resourceTypeEntity = resourceTypeDAO.findById(ResourceType.CLUSTER.getId());
-    if (resourceTypeEntity == null) {
-      resourceTypeEntity = new ResourceTypeEntity();
-      resourceTypeEntity.setId(ResourceType.CLUSTER.getId());
-      resourceTypeEntity.setName(ResourceType.CLUSTER.name());
-      resourceTypeEntity = resourceTypeDAO.merge(resourceTypeEntity);
-    }
-
+    Clusters clusters = injector.getInstance(Clusters.class);
     StackEntity stackEntity = stackDAO.find("HDP", "0.1");
 
-    ResourceEntity resourceEntity = new ResourceEntity();
-    resourceEntity.setResourceType(resourceTypeEntity);
+    clusters.addCluster(clusterName, new StackId(stackEntity));
+    ClusterEntity clusterEntity = clusterDAO.findByName(clusterName);
 
-    ClusterEntity clusterEntity = new ClusterEntity();
-    clusterEntity.setClusterName(clusterName);
-    clusterEntity.setResource(resourceEntity);
-    clusterEntity.setDesiredStack(stackEntity);
-
-    clusterDAO.create(clusterEntity);
+    ConfigGroupEntity configGroupEntity = new ConfigGroupEntity();
 
     configGroupEntity.setClusterEntity(clusterEntity);
     configGroupEntity.setClusterId(clusterEntity.getClusterId());

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostComponentDesiredStateDAOTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostComponentDesiredStateDAOTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostComponentDesiredStateDAOTest.java
index 28adb8c..f993bec 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostComponentDesiredStateDAOTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostComponentDesiredStateDAOTest.java
@@ -18,22 +18,19 @@
 
 package org.apache.ambari.server.orm.dao;
 
-import com.google.inject.Provider;
-import junit.framework.Assert;
-import org.apache.ambari.server.orm.entities.HostComponentDesiredStateEntity;
-import org.apache.ambari.server.orm.entities.HostEntity;
-import org.junit.Test;
-
-import javax.persistence.EntityManager;
-
-import java.util.Collection;
-import java.util.HashSet;
-
 import static org.easymock.EasyMock.createNiceMock;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
 
+import javax.persistence.EntityManager;
+
+import org.apache.ambari.server.orm.entities.HostComponentDesiredStateEntity;
+import org.apache.ambari.server.orm.entities.HostEntity;
+import org.junit.Test;
+
+import com.google.inject.Provider;
+
 /**
  * HostComponentDesiredStateDAO tests.
  */
@@ -46,19 +43,17 @@ public class HostComponentDesiredStateDAOTest {
     EntityManager entityManager = createNiceMock(EntityManager.class);
     HostDAO hostDAO = createNiceMock(HostDAO.class);
     HostEntity hostEntity = createNiceMock(HostEntity.class);
-    
+
     HostComponentDesiredStateEntity hostComponentDesiredStateEntity = createNiceMock(HostComponentDesiredStateEntity.class);
-    expect(hostComponentDesiredStateEntity.getHostId()).andReturn(1L).anyTimes();
     expect(entityManagerProvider.get()).andReturn(entityManager).anyTimes();
 
-    expect(entityManager.merge(hostComponentDesiredStateEntity)).andReturn(hostComponentDesiredStateEntity).anyTimes();
     entityManager.remove(hostComponentDesiredStateEntity);
 
     hostEntity.removeHostComponentDesiredStateEntity(hostComponentDesiredStateEntity);
 
-    expect(hostDAO.merge(hostEntity)).andReturn(hostEntity).anyTimes();
+    expect(hostDAO.merge(hostEntity)).andReturn(hostEntity).atLeastOnce();
 
-    expect(hostDAO.findById(1L)).andReturn(hostEntity).anyTimes();
+    expect(hostComponentDesiredStateEntity.getHostEntity()).andReturn(hostEntity).atLeastOnce();
 
     replay(entityManagerProvider, entityManager, hostDAO, hostEntity, hostComponentDesiredStateEntity);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostComponentStateDAOTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostComponentStateDAOTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostComponentStateDAOTest.java
index 7c7d0ce..5ea0b1e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostComponentStateDAOTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostComponentStateDAOTest.java
@@ -18,21 +18,19 @@
 
 package org.apache.ambari.server.orm.dao;
 
-import com.google.inject.Provider;
-import junit.framework.Assert;
-import org.apache.ambari.server.orm.entities.HostComponentStateEntity;
-import org.apache.ambari.server.orm.entities.HostEntity;
-import org.junit.Test;
-
-import javax.persistence.EntityManager;
-import java.util.Collection;
-import java.util.HashSet;
-
 import static org.easymock.EasyMock.createNiceMock;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
 
+import javax.persistence.EntityManager;
+
+import org.apache.ambari.server.orm.entities.HostComponentStateEntity;
+import org.apache.ambari.server.orm.entities.HostEntity;
+import org.junit.Test;
+
+import com.google.inject.Provider;
+
 /**
  * HostComponentStateDAO tests.
  */
@@ -48,22 +46,12 @@ public class HostComponentStateDAOTest {
 
     HostComponentStateEntity hostComponentStateEntity = createNiceMock(HostComponentStateEntity.class);
 
-    expect(hostComponentStateEntity.getHostName()).andReturn("host1");
-    expect(hostDAO.findByName("host1")).andReturn(hostEntity);
     expect(entityManagerProvider.get()).andReturn(entityManager).anyTimes();
 
-
-    expect(entityManager.merge(hostComponentStateEntity)).andReturn(hostComponentStateEntity).anyTimes();
     entityManager.remove(hostComponentStateEntity);
 
-
-    hostEntity.removeHostComponentStateEntity(hostComponentStateEntity);
-
-    expect(hostDAO.merge(hostEntity)).andReturn(hostEntity).anyTimes();
-
     replay(entityManagerProvider, entityManager, hostDAO, hostEntity, hostComponentStateEntity);
 
-
     HostComponentStateDAO dao = new HostComponentStateDAO();
     dao.entityManagerProvider = entityManagerProvider;
     dao.hostDAO = hostDAO;

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAOTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAOTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAOTest.java
index 9d390a9..1267f96 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAOTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/RepositoryVersionDAOTest.java
@@ -18,6 +18,8 @@
 
 package org.apache.ambari.server.orm.dao;
 
+import java.util.UUID;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
@@ -38,8 +40,6 @@ import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
 
-import java.util.UUID;
-
 /**
  * RepositoryVersionDAO unit tests.
  */
@@ -174,7 +174,7 @@ public class RepositoryVersionDAOTest {
   }
 
   @Test
-  public void testDeleteCascade() {
+  public void testDeleteCascade() throws Exception {
     long clusterId = helper.createCluster();
     ClusterEntity cluster = clusterDAO.findById(clusterId);
     createSingleRecord();

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/SettingDAOTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/SettingDAOTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/SettingDAOTest.java
index 77f87be..4029bae 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/SettingDAOTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/SettingDAOTest.java
@@ -17,8 +17,13 @@
  */
 package org.apache.ambari.server.orm.dao;
 
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.OrmTestHelper;
@@ -26,19 +31,15 @@ import org.apache.ambari.server.orm.entities.SettingEntity;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNull;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
 
 public class SettingDAOTest {
   private  Injector injector;
   private SettingDAO dao;
 
   @Before
-  public void setUp() {
+  public void setUp() throws Exception {
     injector = Guice.createInjector(new InMemoryDefaultTestModule());
     dao = injector.getInstance(SettingDAO.class);
     injector.getInstance(GuiceJpaInitializer.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/WidgetDAOTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/WidgetDAOTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/WidgetDAOTest.java
index 080558a..8be805a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/WidgetDAOTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/WidgetDAOTest.java
@@ -18,6 +18,9 @@
 
 package org.apache.ambari.server.orm.dao;
 
+import java.util.LinkedList;
+import java.util.List;
+
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.OrmTestHelper;
@@ -33,9 +36,6 @@ import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
 
-import java.util.LinkedList;
-import java.util.List;
-
 /**
  * WidgetDAO unit tests.
  */
@@ -49,7 +49,7 @@ public class WidgetDAOTest {
 
 
   @Before
-  public void before() {
+  public void before() throws Exception {
     injector = Guice.createInjector(new InMemoryDefaultTestModule());
     widgetDAO = injector.getInstance(WidgetDAO.class);
     widgetLayoutDAO = injector.getInstance(WidgetLayoutDAO.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/WidgetLayoutDAOTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/WidgetLayoutDAOTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/WidgetLayoutDAOTest.java
index 5b9ea6a..f50ae44 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/WidgetLayoutDAOTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/WidgetLayoutDAOTest.java
@@ -18,9 +18,9 @@
 
 package org.apache.ambari.server.orm.dao;
 
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.persist.PersistService;
+import java.util.LinkedList;
+import java.util.List;
+
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.OrmTestHelper;
@@ -32,8 +32,9 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.LinkedList;
-import java.util.List;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.persist.PersistService;
 
 /**
  * WidgetLayoutDAO unit tests.
@@ -48,7 +49,7 @@ public class WidgetLayoutDAOTest {
 
 
   @Before
-  public void before() {
+  public void before() throws Exception {
     injector = Guice.createInjector(new InMemoryDefaultTestModule());
     widgetLayoutDAO = injector.getInstance(WidgetLayoutDAO.class);
     widgetDAO = injector.getInstance(WidgetDAO.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
index 207b4c7..0163024 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
@@ -152,7 +152,6 @@ public class ComponentVersionCheckActionTest {
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "6");
     host.setHostAttributes(hostAttributes);
-    host.persist();
 
     // Create the starting repo version
     m_helper.getOrCreateRepositoryVersion(sourceStack, sourceRepo);
@@ -208,7 +207,6 @@ public class ComponentVersionCheckActionTest {
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "6");
     host.setHostAttributes(hostAttributes);
-    host.persist();
 
     clusters.mapHostToCluster(hostName, clusterName);
 
@@ -365,7 +363,6 @@ public class ComponentVersionCheckActionTest {
     sch.setDesiredStackVersion(cluster.getDesiredStackVersion());
     sch.setStackVersion(cluster.getCurrentStackVersion());
 
-    sch.persist();
     return sch;
   }
 
@@ -377,7 +374,6 @@ public class ComponentVersionCheckActionTest {
     } catch (ServiceNotFoundException e) {
       service = serviceFactory.createNew(cluster, serviceName);
       cluster.addService(service);
-      service.persist();
     }
 
     return service;
@@ -392,7 +388,6 @@ public class ComponentVersionCheckActionTest {
       serviceComponent = serviceComponentFactory.createNew(service, componentName);
       service.addServiceComponent(serviceComponent);
       serviceComponent.setDesiredState(State.INSTALLED);
-      serviceComponent.persist();
     }
 
     return serviceComponent;

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java
index 5462f7b..7ab2856 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java
@@ -1694,7 +1694,6 @@ public class ConfigureActionTest {
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "6");
     host.setHostAttributes(hostAttributes);
-    host.persist();
 
     // Creating starting repo
     m_helper.getOrCreateRepositoryVersion(HDP_220_STACK, HDP_2_2_0_0);
@@ -1742,7 +1741,6 @@ public class ConfigureActionTest {
     } catch (ServiceNotFoundException e) {
       service = serviceFactory.createNew(cluster, serviceName);
       cluster.addService(service);
-      service.persist();
     }
 
     return service;

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
index 50ce7b4..8f9d4f4 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
@@ -191,7 +191,6 @@ public class UpgradeActionTest {
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "6");
     host.setHostAttributes(hostAttributes);
-    host.persist();
 
     // Create the starting repo version
     m_helper.getOrCreateRepositoryVersion(sourceStack, sourceRepo);
@@ -229,7 +228,6 @@ public class UpgradeActionTest {
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "6");
     host.setHostAttributes(hostAttributes);
-    host.persist();
 
     // Create the starting repo version
     m_helper.getOrCreateRepositoryVersion(sourceStack, sourceRepo);
@@ -295,7 +293,6 @@ public class UpgradeActionTest {
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "6");
     host.setHostAttributes(hostAttributes);
-    host.persist();
 
     // without this, HostEntity will not have a relation to ClusterEntity
     clusters.mapHostsToCluster(Collections.singleton(hostName), clusterName);
@@ -376,7 +373,6 @@ public class UpgradeActionTest {
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "6");
     host.setHostAttributes(hostAttributes);
-    host.persist();
 
     clusters.mapHostToCluster(hostName, clusterName);
 
@@ -1011,8 +1007,6 @@ public class UpgradeActionTest {
     sch.setState(State.INSTALLED);
     sch.setDesiredStackVersion(cluster.getDesiredStackVersion());
     sch.setStackVersion(cluster.getCurrentStackVersion());
-
-    sch.persist();
     return sch;
   }
 
@@ -1024,7 +1018,6 @@ public class UpgradeActionTest {
     } catch (ServiceNotFoundException e) {
       service = serviceFactory.createNew(cluster, serviceName);
       cluster.addService(service);
-      service.persist();
     }
 
     return service;
@@ -1039,7 +1032,6 @@ public class UpgradeActionTest {
       serviceComponent = serviceComponentFactory.createNew(service, componentName);
       service.addServiceComponent(serviceComponent);
       serviceComponent.setDesiredState(State.INSTALLED);
-      serviceComponent.persist();
     }
 
     return serviceComponent;

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigGroupTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigGroupTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigGroupTest.java
index 02ce9fb..80665a5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigGroupTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigGroupTest.java
@@ -21,16 +21,11 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
-import com.google.inject.persist.jpa.AmbariJpaPersistModule;
-import junit.framework.Assert;
-
 import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.dao.ConfigGroupDAO;
 import org.apache.ambari.server.orm.dao.ConfigGroupHostMappingDAO;
-import org.apache.ambari.server.orm.dao.HostDAO;
 import org.apache.ambari.server.orm.entities.ConfigGroupConfigMappingEntity;
 import org.apache.ambari.server.orm.entities.ConfigGroupEntity;
 import org.apache.ambari.server.orm.entities.ConfigGroupHostMappingEntity;
@@ -45,6 +40,8 @@ import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
 import com.google.inject.persist.Transactional;
 
+import junit.framework.Assert;
+
 public class ConfigGroupTest {
 
   private Clusters clusters;
@@ -75,8 +72,6 @@ public class ConfigGroupTest {
     clusters.addHost("h2");
     Assert.assertNotNull(clusters.getHost("h1"));
     Assert.assertNotNull(clusters.getHost("h2"));
-    clusters.getHost("h1").persist();
-    clusters.getHost("h2").persist();
   }
 
   @After
@@ -109,6 +104,7 @@ public class ConfigGroupTest {
       "HDFS", "New HDFS configs for h1", configs, hosts);
 
     configGroup.persist();
+    cluster.addConfigGroup(configGroup);
     return configGroup;
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
index d014bde..d50c92d 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
@@ -23,7 +23,6 @@ import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
 
-import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -32,11 +31,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Random;
 import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
 
 import javax.persistence.EntityManager;
 
@@ -57,12 +52,10 @@ import org.apache.ambari.server.security.SecurityHelper;
 import org.apache.ambari.server.security.TestAuthenticationFactory;
 import org.apache.ambari.server.stack.StackManagerFactory;
 import org.apache.ambari.server.state.cluster.ClusterFactory;
-import org.apache.ambari.server.state.cluster.ClustersImpl;
 import org.apache.ambari.server.state.configgroup.ConfigGroup;
 import org.apache.ambari.server.state.configgroup.ConfigGroupFactory;
 import org.apache.ambari.server.state.host.HostFactory;
 import org.apache.ambari.server.state.stack.OsFamily;
-import org.apache.ambari.server.utils.SynchronousThreadPoolExecutor;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -120,9 +113,6 @@ public class ConfigHelperTest {
       Assert.assertNotNull(clusters.getHost("h1"));
       Assert.assertNotNull(clusters.getHost("h2"));
       Assert.assertNotNull(clusters.getHost("h3"));
-      clusters.getHost("h1").persist();
-      clusters.getHost("h2").persist();
-      clusters.getHost("h3").persist();
 
       // core-site
       ConfigurationRequest cr = new ConfigurationRequest();
@@ -989,7 +979,7 @@ public class ConfigHelperTest {
           bind(AmbariManagementController.class).toInstance(createNiceMock(AmbariManagementController.class));
           bind(AmbariMetaInfo.class).toInstance(mockMetaInfo);
           bind(RequestFactory.class).toInstance(createNiceMock(RequestFactory.class));
-          bind(Clusters.class).toInstance(createNiceMock(ClustersImpl.class));
+          bind(Clusters.class).toInstance(createNiceMock(Clusters.class));
           bind(ClusterController.class).toInstance(clusterController);
           bind(StackManagerFactory.class).toInstance(createNiceMock(StackManagerFactory.class));
           bind(HostRoleCommandDAO.class).toInstance(createNiceMock(HostRoleCommandDAO.class));

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/state/RequestExecutionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/RequestExecutionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/RequestExecutionTest.java
index a5b0e5a5..31d3028 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/RequestExecutionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/RequestExecutionTest.java
@@ -21,8 +21,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import junit.framework.Assert;
-
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.RequestScheduleResponse;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
@@ -46,6 +44,8 @@ import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
 import com.google.inject.persist.Transactional;
 
+import junit.framework.Assert;
+
 public class RequestExecutionTest {
   private Injector injector;
   private Clusters clusters;
@@ -74,9 +74,6 @@ public class RequestExecutionTest {
     Assert.assertNotNull(clusters.getHost("h1"));
     Assert.assertNotNull(clusters.getHost("h2"));
     Assert.assertNotNull(clusters.getHost("h3"));
-    clusters.getHost("h1").persist();
-    clusters.getHost("h2").persist();
-    clusters.getHost("h3").persist();
   }
 
   @After
@@ -120,7 +117,7 @@ public class RequestExecutionTest {
     requestExecution.setDescription("Test Schedule");
 
     requestExecution.persist();
-
+    cluster.addRequestExecution(requestExecution);
     return requestExecution;
   }
 
@@ -270,8 +267,7 @@ public class RequestExecutionTest {
     Assert.assertNotNull(requestExecution);
 
     Long id = requestExecution.getId();
-
-    requestExecution.delete();
+    cluster.deleteRequestExecution(id);
 
     Assert.assertNull(requestScheduleDAO.findById(id));
     Assert.assertNull(cluster.getAllRequestExecutions().get(id));

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
index 0bf21f9..0cf7f09 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
@@ -103,7 +103,6 @@ public class ServiceComponentTest {
 
     Service s = serviceFactory.createNew(cluster, serviceName);
     cluster.addService(s);
-    s.persist();
     service = cluster.getService(serviceName);
     Assert.assertNotNull(service);
   }
@@ -119,7 +118,6 @@ public class ServiceComponentTest {
     ServiceComponent component = serviceComponentFactory.createNew(service,
         componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
@@ -142,7 +140,6 @@ public class ServiceComponentTest {
     ServiceComponent component = serviceComponentFactory.createNew(service,
         componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
@@ -186,12 +183,10 @@ public class ServiceComponentTest {
     h.setIPv6(hostname + "ipv6");
 
     Map<String, String> hostAttributes = new HashMap<String, String>();
-	hostAttributes.put("os_family", "redhat");
-	hostAttributes.put("os_release_version", "6.3");
-	h.setHostAttributes(hostAttributes);
+    hostAttributes.put("os_family", "redhat");
+    hostAttributes.put("os_release_version", "6.3");
+    h.setHostAttributes(hostAttributes);
 
-
-    h.persist();
     clusters.mapHostToCluster(hostname, clusterName);
   }
 
@@ -201,7 +196,6 @@ public class ServiceComponentTest {
     ServiceComponent component = serviceComponentFactory.createNew(service,
         componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
@@ -222,43 +216,23 @@ public class ServiceComponentTest {
     HostEntity hostEntity1 = hostDAO.findByName("h1");
     assertNotNull(hostEntity1);
 
-    ServiceComponentHost sch1 =
-        serviceComponentHostFactory.createNew(sc, "h1");
-    ServiceComponentHost sch2 =
-        serviceComponentHostFactory.createNew(sc, "h2");
-    ServiceComponentHost failSch =
-        serviceComponentHostFactory.createNew(sc, "h2");
-
-    Map<String, ServiceComponentHost> compHosts =
-        new HashMap<String, ServiceComponentHost>();
-    compHosts.put("h1", sch1);
-    compHosts.put("h2", sch2);
-    compHosts.put("h3", failSch);
+    ServiceComponentHost sch1 = sc.addServiceComponentHost("h1");
+    ServiceComponentHost sch2 = sc.addServiceComponentHost("h2");
 
     try {
-      sc.addServiceComponentHosts(compHosts);
+      sc.addServiceComponentHost("h2");
       fail("Expected error for dups");
     } catch (Exception e) {
       // Expected
     }
-    Assert.assertTrue(sc.getServiceComponentHosts().isEmpty());
-
-    compHosts.remove("h3");
-    sc.addServiceComponentHosts(compHosts);
 
     Assert.assertEquals(2, sc.getServiceComponentHosts().size());
 
-    sch1.persist();
-    sch2.persist();
-
     ServiceComponentHost schCheck = sc.getServiceComponentHost("h2");
     Assert.assertNotNull(schCheck);
     Assert.assertEquals("h2", schCheck.getHostName());
 
-    ServiceComponentHost sch3 =
-        serviceComponentHostFactory.createNew(sc, "h3");
-    sc.addServiceComponentHost(sch3);
-    sch3.persist();
+    sc.addServiceComponentHost("h3");
     Assert.assertNotNull(sc.getServiceComponentHost("h3"));
 
     sch1.setDesiredStackVersion(new StackId("HDP-1.2.0"));
@@ -302,7 +276,6 @@ public class ServiceComponentTest {
     ServiceComponent component = serviceComponentFactory.createNew(service,
         componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     addHostToCluster("h1", service.getCluster().getClusterName());
     ServiceComponentHost sch =
@@ -314,7 +287,6 @@ public class ServiceComponentTest {
     compHosts.put("h1", sch);
     component.addServiceComponentHosts(compHosts);
     Assert.assertEquals(1, component.getServiceComponentHosts().size());
-    sch.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
@@ -379,7 +351,6 @@ public class ServiceComponentTest {
     String componentName = "NAMENODE";
     ServiceComponent component = serviceComponentFactory.createNew(service, componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
@@ -430,7 +401,6 @@ public class ServiceComponentTest {
     String componentName = "NAMENODE";
     ServiceComponent component = serviceComponentFactory.createNew(service, componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
@@ -498,7 +468,6 @@ public class ServiceComponentTest {
     String componentName = "NAMENODE";
     ServiceComponent component = serviceComponentFactory.createNew(service, componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
@@ -565,7 +534,6 @@ public class ServiceComponentTest {
     String componentName = "NAMENODE";
     ServiceComponent component = serviceComponentFactory.createNew(service, componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
@@ -616,7 +584,6 @@ public class ServiceComponentTest {
     String componentName = "NAMENODE";
     ServiceComponent component = serviceComponentFactory.createNew(service, componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java
index 8f00b72..ff6dfc9 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java
@@ -18,7 +18,6 @@
 
 package org.apache.ambari.server.state;
 
-import junit.framework.Assert;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
@@ -40,6 +39,8 @@ import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
 
+import junit.framework.Assert;
+
 public class ServiceTest {
 
   private Clusters clusters;
@@ -119,7 +120,6 @@ public class ServiceTest {
     String serviceName = "HDFS";
     Service s = serviceFactory.createNew(cluster, serviceName);
     cluster.addService(s);
-    s.persist();
 
     Service service = cluster.getService(serviceName);
     Assert.assertNotNull(service);
@@ -141,7 +141,6 @@ public class ServiceTest {
     String serviceName = "HDFS";
     Service s = serviceFactory.createNew(cluster, serviceName);
     cluster.addService(s);
-    s.persist();
 
     Service service = cluster.getService(serviceName);
 
@@ -185,17 +184,11 @@ public class ServiceTest {
 
     s.addServiceComponent(sc3);
 
-    sc1.persist();
-    sc2.persist();
-    sc3.persist();
-
     ServiceComponent sc4 = s.addServiceComponent("HDFS_CLIENT");
     Assert.assertNotNull(s.getServiceComponent(sc4.getName()));
     Assert.assertEquals(State.INIT,
         s.getServiceComponent("HDFS_CLIENT").getDesiredState());
     Assert.assertTrue(sc4.isClientComponent());
-    sc4.persist();
-
     Assert.assertEquals(4, s.getServiceComponents().size());
 
     Assert.assertNotNull(s.getServiceComponent(sc3.getName()));
@@ -267,7 +260,6 @@ public class ServiceTest {
     String serviceName = "HDFS";
     Service s = serviceFactory.createNew(cluster, serviceName);
     cluster.addService(s);
-    s.persist();
 
     Service service = cluster.getService(serviceName);
     Assert.assertNotNull(service);
@@ -291,7 +283,6 @@ public class ServiceTest {
     String serviceName = "HDFS";
     Service s = serviceFactory.createNew(cluster, serviceName);
     cluster.addService(s);
-    s.persist();
 
     Service service = cluster.getService(serviceName);
     Assert.assertNotNull(service);
@@ -339,8 +330,6 @@ public class ServiceTest {
     hostAttributes.put("os_release_version", "6.3");
     h.setHostAttributes(hostAttributes);
 
-
-    h.persist();
     clusters.mapHostToCluster(hostname, clusterName);
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
index c2e1f75..a1d4c4b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
@@ -508,8 +508,6 @@ public class UpgradeHelperTest {
     Clusters clusters = injector.getInstance(Clusters.class);
     Host h4 = clusters.getHost("h4");
     h4.setState(HostState.HEARTBEAT_LOST);
-    h4.persist();
-
 
     List<ServiceComponentHost> schs = cluster.getServiceComponentHosts("h4");
     assertEquals(1, schs.size());
@@ -1224,7 +1222,6 @@ public class UpgradeHelperTest {
 
       host.setHostAttributes(hostAttributes);
 
-      host.persist();
       clusters.mapHostToCluster(hostName, clusterName);
     }
 
@@ -1441,7 +1438,6 @@ public class UpgradeHelperTest {
 
       host.setHostAttributes(hostAttributes);
 
-      host.persist();
       clusters.mapHostToCluster(hostName, clusterName);
     }
 
@@ -1521,7 +1517,6 @@ public class UpgradeHelperTest {
 
       host.setHostAttributes(hostAttributes);
 
-      host.persist();
       clusters.mapHostToCluster(hostName, clusterName);
     }
 
@@ -1587,7 +1582,6 @@ public class UpgradeHelperTest {
 
       host.setHostAttributes(hostAttributes);
 
-      host.persist();
       clusters.mapHostToCluster(hostName, clusterName);
     }
 
@@ -1654,7 +1648,6 @@ public class UpgradeHelperTest {
 
       host.setHostAttributes(hostAttributes);
 
-      host.persist();
       clusters.mapHostToCluster(hostName, clusterName);
     }
 
@@ -1773,7 +1766,6 @@ public class UpgradeHelperTest {
 
       host.setHostAttributes(hostAttributes);
 
-      host.persist();
       clusters.mapHostToCluster(hostName, clusterName);
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertEventPublisherTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertEventPublisherTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertEventPublisherTest.java
index c511f1a..015660c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertEventPublisherTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertEventPublisherTest.java
@@ -19,8 +19,6 @@ package org.apache.ambari.server.state.alerts;
 
 import java.util.UUID;
 
-import junit.framework.Assert;
-
 import org.apache.ambari.server.events.AlertDefinitionChangedEvent;
 import org.apache.ambari.server.events.AlertDefinitionDeleteEvent;
 import org.apache.ambari.server.events.AmbariEvent;
@@ -51,12 +49,14 @@ import org.apache.ambari.server.utils.EventBusSynchronizer;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 import com.google.gson.Gson;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
-import org.junit.experimental.categories.Category;
+
+import junit.framework.Assert;
 
 /**
  * Tests that {@link AmbariEvent} instances are fired correctly and that alert
@@ -306,7 +306,6 @@ public class AlertEventPublisherTest {
   private void installHdfsService() throws Exception {
     String serviceName = "HDFS";
     Service service = serviceFactory.createNew(cluster, serviceName);
-    service.persist();
     service = cluster.getService(serviceName);
 
     Assert.assertNotNull(service);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f64fa722/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/InitialAlertEventTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/InitialAlertEventTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/InitialAlertEventTest.java
index c7a5915..85d13a6 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/InitialAlertEventTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/InitialAlertEventTest.java
@@ -41,6 +41,7 @@ import org.apache.ambari.server.utils.EventBusSynchronizer;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 import com.google.common.eventbus.EventBus;
 import com.google.inject.Binder;
@@ -51,7 +52,6 @@ import com.google.inject.persist.PersistService;
 import com.google.inject.util.Modules;
 
 import junit.framework.Assert;
-import org.junit.experimental.categories.Category;
 
 /**
  * Tests that {@link InitialAlertEventTest} instances are fired correctly.
@@ -177,7 +177,6 @@ public class InitialAlertEventTest {
   private void installHdfsService() throws Exception {
     String serviceName = "HDFS";
     Service service = m_serviceFactory.createNew(m_cluster, serviceName);
-    service.persist();
     service = m_cluster.getService(serviceName);
 
     Assert.assertNotNull(service);


Mime
View raw message