Search in sources :

Example 1 with ParameterValueMapper

use of org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper in project spring-boot by spring-projects.

the class EndpointAutoConfigurationTests method mapShouldUseConfigurationConverter.

@Test
void mapShouldUseConfigurationConverter() {
    this.contextRunner.withUserConfiguration(ConverterConfiguration.class).run((context) -> {
        ParameterValueMapper parameterValueMapper = context.getBean(ParameterValueMapper.class);
        Object paramValue = parameterValueMapper.mapParameterValue(new TestOperationParameter(Person.class), "John Smith");
        assertThat(paramValue).isInstanceOf(Person.class);
        Person person = (Person) paramValue;
        assertThat(person.firstName).isEqualTo("John");
        assertThat(person.lastName).isEqualTo("Smith");
    });
}
Also used : ParameterValueMapper(org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper) Test(org.junit.jupiter.api.Test)

Example 2 with ParameterValueMapper

use of org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper in project spring-boot by spring-projects.

the class EndpointAutoConfigurationTests method mapShouldUseGenericConfigurationConverter.

@Test
void mapShouldUseGenericConfigurationConverter() {
    this.contextRunner.withUserConfiguration(GenericConverterConfiguration.class).run((context) -> {
        ParameterValueMapper parameterValueMapper = context.getBean(ParameterValueMapper.class);
        Object paramValue = parameterValueMapper.mapParameterValue(new TestOperationParameter(Person.class), "John Smith");
        assertThat(paramValue).isInstanceOf(Person.class);
        Person person = (Person) paramValue;
        assertThat(person.firstName).isEqualTo("John");
        assertThat(person.lastName).isEqualTo("Smith");
    });
}
Also used : ParameterValueMapper(org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 ParameterValueMapper (org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper)2