### Question:
NewDeployWizard extends AbstractMultiPageWizard { @Override public void onStatusChange(final @Observes WizardPageStatusChangeEvent event) { boolean restart = false; if (event.getPage() == selectPipelinePage) { List<PipelineParamsForm> oldParamsForms = new ArrayList<>(); oldParamsForms.addAll(paramsForms); if (selectPipelinePage.getPipeline() != null) { paramsForms = getParamsForms(selectPipelinePage.getPipeline()); if (!paramsForms.isEmpty()) { paramsForms.forEach(PipelineParamsForm::clear); paramsForms.forEach(PipelineParamsForm::initialise); destroyPipelineParamPages(paramsPages); paramsForms.forEach(form -> paramsPages.add(newPipelineParamsPage(form))); setDefaultPages(); pages.addAll(paramsPages); restart = true; } else if (!oldParamsForms.isEmpty()) { setDefaultPages(); restart = true; } } else if (pages.size() > 1) { paramsForms.clear(); setDefaultPages(); restart = true; } if (!oldParamsForms.isEmpty()) { oldParamsForms.forEach(PipelineParamsForm::clear); } } if (restart) { super.start(); } else { super.onStatusChange(event); } } @Inject  NewDeployWizard(final SelectPipelinePagePresenter selectPipelinePage,
                           final ManagedInstance<PipelineParamsPagePresenter> pipelineParamsPageInstance,
                           final @Any Instance<PipelineDescriptor> pipelineDescriptorInstance,
                           final PopupHelper popupHelper,
                           final TranslationService translationService,
                           final Caller<RuntimeService> runtimeService,
                           final Event<NotificationEvent> notification,
                           final Event<RefreshRuntimeEvent> refreshRuntimeEvent); @PostConstruct void init(); void start(final Provider provider,
                      final Collection<PipelineKey> pipelines); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); @Override void complete(); @Override void onStatusChange(final @Observes WizardPageStatusChangeEvent event); static final String RUNTIME_NAME; }### Answer:
@Test public void testOnStatusChangePipelinePageChangeNoPipelineSelected() { when(selectPipelinePage.getPipeline()).thenReturn(null); wizard.onStatusChange(new WizardPageStatusChangeEvent(selectPipelinePage)); assertEquals(1, wizard.getPages().size()); assertEquals(selectPipelinePage, wizard.getPages().get(0)); }
@Test public void testOnStatusChangePipelinePageSelectedWithNoParamForms() { when(selectPipelinePage.getPipeline()).thenReturn(PIPELINE1_KEY); when(descriptor1.accept(PIPELINE1_KEY)).thenReturn(false); when(descriptor2.accept(PIPELINE1_KEY)).thenReturn(false); wizard.onStatusChange(new WizardPageStatusChangeEvent(selectPipelinePage)); verify(descriptor1, times(1)).accept(PIPELINE1_KEY); verify(descriptor2, times(1)).accept(PIPELINE1_KEY); assertEquals(1, wizard.getPages().size()); assertEquals(selectPipelinePage, wizard.getPages().get(0)); verify(pipelineParamsPageInstance, never()).get(); }
@Test public void testOnStatusChangePipelinePageSelectedWithParamForms() { when(selectPipelinePage.getPipeline()).thenReturn(PIPELINE1_KEY); when(descriptor1.accept(PIPELINE1_KEY)).thenReturn(true); when(descriptor2.accept(PIPELINE1_KEY)).thenReturn(false); when(descriptor1.getParamForms()).thenReturn(paramsForms); wizard.onStatusChange(new WizardPageStatusChangeEvent(selectPipelinePage)); verify(descriptor1, times(1)).accept(PIPELINE1_KEY); int totalPages = 1 + paramsForms.size(); assertEquals(totalPages, wizard.getPages().size()); paramsForms.forEach(paramsForm -> { verify(paramsForm, times(1)).clear(); verify(paramsForm, times(1)).initialise(); }); verify(pipelineParamsPageInstance, times(paramsForms.size())).get(); assertEquals(paramsForms.size(), paramsPages.size()); for (int i = 0; i < paramsForms.size(); i++) { PipelineParamsPagePresenter pagePresenter = paramsPages.get(i); verify(pagePresenter, times(1)).setPipelineParamsForm(paramsForms.get(i)); } }