// 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.*;
        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>();
        Promise3<String, Void, Void> promise2 = promise.map(intToString).onSuccess(onSuccess);

        assertFalse(promise2.isSuccess());

        promise.success(1);

        assertTrue(promise2.isSuccess());
        verify(onSuccess, only()).onCallback("2!");
    }

    @Test
    public void testMapFailure() {
        DeferredObject3<Integer, Throwable, Void> promise = new DeferredObject3<Integer, Throwable, Void>();
        Promise3<String, Throwable, Void> promise2 = promise.map(intToString);

        Callback<String> onSuccess = mock(Callback.class);
        Callback<Throwable> onFailure = 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.*;

        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>();
        Promise3<String, Void, Void> promise2 = promise.map(intToString).onSuccess(onSuccess);

        assertFalse(promise2.isSuccess());

        promise.success(1);

        assertTrue(promise2.isSuccess());
        verify(onSuccess, only()).onCallback("2!");
    }

    @Test
    public void testMapFailure() {
        DeferredObject3<Integer, Throwable, Void> promise = new DeferredObject3<Integer, Throwable, Void>();
        Promise3<String, Throwable, Void> promise2 = promise.map(intToString);

        Callback<String> onSuccess = mock(Callback.class);
        Callback<Throwable> onFailure = mock(Callback.class);
        Callback<Either<Throwable, String>> onComplete = mock(Callback.class);