SetCounterAction extends SymbolAction { @Override public ExecuteResult execute(ConnectorManager connector) { CounterStoreConnector counterStoreConnector = connector.getConnector(CounterStoreConnector.class); VariableStoreConnector variableStoreConnector = connector.getConnector(VariableStoreConnector.class); int val; try { switch (valueType) { case VARIABLE: val = Integer.parseInt(variableStoreConnector.get(value)); break; case NUMBER: val = Integer.parseInt(value); break; default: val = 0; break; } } catch (NumberFormatException | IllegalStateException e) { LOGGER.info(LoggerMarkers.LEARNER, "Could not set the counter '{}' to the value '{}' ", name, value, e); return getFailedOutput(); } counterStoreConnector.set(symbol.getProjectId(), name, val); LOGGER.info(LoggerMarkers.LEARNER, "Set the counter '{}' to the value '{}'.", name, value); return getSuccessOutput(); }  @Override ExecuteResult execute(ConnectorManager connector); String getName(); void setName(String name); String getValue(); void setValue(String value); ValueType getValueType(); void setValueType(ValueType valueType);  }
@Test public void shouldSuccessfulSetTheCounterValue() { CounterStoreConnector counters = mock(CounterStoreConnector.class); ConnectorManager connector = mock(ConnectorManager.class); given(connector.getConnector(CounterStoreConnector.class)).willReturn(counters); ExecuteResult result = setAction.execute(connector); assertTrue(result.isSuccess()); verify(counters).set(PROJECT_ID, TEST_NAME, Integer.parseInt(TEST_VALUE)); }