ElasticsearchSituationStore extends AbstractSituationStore implements SituationStore { @Override public void recordResubmitFailure(final String situationId, final String errorMessage, final String userName) { Situation sit=getSituation(situationId); if (sit != null) { String message = (errorMessage == null ? "" : errorMessage); if (message.length() > PROPERTY_VALUE_MAX_LENGTH) { message = message.substring(0, PROPERTY_VALUE_MAX_LENGTH); } doRecordResubmitFailure(sit, message, userName); _client.update(situationId, ElasticsearchClient.convertTypeToJson(sit)); } } ElasticsearchSituationStore(); @ServiceInit void init(); List<Situation> getSituations(final SituationsQuery sitQuery); void assignSituation(final String situationId, final String userName); void unassignSituation(final String situationId); void updateResolutionState(final String situationId, final ResolutionState resolutionState); @Override void recordSuccessfulResubmit(final String situationId, final String userName); @Override void recordResubmitFailure(final String situationId, final String errorMessage, final String userName); @ServiceClose void close();  }
@Test public void recordResubmitFailure() throws Exception { String name="recordResubmitFailure"; Situation situation = new Situation(); situation.setId(name); situation.setTimestamp(System.currentTimeMillis()); _elasticsearchSituationStore.store(situation); _elasticsearchSituationStore.recordResubmitFailure(situation.getId(), name, name); Situation reload = _elasticsearchSituationStore.getSituation(situation.getId()); assertEquals(name, reload.getSituationProperties().get(SituationStore.RESUBMIT_BY_PROPERTY)); assertEquals(name, reload.getSituationProperties().get(SituationStore.RESUBMIT_ERROR_MESSAGE)); assertTrue(reload.getSituationProperties().containsKey(SituationStore.RESUBMIT_AT_PROPERTY)); assertEquals(SituationStore.RESUBMIT_RESULT_ERROR, reload.getSituationProperties().get(SituationStore.RESUBMIT_RESULT_PROPERTY)); }
@Test public void recordResubmitErrorMessageMaxLength() throws Exception { String name="recordResubmitErrorMessageMaxLength"; Situation situation = new Situation(); situation.setId(name); situation.setTimestamp(System.currentTimeMillis()); _elasticsearchSituationStore.store(situation); _elasticsearchSituationStore.recordResubmitFailure(situation.getId(), Strings.padEnd(name, 10000, '*'), name); Situation reload = _elasticsearchSituationStore.getSituation(situation.getId()); assertEquals(name, reload.getSituationProperties().get(SituationStore.RESUBMIT_BY_PROPERTY)); String errorMessage = reload.getSituationProperties().get(SituationStore.RESUBMIT_ERROR_MESSAGE); assertEquals(Strings.padEnd(name, 250, '*'), errorMessage); assertTrue(reload.getSituationProperties().containsKey(SituationStore.RESUBMIT_AT_PROPERTY)); assertEquals(SituationStore.RESUBMIT_RESULT_ERROR, reload.getSituationProperties().get(SituationStore.RESUBMIT_RESULT_PROPERTY)); }