// Test selectedAll, deselect item, selectAll
 // SearchResultTree 6A - basic flow. SelectAll then deselect one itemNode and then selectAll
 // again.
 // Result: selectedDataSearchResult should contain all Patients and all other JTree items.
 @Test
 public void testUpdatedSelectedDataSearchResult6A() {
   resultTree.addDataSelectionListener(this);
   resultTree.selectAll(true);
   synchronized (this) {
     while (selectedDataSearchResult.getPatients().size() == 0) {
       try {
         this.wait();
       } catch (InterruptedException e1) {
         logger.error(e1, e1);
       }
     }
   }
   DefaultMutableTreeNode rootNode = resultTree.getRootNode();
   DefaultMutableTreeNode locationNode = (DefaultMutableTreeNode) rootNode.getChildAt(0);
   PatientNode patientNode1 = (PatientNode) locationNode.getChildAt(0);
   StudyNode studyNode1 = (StudyNode) patientNode1.getChildAt(0);
   SeriesNode seriesNode1 = (SeriesNode) studyNode1.getChildAt(0);
   ItemNode itemNode1 = (ItemNode) seriesNode1.getChildAt(0);
   resultTree.updateSelection(itemNode1, false);
   synchronized (this) {
     while (selectedDataSearchResult.getPatients().size() == 0) {
       try {
         this.wait();
       } catch (InterruptedException e1) {
         logger.error(e1, e1);
       }
     }
   }
   resultTree.selectAll(true);
   synchronized (this) {
     while (selectedDataSearchResult.getPatients().size() == 0) {
       try {
         this.wait();
       } catch (InterruptedException e1) {
         logger.error(e1, e1);
       }
     }
   }
   assertSelectAll(selectedDataSearchResult);
 }
 // SearchResultTree 1A - basic flow. One ItemNode selected.
 // Result: selectedDataSearchResult should contain one patient, one study, one series and one
 // selected itemNode.
 @Test
 public void testUpdatedSelectedDataSearchResult1A() {
   resultTree.addDataSelectionListener(this);
   DefaultMutableTreeNode rootNode = resultTree.getRootNode();
   DefaultMutableTreeNode locationNode = (DefaultMutableTreeNode) rootNode.getChildAt(0);
   PatientNode patientNode1 = (PatientNode) locationNode.getChildAt(0);
   StudyNode studyNode1 = (StudyNode) patientNode1.getChildAt(0);
   SeriesNode seriesNode1 = (SeriesNode) studyNode1.getChildAt(0);
   ItemNode itemNode1 = (ItemNode) seriesNode1.getChildAt(0);
   resultTree.updateSelection(itemNode1, true);
   synchronized (this) {
     while (selectedDataSearchResult.getPatients().size() == 0) {
       try {
         this.wait();
       } catch (InterruptedException e1) {
         logger.error(e1, e1);
       }
     }
   }
   List<Patient> patients = selectedDataSearchResult.getPatients();
   int numbOfPatients = patients.size();
   assertEquals(
       "Invalid number of patients. Expected: 1, actual: " + numbOfPatients, 1, numbOfPatients);
   if (numbOfPatients == 1) {
     Patient patient = patients.get(0);
     assertEquals(
         "Invalid patient. Expected id: 111, actual: " + patient.getPatientID(),
         "111",
         patient.getPatientID());
   }
   List<Study> studies = patients.get(0).getStudies();
   int numbOfStudies = studies.size();
   assertEquals(
       "Invalid number of studies. Expected: 1, actual: " + numbOfStudies, 1, numbOfStudies);
   if (numbOfStudies == 1) {
     Study study = studies.get(0);
     assertEquals(
         "Invalid study. Expected studyInstanceUID: 101.101, actual: "
             + study.getStudyInstanceUID(),
         "101.101",
         study.getStudyInstanceUID());
   }
   List<Series> series = studies.get(0).getSeries();
   int numbOfSeries = series.size();
   assertEquals("Invalid number of series. Expected: 1, actual: " + numbOfSeries, 1, numbOfSeries);
   if (numbOfSeries == 1) {
     Series oneSeries = series.get(0);
     assertEquals(
         "Invalid series. Expected seriesInstanceUID: 101.101.1, actual: "
             + oneSeries.getSeriesInstanceUID(),
         "101.101.1",
         oneSeries.getSeriesInstanceUID());
   }
   List<Item> items = series.get(0).getItems();
   int numbOfItems = items.size();
   assertEquals("Invalid number of items. Expected: 1, actual: " + numbOfItems, 1, numbOfItems);
   if (numbOfItems == 1) {
     Item item = items.get(0);
     assertEquals(
         "Invalid item. Expected item id: 101.101.1.000.000.1, actual: " + item.getItemID(),
         "101.101.1.000.000.1",
         item.getItemID());
   }
 }