package de.mvitz.jprops.core.api;

import static org.mockito.BDDMockito.given;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class PropertiesInjectorTest {

    @Mock
    private PropertyProvider provider;
    @InjectMocks
    private PropertiesInjector injector;

    @SuppressWarnings("unused")
    private UnknownType unknownType;

    @Test(expected = InvalidPropertiesException.class)
    public void shouldThrowExceptionForUnknownType() throws Exception {
        given(provider.get("unknownType")).willReturn("foo");
        injector.injectInto(this);
    }

    public interface UnknownType {
    }

}

@@ -28,16 +28,154 @@
 e.api;%0A%0A
+import static org.assertj.core.api.Assertions.assertThat;%0Aimport static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown;%0A
 import s
@@ -210,16 +210,16 @@
 .given;%0A
-
 %0Aimport 
@@ -558,40 +558,8 @@
 r;%0A%0A
-    @SuppressWarnings(%22unused%22)%0A
     
@@ -605,53 +605,8 @@
 Test
-(expected = InvalidPropertiesException.class)
 %0A   
@@ -736,16 +736,34 @@
 %22foo%22);%0A
+        try %7B%0A    
         
@@ -789,16 +789,302 @@
 (this);%0A
+            failBecauseExceptionWasNotThrown(InvalidPropertiesException.class);%0A        %7D catch (final InvalidPropertiesException e) %7B%0A            assertThat(e).hasNoCause().hasMessage(%22No converter found for type: UnknownType%22);%0A            assertThat(unknownType).isNull();%0A        %7D%0A
     %7D%0A%0A 

Use AssertJ instead of JUnit expected to assert thrown exception.