package com.mpt.i906.api.prayer;

import com.i906.mpt.api.prayer.PrayerClient;
import com.i906.mpt.api.prayer.PrayerData;
import com.i906.mpt.date.DateTimeHelper;
import com.mpt.i906.api.MockApiUtils;

import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;

import rx.Observable;
import rx.functions.Func1;

/**
 * @author Noorzaini Ilhami
 */
public class MockPrayerClient implements PrayerClient {

    private final MockApiUtils mUtils;
    private final DateTimeHelper mDateHelper;

    public MockPrayerClient(MockApiUtils utils, DateTimeHelper date) {
        mUtils = utils;
        mDateHelper = date;
    }

    @Override
    public Observable<PrayerData> getPrayerTimesByCode(String code, final int year, final int month) {
        return Observable.just(mUtils.randomInt(0, 10))
                .delay(mUtils.randomInt(0, 5000), TimeUnit.MILLISECONDS)
                .flatMap(new Func1<Integer, Observable<PrayerData>>() {
                    @Override
                    public Observable<PrayerData> call(Integer r) {
                        if (r % 4 == 0) {
                            return Observable.error(new RuntimeException("Random error."));
                        } else {
                            PrayerData data = mUtils.getData(PrayerData.class, "json/prayer.json");

                            List<List<Date>> dailyDates = data.getPrayerTimes();

                            for (List<Date> dates : dailyDates) {
                                for (Date date : dates) {
                                    date.setDate(mDateHelper.getCurrentDate());
                                    date.setMonth(month);
                                    date.setYear(year);
                                }
                            }

                            return Observable.just(data);
                        }
                    }
                });
    }

    @Override
    public Observable<PrayerData> getPrayerTimesByCoordinates(double lat, double lng, int year, int month) {
        return getPrayerTimesByCode("xxx", year, month);
    }
}

@@ -27,16 +27,42 @@
 rayer;%0A%0A
+import android.util.Log;%0A%0A
 import c
@@ -774,32 +774,167 @@
 al int month) %7B%0A
+        Log.w(%22MockPrayerClient%22, %22Performing network tasks. Code: %22 + code%0A                + %22 Year: %22 + year + %22 Month: %22 + month);%0A%0A
         return O
@@ -1254,24 +1254,99 @@
 %25 4 == 0) %7B%0A
+                            Log.w(%22MockPrayerClient%22, %22Returning error.%22);%0A
             
@@ -1458,16 +1458,90 @@
  else %7B%0A
+                            Log.w(%22MockPrayerClient%22, %22Returning data.%22);%0A
         
@@ -1843,88 +1843,8 @@
 ) %7B%0A
-                                    date.setDate(mDateHelper.getCurrentDate());%0A
     
@@ -1950,16 +1950,23 @@
 ear(year
+ - 1900
 );%0A     
@@ -2273,32 +2273,182 @@
 r, int month) %7B%0A
+        Log.w(%22MockPrayerClient%22, %22Performing network tasks. Lat: %22 + lat + %22 Lng: %22 + lng%0A                + %22 Year: %22 + year + %22 Month: %22 + month);%0A%0A
         return g

Add logs to MockPrayerClient