├── provider ├── spec │ ├── pacts │ │ └── .gitkeep │ ├── spec_helper.rb │ └── pact_helper.rb ├── .ruby-gemset ├── .ruby-version ├── .gitignore ├── .rspec ├── config.ru ├── Gemfile ├── Rakefile ├── lib │ └── provider.rb └── Gemfile.lock ├── consumer ├── app │ ├── .gitignore │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── au │ │ │ │ │ └── com │ │ │ │ │ └── dius │ │ │ │ │ └── pactconsumer │ │ │ │ │ ├── app │ │ │ │ │ ├── PactView.java │ │ │ │ │ ├── PactPresenter.java │ │ │ │ │ ├── di │ │ │ │ │ │ ├── ApplicationComponent.java │ │ │ │ │ │ ├── ApplicationModule.java │ │ │ │ │ │ └── NetworkModule.java │ │ │ │ │ ├── PactApplication.java │ │ │ │ │ └── PactActivity.java │ │ │ │ │ ├── data │ │ │ │ │ ├── exceptions │ │ │ │ │ │ ├── ServiceException.java │ │ │ │ │ │ └── BadRequestException.java │ │ │ │ │ ├── Repository.java │ │ │ │ │ ├── FakeService.java │ │ │ │ │ ├── model │ │ │ │ │ │ ├── Animal.java │ │ │ │ │ │ └── ServiceResponse.java │ │ │ │ │ └── Service.java │ │ │ │ │ ├── domain │ │ │ │ │ ├── Contract.java │ │ │ │ │ ├── Presenter.java │ │ │ │ │ └── ViewState.java │ │ │ │ │ ├── util │ │ │ │ │ ├── Logger.java │ │ │ │ │ ├── DateHelper.java │ │ │ │ │ └── RxBinder.java │ │ │ │ │ └── presentation │ │ │ │ │ ├── AnimalsAdapter.java │ │ │ │ │ └── HomeActivity.java │ │ │ ├── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── values │ │ │ │ │ ├── dimens.xml │ │ │ │ │ ├── colors.xml │ │ │ │ │ ├── strings.xml │ │ │ │ │ └── styles.xml │ │ │ │ ├── menu │ │ │ │ │ └── menu_animals.xml │ │ │ │ ├── layout │ │ │ │ │ ├── activity_animals.xml │ │ │ │ │ ├── layout_animal.xml │ │ │ │ │ └── content_animals.xml │ │ │ │ └── drawable │ │ │ │ │ ├── bird.xml │ │ │ │ │ ├── dog.xml │ │ │ │ │ └── cat.xml │ │ │ └── AndroidManifest.xml │ │ └── test │ │ │ └── java │ │ │ └── au │ │ │ └── com │ │ │ └── dius │ │ │ └── pactconsumer │ │ │ ├── data │ │ │ ├── FakeServiceTest.java │ │ │ ├── ServiceTest.java │ │ │ ├── ServiceMissingQueryPactTest.java │ │ │ ├── ServiceNoContentPactTest.java │ │ │ └── ServicePactTest.java │ │ │ ├── util │ │ │ └── TestRxBinder.java │ │ │ └── domain │ │ │ └── PresenterTest.java │ ├── proguard-rules.pro │ └── build.gradle ├── settings.gradle ├── .idea │ ├── copyright │ │ └── profiles_settings.xml │ ├── vcs.xml │ ├── modules.xml │ ├── runConfigurations.xml │ ├── gradle.xml │ ├── compiler.xml │ └── misc.xml ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── .gitignore ├── build.gradle ├── gradle.properties ├── gradlew.bat └── gradlew ├── LICENSE └── README.md /provider/spec/pacts/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /consumer/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /provider/.ruby-gemset: -------------------------------------------------------------------------------- 1 | example_pact 2 | -------------------------------------------------------------------------------- /provider/.ruby-version: -------------------------------------------------------------------------------- 1 | ruby-2.3.0 2 | -------------------------------------------------------------------------------- /consumer/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /provider/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'ap' 2 | -------------------------------------------------------------------------------- /provider/.gitignore: -------------------------------------------------------------------------------- 1 | log/ 2 | reports/ 3 | spec/pacts/* 4 | -------------------------------------------------------------------------------- /provider/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --format documentation 3 | -------------------------------------------------------------------------------- /provider/config.ru: -------------------------------------------------------------------------------- 1 | #\ -w -p 4567 2 | require './lib/provider' 3 | run Provider 4 | -------------------------------------------------------------------------------- /consumer/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /consumer/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DiUS/pact-workshop-android/HEAD/consumer/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /consumer/app/src/main/java/au/com/dius/pactconsumer/app/PactView.java: -------------------------------------------------------------------------------- 1 | package au.com.dius.pactconsumer.app; 2 | 3 | public interface PactView { 4 | } 5 | -------------------------------------------------------------------------------- /consumer/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DiUS/pact-workshop-android/HEAD/consumer/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /consumer/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DiUS/pact-workshop-android/HEAD/consumer/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /consumer/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DiUS/pact-workshop-android/HEAD/consumer/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /consumer/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DiUS/pact-workshop-android/HEAD/consumer/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /consumer/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DiUS/pact-workshop-android/HEAD/consumer/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /consumer/app/src/main/java/au/com/dius/pactconsumer/app/PactPresenter.java: -------------------------------------------------------------------------------- 1 | package au.com.dius.pactconsumer.app; 2 | 3 | 4 | public interface PactPresenter { 5 | void onStart(); 6 | void onStop(); 7 | } 8 | -------------------------------------------------------------------------------- /consumer/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /consumer/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | app/target/pacts/* 11 | app/okhttp_cache/ 12 | -------------------------------------------------------------------------------- /provider/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'rake' 4 | gem 'activesupport' 5 | gem 'rack' 6 | gem 'sinatra' 7 | 8 | group :development, :test do 9 | gem 'pry' 10 | gem 'rspec' 11 | gem 'awesome_print' 12 | gem 'pact' 13 | end 14 | -------------------------------------------------------------------------------- /consumer/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 180dp 3 | 8dp 4 | 8dp 5 | 100dp 6 | 7 | -------------------------------------------------------------------------------- /consumer/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /consumer/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /consumer/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | PactConsumer 3 | Settings 4 | Oops, something went wrong 5 | No animals found 6 | 7 | -------------------------------------------------------------------------------- /consumer/app/src/main/java/au/com/dius/pactconsumer/data/exceptions/ServiceException.java: -------------------------------------------------------------------------------- 1 | package au.com.dius.pactconsumer.data.exceptions; 2 | 3 | public class ServiceException extends RuntimeException { 4 | 5 | public ServiceException() { } 6 | 7 | public ServiceException(String message, Throwable cause) { 8 | super(message, cause); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /consumer/app/src/main/java/au/com/dius/pactconsumer/data/exceptions/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package au.com.dius.pactconsumer.data.exceptions; 2 | 3 | public class BadRequestException extends ServiceException { 4 | 5 | public BadRequestException() { } 6 | 7 | public BadRequestException(String message, Throwable cause) { 8 | super(message, cause); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /consumer/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /consumer/app/src/main/java/au/com/dius/pactconsumer/data/Repository.java: -------------------------------------------------------------------------------- 1 | package au.com.dius.pactconsumer.data; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | import org.joda.time.DateTime; 6 | 7 | import au.com.dius.pactconsumer.data.model.ServiceResponse; 8 | import io.reactivex.Single; 9 | 10 | public interface Repository { 11 | 12 | @NonNull 13 | Single fetchResponse(@NonNull DateTime dateTime); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /consumer/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | 3 | repositories { 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' 10 | classpath 'me.tatarka:gradle-retrolambda:3.3.0' 11 | } 12 | 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /consumer/app/src/main/java/au/com/dius/pactconsumer/domain/Contract.java: -------------------------------------------------------------------------------- 1 | package au.com.dius.pactconsumer.domain; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | import au.com.dius.pactconsumer.app.PactPresenter; 6 | import au.com.dius.pactconsumer.app.PactView; 7 | 8 | public interface Contract { 9 | 10 | interface View extends PactView { 11 | void setViewState(@NonNull ViewState viewState); 12 | } 13 | 14 | interface Presenter extends PactPresenter { 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /provider/Rakefile: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require 'rubygems' 4 | require 'bundler' 5 | 6 | begin 7 | Bundler.setup(:default, :development) 8 | rescue Bundler::BundlerError => e 9 | $stderr.puts e.message 10 | $stderr.puts "Run `bundle install` to install missing gems" 11 | exit e.status_code 12 | end 13 | 14 | require 'rake' 15 | require 'rspec/core/rake_task' 16 | RSpec::Core::RakeTask.new(:spec) 17 | 18 | require 'pact/tasks' 19 | 20 | task :default => [:spec] 21 | 22 | $:.unshift 'lib' 23 | -------------------------------------------------------------------------------- /consumer/app/src/main/res/menu/menu_animals.xml: -------------------------------------------------------------------------------- 1 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /consumer/app/src/main/java/au/com/dius/pactconsumer/util/Logger.java: -------------------------------------------------------------------------------- 1 | package au.com.dius.pactconsumer.util; 2 | 3 | import android.support.annotation.NonNull; 4 | import android.util.Log; 5 | 6 | import javax.inject.Inject; 7 | import javax.inject.Singleton; 8 | 9 | @Singleton 10 | public class Logger { 11 | 12 | @Inject 13 | public Logger() { 14 | } 15 | 16 | public void d(@NonNull String tag, @NonNull String msg) { 17 | Log.d(tag, msg); 18 | } 19 | 20 | public void e(@NonNull String tag, @NonNull String msg, @NonNull Throwable tr) { 21 | Log.e(tag, msg, tr); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /provider/spec/pact_helper.rb: -------------------------------------------------------------------------------- 1 | require 'pact/provider/rspec' 2 | 3 | Pact.service_provider "our_provider" do 4 | 5 | honours_pact_with 'our_consumer' do 6 | pact_uri URI.encode('https://test.pact.dius.com.au/pact/provider/our_provider/consumer/our_consumer/latest') 7 | end 8 | 9 | end 10 | 11 | Pact.provider_states_for "our_consumer" do 12 | 13 | provider_state "data count is > 0" do 14 | set_up do 15 | ProviderData.animals = ANIMALS_LIST 16 | end 17 | end 18 | 19 | provider_state "data count is == 0" do 20 | set_up do 21 | ProviderData.animals = [] 22 | end 23 | end 24 | 25 | end 26 | -------------------------------------------------------------------------------- /consumer/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /consumer/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /consumer/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/theeban/Android/Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /consumer/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /consumer/app/src/main/java/au/com/dius/pactconsumer/app/di/ApplicationComponent.java: -------------------------------------------------------------------------------- 1 | package au.com.dius.pactconsumer.app.di; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.NonNull; 5 | 6 | import javax.inject.Singleton; 7 | 8 | import au.com.dius.pactconsumer.data.Repository; 9 | import au.com.dius.pactconsumer.presentation.HomeActivity; 10 | import au.com.dius.pactconsumer.util.Logger; 11 | import dagger.Component; 12 | 13 | @Singleton 14 | @Component(modules = {ApplicationModule.class, NetworkModule.class}) 15 | public interface ApplicationComponent { 16 | 17 | @NonNull 18 | Context getContext(); 19 | 20 | @NonNull 21 | Logger getLogger(); 22 | 23 | @NonNull 24 | Repository getRepository(); 25 | 26 | void inject(HomeActivity homeActivity); 27 | } 28 | -------------------------------------------------------------------------------- /consumer/app/src/test/java/au/com/dius/pactconsumer/data/FakeServiceTest.java: -------------------------------------------------------------------------------- 1 | package au.com.dius.pactconsumer.data; 2 | 3 | import org.joda.time.DateTime; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | 7 | import au.com.dius.pactconsumer.data.model.ServiceResponse; 8 | import io.reactivex.observers.TestObserver; 9 | 10 | public class FakeServiceTest { 11 | 12 | FakeService service; 13 | 14 | @Before 15 | public void setUp() { 16 | service = new FakeService(); 17 | } 18 | 19 | @Test 20 | public void should_return_list_of_animals() { 21 | // when 22 | TestObserver observer = service.fetchResponse(DateTime.now()).test(); 23 | 24 | // then 25 | observer.assertNoErrors(); 26 | observer.assertValue(FakeService.RESPONSE); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /consumer/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /consumer/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |