コード例 #1
0
  @Test
  public void testGetMergedConfig_with2LevelsParent() {
    TestConfigurable l0 = new TestConfigurable();
    {
      Map<String, Object> config = new HashMap<>();
      config.put(PROP_0, 0);
      l0.setConfig(config);
    }

    TestConfigurable l1 = new TestConfigurable();
    l1.setParent(l0);
    {
      Map<String, Object> config = new HashMap<>();
      config.put(PROP_1, 1);
      config.put(PROP_2, 2);
      l1.setConfig(config);
    }

    TestConfigurable l2 = new TestConfigurable();
    l2.setParent(l1);
    {
      Map<String, Object> config = new HashMap<>();
      config.put(PROP_1, 3);
      l2.setConfig(config);
    }

    Map<String, Object> mergedConfig = l2.getKafkaConfig();
    assertThat(mergedConfig.get(PROP_0), equalTo(0));
    assertThat(mergedConfig.get(PROP_1), equalTo(3)); // overrides the same value in the parent
    assertThat(mergedConfig.get(PROP_2), equalTo(2));
  }
コード例 #2
0
 @Test
 public void testGetMergedConfig_noParent() {
   TestConfigurable child = new TestConfigurable();
   {
     Map<String, Object> config = new HashMap<>();
     config.put(PROP_1, 1);
     child.setConfig(config);
   }
   Map<String, Object> mergedConfig = child.getKafkaConfig();
   assertThat(mergedConfig.get(PROP_1), equalTo(1));
   assertThat(mergedConfig.get(PROP_2), nullValue());
 }