RTGovSituationsProvider implements SituationsProvider, ActiveChangeListener { public java.util.List<SituationSummaryBean> search(SituationsFilterBean filters) throws UiException { ArrayList<SituationSummaryBean> situations = new ArrayList<SituationSummaryBean>(); try { java.util.List<Situation> results=querySituations(filters); for (Situation item : results) { if (!filters.isRootOnly() || !item.getProperties().containsKey(Situation.RESUBMITTED_SITUATION_ID)) { SituationSummaryBean ssb=RTGovSituationsUtil.getSituationBean(item); java.util.List<Situation> resubmitted=getResubmittedSituations(item.getId(), true); ssb.setResubmissionFailureTotalCount(resubmitted.size()); situations.add(ssb); } } } catch (Exception e) { throw new UiException(e); } return (situations); } 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 testSearch() { RTGovSituationsProvider provider=new RTGovSituationsProvider(); SituationStore sits=new SituationStore() { public Situation getSituation(String id) { throw new AssertionError("Fail"); } public java.util.List<Situation> getSituations(SituationsQuery query) { java.util.List<Situation> ret=new java.util.ArrayList<Situation>(); if (query.getType() == null && query.getProperties().containsKey(Situation.RESUBMITTED_SITUATION_ID)) { } else { if (!query.getType().equals(TEST_TYPE)) { throw new AssertionError("Unexpected query type: "+query.getType()); } Situation s1=new Situation(); s1.setSubject(TEST_SUBJECT); ret.add(s1); } return (ret); } 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(); SituationsFilterBean sfb=new SituationsFilterBean(); sfb.setType(TEST_TYPE); try { java.util.List<SituationSummaryBean> results=provider.search(sfb); if (results == null) { fail("No results"); } if (results.size() != 1) { fail("Expecting 1 result: "+results.size()); } SituationSummaryBean ssb=results.get(0); if (!ssb.getSubject().equals(TEST_SUBJECT)) { fail("Subject was incorrect: "+ssb.getSubject()); } } catch (Exception e) { e.printStackTrace(); fail("Search failed: "+e.getMessage()); } }