@Test
public void shouldThrowApplicationLoadExceptionWhenIOExceptionOccurs() throws Exception {

    //given
    Resource applicationResource = mock(Resource.class);
    IOException ioException = new IOException();
    given(applicationResource.getInputStream()).willThrow(ioException);
    given(applicationDiscovery.discoverApplications()).willReturn(Collections.singletonList(applicationResource));
    //when
    Throwable thrown = catchThrowable(() ->
                                              applicationService.loadApplications());
    //then
    assertThat(thrown).isInstanceOf(AppliationLoadException.class)
            .hasCause(ioException);
}