RealFlagRepository implements FlagRepository { @Override public Map<FlagId, FlagData> getAllFlagData() { WireFlagDataList list = configServerApi.get("/flags/v1/data?recursive=true", WireFlagDataList.class); return FlagData.listFromWire(list).stream().collect(Collectors.toMap(FlagData::id, Function.identity())); } RealFlagRepository(ConfigServerApi configServerApi); @Override Map<FlagId, FlagData> getAllFlagData();  }
@Test public void test() { WireFlagDataList list = new WireFlagDataList(); list.flags = new ArrayList<>(); list.flags.add(new WireFlagData()); list.flags.get(0).id = "id1"; when(configServerApi.get(any(), eq(WireFlagDataList.class))).thenReturn(list); Map<FlagId, FlagData> allFlagData = repository.getAllFlagData(); assertThat(allFlagData, IsMapWithSize.aMapWithSize(1)); assertThat(allFlagData, IsMapContaining.hasKey(new FlagId("id1"))); }