// Path: consumer/app/src/main/java/au/com/dius/pactconsumer/app/di/NetworkModule.java
// @Module
// public class NetworkModule {
// 
//   @Singleton
//   @Provides
//   @NonNull
//   public Retrofit getRetrofit(@NonNull Context context) {
//     return getRetrofit(context, BuildConfig.BASE_URL);
//   }
// 
//   @VisibleForTesting
//   public Retrofit getRetrofit(@NonNull Context context,
//                               @NonNull String baseUrl) {
//     return new Retrofit.Builder()
//         .baseUrl(baseUrl)
//         .client(getOkHttpClient(context))
//         .addConverterFactory(MoshiConverterFactory.create(getMoshi()))
//         .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
//         .build();
//   }
// 
//   private OkHttpClient getOkHttpClient(@NonNull Context context) {
//     OkHttpClient.Builder builder = new OkHttpClient.Builder();
//     if (BuildConfig.DEBUG) {
//       HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
//       interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
//       builder.addNetworkInterceptor(interceptor);
//     }
//     builder.cache(new Cache(new File(context.getCacheDir(), "okhttp_cache"), 10 * 1024 * 1024));
//     return builder.build();
//   }
// 
//   private Moshi getMoshi() {
//     return new Moshi.Builder().add(new DateTimeAdapter()).build();
//   }
// 
//   public static class DateTimeAdapter {
// 
//     @ToJson
//     public String toJson(DateTime dateTime) {
//       return DateHelper.toString(dateTime);
//     }
// 
//     @FromJson
//     public DateTime fromJson(String json) {
//       return DateHelper.parse(json);
//     }
//   }
// 
// }
// 
// Path: consumer/app/src/main/java/au/com/dius/pactconsumer/data/model/ServiceResponse.java
// public class ServiceResponse {
// 
//   @Json(name = "valid_date")
//   private final DateTime validDate;
// 
//   @Json(name = "animals")
//   private final List<Animal> animals;
// 
//   public ServiceResponse(@Nullable DateTime validDate,
//                          @NonNull List<Animal> animals) {
//     this.validDate = validDate;
//     this.animals = animals;
//   }
// 
//   @Nullable
//   public DateTime getValidDate() {
//     return validDate;
//   }
// 
//   @NonNull
//   public List<Animal> getAnimals() {
//     return animals;
//   }
// 
//   @Override
//   public boolean equals(Object o) {
//     if (this == o) return true;
//     if (o == null || getClass() != o.getClass()) return false;
// 
//     ServiceResponse that = (ServiceResponse) o;
// 
//     long millis = validDate != null ? validDate.getMillis() : -1;
//     long thatMillis = that.validDate != null ? that.validDate.getMillis() : -1;
//     if (millis != thatMillis)
//       return false;
// 
//     return animals != null ? animals.equals(that.animals) : that.animals == null;
//   }
// 
//   @Override
//   public int hashCode() {
//     int result = validDate != null ? validDate.hashCode() : 0;
//     result = 31 * result + (animals != null ? animals.hashCode() : 0);
//     return result;
//   }
// 
//   @Override
//   public String toString() {
//     return "ServiceResponse{" +
//         "validDate=" + validDate +
//         ", animals=" + animals +
//         '}';
//   }
// 
//   public static ServiceResponse create(@NonNull DateTime validDate, @NonNull List<Animal> animals) {
//     return new ServiceResponse(validDate, animals);
//   }
// }
// 
// Path: consumer/app/src/main/java/au/com/dius/pactconsumer/util/DateHelper.java
// public final class DateHelper {
// 
//   private DateHelper() {
//   }
// 
//   public static String encodeDate(@Nullable DateTime dateTime) throws UnsupportedEncodingException {
//     if (dateTime == null) {
//       return null;
//     }
//     return URLEncoder.encode(toString(dateTime), "UTF-8");
//   }
// 
//   public static DateTime parse(@NonNull String value) {
//     return DateTime.parse(value);
//   }
// 
//   public static String toString(@NonNull DateTime value) {
//     return value.toString();
//   }
// 
// }


import android.content.Context;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import java.io.UnsupportedEncodingException;
import java.util.Collections;
import au.com.dius.pact.consumer.Pact;
import au.com.dius.pact.consumer.PactProviderRule;
import au.com.dius.pact.consumer.PactVerification;
import au.com.dius.pact.consumer.dsl.PactDslWithProvider;
import au.com.dius.pact.model.PactFragment;
import au.com.dius.pactconsumer.app.di.NetworkModule;
import au.com.dius.pactconsumer.data.model.ServiceResponse;
import au.com.dius.pactconsumer.util.DateHelper;
import io.reactivex.observers.TestObserver;
import static org.mockito.Mockito.mock;
package au.com.dius.pactconsumer.data;







public class ServiceNoContentPactTest {

  static final DateTime DATE_TIME;

  static {
    DATE_TIME = DateTime.now();
  }

  Service service;

  @Before
  public void setUp() {
    NetworkModule networkModule = new NetworkModule();
    service = new Service(networkModule.getRetrofit(mock(Context.class), "http://localhost:9292").create(Service.Api.class));
  }

  @Rule
  public PactProviderRule mockProvider = new PactProviderRule("our_provider", "localhost", 9292, this);

