/*
 * Copyright 2013-2015 the original author or authors.
 *
 * 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.cloudfoundry.operations;

import org.cloudfoundry.client.CloudFoundryClient;
import org.cloudfoundry.client.v2.applications.ApplicationsV2;
import org.cloudfoundry.client.v2.domains.Domains;
import org.cloudfoundry.client.v2.organizations.Organizations;
import org.cloudfoundry.client.v2.spacequotadefinitions.SpaceQuotaDefinitions;
import org.cloudfoundry.client.v2.spaces.Spaces;
import org.junit.Before;
import reactor.rx.Stream;
import reactor.rx.Streams;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public abstract class AbstractOperationsTest {

    protected static final Stream<String> MISSING_ID = Streams.fail(new java.lang.IllegalStateException());

    protected static final String TEST_ORGANIZATION = "test-organization-id";

    protected static final String TEST_SPACE = "test-space-id";

    protected final ApplicationsV2 applications = mock(ApplicationsV2.class);

    protected final CloudFoundryClient cloudFoundryClient = mock(CloudFoundryClient.class);

    protected final Domains domains = mock(Domains.class);

    protected final Organizations organizations = mock(Organizations.class);

    protected final org.cloudfoundry.client.v2.routes.Routes routes = mock(org.cloudfoundry.client.v2.routes.Routes
            .class);

    protected final SpaceQuotaDefinitions spaceQuotaDefinitions = mock(SpaceQuotaDefinitions.class);

    protected final Spaces spaces = mock(Spaces.class);

    @Before
    public final void mockClient() throws Exception {
        when(this.cloudFoundryClient.applicationsV2()).thenReturn(this.applications);
        when(this.cloudFoundryClient.domains()).thenReturn(this.domains);
        when(this.cloudFoundryClient.organizations()).thenReturn(this.organizations);
        when(this.cloudFoundryClient.routes()).thenReturn(this.routes);
        when(this.cloudFoundryClient.spaceQuotaDefinitions()).thenReturn(this.spaceQuotaDefinitions);
        when(this.cloudFoundryClient.spaces()).thenReturn(this.spaces);
    }

}

@@ -1034,16 +1034,44 @@
 Before;%0A
+import org.mockito.Mockito;%0A
 import r
@@ -1569,24 +1569,53 @@
 ionsV2.class
+, Mockito.RETURNS_SMART_NULLS
 );%0A%0A    prot
@@ -1691,24 +1691,53 @@
 Client.class
+, Mockito.RETURNS_SMART_NULLS
 );%0A%0A    prot
@@ -1776,32 +1776,61 @@
 ck(Domains.class
+, Mockito.RETURNS_SMART_NULLS
 );%0A%0A    protecte
@@ -1883,32 +1883,61 @@
 anizations.class
+, Mockito.RETURNS_SMART_NULLS
 );%0A%0A    protecte
@@ -2054,24 +2054,53 @@
       .class
+, Mockito.RETURNS_SMART_NULLS
 );%0A%0A    prot
@@ -2185,24 +2185,53 @@
 itions.class
+, Mockito.RETURNS_SMART_NULLS
 );%0A%0A    prot
@@ -2275,16 +2275,45 @@
 es.class
+, Mockito.RETURNS_SMART_NULLS
 );%0A%0A    

Improve mock diagnostics