@Test
public void testUpdateClusters__RollbackException() throws Exception {

  // member state mocks
  Capture<AmbariManagementController> controllerCapture = EasyMock.newCapture();
  Injector injector = createStrictMock(Injector.class);
  Cluster cluster = createNiceMock(Cluster.class);
  ActionManager actionManager = createNiceMock(ActionManager.class);
  ClusterRequest clusterRequest = createNiceMock(ClusterRequest.class);
  // requests
  Set<ClusterRequest> setRequests = Collections.singleton(clusterRequest);
  // expectations
  injector.injectMembers(capture(controllerCapture));
  expect(injector.getInstance(Gson.class)).andReturn(null);
  expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(null);
  expect(injector.getInstance(KerberosHelper.class)).andReturn(createNiceMock(KerberosHelper.class));
  expect(clusterRequest.getClusterName()).andReturn("clusterNew").times(3);
  expect(clusterRequest.getClusterId()).andReturn(1L).times(6);
  expect(clusters.getClusterById(1L)).andReturn(cluster).times(2);
  expect(cluster.getClusterName()).andReturn("clusterOld").times(1);
  cluster.setClusterName("clusterNew");
  expectLastCall().andThrow(new RollbackException());
  // replay mocks
  replay(actionManager, cluster, clusters, injector, clusterRequest, sessionManager);
  // test
  AmbariManagementController controller = new AmbariManagementControllerImpl(actionManager, clusters, injector);
  try {
    controller.updateClusters(setRequests, null);
    fail("Expected RollbackException");
  } catch (RollbackException e) {
    //expected
  }
  // assert and verify
  assertSame(controller, controllerCapture.getValue());
  verify(actionManager, cluster, clusters, injector, clusterRequest, sessionManager);
}