@Test
public void testupdateKnoxTopology_ProviderAlreadyExists() throws Exception {

  EasyMockSupport easyMockSupport = new EasyMockSupport();
  final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);
  final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
  final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
  final Map<String, String> propertiesTopologyWitAuthorizationProvider = new HashMap<String, String>() {{
    put("content", "<topology> <gateway>  <provider>" +
            "<role>authorization</role>" +
            "<name>AclsAuthz</name>" +
            "<enabled>true</enabled>" +
            "</provider>" +
            "</gateway> </topology>\n");
  }};
  final Config mockTopologyConf = easyMockSupport.createNiceMock(Config.class);
  final Injector mockInjector = Guice.createInjector(new AbstractModule() {
    @Override
    protected void configure() {
      bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
      bind(Clusters.class).toInstance(mockClusters);
      bind(EntityManager.class).toInstance(entityManager);
      bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
      bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
    }
  });
  expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
  expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
    put("cl1", mockClusterExpected);
  }}).atLeastOnce();
  expect(mockClusterExpected.getDesiredConfigByType("topology")).andReturn(mockTopologyConf).atLeastOnce();
  expect(mockTopologyConf.getProperties()).andReturn(propertiesTopologyWitAuthorizationProvider).once();
  // ATTENTION, this mock should not be called at all. If it was, then something wrong with code
  UpgradeCatalog220 upgradeCatalog220 = createMockBuilder(UpgradeCatalog220.class)
          .withConstructor(Injector.class)
          .withArgs(mockInjector)
          .addMockedMethod("updateConfigurationPropertiesForCluster", Cluster.class, String.class,
                  Map.class, boolean.class, boolean.class)
          .createMock();
  easyMockSupport.replayAll();
  replay(upgradeCatalog220);
  upgradeCatalog220.updateKnoxTopology();
  easyMockSupport.verifyAll();
}