This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies: | |
pre: | |
- echo y | android update sdk --all --no-ui --filter "build-tools-25.0.2" | |
- echo y | android update sdk --all --no-ui --filter "android-25" | |
- echo y | android update sdk --all --no-ui --filter "extra-android-m2repository" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<string name="success_title">Success</string> | |
<string name="success_description">Congrats you did it!</string> | |
<string name="error_title">Error</string> | |
<string name="error_description">Uh oh something went wrong</string> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ResourceManagerTest { | |
private TestResources resources = new TestResources(); | |
private ResourceManager resourceManager = new ResourceManager(resources); | |
@Test public void shouldNotBeNull() throws Exception { | |
assertThat(resourceManager).isNotNull(); | |
} | |
@Test public void getTitle_true_shouldReturnSuccessTitle() throws Exception { | |
assertThat(resourceManager.getTitle(true)).isEqualTo("Success"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ResourceManager { | |
private Resources resources; | |
public ResourceManager(Resources resources) { | |
this.resources = resources; | |
} | |
public String getTitle(boolean success) { | |
if (success) { | |
return resources.getString(R.string.success_title); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void initMockSslContext() throws KeyStoreException, NoSuchAlgorithmException { | |
final TrustManagerFactory trustManagerFactory = PowerMockito.mock(TrustManagerFactory.class); | |
final TrustManager[] trustManagers = new TrustManager[1]; | |
// Mock TrustManagerFactory.getInstance(String) | |
mockStatic(TrustManagerFactory.class); | |
when(TrustManagerFactory.getInstance(anyString())).thenReturn(trustManagerFactory); | |
// Mock TrustManagerFactory#getTrustManagers() | |
trustManagers[0] = PowerMockito.mock(X509TrustManager.class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(PowerMockRunner.class) | |
@PrepareForTest(ContextCompat.class) | |
@PowerMockIgnore("javax.net.ssl.*") | |
public class UserLocationStoreTest { | |
private UserLocationStore userLocationStore; | |
@Before public void setUp() throws Exception { | |
userLocationStore = new UserLocationStore(PowerMockito.mock(Context.class)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(PowerMockRunner.class) | |
@PrepareForTest(ContextCompat.class) | |
public class UserLocationStoreTest { | |
private UserLocationStore userLocationStore; | |
@Before public void setUp() throws Exception { | |
userLocationStore = new UserLocationStore(PowerMockito.mock(Context.class)); | |
} | |
@Test public void getLocation_shouldReturnDeviceLocation() throws Exception { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UserLocationStore { | |
private final Context context; | |
public UserLocationStore(Context context) { | |
this.context = context; | |
} | |
public UserLocation getLocation() { | |
if (ContextCompat.checkSelfPermission(context, | |
Manifest.permission.ACCESS_FINE_LOCATION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.lang.AssertionError | |
at okhttp3.OkHttpClient.systemDefaultTrustManager(OkHttpClient.java:275) | |
at okhttp3.OkHttpClient.<init>(OkHttpClient.java:242) | |
at okhttp3.OkHttpClient$Builder.build(OkHttpClient.java:878) | |
at com.example.ecgreb.mvpc.model.NetworkClient.<init>(NetworkClient.java:16) | |
at com.example.ecgreb.mvpc.model.NetworkClientTest.setUp(NetworkClientTest.java:15) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
at java.lang.reflect.Method.invoke(Method.java:498) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MapViewTest { | |
// ... | |
@Test public void shouldInflateLayoutWithOverlayModeSdk() throws Exception { | |
Context context = mock(Context.class); | |
TypedArray typedArray = mock(TypedArray.class); | |
TestLayoutInflater layoutInflater = new TestLayoutInflater(context); | |
initMockAttributes(context, typedArray, layoutInflater, OVERLAY_MODE_SDK); |