### Question:
ReceivedMessageConfig implements ConditionConfig { @Override public Condition generate(Map<String, Object> values) { Preconditions.checkState(messageType != null, "must specify a message type"); Predicate<Address> fromPred = this.source == null ? Predicates.alwaysTrue() : Predicates.equalTo( FunctionFactory.toAddress(this.source.toTemplate(), values) ); Predicate<String> messageTypePred = Predicates.equalTo( FunctionFactory.toString(this.messageType.toTemplate(), values) ); Predicate<Map<String,Object>> attributesPred; if(this.attributes.isEmpty()) { attributesPred = Predicates.alwaysTrue(); } else { Map<String, Predicate<? super Object>> matches = new HashMap<>(); for(Map.Entry<String, TemplatedExpression> attributeAndExpression: this.attributes.entrySet()) { String attribute = attributeAndExpression.getKey(); TemplatedExpression expression = attributeAndExpression.getValue(); matches.put( attribute, Predicates.equalTo( expression.toTemplate().apply(values) ) ); } attributesPred = FunctionFactory.containsAll(matches); } ReceivedMessageCondition condition = new ReceivedMessageCondition(messageTypePred,fromPred,attributesPred); return condition; } ReceivedMessageConfig();  ReceivedMessageConfig(
         TemplatedExpression sourceExpression,
         TemplatedExpression messageTypeExpression
   ); TemplatedExpression getSourceExpression(); void setSourceExpression(TemplatedExpression sourceExpression); TemplatedExpression getMessageTypeExpression(); void setMessageTypeExpression(TemplatedExpression messageTypeExpression); Map<String, TemplatedExpression> getAttributeExpressions(); void setAttributeExpressions(Map<String, TemplatedExpression> attributeExpressions); ReceivedMessageConfig addAttributeExpression(String value, TemplatedExpression attributeExpression); @Override String getType(); @Override Condition generate(Map<String, Object> values); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static final String TYPE; }### Answer:
@Test public void testInvalidConfig() { ReceivedMessageConfig empty = new ReceivedMessageConfig(); try { empty.generate(ImmutableMap.of()); fail("Allowed to be creqted with missing attributes"); } catch(IllegalStateException e) { } }
@Test public void testItsAllAlright() { ReceivedMessageConfig config = createFullConfig(); Condition condition = config.generate(ImmutableMap.of( "address", "SERV:note:", "type", "base:ValueChange", "name", "name", "foo", "foo", "bar", "bar" )); assertTrue(condition instanceof ReceivedMessageCondition); }