CounterStoreConnector implements Connector { public void incrementBy(Long projectId, String name, int incrementBy) { if (!countersMap.containsKey(name)) { throw new IllegalStateException("Undefined counter: " + name); } countersMap.put(name, countersMap.get(name) + incrementBy); LOGGER.debug("Incremented the counter '{}' in the project <{}> of user <{}> to '{}'.", name, projectId, countersMap.get(name)); } CounterStoreConnector(CounterDAO counterDAO, User user, Project project, List<Counter> counterList); @Override void reset(); @Override void dispose(); @Override void post(); void set(Long projectId, String name, Integer value); void incrementBy(Long projectId, String name, int incrementBy); Integer get(String name); boolean contains(String name); Map<String, Integer> getStore(); CounterStoreConnector copy();  }
@Test(expected = IllegalStateException.class) public void shouldFailToIncrementTheCounterIfNotDefined() { connector.incrementBy(PROJECT_ID, COUNTER_NAME, 5); }