Program: 142117
Project: 142117
Buggy source:
@Test public void makeQueryWithBadServerPayloadTest(){
  ModernHttpRequesterMock.setResponseCodes(new Integer[]{200});
  ModernHttpRequesterMock.setExpectedUrls(new String[]{"String_Node_Str"});
  ModernHttpRequesterMock.setRequestPayloads(new String[]{"String_Node_Str"});
  AndroidSessionWrapper sessionWrapper=CommCareApplication._().getCurrentSessionWrapper();
  CommCareSession session=sessionWrapper.getSession();
  session.setCommand("String_Node_Str");
  Intent queryActivityIntent=new Intent(RuntimeEnvironment.application,QueryRequestActivity.class);
  QueryRequestActivity queryRequestActivity=Robolectric.buildActivity(QueryRequestActivity.class).withIntent(queryActivityIntent).create().start().resume().get();
  LinearLayout promptsLayout=(LinearLayout)queryRequestActivity.findViewById(R.id.query_prompts);
  EditText patientId=(EditText)promptsLayout.getChildAt(1);
  patientId.setText("String_Node_Str");
  EditText patientName=(EditText)promptsLayout.getChildAt(3);
  patientName.setText("String_Node_Str");
  Button queryButton=(Button)queryRequestActivity.findViewById(R.id.request_button);
  queryButton.performClick();
  TextView errorMessage=(TextView)queryRequestActivity.findViewById(R.id.error_message);
  assertEquals(View.VISIBLE,errorMessage.getVisibility());
  assertTrue(((String)errorMessage.getText()).contains(Localization.get("String_Node_Str","String_Node_Str")));
}

Fixed version (ground truth):
@Test public void makeQueryWithBadServerPayloadTest(){
  ModernHttpRequesterMock.setResponseCodes(new Integer[]{200});
  ModernHttpRequesterMock.setExpectedUrls(new String[]{"String_Node_Str"});
  ModernHttpRequesterMock.setRequestPayloads(new String[]{"String_Node_Str"});
  AndroidSessionWrapper sessionWrapper=CommCareApplication._().getCurrentSessionWrapper();
  CommCareSession session=sessionWrapper.getSession();
  session.setCommand("String_Node_Str");
  Intent queryActivityIntent=new Intent(RuntimeEnvironment.application,QueryRequestActivity.class);
  ActivityController<QueryRequestActivity> controller=Robolectric.buildActivity(QueryRequestActivity.class).withIntent(queryActivityIntent).create().start().resume();
  QueryRequestActivity queryRequestActivity=controller.get();
  LinearLayout promptsLayout=(LinearLayout)queryRequestActivity.findViewById(R.id.query_prompts);
  EditText patientId=(EditText)promptsLayout.getChildAt(1);
  patientId.setText("String_Node_Str");
  EditText patientName=(EditText)promptsLayout.getChildAt(3);
  patientName.setText("String_Node_Str");
  Button queryButton=(Button)queryRequestActivity.findViewById(R.id.request_button);
  queryButton.performClick();
  TextView errorMessage=(TextView)queryRequestActivity.findViewById(R.id.error_message);
  assertEquals(View.VISIBLE,errorMessage.getVisibility());
  assertTrue(((String)errorMessage.getText()).contains(Localization.get("String_Node_Str","String_Node_Str")));
  Bundle savedInstanceState=new Bundle();
  controller.saveInstanceState(savedInstanceState);
  queryRequestActivity=Robolectric.buildActivity(QueryRequestActivity.class).withIntent(queryActivityIntent).create(savedInstanceState).start().resume().get();
  errorMessage=(TextView)queryRequestActivity.findViewById(R.id.error_message);
  assertEquals(View.VISIBLE,errorMessage.getVisibility());
  assertTrue(((String)errorMessage.getText()).contains(Localization.get("String_Node_Str","String_Node_Str")));
}