AppIntegrationPalette extends Composite { Argument createNewArgument(ArgumentType type) { AutoBean<Argument> argAb = factory.argument(); argAb.setTag(Argument.IS_NEW, "--"); Argument argument = argAb.as(); argument.setLabel("DEFAULT"); argument.setDescription(""); argument.setType(type); argument.setName(""); argument.setVisible(true); argument.setRequired(false); argument.setOmitIfBlank(false); if (appTemplateUtils.isSimpleSelectionArgumentType(type)) { argument.setSelectionItems(Lists.<SelectionItem> newArrayList()); } else if (type.equals(ArgumentType.TreeSelection)) { SelectionItemGroup sig = appTemplateUtils.addSelectionItemAutoBeanIdTag(factory.selectionItemGroup().as(), "rootId"); sig.setSingleSelect(false); sig.setSelectionCascade(CheckCascade.CHILDREN); sig.setArguments(Lists.<SelectionItem> newArrayList()); sig.setGroups(Lists.<SelectionItemGroup> newArrayList()); argument.setSelectionItems(Lists.<SelectionItem> newArrayList(sig)); } else if (appTemplateUtils.isDiskResourceArgumentType(type) || appTemplateUtils.isDiskResourceOutputType(type)) { FileParameters dataObj = factory.fileParameters().as(); dataObj.setFormat("Unspecified"); dataObj.setDataSource(DataSourceEnum.file); dataObj.setFileInfoType(FileInfoTypeEnum.File); argument.setFileParameters(dataObj); } switch (type) { case TextSelection: argument.setLabel(defaultLabels.defTextSelection()); break; case IntegerSelection: argument.setLabel(defaultLabels.defIntegerSelection()); break; case DoubleSelection: argument.setLabel(defaultLabels.defDoubleSelection()); break; case TreeSelection: argument.setLabel(defaultLabels.defTreeSelection()); break; case FileInput: argument.setLabel(defaultLabels.defFileInput()); break; case FolderInput: argument.setLabel(defaultLabels.defFolderInput()); break; case MultiFileSelector: argument.setLabel(defaultLabels.defMultiFileSelector()); break; case Flag: argument.setLabel(defaultLabels.defCheckBox()); break; case Text: argument.setLabel(defaultLabels.defTextInput()); break; case MultiLineText: argument.setLabel(defaultLabels.defMultiLineText()); break; case EnvironmentVariable: argument.setLabel(defaultLabels.defEnvVar()); break; case Integer: argument.setLabel(defaultLabels.defIntegerInput()); break; case Double: argument.setLabel(defaultLabels.defDoubleInput()); break; case FileOutput: argument.setLabel(defaultLabels.defFileOutput()); break; case FolderOutput: argument.setLabel(defaultLabels.defFolderOutput()); break; case MultiFileOutput: argument.setLabel(defaultLabels.defMultiFileOutput()); break; case ReferenceAnnotation: argument.setLabel(defaultLabels.defReferenceAnnotation()); break; case ReferenceGenome: argument.setLabel(defaultLabels.defReferenceGenome()); break; case ReferenceSequence: argument.setLabel(defaultLabels.defReferenceSequence()); break; case Info: argument.setLabel(defaultLabels.defInfo()); break; default: argument.setLabel(defaultLabels.defaultLabel()); break; } return argument; } @Inject  AppIntegrationPalette(final AppTemplateWizardAppearance appearance,
                                 final AppsWidgetsDefaultLabels defaultLabels,
                                 final AppTemplateAutoBeanFactory factory,
                                 final IplantContextualHelpAccessStyle style,
                                 final AppTemplateUtils appTemplateUtils); void setOnlyLabelEditMode(boolean onlyLabelEditMode);  }
@Test public void testCreateNewArgument_FileOutput() { when(mockFactory.argument()).thenReturn(mockAbArgument); when(mockFactory.fileParameters()).thenReturn(mockAbDataObject); Argument mockArgument = mock(Argument.class); FileParameters mockDataObject = mock(FileParameters.class); when(mockAbArgument.as()).thenReturn(mockArgument); when(mockAbDataObject.as()).thenReturn(mockDataObject); uut.createNewArgument(ArgumentType.FileOutput); verify(mockFactory).argument(); verify(mockFactory).fileParameters(); verify(mockArgument).setFileParameters(eq(mockDataObject)); verify(mockLabels).defFileOutput(); verifyNoMoreInteractions(mockFactory, mockLabels); }
@Test public void testCreateNewArgument_FolderOutput() { when(mockFactory.argument()).thenReturn(mockAbArgument); when(mockFactory.fileParameters()).thenReturn(mockAbDataObject); Argument mockArgument = mock(Argument.class); FileParameters mockDataObject = mock(FileParameters.class); when(mockAbArgument.as()).thenReturn(mockArgument); when(mockAbDataObject.as()).thenReturn(mockDataObject); uut.createNewArgument(ArgumentType.FolderOutput); verify(mockFactory).argument(); verify(mockFactory).fileParameters(); verify(mockArgument).setFileParameters(eq(mockDataObject)); verify(mockLabels).defFolderOutput(); verifyNoMoreInteractions(mockFactory, mockLabels); }
@Test public void testCreateNewArgument_MultiFileOutput() { when(mockFactory.argument()).thenReturn(mockAbArgument); when(mockFactory.fileParameters()).thenReturn(mockAbDataObject); Argument mockArgument = mock(Argument.class); FileParameters mockDataObject = mock(FileParameters.class); when(mockAbArgument.as()).thenReturn(mockArgument); when(mockAbDataObject.as()).thenReturn(mockDataObject); uut.createNewArgument(ArgumentType.MultiFileOutput); verify(mockFactory).argument(); verify(mockFactory).fileParameters(); verify(mockArgument).setFileParameters(eq(mockDataObject)); verify(mockLabels).defMultiFileOutput(); verifyNoMoreInteractions(mockFactory, mockLabels); }