/*
 * Copyright 2018 New Vector Ltd
 *
 * 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 org.matrix.androidsdk;

import android.support.annotation.CallSuper;
import android.support.annotation.NonNull;

import org.matrix.androidsdk.rest.callback.ApiCallback;
import org.matrix.androidsdk.rest.model.MatrixError;

import java.util.concurrent.CountDownLatch;

/**
 * Simple implementation of ApiCallback, which count down the CountDownLatch on each API callback
 *
 * @param <T>
 */
class TestApiCallback<T> implements ApiCallback<T> {

    @NonNull
    private final CountDownLatch mCountDownLatch;

    TestApiCallback(@NonNull CountDownLatch countDownLatch) {
        mCountDownLatch = countDownLatch;
    }

    @CallSuper
    @Override
    public void onSuccess(T info) {
        mCountDownLatch.countDown();
    }

    @CallSuper
    @Override
    public void onNetworkError(Exception e) {
        mCountDownLatch.countDown();
    }

    @CallSuper
    @Override
    public void onMatrixError(MatrixError e) {
        mCountDownLatch.countDown();
    }

    @CallSuper
    @Override
    public void onUnexpectedError(Exception e) {
        mCountDownLatch.countDown();
    }
}

@@ -821,16 +821,55 @@
 ixError;
+%0Aimport org.matrix.androidsdk.util.Log;
 %0A%0Aimport
@@ -1435,32 +1435,86 @@
 (Exception e) %7B%0A
+        Log.e(%22TestApiCallback%22, e.getMessage(), e);%0A%0A
         mCountDo
@@ -1526,32 +1526,32 @@
 ch.countDown();%0A
-
     %7D%0A%0A    @Call
@@ -1613,24 +1613,93 @@
 xError e) %7B%0A
+        Log.e(%22TestApiCallback%22, e.getMessage() + %22 %22 + e.errcode);%0A%0A
         mCou
@@ -1751,32 +1751,32 @@
 r%0A    @Override%0A
-
     public void 
@@ -1800,32 +1800,86 @@
 (Exception e) %7B%0A
+        Log.e(%22TestApiCallback%22, e.getMessage(), e);%0A%0A
         mCountDo

add log on errors