}
private AlertDefinition createAlertDefinitionWithTwoConditionsALL(MeasurementDefinition metricDef, int resourceId) {
// create alert definition with the conditions "metric value > 40 AND metric value < 60"
HashSet<AlertCondition> conditions = new HashSet<AlertCondition>(2);
AlertCondition cond1 = new AlertCondition();
cond1.setCategory(AlertConditionCategory.THRESHOLD);
cond1.setName(metricDef.getDisplayName());
cond1.setComparator(">");
cond1.setThreshold(40.0); // value > 40 threshold
cond1.setOption(null);
cond1.setMeasurementDefinition(metricDef);
conditions.add(cond1);
AlertCondition cond2 = new AlertCondition();
cond2.setCategory(AlertConditionCategory.THRESHOLD);
cond2.setName(metricDef.getDisplayName());
cond2.setComparator("<");
cond2.setThreshold(60.0); // value < 60 threshold
cond2.setOption(null);
cond2.setMeasurementDefinition(metricDef);
conditions.add(cond2);
AlertDefinition alertDefinition = new AlertDefinition();
alertDefinition.setName("two condition ALL alert");
alertDefinition.setEnabled(true);