@Test public void registerEnvironment() throws Exception { // When bundle.run(configuration, environment); // Then assertThat(context.getBean("dwEnv"), instanceOf(Environment.class)); }
@Test public void registerTasks() throws Exception { // When bundle.run(configuration, environment); // Then ArgumentCaptor<? extends Task> task = ArgumentCaptor.forClass(Task.class); verify(environment).addTask(task.capture()); assertThat(task.getValue(), is(HelloTask.class)); }
@Test public void registerResources() throws Exception { // When bundle.run(configuration, environment); // Then ArgumentCaptor<HelloResource> resource = ArgumentCaptor.forClass(HelloResource.class); verify(environment).addResource(resource.capture()); assertThat(resource.getValue(), is(HelloResource.class)); }
@Test public void registerHealthChecks() throws Exception { // When bundle.run(configuration, environment); // Then ArgumentCaptor<? extends HealthCheck> healthCheck = ArgumentCaptor.forClass(HealthCheck.class); verify(environment).addHealthCheck(healthCheck.capture()); assertThat(healthCheck.getValue(), is(HelloHealthCheck.class)); }
@Test public void wiresUpDependencies() throws Exception { // When bundle.run(configuration, environment); // Then ArgumentCaptor<HelloResource> resource = ArgumentCaptor.forClass(HelloResource.class); verify(environment).addResource(resource.capture()); HelloResource r = resource.getValue(); final HelloService helloService = r.getHelloService(); assertNotNull(helloService); assertThat(helloService.getMessage(), is("Hello")); assertThat(r.getConfiguration(), instanceOf(Configuration.class)); assertThat(r.getEnvironment(), instanceOf(Environment.class)); }