scalecube-config icon indicating copy to clipboard operation
scalecube-config copied to clipboard

Exception occurred when a few fields refer to the same property name

Open segabriel opened this issue 7 years ago • 0 comments

  @Test
  public void testSomeFieldsReferToTheSamePropertyName() {
    when(configSource.loadConfig()).thenReturn(toConfigProps(mapBuilder().put("prop", "key=value").build()));
    ConfigRegistry configRegistry = newConfigRegistry(configSource);
    Map<String, String> bindingMap = ImmutableMap.<String, String>builder()
        .put("stringProperty", "prop")
        .put("stringListProperty", "prop")
        .put("stringMultimapProperty", "prop")
        .build();

    OnePropertyRepresentation objectProperty =
        configRegistry.objectProperty(bindingMap, OnePropertyRepresentation.class).value().get();

    assertEquals("key=value", objectProperty.stringProperty);
    assertEquals(ImmutableList.of("key=value"), objectProperty.stringListProperty);
    assertEquals(ImmutableMap.of("key", ImmutableList.of("value")), objectProperty.stringMultimapProperty);
  }

  public static class OnePropertyRepresentation {
    String stringProperty;
    List<String> stringListProperty;
    Map<String, List<String>> stringMultimapProperty;
  }

segabriel avatar Dec 11 '17 14:12 segabriel