/*
Copyright 2016 StepStone Services

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 com.stepstone.inbucket;

import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;
import retrofit2.mock.BehaviorDelegate;
import retrofit2.mock.MockRetrofit;
import retrofit2.mock.NetworkBehavior;

public class InbucketTestClient extends InbucketClient {
    public InbucketTestClient(String baseUrl) {
        super(baseUrl);

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(baseUrl)
                .addConverterFactory(JacksonConverterFactory.create())
                .build();

        NetworkBehavior behavior = NetworkBehavior.create();
        MockRetrofit mockRetrofit = new MockRetrofit.Builder(retrofit)
                .networkBehavior(behavior)
                .build();

        BehaviorDelegate<InbucketService> delegate = mockRetrofit.create(InbucketService.class);
        service = new InbucketMockService(delegate);


        retrofit = new Retrofit.Builder()
                .baseUrl(baseUrl)
                .build();
        mockRetrofit = new MockRetrofit.Builder(retrofit)
                .networkBehavior(behavior)
                .build();

        delegate = mockRetrofit.create(InbucketService.class);
        simpleService = new InbucketMockService(delegate);
    }
}

@@ -1166,24 +1166,63 @@
 r.create();%0A
+        behavior.setFailurePercent(0);%0A
         Mock

fix failing test