use of org.springframework.core.type.AnnotatedTypeMetadata in project spring-boot by spring-projects.
the class ConditionalOnExpressionTests method mockMetaData.
private AnnotatedTypeMetadata mockMetaData(String value) {
AnnotatedTypeMetadata metadata = mock(AnnotatedTypeMetadata.class);
given(metadata.getAnnotationAttributes(ConditionalOnExpression.class.getName())).willReturn(Collections.singletonMap("value", value));
return metadata;
}
use of org.springframework.core.type.AnnotatedTypeMetadata in project spring-boot by spring-projects.
the class ConditionalOnJndiTests method mockMetaData.
private AnnotatedTypeMetadata mockMetaData(String... value) {
AnnotatedTypeMetadata metadata = mock(AnnotatedTypeMetadata.class);
Map<String, Object> attributes = new HashMap<>();
attributes.put("value", value);
given(metadata.getAnnotationAttributes(ConditionalOnJndi.class.getName())).willReturn(attributes);
return metadata;
}
use of org.springframework.core.type.AnnotatedTypeMetadata in project spring-boot by spring-projects.
the class AbstractSessionCondition method getMatchOutcome.
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
ConditionMessage.Builder message = ConditionMessage.forCondition("Session Condition");
Environment environment = context.getEnvironment();
StoreType required = SessionStoreMappings.getType(this.webApplicationType, ((AnnotationMetadata) metadata).getClassName());
if (!environment.containsProperty("spring.session.store-type")) {
return ConditionOutcome.match(message.didNotFind("property", "properties").items(ConditionMessage.Style.QUOTE, "spring.session.store-type"));
}
try {
Binder binder = Binder.get(environment);
return binder.bind("spring.session.store-type", StoreType.class).map((t) -> new ConditionOutcome(t == required, message.found("spring.session.store-type property").items(t))).orElseGet(() -> ConditionOutcome.noMatch(message.didNotFind("spring.session.store-type property").atAll()));
} catch (BindException ex) {
return ConditionOutcome.noMatch(message.found("invalid spring.session.store-type property").atAll());
}
}
use of org.springframework.core.type.AnnotatedTypeMetadata in project spring-boot-admin by codecentric.
the class SpringBootAdminClientEnabledConditionTest method setUp.
@Before
public void setUp() {
condition = new SpringBootAdminClientEnabledCondition();
annotatedTypeMetadata = mock(AnnotatedTypeMetadata.class);
conditionContext = mock(ConditionContext.class);
}
Aggregations