PropertyFileMessages implements Messages { @Override public boolean hasMessage(final String key) { Validate.notEmpty(key, "Key can not be empty"); return bundle.containsKey(key); } PropertyFileMessages(@NonNls final String baseName); @Override boolean hasMessage(final String key); @Override String getMessage(final String key, final Object... arguments);  }
@Test public void hasMessageShouldThrowExceptionIfKeyIsNull() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Key can not be empty"); messages.hasMessage(null); }
@Test public void hasMessageShouldThrowExceptionIfKeyIsEmpty() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Key can not be empty"); messages.hasMessage(" "); }
@Test public void hasMessageShouldBeTrueIfKeyExist() { assertTrue(messages.hasMessage("test.string1")); assertTrue(messages.hasMessage("test.string2")); assertTrue(messages.hasMessage("test.hello")); }
@Test public void hasMessageShouldBeFalseIfKeyDontExist() { assertFalse(messages.hasMessage("test.string10")); assertFalse(messages.hasMessage("test.hi")); assertFalse(messages.hasMessage("nothing")); }