Skip to content

Commit

Permalink
Add indexed order test
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Feb 15, 2025
1 parent 1b4cd3e commit a6301e3
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
Expand Down Expand Up @@ -150,6 +151,29 @@ void getIndexedValues() {
() -> config.getIndexedValues("not.found", config.requireConverter(String.class), ArrayList::new));
}

@Test
void indexedOrder() {
List<Integer> indexes = new ArrayList<>();
for (int i = 0; i < 100; i++) {
indexes.add(i);
}
Collections.shuffle(indexes);

Map<String, String> properties = new HashMap<>();
for (Integer index : indexes) {
properties.put("prop[" + index + "]", index.toString());
}

SmallRyeConfig config = new SmallRyeConfigBuilder()
.withSources(new PropertiesConfigSource(properties, ""))
.build();

List<Integer> values = config.getValues("prop", Integer.class, ArrayList::new);
for (int i = 0; i < 100; i++) {
assertEquals(i, values.get(i));
}
}

@Test
void getValuesNotIndexed() {
SmallRyeConfig config = new SmallRyeConfigBuilder()
Expand Down

0 comments on commit a6301e3

Please sign in to comment.