@Test(expected = PropertyInjectionException.class) public void whenConfigurationIsMissing_thenShouldThrowAnException() throws Exception { // given BeanWithInvalidConfiguration bean = new BeanWithInvalidConfiguration(); // when propertiesInjector.injectProperties(bean); // then should throw exception }
@Test public void whenKeyIsMissing_thenShouldSilentlyIgnoreTheField() throws Exception { // given BeanWithInvalidKey bean = new BeanWithInvalidKey(); // when propertiesInjector.injectProperties(bean); // then assertThat(bean.getName()).isNull(); }
@Test public void testPropertyInjectionFromDatabase() throws Exception { // given Bean bean = new Bean(); // when propertiesInjector.injectProperties(bean); // then assertThat(bean.getName()).isEqualTo("Foo"); }