### Question:
AddStudyWizardPresentation { void deleteOrphanUsedBys() { for (StudyActivity sa : getNewStudy().getStudyActivities()) { for (UsedBy ub: sa.getUsedBy()) { if(getNewStudy().findArm(ub.getArm().getName()) == null || getNewStudy().findEpoch(ub.getEpoch().getName()) == null) { HashSet<UsedBy> usedBy = new HashSet<UsedBy>(sa.getUsedBy()); usedBy.remove(ub); sa.setUsedBy(usedBy); } } } } AddStudyWizardPresentation(final Domain d, final PresentationModelFactory pmf, final AddisWindow mainWindow);  AddStudyWizardPresentation(final Domain d, final PresentationModelFactory pmf, final AddisWindow mainWindow, final Study origStudy); ValueModel getSourceModel(); ValueModel getSourceNoteModel(); ValueModel getIdModel(); ValueModel getIdNoteModel(); ValueModel getTitleModel(); Domain getDomain(); ValueHolder<Boolean> shouldImportCTWithResults(); void importCT(); void setNewStudy(final Study study); SortedSetModel<Indication> getIndicationsModel(); ValueModel getIndicationModel(); ValueModel getIndicationNoteModel(); void resetStudy(); MutableCharacteristicHolder getCharacteristicModel(final BasicStudyCharacteristic c); ValueModel getCharacteristicNoteModel(final BasicStudyCharacteristic c); ObservableList<Arm> getArms(); ObservableList<Epoch> getEpochs(); SortedSetModel<Drug> getDrugsModel(); BasicArmPresentation getArmModel(final int armNumber); AddArmsPresentation getAddArmsModel(); AddEpochsPresentation getAddEpochsModel(); TreatmentActivityPresentation getTreatmentActivityModel(final int armNumber); ValueModel getArmNoteModel(final int idx); StudyMeasurementTableModel getEndpointMeasurementTableModel(); Study saveStudy(); boolean isIdAvailable(); StudyPresentation getNewStudyPM(); OutcomeMeasurementsModel getAdverseEventsModel(); OutcomeMeasurementsModel getEndpointsModel(); OutcomeMeasurementsModel getPopulationCharsModel(); SelectFromFiniteListPresentation<AdverseEvent> getAdverseEventSelectModel(); SelectFromFiniteListPresentation<Endpoint> getEndpointSelectModel(); SelectFromFiniteListPresentation<PopulationCharacteristic> getPopulationCharSelectModel(); boolean isEditing(); Study getOldStudy(); static final String CLINICALTRIALS_GOV_BASE; }### Answer:
@Test public void testDeleteOrphanUsedBys() throws MalformedURLException, IOException { importStudy(); Study study = d_wizard.getStudy(); ObservableList<Arm> arms = study.getArms(); ObservableList<Epoch> epochs = study.getEpochs(); ObservableList<StudyActivity> studyActivities = study.getStudyActivities(); studyActivities.add(new StudyActivity("test", PredefinedActivity.RANDOMIZATION)); study.setStudyActivityAt(arms.get(0), epochs.get(0), studyActivities.get(0)); study.setStudyActivityAt(arms.get(1), epochs.get(0), studyActivities.get(0)); Set<UsedBy> usedBy = study.getStudyActivities().get(0).getUsedBy(); d_wizard.deleteOrphanUsedBys(); assertEquals(usedBy, study.getStudyActivities().get(0).getUsedBy()); arms.remove(1); assertFalse(usedBy.equals(study.getStudyActivities().get(0).getUsedBy())); }