private void assertHasEvent(
     Sensor<?> sensor,
     Predicate<Object> componentPredicate,
     Predicate<? super CharSequence> descriptionPredicate) {
   for (SensorEvent<FailureDescriptor> event : events) {
     if (event.getSensor().equals(sensor)
         && (componentPredicate == null
             || componentPredicate.apply(event.getValue().getComponent()))
         && (descriptionPredicate == null
             || descriptionPredicate.apply(event.getValue().getDescription()))) {
       return;
     }
   }
   fail("No matching " + sensor + " event found; events=" + events);
 }
Example #2
0
 @Override
 public void onEvent(SensorEvent<T> event) {
   Entity e = event.getSource();
   synchronized (values) {
     if (values.containsKey(e)) {
       values.put(e, event.getValue());
     } else {
       if (LOG.isDebugEnabled())
         LOG.debug(
             "{} received event for unknown producer ({}); presumably that producer has recently been removed",
             this,
             e);
     }
   }
   onUpdated();
 }