  @Pact(provider = "our_provider", consumer = "our_consumer")
  public PactFragment createFragment(PactDslWithProvider builder) throws UnsupportedEncodingException {
    return builder
        .given("data count is == 0")
        .uponReceiving("a request for json data")
        .path("/provider.json")
        .method("GET")
// Path: consumer/app/src/main/java/au/com/dius/pactconsumer/app/di/NetworkModule.java
// @Module
// public class NetworkModule {
// 
//   @Singleton
//   @Provides
//   @NonNull
//   public Retrofit getRetrofit(@NonNull Context context) {
//     return getRetrofit(context, BuildConfig.BASE_URL);
//   }
// 
//   @VisibleForTesting
//   public Retrofit getRetrofit(@NonNull Context context,
//                               @NonNull String baseUrl) {
//     return new Retrofit.Builder()
//         .baseUrl(baseUrl)
//         .client(getOkHttpClient(context))
//         .addConverterFactory(MoshiConverterFactory.create(getMoshi()))
//         .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
//         .build();
//   }
// 
//   private OkHttpClient getOkHttpClient(@NonNull Context context) {
//     OkHttpClient.Builder builder = new OkHttpClient.Builder();
//     if (BuildConfig.DEBUG) {
//       HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
//       interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
//       builder.addNetworkInterceptor(interceptor);
//     }
//     builder.cache(new Cache(new File(context.getCacheDir(), "okhttp_cache"), 10 * 1024 * 1024));
//     return builder.build();
//   }
// 
//   private Moshi getMoshi() {
//     return new Moshi.Builder().add(new DateTimeAdapter()).build();
//   }
// 
//   public static class DateTimeAdapter {
// 
//     @ToJson
//     public String toJson(DateTime dateTime) {
//       return DateHelper.toString(dateTime);
//     }
// 
//     @FromJson
//     public DateTime fromJson(String json) {
//       return DateHelper.parse(json);
//     }
//   }
// 
// }
// 
// Path: consumer/app/src/main/java/au/com/dius/pactconsumer/data/model/ServiceResponse.java
// public class ServiceResponse {
// 
//   @Json(name = "valid_date")
//   private final DateTime validDate;
// 
//   @Json(name = "animals")
//   private final List<Animal> animals;
// 
//   public ServiceResponse(@Nullable DateTime validDate,
//                          @NonNull List<Animal> animals) {
//     this.validDate = validDate;
//     this.animals = animals;
//   }
// 
//   @Nullable
//   public DateTime getValidDate() {
//     return validDate;
//   }
// 
//   @NonNull
//   public List<Animal> getAnimals() {
//     return animals;
//   }
// 
//   @Override
//   public boolean equals(Object o) {
//     if (this == o) return true;
//     if (o == null || getClass() != o.getClass()) return false;
// 
//     ServiceResponse that = (ServiceResponse) o;
// 
//     long millis = validDate != null ? validDate.getMillis() : -1;
//     long thatMillis = that.validDate != null ? that.validDate.getMillis() : -1;
//     if (millis != thatMillis)
//       return false;
// 
//     return animals != null ? animals.equals(that.animals) : that.animals == null;
//   }
// 
//   @Override
//   public int hashCode() {
//     int result = validDate != null ? validDate.hashCode() : 0;
//     result = 31 * result + (animals != null ? animals.hashCode() : 0);
//     return result;
//   }
// 
//   @Override
//   public String toString() {
//     return "ServiceResponse{" +
//         "validDate=" + validDate +
//         ", animals=" + animals +
//         '}';
//   }
// 
//   public static ServiceResponse create(@NonNull DateTime validDate, @NonNull List<Animal> animals) {
//     return new ServiceResponse(validDate, animals);
//   }
// }
// 
// Path: consumer/app/src/main/java/au/com/dius/pactconsumer/util/DateHelper.java
// public final class DateHelper {
// 
//   private DateHelper() {
//   }
// 
//   public static String encodeDate(@Nullable DateTime dateTime) throws UnsupportedEncodingException {
//     if (dateTime == null) {
//       return null;
//     }
//     return URLEncoder.encode(toString(dateTime), "UTF-8");
//   }
// 
//   public static DateTime parse(@NonNull String value) {
//     return DateTime.parse(value);
//   }
// 
//   public static String toString(@NonNull DateTime value) {
//     return value.toString();
//   }
// 
// }


// Path: consumer/app/src/test/java/au/com/dius/pactconsumer/data/ServiceNoContentPactTest.java
import android.content.Context;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import java.io.UnsupportedEncodingException;
import java.util.Collections;
import au.com.dius.pact.consumer.Pact;
import au.com.dius.pact.consumer.PactProviderRule;
import au.com.dius.pact.consumer.PactVerification;
import au.com.dius.pact.consumer.dsl.PactDslWithProvider;
import au.com.dius.pact.model.PactFragment;
import au.com.dius.pactconsumer.app.di.NetworkModule;
import au.com.dius.pactconsumer.data.model.ServiceResponse;
import au.com.dius.pactconsumer.util.DateHelper;
import io.reactivex.observers.TestObserver;
import static org.mockito.Mockito.mock;

package au.com.dius.pactconsumer.data;







public class ServiceNoContentPactTest {

  static final DateTime DATE_TIME;

  static {
    DATE_TIME = DateTime.now();
  }

  Service service;

  @Before
  public void setUp() {
    NetworkModule networkModule = new NetworkModule();
    service = new Service(networkModule.getRetrofit(mock(Context.class), "http://localhost:9292").create(Service.Api.class));
  }

  @Rule
  public PactProviderRule mockProvider = new PactProviderRule("our_provider", "localhost", 9292, this);

  @Pact(provider = "our_provider", consumer = "our_consumer")
  public PactFragment createFragment(PactDslWithProvider builder) throws UnsupportedEncodingException {
    return builder
        .given("data count is == 0")
        .uponReceiving("a request for json data")
        .path("/provider.json")
        .method("GET")
        .query("valid_date=" + DateHelper.encodeDate(DATE_TIME))