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);  }
@Test public void testNetworkConnectionErrorMessage() { String expectedMessage = Robolectric.application.getString(R.string.exception_message_no_connection); String actualMessage = ErrorMessageFactory.create(Robolectric.application, ErrorBundle.Error.NetworkConnection); assertThat(actualMessage, is(equalTo(expectedMessage))); }
@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))); }