@Test public void testUserNotFoundErrorMessage() { String expectedMessage = Robolectric.application.getString(R.string.exception_message_user_not_found); String actualMessage = ErrorMessageFactory.create(Robolectric.application, ErrorBundle.Error.UserNotFound); assertThat(actualMessage, is(equalTo(expectedMessage))); }
public static String create(Context context, ErrorBundle.Error exception) { for (ErrorMessage errorMessage : ErrorMessage.values()) { if(errorMessage.error.equals(exception)) { return context.getString(errorMessage.message); } } return context.getString(ErrorMessage.Unexpected.message); }
ErrorMessageFactory { public static String create(Context context, ErrorBundle.Error exception) { for (ErrorMessage errorMessage : ErrorMessage.values()) { if(errorMessage.error.equals(exception)) { return context.getString(errorMessage.message); } } return context.getString(ErrorMessage.Unexpected.message); } }
ErrorMessageFactory { public static String create(Context context, ErrorBundle.Error exception) { for (ErrorMessage errorMessage : ErrorMessage.values()) { if(errorMessage.error.equals(exception)) { return context.getString(errorMessage.message); } } return context.getString(ErrorMessage.Unexpected.message); } private  ErrorMessageFactory(); }
ErrorMessageFactory { public static String create(Context context, ErrorBundle.Error exception) { for (ErrorMessage errorMessage : ErrorMessage.values()) { if(errorMessage.error.equals(exception)) { return context.getString(errorMessage.message); } } return context.getString(ErrorMessage.Unexpected.message); } private  ErrorMessageFactory(); static String create(Context context, ErrorBundle.Error exception); }
ErrorMessageFactory { public static String create(Context context, ErrorBundle.Error exception) { for (ErrorMessage errorMessage : ErrorMessage.values()) { if(errorMessage.error.equals(exception)) { return context.getString(errorMessage.message); } } return context.getString(ErrorMessage.Unexpected.message); } private  ErrorMessageFactory(); static String create(Context context, ErrorBundle.Error exception);  }