PhaseConfigForm implements IsWidget { public void setModel(final List<PhaseConfigModel> model) { this.model = model; for (PhaseConfigModel phaseConfigModel : model) { if (phaseConfigModel instanceof ConstructionHeuristicPhaseConfigModel) { addConstructionHeuristic((ConstructionHeuristicPhaseConfigModel) phaseConfigModel); } else if (phaseConfigModel instanceof LocalSearchPhaseConfigModel) { addLocalSearch((LocalSearchPhaseConfigModel) phaseConfigModel); } } } @Inject  PhaseConfigForm(final PhaseConfigFormView view,
                           final ManagedInstance<ConstructionHeuristicForm> constructionHeuristicFormProvider,
                           final ManagedInstance<LocalSearchForm> localSearchFormProvider); void addConstructionHeuristic(); void addConstructionHeuristic(final ConstructionHeuristicPhaseConfigModel constructionHeuristicPhaseConfigModel); void removeConstructionHeuristic(final ConstructionHeuristicForm constructionHeuristicForm); void addLocalSearch(); void addLocalSearch(final LocalSearchPhaseConfigModel localSearchPhaseConfigModel); void removeLocalSearch(final LocalSearchForm localSearchForm); List<PhaseConfigModel> getModel(); void setModel(final List<PhaseConfigModel> model); @Override Widget asWidget();  }
@Test public void setModel() { List<PhaseConfigModel> phaseConfigModelList = new ArrayList<>(); phaseConfigModelList.add(new ConstructionHeuristicPhaseConfigModel()); phaseConfigModelList.add(new ConstructionHeuristicPhaseConfigModel()); phaseConfigModelList.add(new LocalSearchPhaseConfigModel()); phaseConfigModelList.add(new LocalSearchPhaseConfigModel()); when(constructionHeuristicFormProvider.get()).thenReturn(constructionHeuristicForm); when(localSearchFormProvider.get()).thenReturn(localSearchForm); phaseConfigForm.setModel(phaseConfigModelList); verify(view, times(2)).addConstructionHeuristic(any()); verify(view, times(2)).addLocalSearch(any()); }