@Test
  public void testUpdateClustersToggleKerberosNotInvoked() 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);

    KerberosHelper kerberosHelper = createStrictMock(KerberosHelper.class);
    Provider<MetadataHolder> m_metadataHolder = createMock(Provider.class);
    MetadataHolder metadataHolder = createMock(MetadataHolder.class);
    Provider<AgentConfigsHolder> m_agentConfigsHolder = createMock(Provider.class);
    AgentConfigsHolder agentConfigsHolder = createMockBuilder(AgentConfigsHolder.class)
        .addMockedMethod("updateData").createMock();
    // expectations
    constructorInit(injector, controllerCapture, null, null,
        kerberosHelper, m_metadataHolder, m_agentConfigsHolder);

    expect(m_metadataHolder.get()).andReturn(metadataHolder).anyTimes();
    expect(metadataHolder.updateData(anyObject())).andReturn(true).anyTimes();

    expect(m_agentConfigsHolder.get()).andReturn(agentConfigsHolder).anyTimes();
    agentConfigsHolder.updateData(anyLong(), anyObject(List.class));
    expectLastCall().anyTimes();

    expect(clusterRequest.getClusterId()).andReturn(1L).times(4);
    expect(clusters.getClusterById(1L)).andReturn(cluster).times(1);

    // replay mocks
    replay(actionManager, cluster, clusters, injector, clusterRequest, sessionManager, kerberosHelper,
        m_metadataHolder, metadataHolder, m_agentConfigsHolder, agentConfigsHolder);

    // test
    AmbariManagementController controller = partialMockBuilder(AmbariManagementControllerImpl.class)
        .withConstructor(actionManager, clusters, injector)
        .addMockedMethod("getClusterMetadataOnConfigsUpdate")
        .createMock();
    controller.updateClusters(setRequests, null);

    // assert and verify
    assertSame(controller, controllerCapture.getValue());
    verify(actionManager, cluster, clusters, injector, clusterRequest, sessionManager, kerberosHelper,
        m_metadataHolder, metadataHolder, m_agentConfigsHolder, agentConfigsHolder);
  }
Ensure that when the cluster is updated KerberosHandler.toggleKerberos is not invoked unless
the security type is altered
ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java