use of org.springframework.boot.origin.OriginProvider in project spring-boot by spring-projects.
the class ConfigurationPropertyTests method getPropertyOriginShouldReturnValuePropertyOrigin.
@Test
void getPropertyOriginShouldReturnValuePropertyOrigin() {
Origin origin = mock(Origin.class);
OriginProvider property = ConfigurationProperty.of(this.source, NAME, "foo", origin);
assertThat(property.getOrigin()).isEqualTo(origin);
}
use of org.springframework.boot.origin.OriginProvider in project spring-boot by spring-projects.
the class InputStreamSourceToByteArrayConverterTests method convertWhenFailsWithIOExceptionFromOriginProviderThrowsException.
@ConversionServiceTest
void convertWhenFailsWithIOExceptionFromOriginProviderThrowsException(ConversionService conversionService) throws Exception {
Origin origin = new TestOrigin("mylocation");
InputStreamSource source = mock(InputStreamSource.class, withSettings().extraInterfaces(OriginProvider.class));
given(source.getInputStream()).willThrow(IOException.class);
given(((OriginProvider) source).getOrigin()).willReturn(origin);
assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() -> conversionService.convert(source, byte[].class)).withCauseExactlyInstanceOf(IllegalStateException.class).withMessageContaining("Unable to read from mylocation");
}
Aggregations