private List<Map<String, String>> mockParamFormsValues(List<PipelineParamsForm> paramsForms) { List<Map<String, String>> paramValues = new ArrayList<>(); for (int i = 0; i < paramsForms.size(); i++) { PipelineParamsForm form = paramsForms.get(i); Map<String, String> params = mockParamSet(PARAM_VALUES_COUNT, String.valueOf(i)); when(form.buildParams()).thenReturn(params); paramValues.add(params); } return paramValues; }
private void preCompleteWizard(PipelineKey pipelineKey, String runtimeName) { when(selectPipelinePage.getPipeline()).thenReturn(pipelineKey); wizard.getPages().forEach(page -> preparePageCompletion(page)); //let an arbitrary form populate the runtime name. int index = 2; paramsFormsValues.get(index).put(RUNTIME_NAME, runtimeName); wizard.isComplete(Assert::assertTrue); }
@Test public void testStartDeploymentFailure() { //initialize and start the wizard. wizard.start(provider, pipelines); verifyStart(); //e.g. PIPELINE1 was selected. preSelectForms(PIPELINE1_KEY); //emulate the user completing the wizard. preCompleteWizard(PIPELINE1_KEY, RUNTIME); prepareServiceCallerError(runtimeService, runtimeServiceCaller); //emulates the user pressing the finish button wizard.complete(); //the parameters must the the values collected by the forms. Map<String, String> expectedPrams = buildExpectedParams(paramsFormsValues); expectedPrams.put(RUNTIME_NAME, RUNTIME); verify(runtimeService, times(1)).createRuntime(provider.getKey(), RUNTIME, PIPELINE1_KEY, expectedPrams); verify(defaultErrorCallback, times(1)).error(any(Message.class), any(Throwable.class)); verify(notification, never()).fire(any(NotificationEvent.class)); }
paramsForms = mockParamForms(PARAM_FORMS_COUNT); paramsFormsValues = mockParamFormsValues(paramsForms);
@Test public void testStart() { wizard.start(provider, pipelines); verifyStart(); }
@Test public void testStartDeploymentFailure() { //initialize and start the wizard. wizard.start(provider, pipelines); verifyStart(); //e.g. PIPELINE1 was selected. preSelectForms(PIPELINE1_KEY); //emulate the user completing the wizard. preCompleteWizard(PIPELINE1_KEY, RUNTIME); prepareServiceCallerError(runtimeService, runtimeServiceCaller); //emulates the user pressing the finish button wizard.complete(); //the parameters must the the values collected by the forms. Map<String, String> expectedPrams = buildExpectedParams(paramsFormsValues); expectedPrams.put(RUNTIME_NAME, RUNTIME); verify(runtimeService, times(1)).createRuntime(provider.getKey(), RUNTIME, PIPELINE1_KEY, expectedPrams); verify(defaultErrorCallback, times(1)).error(any(Message.class), any(Throwable.class)); verify(notification, never()).fire(any(NotificationEvent.class)); }
paramsForms = mockParamForms(PARAM_FORMS_COUNT); paramsFormsValues = mockParamFormsValues(paramsForms);
@Test public void testStart() { wizard.start(provider, pipelines); verifyStart(); }
@Test public void testStartDeploymentSuccess() { //initialize and start the wizard. wizard.start(provider, pipelines); verifyStart(); //e.g. PIPELINE1 was selected. preSelectForms(PIPELINE1_KEY); //emulate the user completing the wizard. preCompleteWizard(PIPELINE1_KEY, RUNTIME); //emulates the user pressing the finish button wizard.complete(); //the parameters must the the values collected by the forms. Map<String, String> expectedPrams = buildExpectedParams(paramsFormsValues); expectedPrams.put(RUNTIME_NAME, RUNTIME); verify(runtimeService, times(1)).createRuntime(provider.getKey(), RUNTIME, PIPELINE1_KEY, expectedPrams); verify(notification, times(1)).fire(new NotificationEvent(SUCCESS_MESSAGE, NotificationEvent.NotificationType.SUCCESS)); verify(refreshRuntimeEvent, times(1)).fire(new RefreshRuntimeEvent(provider.getKey())); }
private void preCompleteWizard(PipelineKey pipelineKey, String runtimeName) { when(selectPipelinePage.getPipeline()).thenReturn(pipelineKey); wizard.getPages().forEach(page -> preparePageCompletion(page)); //let an arbitrary form populate the runtime name. int index = 2; paramsFormsValues.get(index).put(RUNTIME_NAME, runtimeName); wizard.isComplete(Assert::assertTrue); }
private List<Map<String, String>> mockParamFormsValues(List<PipelineParamsForm> paramsForms) { List<Map<String, String>> paramValues = new ArrayList<>(); for (int i = 0; i < paramsForms.size(); i++) { PipelineParamsForm form = paramsForms.get(i); Map<String, String> params = mockParamSet(PARAM_VALUES_COUNT, String.valueOf(i)); when(form.buildParams()).thenReturn(params); paramValues.add(params); } return paramValues; }
@Test public void testStartDeploymentSuccess() { //initialize and start the wizard. wizard.start(provider, pipelines); verifyStart(); //e.g. PIPELINE1 was selected. preSelectForms(PIPELINE1_KEY); //emulate the user completing the wizard. preCompleteWizard(PIPELINE1_KEY, RUNTIME); //emulates the user pressing the finish button wizard.complete(); //the parameters must the the values collected by the forms. Map<String, String> expectedPrams = buildExpectedParams(paramsFormsValues); expectedPrams.put(RUNTIME_NAME, RUNTIME); verify(runtimeService, times(1)).createRuntime(provider.getKey(), RUNTIME, PIPELINE1_KEY, expectedPrams); verify(notification, times(1)).fire(new NotificationEvent(SUCCESS_MESSAGE, NotificationEvent.NotificationType.SUCCESS)); verify(refreshRuntimeEvent, times(1)).fire(new RefreshRuntimeEvent(provider.getKey())); }