use of org.springframework.boot.autoconfigure.condition.ConditionOutcome in project spring-boot by spring-projects.
the class LocalDebugPortAvailableConditionTests method getOutcome.
private ConditionOutcome getOutcome() {
MockEnvironment environment = new MockEnvironment();
EnvironmentTestUtils.addEnvironment(environment, "spring.devtools.remote.debug.local-port:" + this.port);
ConditionContext context = mock(ConditionContext.class);
given(context.getEnvironment()).willReturn(environment);
ConditionOutcome outcome = this.condition.getMatchOutcome(context, null);
return outcome;
}
use of org.springframework.boot.autoconfigure.condition.ConditionOutcome in project spring-boot by spring-projects.
the class LocalDebugPortAvailableConditionTests method portInUse.
@Test
public void portInUse() throws Exception {
final ServerSocket serverSocket = ServerSocketFactory.getDefault().createServerSocket(this.port);
ConditionOutcome outcome = getOutcome();
serverSocket.close();
assertThat(outcome.isMatch()).isFalse();
assertThat(outcome.getMessage()).isEqualTo("Local Debug Port Condition did not find local debug port");
}
use of org.springframework.boot.autoconfigure.condition.ConditionOutcome in project spring-boot by spring-projects.
the class LocalDebugPortAvailableConditionTests method portAvailable.
@Test
public void portAvailable() throws Exception {
ConditionOutcome outcome = getOutcome();
assertThat(outcome.isMatch()).isTrue();
assertThat(outcome.getMessage()).isEqualTo("Local Debug Port Condition found local debug port");
}
use of org.springframework.boot.autoconfigure.condition.ConditionOutcome in project spring-boot by spring-projects.
the class OnEnabledEndpointElementCondition method getMatchOutcome.
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(this.annotationType.getName()));
String endpointName = annotationAttributes.getString("value");
ConditionOutcome outcome = getEndpointOutcome(context, endpointName);
if (outcome != null) {
return outcome;
}
return getDefaultEndpointsOutcome(context);
}
use of org.springframework.boot.autoconfigure.condition.ConditionOutcome in project spring-boot by spring-projects.
the class OnEnabledEndpointCondition method getMatchOutcome.
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(ConditionalOnEnabledEndpoint.class.getName()));
String endpointName = annotationAttributes.getString("value");
boolean enabledByDefault = annotationAttributes.getBoolean("enabledByDefault");
ConditionOutcome outcome = determineEndpointOutcome(endpointName, enabledByDefault, context);
if (outcome != null) {
return outcome;
}
return determineAllEndpointsOutcome(context);
}
Aggregations