// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
// 
//     private final T1 left;
// 
//     public Left(T1 left) {
//         this.left = left;
//     }
// 
//     @Override
//     public boolean isLeft() {
//         return true;
//     }
// 
//     @Override
//     public T1 getLeft() {
//         return left;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         Left left1 = (Left) o;
// 
//         if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         return left != null ? left.hashCode() : 0;
//     }
// }
// 
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
// 
//     private final T2 right;
// 
//     public Right(T2 right) {
//         this.right = right;
//     }
// 
//     @Override
//     public boolean isRight() {
//         return true;
//     }
// 
//     @Override
//     public T2 getRight() {
//         return right;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         Right right1 = (Right) o;
// 
//         if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         return right != null ? right.hashCode() : 0;
//     }
// }
// 
// Path: core/src/main/java/org/codeandmagic/promise/impl/DeferredObject3.java
// public class DeferredObject3<Success, Failure, Progress> extends AbstractPromise3<Success, Failure, Progress> {
// 
//     public static <S, F, P> DeferredObject3<S, F, P> successful(S value) {
//         final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
//         deferredObject.success(value);
//         return deferredObject;
//     }
// 
//     public static <S, F, P> DeferredObject3<S, F, P> failed(F value) {
//         final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
//         deferredObject.failure(value);
//         return deferredObject;
//     }
// 
//     @Override
//     public final void progress(Progress progress) {
//         super.progress(progress);
//     }
// 
//     @Override
//     public final void success(Success resolved) {
//         super.success(resolved);
//     }
// 
//     @Override
//     public final void failure(Failure failure) {
//         super.failure(failure);
//     }
// }


import org.codeandmagic.promise.*;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import org.codeandmagic.promise.impl.DeferredObject3;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.mockito.Mockito.*;
import static org.junit.Assert.*;
/*
 * Copyright (c) 2014 Cristian Vrabie, Evelina Vrabie.
 *
 * This file is part of android-promise.
 * android-deferred-object is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation, either version 3 of the License,or (at your option)
 * any later version.
 *
 * android-promise is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with android-promise
 * If not, see <http://www.gnu.org/licenses/>.
 */

package org.codeandmagic.promise.tests;



/**
 * Created by cristian on 10/02/2014.
 */
@RunWith(JUnit4.class)
public class TransformationTests {

    private Transformation<Integer, String> intToString = new Transformation<Integer, String>() {
        @Override
        public String transform(Integer success) {
            return (success * 2) + "!";
        }
    };

    private Transformation<String, Either<Throwable, Integer>> stringToInt = new Transformation<String, Either<Throwable,Integer>>() {
        @Override
        public Either<Throwable, Integer> transform(String value) {
            try {
                return new Right<Throwable, Integer>(Integer.parseInt(value));
            } catch (NumberFormatException e) {
                return new Left<Throwable, Integer>(e);
            }
        }
    };

    @Test
    public void testMapSuccess() {
        Callback<String> onSuccess = mock(Callback.class);
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
// 
//     private final T1 left;
// 
//     public Left(T1 left) {
//         this.left = left;
//     }
// 
//     @Override
//     public boolean isLeft() {
//         return true;
//     }
// 
//     @Override
//     public T1 getLeft() {
//         return left;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         Left left1 = (Left) o;
// 
//         if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         return left != null ? left.hashCode() : 0;
//     }
// }
// 
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
// 
//     private final T2 right;
// 
//     public Right(T2 right) {
//         this.right = right;
//     }
// 
//     @Override
//     public boolean isRight() {
//         return true;
//     }
// 
//     @Override
//     public T2 getRight() {
//         return right;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         Right right1 = (Right) o;
// 
//         if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         return right != null ? right.hashCode() : 0;
//     }
// }
// 
// Path: core/src/main/java/org/codeandmagic/promise/impl/DeferredObject3.java
// public class DeferredObject3<Success, Failure, Progress> extends AbstractPromise3<Success, Failure, Progress> {
// 
//     public static <S, F, P> DeferredObject3<S, F, P> successful(S value) {
//         final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
//         deferredObject.success(value);
//         return deferredObject;
//     }
// 
//     public static <S, F, P> DeferredObject3<S, F, P> failed(F value) {
//         final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
//         deferredObject.failure(value);
//         return deferredObject;
//     }
// 
//     @Override
//     public final void progress(Progress progress) {
//         super.progress(progress);
//     }
// 
//     @Override
//     public final void success(Success resolved) {
//         super.success(resolved);
//     }
// 
//     @Override
//     public final void failure(Failure failure) {
//         super.failure(failure);
//     }
// }


// Path: core/src/test/java/org/codeandmagic/promise/tests/TransformationTests.java
import org.codeandmagic.promise.*;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import org.codeandmagic.promise.impl.DeferredObject3;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.mockito.Mockito.*;
import static org.junit.Assert.*;

/*
 * Copyright (c) 2014 Cristian Vrabie, Evelina Vrabie.
 *
 * This file is part of android-promise.
 * android-deferred-object is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation, either version 3 of the License,or (at your option)
 * any later version.
 *
 * android-promise is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with android-promise
 * If not, see <http://www.gnu.org/licenses/>.
 */

package org.codeandmagic.promise.tests;



/**
 * Created by cristian on 10/02/2014.
 */
@RunWith(JUnit4.class)
public class TransformationTests {

    private Transformation<Integer, String> intToString = new Transformation<Integer, String>() {
        @Override
        public String transform(Integer success) {
            return (success * 2) + "!";
        }
    };

    private Transformation<String, Either<Throwable, Integer>> stringToInt = new Transformation<String, Either<Throwable,Integer>>() {
        @Override
        public Either<Throwable, Integer> transform(String value) {
            try {
                return new Right<Throwable, Integer>(Integer.parseInt(value));
            } catch (NumberFormatException e) {
                return new Left<Throwable, Integer>(e);
            }
        }
    };

    @Test
    public void testMapSuccess() {
        Callback<String> onSuccess = mock(Callback.class);
        DeferredObject3<Integer, Void, Void> promise = new DeferredObject3<Integer, Void, Void>();