JPASituationStore extends AbstractSituationStore implements SituationStore { @Override public void recordResubmitFailure(final String situationId, final String errorMessage, final String userName) { _jpaStore.withJpa(new JpaWork<Void>() { public Void perform(Session s) { String message = (errorMessage == null ? "" : errorMessage); if (message.length() > PROPERTY_VALUE_MAX_LENGTH) { message = message.substring(0, PROPERTY_VALUE_MAX_LENGTH); } doRecordResubmitFailure(loadSituation(s, situationId), message, userName); return null; } }); } JPASituationStore();  JPASituationStore(JpaStore jpaStore); @SuppressWarnings("unchecked") 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);  }
@Test public void recordResubmitFailure() throws Exception { Situation situation = new Situation(); situation.setId(name.getMethodName()); situation.setTimestamp(System.currentTimeMillis()); persist(situation); _situationStore.recordResubmitFailure(situation.getId(), name.getMethodName(), name.getMethodName()); Situation reload = _situationStore.getSituation(situation.getId()); assertEquals(name.getMethodName(), reload.getSituationProperties().get(SituationStore.RESUBMIT_BY_PROPERTY)); assertEquals(name.getMethodName(), 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 { Situation situation = new Situation(); situation.setId(name.getMethodName()); situation.setTimestamp(System.currentTimeMillis()); persist(situation); _situationStore.recordResubmitFailure(situation.getId(), Strings.padEnd(name.getMethodName(), 10000, '*'), name.getMethodName()); Situation reload = _situationStore.getSituation(situation.getId()); assertEquals(name.getMethodName(), reload.getSituationProperties().get(SituationStore.RESUBMIT_BY_PROPERTY)); String errorMessage = reload.getSituationProperties().get(SituationStore.RESUBMIT_ERROR_MESSAGE); assertEquals(Strings.padEnd(name.getMethodName(), 250, '*'), errorMessage); assertTrue(reload.getSituationProperties().containsKey(SituationStore.RESUBMIT_AT_PROPERTY)); assertEquals(SituationStore.RESUBMIT_RESULT_ERROR, reload.getSituationProperties().get(SituationStore.RESUBMIT_RESULT_PROPERTY)); }