All pastes #242774 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-11-07 17:58 UTC
rendered paste body
The Test - This is a red bar....
	public void testCurrentByRange() {		

		Collection<OnmsOutage> expectedOutages = new JdbcSet();
		OnmsOutage expectedCurrent = new OnmsOutage();
		expectedCurrent.setId(1);

		expectedOutages.add(expectedCurrent);

		expect(outageDao.currentOutages(1, 1, "ifLostService", true))
				.andReturn(expectedOutages);
		replay(outageDao);

		Set suppressed = (Set) outageService.getCurrentOutagesByRange(1, 1, "ifLostService", "asc");
		verify(outageDao);
		assertTrue("Current Outages", suppressed.equals(expectedOutages));

	}


The Interface

public Collection<OnmsOutage> getCurrentOutagesByRange(Integer offset,
			Integer limit, String orderProperty, String direction) {
		throw new UnsupportedOperationException("not implemented since switch to hibernate");
	}

The Dao ---- Really what I need to understand...

<COMMENT>

I assume along the lines of:


public Collection<OnmsOutage> matchingCurrentOutages(ServiceSelector selector) {
    	Filter filter = new Filter();
    	Set<String> matchingIps = new HashSet<String>(filter.getIPList(selector.getFilterRule()));
    	Set<String> matchingSvcs = new HashSet<String>(selector.getServiceNames());
    	
    	List<OnmsOutage> matchingOutages = new LinkedList<OnmsOutage>();
    	Collection<OnmsOutage> outages = currentOutages();
		for (OnmsOutage outage : outages) {
    		OnmsMonitoredService svc = outage.getMonitoredService();
    		if ((matchingSvcs.contains(svc.getServiceName()) || matchingSvcs.isEmpty()) &&
    			matchingIps.contains(svc.getIpAddress())) {
    			
    			matchingOutages.add(outage);
    		}
			
		}
    	
    	
    	return matchingOutages;
	}




</COMMENT>



	public Collection<OnmsOutage> suppressedOutages() {
		return find("from OnmsOutage as o where (o.ifRegainedService is null and o.SupressTime > now()");
	}

	public Collection<OnmsOutage> openAndResolvedOutages(Integer Offset, Integer Limit) {
		// TODO Auto-generated method stub
		return null;
	}


	public Collection<OnmsOutage> currentOutages(Integer offset, Integer limit, String sortOrder, boolean All) {
		// TODO Auto-generated method stub
		return null;
	}