/** * Returns a copy of this ThresholdEntity object. * * NOTE: The m_lowThreshold and m_highThreshold member variables are not * actually cloned...the returned ThresholdEntity object will simply contain * references to the same Threshold objects as the original * ThresholdEntity object. * * All state will be lost, particularly instances, so it's not a true clone by any stretch of the imagination * * @return a {@link org.opennms.netmgt.threshd.ThresholdEntity} object. */ @Override public ThresholdEntity clone() { ThresholdEntity clone = new ThresholdEntity(); for (ThresholdEvaluatorState thresholdItem : getThresholdEvaluatorStates(null)) { clone.addThreshold(thresholdItem.getThresholdConfig()); } return clone; }
thresholdEntity.addThreshold(wrapper); if (merge) { boolean updated = false;
public void testThresholdEntityRequiredDataSources() throws Exception { ThresholdEntity entity=new ThresholdEntity(); expression.setExpression("(hrStorageSize-hrStorageUsed)*hrStorageAllocationUnits"); BaseThresholdDefConfigWrapper wrapper=BaseThresholdDefConfigWrapper.getConfigWrapper(expression); assertEquals(3, wrapper.getRequiredDatasources().size()); for (String ds : new String[] { "hrStorageSize", "hrStorageUsed", "hrStorageAllocationUnits" }) { assertTrue("Could not find expected variable: " + ds, wrapper.getRequiredDatasources().contains(ds)); } entity.addThreshold(wrapper); Collection<String> dataSources=entity.getRequiredDatasources(); final StringBuilder dsStringBuffer = new StringBuilder(); for (String dataSource : dataSources) { dsStringBuffer.append(dataSource).append(" "); } String dsString = dsStringBuffer.toString().trim(); assertTrue("Required data sources should contain hrStorageSize: " + dsString, dataSources.contains("hrStorageSize")); assertTrue("Required data sources should contain hrStorageUsed: " + dsString, dataSources.contains("hrStorageUsed")); assertTrue("Required data sources should contain hrStorageAllocationUnits: " + dsString, dataSources.contains("hrStorageAllocationUnits")); }