RTGovSituationsProvider implements SituationsProvider, ActiveChangeListener { @Override public SituationBean getSituation(String situationId) throws UiException { SituationBean ret=null; try { Situation situation=_situationStore.getSituation(situationId); if (situation == null) { throw new UiException(i18n.format("RTGovSituationsProvider.SitNotFound", situationId)); } ret = RTGovSituationsUtil.getSituationBean(situation); MessageBean message = getMessage(situation); ret.setMessage(message); CallTraceBean callTrace = getCallTrace(situation); ret.setCallTrace(callTrace); java.util.List<Situation> resubmits=getResubmittedSituations(situationId, true); ret.setResubmissionFailureTotalCount(resubmits.size()); if (resubmits.size() == 0 && !ret.getResolutionState().equalsIgnoreCase(ResolutionState.RESOLVED.name())) { ret.setResubmitPossible(any(_providers, new IsResubmitSupported(situation))); } ret.setManualResolutionPossible(RTGovProperties.getPropertyAsBoolean("UI.manualResolution", Boolean.TRUE)); } catch (UiException uie) { throw uie; } catch (Exception e) { throw new UiException("Failed to retrieve situation", e); } return (ret); } RTGovSituationsProvider(); @PostConstruct void init(); String getName(); void addSituationEventListener(SituationEventListener l); void removeSituationEventListener(SituationEventListener l); java.util.List<SituationSummaryBean> search(SituationsFilterBean filters); @Override SituationBean getSituation(String situationId); @Override void resubmit(String situationId, MessageBean message, String username); @Override BatchRetryResult resubmit(SituationsFilterBean situationsFilterBean, String username); @Override java.util.List<SituationSummaryBean> getResubmitFailures(String situationId); @Override void export(SituationsFilterBean situationsFilterBean, OutputStream outputStream); @Override void inserted(Object key, Object value); @Override void updated(Object key, Object value); @Override void removed(Object key, Object value); @Override void assign(String situationId, final String userName); @Override void unassign(String situationId); @Override void updateResolutionState(String situationId, final ResolutionState resolutionState); @Override int delete(SituationsFilterBean situationsFilterBean);  }
@Test public void testGetSituation() { RTGovSituationsProvider provider=new RTGovSituationsProvider(); SituationStore sits=new SituationStore() { public Situation getSituation(String id) { if (!id.equals(TEST_ID)) { throw new AssertionError("Incorrect id"); } Situation ret=new Situation(); ret.setSubject("Service|Operation"); ret.setId(id); return (ret); } public java.util.List<Situation> getSituations(SituationsQuery query) { return java.util.Collections.<Situation>emptyList(); } public void assignSituation(String situationId, String userName) throws Exception { throw new Exception("Fail"); } public void unassignSituation(String situationId) throws Exception { throw new Exception("Fail"); } public void updateResolutionState(String situationId, ResolutionState resolutionState) throws Exception { throw new Exception("Fail"); } public void recordResubmitFailure(String situationId, String message, String userName) { Assert.fail(); }; public void recordSuccessfulResubmit(String situationId, String userName) { Assert.fail(); }; public int delete(SituationsQuery query) { return 0; } public void delete(Situation sit) { }; public void store(Situation situation) throws Exception { }; }; provider.setSituationStore(sits); provider.setSituations(new ActiveList("Test")); provider.init(); try { SituationBean sb=provider.getSituation(TEST_ID); if (sb == null) { fail("Result is null"); } if (!sb.getSituationId().equals(TEST_ID)) { fail("Situation id is incorrect: "+sb.getSituationId()); } } catch (Exception e) { e.printStackTrace(); fail("Get situation failed: "+e.getMessage()); } }