// Path: 2016-07-12_rxjava_in_action/src/main/java/com/androidhuman/example/rxjavainaction/error/ContentNotAvailableError.java
// public final class ContentNotAvailableError extends Error {
// 
// }
// 
// Path: 2016-07-12_rxjava_in_action/src/main/java/com/androidhuman/example/rxjavainaction/error/ContentRatingError.java
// public final class ContentRatingError extends Error {
// 
// }
// 
// Path: 2016-07-12_rxjava_in_action/src/main/java/com/androidhuman/example/rxjavainaction/error/InsufficientBalanceError.java
// public final class InsufficientBalanceError extends Error {
// 
//     private int amount;
// 
//     public InsufficientBalanceError(int amount) {
//         this.amount = amount;
//     }
// 
//     public int getAmount() {
//         return amount;
//     }
// }


import com.androidhuman.example.rxjavainaction.error.ContentNotAvailableError;
import com.androidhuman.example.rxjavainaction.error.ContentRatingError;
import com.androidhuman.example.rxjavainaction.error.InsufficientBalanceError;
import com.androidhuman.example.rxjavainaction.model.Content;
import com.androidhuman.example.rxjavainaction.model.User;
import org.junit.Test;
import rx.Observable;
import rx.Subscription;
import rx.functions.Func3;
import rx.observers.TestSubscriber;
import static org.junit.Assert.assertEquals;
        s.unsubscribe();

        sub.assertError(ContentNotAvailableError.class);
    }

    @Test
    public void testChecksBalance() {
        Content content = new Content("test", 100, true, false);
        User user = new User("Foobar", true, 100);

        TestSubscriber<Void> sub = new TestSubscriber<>();
        Subscription s = RxContent.checksBalance(content, user).subscribe(sub);
        s.unsubscribe();

        sub.assertNoErrors();
        sub.assertCompleted();
        sub.assertValue(null);
    }

    @Test
    public void testChecksBalance_lowBalance() {
        Content content = new Content("test", 100, true, false);
        User user = new User("Foobar", true, 99);

        TestSubscriber<Void> sub = new TestSubscriber<>();
        Subscription s = RxContent.checksBalance(content, user).subscribe(sub);
        s.unsubscribe();

        sub.assertError(InsufficientBalanceError.class);
        //noinspection ThrowableResultOfMethodCallIgnored
// Path: 2016-07-12_rxjava_in_action/src/main/java/com/androidhuman/example/rxjavainaction/error/ContentNotAvailableError.java
// public final class ContentNotAvailableError extends Error {
// 
// }
// 
// Path: 2016-07-12_rxjava_in_action/src/main/java/com/androidhuman/example/rxjavainaction/error/ContentRatingError.java
// public final class ContentRatingError extends Error {
// 
// }
// 
// Path: 2016-07-12_rxjava_in_action/src/main/java/com/androidhuman/example/rxjavainaction/error/InsufficientBalanceError.java
// public final class InsufficientBalanceError extends Error {
// 
//     private int amount;
// 
//     public InsufficientBalanceError(int amount) {
//         this.amount = amount;
//     }
// 
//     public int getAmount() {
//         return amount;
//     }
// }


// Path: 2016-07-12_rxjava_in_action/src/test/java/com/androidhuman/example/rxjavainaction/rx/RxContentTestJava.java
import com.androidhuman.example.rxjavainaction.error.ContentNotAvailableError;
import com.androidhuman.example.rxjavainaction.error.ContentRatingError;
import com.androidhuman.example.rxjavainaction.error.InsufficientBalanceError;
import com.androidhuman.example.rxjavainaction.model.Content;
import com.androidhuman.example.rxjavainaction.model.User;
import org.junit.Test;
import rx.Observable;
import rx.Subscription;
import rx.functions.Func3;
import rx.observers.TestSubscriber;
import static org.junit.Assert.assertEquals;

        s.unsubscribe();

        sub.assertError(ContentNotAvailableError.class);
    }

    @Test
    public void testChecksBalance() {
        Content content = new Content("test", 100, true, false);
        User user = new User("Foobar", true, 100);

        TestSubscriber<Void> sub = new TestSubscriber<>();
        Subscription s = RxContent.checksBalance(content, user).subscribe(sub);
        s.unsubscribe();

        sub.assertNoErrors();
        sub.assertCompleted();
        sub.assertValue(null);
    }

    @Test
    public void testChecksBalance_lowBalance() {
        Content content = new Content("test", 100, true, false);
        User user = new User("Foobar", true, 99);

        TestSubscriber<Void> sub = new TestSubscriber<>();
        Subscription s = RxContent.checksBalance(content, user).subscribe(sub);
        s.unsubscribe();

        sub.assertError(InsufficientBalanceError.class);
        //noinspection ThrowableResultOfMethodCallIgnored
        InsufficientBalanceError e = (InsufficientBalanceError) sub.getOnErrorEvents().get(0);