### Question:
ContainsDisplayNameCondition extends Condition { public boolean isSatisfied(Event event, String myDisplayName) { if (Event.EVENT_TYPE_MESSAGE.equals(event.getType())) { Message msg = JsonUtils.toMessage(event.getContent()); if (null != msg) { return EventUtils.caseInsensitiveFind(myDisplayName, msg.body); } } return false; } ContainsDisplayNameCondition(); boolean isSatisfied(Event event, String myDisplayName);  }### Answer:
@Test public void testTextMessages() { setEventTextMessageBody("Bob"); Assert.assertTrue(condition.isSatisfied(event, displayName)); setEventTextMessageBody("bob"); Assert.assertTrue(condition.isSatisfied(event, displayName)); setEventTextMessageBody("Hi Bob!"); Assert.assertTrue(condition.isSatisfied(event, displayName)); setEventTextMessageBody("Hi Bobby!"); Assert.assertFalse(condition.isSatisfied(event, displayName)); setEventTextMessageBody("Hi MrBob"); Assert.assertFalse(condition.isSatisfied(event, displayName)); setEventTextMessageBody("Hi Robert!"); Assert.assertFalse(condition.isSatisfied(event, displayName)); }
@Test public void testOtherMessageTypes() { setEventMessage("m.image", "'body': 'Bob.jpeg'"); Assert.assertTrue(condition.isSatisfied(event, displayName)); setEventMessage("m.image", "'url': 'Bob'"); Assert.assertFalse(condition.isSatisfied(event, displayName)); setEventMessage("m.notice", "'body': 'Bob did something or other'"); Assert.assertTrue(condition.isSatisfied(event, displayName)); setEventMessage("m.emote", "'body': 'is angry with Bob'"); Assert.assertTrue(condition.isSatisfied(event, displayName)); }
@Test public void testOtherEventType() { event.type = Event.EVENT_TYPE_TYPING; setEventTextMessageBody("Bob"); Assert.assertFalse(condition.isSatisfied(event, displayName)); }