### Question:
AppDeploymentInstanceWorkflow { protected Mono<Boolean> accept(ServiceDefinition serviceDefinition, Plan plan) { return getBackingApplicationsForService(serviceDefinition, plan) .map(backingApplications -> !backingApplications.isEmpty()) .filter(Boolean::booleanValue) .switchIfEmpty( getBackingServicesForService(serviceDefinition, plan) .map(backingServices -> !backingServices.isEmpty()) .defaultIfEmpty(false) ); } protected  AppDeploymentInstanceWorkflow(BrokeredServices brokeredServices);   }### Answer:
@Test void acceptWithMatchingService() { ServiceDefinition serviceDefinition = buildServiceDefinition("service1", "plan1"); StepVerifier .create(workflow.accept(serviceDefinition, serviceDefinition.getPlans().get(0))) .expectNextMatches(value -> value) .verifyComplete(); }
@Test void acceptWithMatchingServiceAndNoBackingApplication() { ServiceDefinition serviceDefinition = buildServiceDefinition("service2_without_backing_app", "plan1"); StepVerifier .create(workflow.accept(serviceDefinition, serviceDefinition.getPlans().get(0))) .expectNextMatches(value -> value) .verifyComplete(); }
@Test void doNotAcceptWithMatchingServiceWithoutBackingServiceNorBackingApplication() { ServiceDefinition serviceDefinition = buildServiceDefinition("service3_without_backing_app_nor_service", "plan1"); StepVerifier .create(workflow.accept(serviceDefinition, serviceDefinition.getPlans().get(0))) .expectNextMatches(value -> !value) .verifyComplete(); }
@Test void doNotAcceptWithUnsupportedService() { ServiceDefinition serviceDefinition = buildServiceDefinition("unknown-service", "plan1"); StepVerifier .create(workflow.accept(serviceDefinition, serviceDefinition.getPlans().get(0))) .expectNextMatches(value -> !value) .verifyComplete(); }
@Test void doNotAcceptWithUnsupportedPlan() { ServiceDefinition serviceDefinition = buildServiceDefinition("service1", "unknown-plan"); StepVerifier .create(workflow.accept(serviceDefinition, serviceDefinition.getPlans().get(0))) .expectNextMatches(value -> !value) .verifyComplete(); }