QuickNewProcessInstancePopup extends BaseModal implements FormDisplayerView { protected void loadFormValues(String serverTemplateId) { this.serverTemplateId = serverTemplateId; processDefinitionsListBox.clear(); processRuntimeDataService.call((List<ProcessSummary> processSummaries) -> { Map<String, List<ProcessSummary>> defs = processSummaries.stream().filter(p -> p.isDynamic() == false).collect(groupingBy(ProcessSummary::getDeploymentId)); defs.keySet().stream().sorted().forEach(deploymentId -> { final OptGroup group = GWT.create(OptGroup.class); group.setLabel(deploymentId); defs.get(deploymentId).stream().sorted().forEach(p -> { final Option option = GWT.create(Option.class); option.setText(p.getProcessDefId()); option.setValue(p.getProcessDefId()); group.add(option); }); processDefinitionsListBox.add(group); }); Scheduler.get().scheduleDeferred(() -> processDefinitionsListBox.refresh()); }).getProcesses(serverTemplateId, 0, Integer.MAX_VALUE, FIELD_ID_PROCESSNAME, true); } QuickNewProcessInstancePopup(); void show(Long parentProcessInstanceId); void show(String serverTemplateId); void displayNotification(String text); @Override void display(GenericFormDisplayer displayer); void closePopup(); @Override void displayErrorMessage(String header, String errorMessage); @Override Command getOnCloseCommand(); @Override void setOnCloseCommand(Command onCloseCommand); @Override GenericFormDisplayer getCurrentDisplayer(); @Inject void setProcessRuntimeDataService(Caller<ProcessRuntimeDataService> processRuntimeDataService); static final String FIELD_ID_PROCESSNAME; @UiField
    public FlowPanel processForm; @UiField
    public FlowPanel basicForm; @UiField
    public HelpBlock errorMessages; @UiField
    public FormGroup errorMessagesGroup; @UiField
    public FormGroup processDefinitionsControlGroup; @UiField
    public Select processDefinitionsListBox; @UiField
    public HelpBlock processDefinitionsHelpLabel; @UiField
    public FlowPanel body; }
@Test public void loadFormValuesTest() { String serverTemplateId = "serverTemplateId"; String deploymentId = "def_deploymentId"; String processDefinitionId = "def_Id"; ProcessSummary processSummary = new ProcessSummary(processDefinitionId, "def_name", deploymentId, "1.0", false); when(processRuntimeDataServiceMock.getProcesses(serverTemplateId, 0, Integer.MAX_VALUE, FIELD_ID_PROCESSNAME, true)).thenReturn(Arrays.asList(processSummary)); quickNewProcessInstancePopup.loadFormValues(serverTemplateId); verify(processDefinitionsListBox).clear(); verify(processRuntimeDataServiceMock).getProcesses(eq(serverTemplateId), eq(0), eq(Integer.MAX_VALUE), eq(FIELD_ID_PROCESSNAME), eq(true)); final ArgumentCaptor<OptGroup> captor = ArgumentCaptor.forClass(OptGroup.class); verify(processDefinitionsListBox).add(captor.capture()); verify(captor.getValue()).setLabel(deploymentId); final ArgumentCaptor<Option> captorOption = ArgumentCaptor.forClass(Option.class); verify(captor.getValue()).add(captorOption.capture()); verify(captorOption.getValue()).setValue(processDefinitionId); verify(captorOption.getValue()).setText(processDefinitionId); }