### Question:
APICase extends ConsoleAPI<CaseItem> implements APIHasGet<CaseItem>, APIHasAdd<CaseItem>, APIHasSearch<CaseItem>, APIHasDelete { @Override protected void fillCounters(final CaseItem item, final List<String> counters) { fillNumberOfFailedFlowNodesIfFailedCounterExists(item, counters); fillNumberOfPendingFlowNodesIfActiveCounterExists(item, counters); }  @Override CaseItem add(final CaseItem caseItem); @Override CaseItem get(final APIID id); @Override ItemSearchResult<CaseItem> search(final int page, final int resultsByPage, final String search, final String orders,
            final Map<String, String> filters); @Override String defineDefaultSearchOrder(); @Override void delete(final List<APIID> ids);  }### Answer:
@Test public final void fillCounters_should_fill_number_of_failed_flow_nodes_when_counter_of_failed_flow_nodes_is_active() { final APIID id = APIID.makeAPIID(78L); final CaseItem item = mock(CaseItem.class); doReturn(id).when(item).getId(); final List<String> counters = Arrays.asList(CaseItem.COUNTER_FAILED_FLOW_NODES); final Map<String, String> filters = new HashMap<String, String>(); filters.put(FlowNodeItem.ATTRIBUTE_STATE, FlowNodeItem.VALUE_STATE_FAILED); filters.put(FlowNodeItem.ATTRIBUTE_PARENT_CASE_ID, String.valueOf(id.toLong())); final long numberOfFailedFlowNodes = 2L; doReturn(numberOfFailedFlowNodes).when(flowNodeDatastore).count(null, null, filters); apiCase.fillCounters(item, counters); verify(item).setAttribute(CaseItem.COUNTER_FAILED_FLOW_NODES, numberOfFailedFlowNodes); }
@Test public final void fillCounters_should_do_nothing_when_counter_of_failed_flow_nodes_is_not_active() { final CaseItem item = mock(CaseItem.class); final List<String> counters = new ArrayList<String>(); apiCase.fillCounters(item, counters); verify(item, never()).setAttribute(anyString(), anyLong()); }
@Test public void fillNumberOfActiveFlowNodesIfActiveCounterExists() { final APIID id = APIID.makeAPIID(78L); final CaseItem item = mock(CaseItem.class); doReturn(id).when(item).getId(); final List<String> counters = Arrays.asList(CaseItem.COUNTER_ACTIVE_FLOW_NODES); final Map<String, String> filters = new HashMap<String, String>(); filters.put(FlowNodeItem.ATTRIBUTE_PARENT_CASE_ID, String.valueOf(id.toLong())); final long numberOfFailedFlowNodes = 2L; doReturn(numberOfFailedFlowNodes).when(flowNodeDatastore).count(null, null, filters); apiCase.fillCounters(item, counters); verify(item).setAttribute(CaseItem.COUNTER_ACTIVE_FLOW_NODES, numberOfFailedFlowNodes); }