test_class.declarator: rule = MockitoJUnit.rule()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public MockitoRule rule = MockitoJUnit.rule();
test_class.type: MockitoRule
test_class.var_name: rule
test_class.declarator: referenceManager
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ReferenceManager referenceManager;
test_class.type: ReferenceManager
test_class.var_name: referenceManager
test_class.declarator: audioHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private AudioHelper audioHelper;
test_class.type: AudioHelper
test_class.var_name: audioHelper
test_class.declarator: analytics
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private Analytics analytics;
test_class.type: Analytics
test_class.var_name: analytics
test_class.file: collect_app/src/test/java/org/odk/collect/android/widgets/GridMultiWidgetTest.java
test_class.identifier: GridMultiWidgetTest
test_class.superclass: extends GeneralSelectMultiWidgetTest<GridMultiWidget>
test_case.body: @Test
      public void getAnswerShouldReflectWhichSelectionsWereMade() {
          GridMultiWidget widget = getWidget();
          assertNull(widget.getAnswer());
  
          List<SelectChoice> selectChoices = getSelectChoices();
          List<String> selectedValues = new ArrayList<>();
  
          boolean atLeastOneSelected = false;
  
          for (int i = 0; i < widget.selectedItems.size(); i++) {
              boolean shouldBeSelected = random.nextBoolean();
              if (shouldBeSelected) {
                  widget.selectedItems.add(i);
              }
  
              atLeastOneSelected = atLeastOneSelected || shouldBeSelected;
  
              if (shouldBeSelected) {
                  SelectChoice selectChoice = selectChoices.get(i);
                  selectedValues.add(selectChoice.getValue());
              }
          }
  
          // Make sure at least one item is selected, so we're not just retesting the
          // null answer case:
          if (!atLeastOneSelected) {
              int randomIndex = Math.abs(random.nextInt()) % widget.items.size();
  
              widget.selectedItems.add(randomIndex);
              SelectChoice selectChoice = selectChoices.get(randomIndex);
              selectedValues.add(selectChoice.getValue());
          }
  
          SelectMultiData answer = (SelectMultiData) widget.getAnswer();
  
          @SuppressWarnings("unchecked")
          List<Selection> answerSelections = (List<Selection>) answer.getValue();
          List<String> answerValues = selectionsToValues(answerSelections);
  
          for (String selectedValue : selectedValues) {
              assertTrue(answerValues.contains(selectedValue));
          }
      }
test_case.class_method_signature: GridMultiWidgetTest.getAnswerShouldReflectWhichSelectionsWereMade()
test_case.full_signature: @Test public void getAnswerShouldReflectWhichSelectionsWereMade()
test_case.identifier: getAnswerShouldReflectWhichSelectionsWereMade
test_case.invocations: getWidget assertNull getAnswer getSelectChoices size nextBoolean add get add getValue abs nextInt size add get add getValue getAnswer getValue selectionsToValues assertTrue contains
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void getAnswerShouldReflectWhichSelectionsWereMade()
focal_class.file: collect_app/src/main/java/org/odk/collect/android/widgets/GridMultiWidget.java
focal_class.identifier: GridMultiWidget
focal_class.class_method_signature: GridMultiWidget.GridMultiWidget(Context context, QuestionDetails questionDetails)
focal_class.full_signature: public  GridMultiWidget(Context context, QuestionDetails questionDetails)
focal_class.identifier: GridMultiWidget
focal_class.modifiers: public
focal_class.parameters: (Context context, QuestionDetails questionDetails)
focal_class.signature:  GridMultiWidget(Context context, QuestionDetails questionDetails)
focal_class.class_method_signature: GridMultiWidget.fillInAnswer()
focal_class.full_signature: @Override protected void fillInAnswer()
focal_class.identifier: fillInAnswer
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void fillInAnswer()
focal_class.class_method_signature: GridMultiWidget.onItemClick(int index)
focal_class.full_signature: @Override protected void onItemClick(int index)
focal_class.identifier: onItemClick
focal_class.modifiers: @Override protected
focal_class.parameters: (int index)
focal_class.return: void
focal_class.signature: void onItemClick(int index)
focal_class.class_method_signature: GridMultiWidget.getAnswer()
focal_class.full_signature: @Override public IAnswerData getAnswer()
focal_class.identifier: getAnswer
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: IAnswerData
focal_class.signature: IAnswerData getAnswer()
focal_class.class_method_signature: GridMultiWidget.setChoiceSelected(int choiceIndex, boolean isSelected)
focal_class.full_signature: @Override public void setChoiceSelected(int choiceIndex, boolean isSelected)
focal_class.identifier: setChoiceSelected
focal_class.modifiers: @Override public
focal_class.parameters: (int choiceIndex, boolean isSelected)
focal_class.return: void
focal_class.signature: void setChoiceSelected(int choiceIndex, boolean isSelected)
focal_class.superclass: extends BaseGridWidget
focal_method.body: @Override
      public IAnswerData getAnswer() {
          List<Selection> answers = new ArrayList<>();
          for (int selectedItem : selectedItems) {
              SelectChoice sc = items.get(selectedItem);
              answers.add(new Selection(sc));
          }
          return answers.isEmpty() ? null : new SelectMultiData(answers);
      }
focal_method.class_method_signature: GridMultiWidget.getAnswer()
focal_method.full_signature: @Override public IAnswerData getAnswer()
focal_method.identifier: getAnswer
focal_method.invocations: get add isEmpty
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: IAnswerData
focal_method.signature: IAnswerData getAnswer()