@Test
  public void testUpdateAmsConfigs() throws Exception {

    Map<String, String> oldProperties = new HashMap<String, String>() {
      {
        put("timeline.metrics.service.default.result.limit", "15840");
        put("timeline.container-metrics.ttl", "2592000");
        put("timeline.metrics.cluster.aggregate.splitpoints", "cpu_user,mem_free");
        put("timeline.metrics.host.aggregate.splitpoints", "kafka.metric,nimbus.metric");
        put("timeline.metrics.downsampler.topn.metric.patterns", "dfs.NNTopUserOpCounts.windowMs=60000.op=__%.user=%," +
          "dfs.NNTopUserOpCounts.windowMs=300000.op=__%.user=%,dfs.NNTopUserOpCounts.windowMs=1500000.op=__%.user=%");
      }
    };
    Map<String, String> newProperties = new HashMap<String, String>() {
      {
        put("timeline.metrics.service.default.result.limit", "5760");
        put("timeline.container-metrics.ttl", "1209600");
        put("timeline.metrics.downsampler.topn.metric.patterns", StringUtils.EMPTY);
      }
    };

    Map<String, String> oldAmsHBaseSiteProperties = new HashMap<String, String>() {
      {
        put("hbase.snapshot.enabled", "false");
      }
    };

    Map<String, String> newAmsHBaseSiteProperties = new HashMap<String, String>() {
      {
        put("hbase.snapshot.enabled", "true");
      }
    };

    EasyMockSupport easyMockSupport = new EasyMockSupport();

    Clusters clusters = easyMockSupport.createNiceMock(Clusters.class);
    final Cluster cluster = easyMockSupport.createNiceMock(Cluster.class);
    Config mockAmsSite = easyMockSupport.createNiceMock(Config.class);

    expect(clusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
      put("normal", cluster);
    }}).once();
    expect(cluster.getDesiredConfigByType("ams-site")).andReturn(mockAmsSite).atLeastOnce();
    expect(mockAmsSite.getProperties()).andReturn(oldProperties).anyTimes();

    Config mockAmsHbaseSite = easyMockSupport.createNiceMock(Config.class);
    expect(cluster.getDesiredConfigByType("ams-hbase-site")).andReturn(mockAmsHbaseSite).atLeastOnce();
    expect(mockAmsHbaseSite.getProperties()).andReturn(oldAmsHBaseSiteProperties).anyTimes();

    Injector injector = easyMockSupport.createNiceMock(Injector.class);
    expect(injector.getInstance(Gson.class)).andReturn(null).anyTimes();
    expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(null).anyTimes();

    replay(injector, clusters, mockAmsSite, mockAmsHbaseSite, cluster);

    AmbariManagementControllerImpl controller = createMockBuilder(AmbariManagementControllerImpl.class)
      .addMockedMethod("createConfiguration", ConfigurationRequest.class)
      .addMockedMethod("getClusters", new Class[] { })
      .addMockedMethod("createConfig", Cluster.class, StackId.class, String.class, Map.class,
          String.class, Map.class)
      .withConstructor(createNiceMock(ActionManager.class), clusters, injector)
      .createNiceMock();

    Injector injector2 = easyMockSupport.createNiceMock(Injector.class);
    Capture<Map> propertiesCapture = EasyMock.newCapture(CaptureType.ALL);

    expect(injector2.getInstance(AmbariManagementController.class)).andReturn(controller).anyTimes();
    expect(controller.getClusters()).andReturn(clusters).anyTimes();
    expect(controller.createConfig(anyObject(Cluster.class), anyObject(StackId.class), anyString(), capture(propertiesCapture), anyString(),
      anyObject(Map.class))).andReturn(createNiceMock(Config.class)).times(2);

    replay(controller, injector2);
    new UpgradeCatalog270(injector2).updateAmsConfigs();
    easyMockSupport.verifyAll();

    assertEquals(propertiesCapture.getValues().size(), 2);

    Map<String, String> updatedProperties = propertiesCapture.getValues().get(0);
    assertTrue(Maps.difference(newProperties, updatedProperties).areEqual());

    updatedProperties = propertiesCapture.getValues().get(1);
    assertTrue(Maps.difference(newAmsHBaseSiteProperties, updatedProperties).areEqual());

  }
@return sample JSON data from repo_version data (no repositories defined) where 'OperatingSystems/ambari_managed_repositories' is missing
ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog270Test.java