LookupExecutor { public long executeCount(Map<String, ?> lookupMap) { List<Object> args = getLookupArgs(lookupMap); List<Class> argTypes = buildArgTypes(); String countMethodName = LookupName.lookupCountMethod(lookup.getMethodName()); try { return (long) MethodUtils.invokeMethod(dataService, countMethodName, args.toArray(new Object[args.size()]), argTypes.toArray(new Class[argTypes.size()])); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new LookupExecutorException("Unable to execute count lookup " + lookup.getLookupName() + ".", e, null); } } LookupExecutor(MotechDataService dataService, LookupDto lookup, Map<String, FieldDto> fieldsByName); Object execute(Map<String, ?> lookupMap); Object execute(Map<String, ?> lookupMap, QueryParams queryParams); long executeCount(Map<String, ?> lookupMap);  }
@Test public void shouldExecuteCountLookup() { Map<String, Object> lookupMap = new HashMap<>(); lookupMap.put(STR_FIELD_NAME, STR_ARG); lookupMap.put(INT_FIELD_NAME, INT_ARG); lookupMap.put(TEXTAREA_FIELD_NAME, TEXTAREA_ARG); long result = lookupExecutor1.executeCount(lookupMap); assertEquals(COUNT, result); }