Skip to content

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

@segabriel

Description

@segabriel
  @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;
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions