use of io.github.hidroh.materialistic.accounts.UserServices in project materialistic by hidroh.
the class SubmitActivityTest method testSubmitError.
@Test
public void testSubmitError() {
((EditText) activity.findViewById(R.id.edittext_title)).setText("title");
((EditText) activity.findViewById(R.id.edittext_content)).setText("http://example.com");
shadowOf(activity).clickMenuItem(R.id.menu_send);
ShadowAlertDialog.getLatestAlertDialog().getButton(DialogInterface.BUTTON_POSITIVE).performClick();
verify(userServices).submit(any(Context.class), eq("title"), eq("http://example.com"), eq(true), submitCallback.capture());
Uri redirect = Uri.parse(BuildConfig.APPLICATION_ID + "://item?id=1234");
UserServices.Exception exception = new UserServices.Exception(R.string.item_exist);
exception.data = redirect;
submitCallback.getValue().onError(exception);
assertEquals(activity.getString(R.string.item_exist), ShadowToast.getTextOfLatestToast());
assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_VIEW).hasData(redirect);
}
Aggregations