/**
 * Copyright 2012 Netflix, Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.netflix.hystrix.examples.basic;

import static org.junit.Assert.*;

import java.util.concurrent.Future;

import org.junit.Test;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;

/**
 * The obligatory "Hello World!" showing a simple implementation of a {@link HystrixCommand}.
 */
public class CommandHelloWorld extends HystrixCommand<String> {

    private final String name;

    public CommandHelloWorld(String name) {
        super(HystrixCommandGroupKey.Factory.asKey("ExampleGroup"));
        this.name = name;
    }

    @Override
    protected String run() {
        return "Hello " + name + "!";
    }

    public static class UnitTest {

        @Test
        public void testSynchronous() {
            assertEquals("Hello World!", new CommandHelloWorld("World").execute());
            assertEquals("Hello Bob!", new CommandHelloWorld("Bob").execute());
        }

        @Test
        public void testAsynchronous1() throws Exception {
            assertEquals("Hello World!", new CommandHelloWorld("World").queue().get());
            assertEquals("Hello Bob!", new CommandHelloWorld("Bob").queue().get());
        }

        @Test
        public void testAsynchronous2() throws Exception {

            Future<String> fWorld = new CommandHelloWorld("World").queue();
            Future<String> fBob = new CommandHelloWorld("Bob").queue();

            assertEquals("Hello World!", fWorld.get());
            assertEquals("Hello Bob!", fBob.get());
        }
    }

}

@@ -731,16 +731,93 @@
 .Test;%0A%0A
+import rx.Observable;%0Aimport rx.Observer;%0Aimport rx.util.functions.Action1;%0A%0A
 import c
@@ -2197,16 +2197,2118 @@
        %7D
+%0A%0A        @Test%0A        public void testObservable() throws Exception %7B%0A%0A            Observable%3CString%3E fWorld = new CommandHelloWorld(%22World%22).observe();%0A            Observable%3CString%3E fBob = new CommandHelloWorld(%22Bob%22).observe();%0A%0A            // blocking%0A            assertEquals(%22Hello World!%22, fWorld.toBlockingObservable().single());%0A            assertEquals(%22Hello Bob!%22, fBob.toBlockingObservable().single());%0A%0A            // non-blocking %0A            // - this is a verbose anonymous inner-class approach and doesn't do assertions%0A            fWorld.subscribe(new Observer%3CString%3E() %7B%0A%0A                @Override%0A                public void onCompleted() %7B%0A                    // nothing needed here%0A                %7D%0A%0A                @Override%0A                public void onError(Throwable e) %7B%0A                    e.printStackTrace();%0A                %7D%0A%0A                @Override%0A                public void onNext(String v) %7B%0A                    System.out.println(%22onNext: %22 + v);%0A                %7D%0A%0A            %7D);%0A%0A            // non-blocking%0A            // - also verbose anonymous inner-class%0A            // - ignore errors and onCompleted signal%0A            fBob.subscribe(new Action1%3CString%3E() %7B%0A%0A                @Override%0A                public void call(String v) %7B%0A                    System.out.println(%22onNext: %22 + v);%0A                %7D%0A%0A            %7D);%0A%0A            // non-blocking%0A            // - using closures in Java 8 would look like this:%0A            %0A            //            fWorld.subscribe((v) -%3E %7B%0A            //                System.out.println(%22onNext: %22 + v);%0A            //            %7D)%0A            %0A            // - or while also including error handling%0A            %0A            //            fWorld.subscribe((v) -%3E %7B%0A            //                System.out.println(%22onNext: %22 + v);%0A            //            %7D, (exception) -%3E %7B%0A            //                exception.printStackTrace();%0A            //            %7D)%0A            %0A            // More information about Observable can be found at https://github.com/Netflix/RxJava/wiki/How-To-Use%0A%0A        %7D
 %0A    %7D%0A%0A

Add RxJava Observable example