Java Code Examples for org.springframework.boot.test.context.assertj.AssertableApplicationContext#getBean()
The following examples show how to use
org.springframework.boot.test.context.assertj.AssertableApplicationContext#getBean() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppBrokerAutoConfigurationTest.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
private void assertPropertiesLoaded(AssertableApplicationContext context) { BrokeredServices brokeredServices = context.getBean(BrokeredServices.class); assertThat(brokeredServices).hasSize(2); assertThat(brokeredServices.get(0).getServiceName()).isEqualTo("service1"); assertThat(brokeredServices.get(0).getPlanName()).isEqualTo("service1-plan1"); assertThat(brokeredServices.get(0).getApps().get(0).getName()).isEqualTo("app1"); assertThat(brokeredServices.get(0).getApps().get(0).getPath()).isEqualTo("classpath:app1.jar"); assertThat(brokeredServices.get(0).getApps().get(0).getProperties().get("memory")).isEqualTo("1G"); assertThat(brokeredServices.get(0).getApps().get(0).getProperties().get("instances")).isNull(); assertThat(brokeredServices.get(0).getApps().get(1).getName()).isEqualTo("app2"); assertThat(brokeredServices.get(0).getApps().get(1).getPath()).isEqualTo("classpath:app2.jar"); assertThat(brokeredServices.get(0).getApps().get(1).getProperties().get("memory")).isEqualTo("2G"); assertThat(brokeredServices.get(0).getApps().get(1).getProperties().get("instances")).isEqualTo("2"); assertThat(brokeredServices.get(1).getServiceName()).isEqualTo("service2"); assertThat(brokeredServices.get(1).getPlanName()).isEqualTo("service2-plan1"); assertThat(brokeredServices.get(1).getApps().get(0).getName()).isEqualTo("app3"); assertThat(brokeredServices.get(1).getApps().get(0).getPath()).isEqualTo("classpath:app3.jar"); }
Example 2
Source File: CredHubAutoConfigurationTests.java From spring-credhub with Apache License 2.0 | 5 votes |
private void assertPropertiesConfigured(AssertableApplicationContext context) { assertThat(context).hasSingleBean(CredHubProperties.class); CredHubProperties properties = context.getBean(CredHubProperties.class); assertThat(properties.getUrl()).isEqualTo("https://localhost"); assertThat(properties.getOauth2().getRegistrationId()).isEqualTo("test-client"); assertThat(context).hasSingleBean(ClientOptions.class); ClientOptions options = context.getBean(ClientOptions.class); assertThat(options.getConnectionTimeout()).isEqualTo(Duration.ofMillis(30)); assertThat(options.getReadTimeout()).isEqualTo(Duration.ofMillis(60)); }
Example 3
Source File: IapAuthenticationAutoConfigurationTests.java From spring-cloud-gcp with Apache License 2.0 | 5 votes |
private void verifyJwtBeans(AssertableApplicationContext context) { JwtDecoder jwtDecoder = context.getBean(JwtDecoder.class); assertThat(jwtDecoder).isNotNull(); assertThat(jwtDecoder).isInstanceOf(NimbusJwtDecoderJwkSupport.class); BearerTokenResolver resolver = context.getBean(BearerTokenResolver.class); assertThat(resolver).isNotNull(); assertThat(resolver.resolve(this.mockIapRequest)).isEqualTo("very fake jwt"); assertThat(resolver.resolve(this.mockNonIapRequest)).isNull(); }
Example 4
Source File: TaskJobLauncherAutoConfigurationTests.java From spring-cloud-task with Apache License 2.0 | 5 votes |
private void validateJobNames(AssertableApplicationContext context, String jobNames) throws Exception { JobLauncherCommandLineRunner jobLauncherCommandLineRunner = context .getBean(JobLauncherCommandLineRunner.class); Object names = ReflectionTestUtils.getField(jobLauncherCommandLineRunner, "jobNames"); assertThat(names).isEqualTo(jobNames); }
Example 5
Source File: InfluxDB2AutoConfigurationTest.java From influxdb-client-java with MIT License | 4 votes |
private int getReadTimeoutProperty(AssertableApplicationContext context) { InfluxDBClient influxDB = context.getBean(InfluxDBClient.class); Retrofit retrofit = (Retrofit) ReflectionTestUtils.getField(influxDB, "retrofit"); OkHttpClient callFactory = (OkHttpClient) retrofit.callFactory(); return callFactory.readTimeoutMillis(); }
Example 6
Source File: DmnEngineAutoConfigurationTest.java From flowable-engine with Apache License 2.0 | 4 votes |
protected void assertAutoDeploymentWithAppEngine(AssertableApplicationContext context) { DmnRepositoryService repositoryService = context.getBean(DmnRepositoryService.class); List<DmnDecision> definitions = repositoryService.createDecisionQuery().list(); assertThat(definitions) .extracting(DmnDecision::getKey, DmnDecision::getName) .containsExactlyInAnyOrder( tuple("RiskRating", "Risk Rating Decision Table"), tuple("simple", "Full Decision"), tuple("strings1", "Simple decision"), tuple("strings2", "Simple decision"), tuple("managerApprovalNeeded", "Manager approval needed2") ); DmnDecision definition = repositoryService.createDecisionQuery().latestVersion().decisionKey("strings1").singleResult(); assertThat(definition.getVersion()).isOne(); definition = repositoryService.createDecisionQuery().latestVersion().decisionKey("managerApprovalNeeded").singleResult(); assertThat(definition.getVersion()).isOne(); List<DmnDeployment> deployments = repositoryService.createDeploymentQuery().list(); assertThat(deployments).hasSize(2) .extracting(DmnDeployment::getName) .containsExactlyInAnyOrder("SpringBootAutoDeployment", "vacationRequest.zip"); AppRepositoryService appRepositoryService = context.getBean(AppRepositoryService.class); List<AppDefinition> appDefinitions = appRepositoryService.createAppDefinitionQuery().list(); assertThat(appDefinitions) .extracting(AppDefinition::getKey) .contains("simpleApp", "vacationRequestApp"); AppDefinition appDefinition = appRepositoryService.createAppDefinitionQuery().latestVersion().appDefinitionKey("simpleApp").singleResult(); assertThat(appDefinition.getVersion()).isOne(); appDefinition = appRepositoryService.createAppDefinitionQuery().latestVersion().appDefinitionKey("vacationRequestApp").singleResult(); assertThat(appDefinition.getVersion()).isOne(); List<AppDeployment> appDeployments = appRepositoryService.createDeploymentQuery().list(); assertThat(appDeployments).hasSize(3) .extracting(AppDeployment::getName) .containsExactlyInAnyOrder("simple.bar", "vacationRequest.zip", "processTask.bar"); }
Example 7
Source File: EventFlowsAutoConfigurationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
private void assertBeans(AssertableApplicationContext context) { assertThat(context) .getBean(CreateServiceInstanceEventFlowRegistry.class) .isNotNull(); assertThat(context) .getBean(UpdateServiceInstanceEventFlowRegistry.class) .isNotNull(); assertThat(context) .getBean(DeleteServiceInstanceEventFlowRegistry.class) .isNotNull(); assertThat(context) .getBean(AsyncOperationServiceInstanceEventFlowRegistry.class) .isNotNull(); assertThat(context) .getBean(CreateServiceInstanceBindingEventFlowRegistry.class) .isNotNull(); assertThat(context) .getBean(DeleteServiceInstanceBindingEventFlowRegistry.class) .isNotNull(); assertThat(context) .getBean(AsyncOperationServiceInstanceBindingEventFlowRegistry.class) .isNotNull(); assertThat(context) .getBean(EventFlowRegistries.class) .isNotNull(); EventFlowRegistries eventFlowRegistries = context.getBean(EventFlowRegistries.class); assertThat(eventFlowRegistries.getCreateInstanceRegistry()) .isEqualTo(context.getBean(CreateServiceInstanceEventFlowRegistry.class)); assertThat(eventFlowRegistries.getUpdateInstanceRegistry()) .isEqualTo(context.getBean(UpdateServiceInstanceEventFlowRegistry.class)); assertThat(eventFlowRegistries.getDeleteInstanceRegistry()) .isEqualTo(context.getBean(DeleteServiceInstanceEventFlowRegistry.class)); assertThat(eventFlowRegistries.getAsyncOperationRegistry()) .isEqualTo(context.getBean(AsyncOperationServiceInstanceEventFlowRegistry.class)); assertThat(eventFlowRegistries.getCreateInstanceBindingRegistry()) .isEqualTo(context.getBean(CreateServiceInstanceBindingEventFlowRegistry.class)); assertThat(eventFlowRegistries.getDeleteInstanceBindingRegistry()) .isEqualTo(context.getBean(DeleteServiceInstanceBindingEventFlowRegistry.class)); assertThat(eventFlowRegistries.getAsyncOperationBindingRegistry()) .isEqualTo(context.getBean(AsyncOperationServiceInstanceBindingEventFlowRegistry.class)); }