package com.sdoward.rxgooglemap;

import com.google.android.gms.maps.*;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.*;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import rx.observers.TestSubscriber;

import static org.mockito.Mockito.verify;

@RunWith(PowerMockRunner.class)
@PrepareForTest(GoogleMap.class)
public class MapObservableProviderTest {

    @Mock
    private MapFragment mapFragment;
    @Mock
    private SupportMapFragment supportMapFragment;
    @Mock
    private MapView mapView;
    @Mock
    private GoogleMap googleMap;
    @Captor
    private ArgumentCaptor<OnMapReadyCallback> argumentCaptor;

    @Test
    public void shouldReturnMapFromFragment() {
        TestSubscriber<GoogleMap> subscriber = new TestSubscriber<>();
        new MapObservableProvider(mapFragment)
                .getMapReadyObservable()
                .subscribe(subscriber);
        verify(mapFragment).getMapAsync(argumentCaptor.capture());
        argumentCaptor.getValue().onMapReady(googleMap);
        subscriber.assertNoErrors();
        subscriber.assertValue(googleMap);
    }

    @Test
    public void shouldReturnMapFromSupportFragment() {
        TestSubscriber<GoogleMap> subscriber = new TestSubscriber<>();
        new MapObservableProvider(supportMapFragment)
                .getMapReadyObservable()
                .subscribe(subscriber);
        verify(supportMapFragment).getMapAsync(argumentCaptor.capture());
        argumentCaptor.getValue().onMapReady(googleMap);
        subscriber.assertNoErrors();
        subscriber.assertValue(googleMap);
    }

    @Test
    public void shouldReturnMapFromView() {
        TestSubscriber<GoogleMap> subscriber = new TestSubscriber<>();
        new MapObservableProvider(mapView)
                .getMapReadyObservable()
                .subscribe(subscriber);
        verify(mapView).getMapAsync(argumentCaptor.capture());
        argumentCaptor.getValue().onMapReady(googleMap);
        subscriber.assertNoErrors();
        subscriber.assertValue(googleMap);
    }

}
@@ -66,16 +66,48 @@
 aps.*;%0A%0A
+import junit.framework.Assert;%0A%0A
 import o
@@ -117,24 +117,24 @@
 junit.Test;%0A
-
 import org.j
@@ -292,24 +292,46 @@
 ockRunner;%0A%0A
+import rx.Observable;%0A
 import rx.ob
@@ -2184,9 +2184,2848 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void shouldProvideClickObservable() throws Exception %7B%0A        Observable observable = new MapObservableProvider(mapFragment).getMapClickObservable();%0A        Assert.assertNotNull(observable);%0A    %7D%0A%0A    @Test%0A    public void shouldProvideLongClickObservable() throws Exception %7B%0A        Observable observable = new MapObservableProvider(mapFragment).getMapLongClickObservable();%0A        Assert.assertNotNull(observable);%0A    %7D%0A%0A    @Test%0A    public void shouldProvideDragObservable() throws Exception %7B%0A        Observable observable = new MapObservableProvider(mapFragment).getDragObservable();%0A        Assert.assertNotNull(observable);%0A    %7D%0A%0A    @Test%0A    public void shouldProvideMarkerClickObservable() throws Exception %7B%0A        Observable observable = new MapObservableProvider(mapFragment).getMarkerClickObservable();%0A        Assert.assertNotNull(observable);%0A    %7D%0A%0A    @Test%0A    public void shouldProvideInfoWindowClickObservable() throws Exception %7B%0A        Observable observable =%0A                new MapObservableProvider(mapFragment).getInfoWindowClickObservable();%0A        Assert.assertNotNull(observable);%0A    %7D%0A%0A    @Test%0A    public void shouldProvideInfoLongClickObservable() throws Exception %7B%0A        Observable observable =%0A                new MapObservableProvider(mapFragment).getInfoWindowLongClickObservable();%0A        Assert.assertNotNull(observable);%0A    %7D%0A%0A    @Test%0A    public void shouldProvideInfoClosedObservable() throws Exception %7B%0A        Observable observable =%0A                new MapObservableProvider(mapFragment).getInfoWindowCloseObservable();%0A        Assert.assertNotNull(observable);%0A    %7D%0A%0A    @Test%0A    public void shouldProvideCameraChangedObservable() throws Exception %7B%0A        Observable observable = new MapObservableProvider(mapFragment).getCameraChangeObservable();%0A        Assert.assertNotNull(observable);%0A    %7D%0A%0A    @Test%0A    public void shouldProvideIndoorBuildingObservable() throws Exception %7B%0A        Observable observable%0A                = new MapObservableProvider(mapFragment).getIndoorBuildingObservable();%0A        Assert.assertNotNull(observable);%0A    %7D%0A%0A    @Test%0A    public void shouldProvidePolylineClickObservable() throws Exception %7B%0A        Observable observable = new MapObservableProvider(mapFragment).getPolylineClickObservable();%0A        Assert.assertNotNull(observable);%0A    %7D%0A%0A    @Test%0A    public void shouldProvidePolygonClickObservable() throws Exception %7B%0A        Observable observable = new MapObservableProvider(mapFragment).getPolygonClickObservable();%0A        Assert.assertNotNull(observable);%0A    %7D%0A%0A    @Test%0A    public void shouldProvideGroundOverlayObservable() throws Exception %7B%0A        Observable observable = new MapObservableProvider(mapFragment).getGroundOverlayObservable();%0A        Assert.assertNotNull(observable);%0A    %7D%0A
 %7D

Add tests for MapObservableProvider