Program: 142025
Project: 142025
Buggy source:
/** 
 * Use the update activity to update to a ccz with an invalid suite file. Assert that an error is shown and pinned notification is created w/ more details
 */
@Test public void invalidUpdateTest(){
  String invalidUpdateReference="String_Node_Str";
  Intent updateActivityIntent=new Intent(RuntimeEnvironment.application,UpdateActivity.class);
  UpdateActivity updateActivity=Robolectric.buildActivity(UpdateActivity.class).withIntent(updateActivityIntent).setup().get();
  ShadowActivity shadowActivity=Shadows.shadowOf(updateActivity);
  shadowActivity.clickMenuItem(UpdateActivity.MENU_UPDATE_FROM_CCZ);
  NotificationManager notificationManager=(NotificationManager)RuntimeEnvironment.application.getSystemService(Context.NOTIFICATION_SERVICE);
  Notification notification=Shadows.shadowOf(notificationManager).getNotification(CommCareApplication.MESSAGE_NOTIFICATION);
  assertNull(notification);
  Intent referenceIntent=new Intent();
  referenceIntent.putExtra(InstallArchiveActivity.ARCHIVE_JR_REFERENCE,invalidUpdateReference);
  shadowActivity.receiveResult(shadowActivity.getNextStartedActivity(),Activity.RESULT_OK,referenceIntent);
  Robolectric.flushBackgroundThreadScheduler();
  Robolectric.flushForegroundThreadScheduler();
  String errorMessage=(String)((TextView)updateActivity.findViewById(R.id.update_progress_text)).getText();
  assertEquals(Localization.get("String_Node_Str"),errorMessage);
  notification=Shadows.shadowOf(notificationManager).getNotification(CommCareApplication.MESSAGE_NOTIFICATION);
  assertNotNull(notification);
}

Fixed version (ground truth):
/** 
 * Use the update activity to update to a ccz with an invalid suite file. Assert that an error is shown and pinned notification is created w/ more details
 */
@Test public void invalidUpdateTest(){
  String invalidUpdateReference="String_Node_Str";
  Intent updateActivityIntent=new Intent(RuntimeEnvironment.application,UpdateActivity.class);
  UpdateActivity updateActivity=Robolectric.buildActivity(UpdateActivity.class).withIntent(updateActivityIntent).setup().get();
  ShadowActivity shadowActivity=Shadows.shadowOf(updateActivity);
  shadowActivity.clickMenuItem(UpdateActivity.MENU_UPDATE_FROM_CCZ);
  NotificationManager notificationManager=(NotificationManager)RuntimeEnvironment.application.getSystemService(Context.NOTIFICATION_SERVICE);
  Notification notification=Shadows.shadowOf(notificationManager).getNotification(CommCareNoficationManager.MESSAGE_NOTIFICATION);
  assertNull(notification);
  Intent referenceIntent=new Intent();
  referenceIntent.putExtra(InstallArchiveActivity.ARCHIVE_JR_REFERENCE,invalidUpdateReference);
  shadowActivity.receiveResult(shadowActivity.getNextStartedActivity(),Activity.RESULT_OK,referenceIntent);
  Robolectric.flushBackgroundThreadScheduler();
  Robolectric.flushForegroundThreadScheduler();
  String errorMessage=(String)((TextView)updateActivity.findViewById(R.id.update_progress_text)).getText();
  assertEquals(Localization.get("String_Node_Str"),errorMessage);
  notification=Shadows.shadowOf(notificationManager).getNotification(CommCareNoficationManager.MESSAGE_NOTIFICATION);
  assertNotNull(notification);
}