CountersDelegator extends BaseDelegator implements ICountersDelegator { Map<String, String> parseCounterCommandResultMaps( final List<Map<String, Object>> resultMaps, @Nonnull final Function<Map<String, Object>, Boolean> errorOrInfoStringCheckFunc) throws AccessException, RequestException { Map<String, String> counterMap = new HashMap<>(); if (nonNull(resultMaps)) { for (Map<String, Object> map : resultMaps) { if (!errorOrInfoStringCheckFunc.apply(map)) { counterMap.put(parseString(map, "counter"), parseString(map, VALUE)); } } } return counterMap; } CountersDelegator(IOptionsServer server); @Override Map<String, String> getCounters(); @Override Map<String, String> getCounters(final CounterOptions opts); @Override Map<String, String> getCounters(final GetCountersOptions opts);  }
@SuppressWarnings("unchecked") @Test public void testNullResultMaps() throws P4JavaException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { Map<String, String> actual = countersDelegator.parseCounterCommandResultMaps(null, errorOrInfoStringCheckFunc); assertThat(actual.size(), is(0)); checkEmptyCounters(() -> { }, () -> countersDelegator.parseCounterCommandResultMaps( null, errorOrInfoStringCheckFunc)); }
@SuppressWarnings("unchecked") @Test public void testEmptyResultMaps() throws P4JavaException, InvocationTargetException, IllegalAccessException { checkEmptyCounters(() -> resultMaps = newArrayList(), () -> countersDelegator.parseCounterCommandResultMaps(resultMaps, errorOrInfoStringCheckFunc)); }