### Question:
FunctionEditorModel { public void removeParameters() { if (!canRemoveParameters()) { throw new AssertException("Attempted to remove parameters when not allowed."); } listener.tableRowsChanged(); Arrays.sort(selectedFunctionRows); for (int i = selectedFunctionRows.length - 1; i >= 0; i--) { int index = selectedFunctionRows[i]; parameters.remove(index - 1); } if (parameters.isEmpty()) { selectedFunctionRows = new int[0]; } else { int selectRow = Math.min(selectedFunctionRows[0], parameters.size()); selectedFunctionRows = new int[] { selectRow }; } fixupOrdinals(); updateParameterAndReturnStorage(); notifyDataChanged(); } FunctionEditorModel(DataTypeManagerService service, Function function); List<String> getCallingConventionNames(); String[] getCallFixupNames(); void setName(String name); void setCallingConventionName(String callingConventionName); String getCallingConventionName(); void setHasVarArgs(boolean b); String getName(); void dispose(); boolean hasValidName(); boolean isValid(); String getFunctionSignatureTextFromModel(); String getNameString(); boolean hasVarArgs(); DataType getReturnType(); DataType getFormalReturnType(); void setFormalReturnType(DataType formalReturnType); String getStatusText(); void setIsInLine(boolean isInLine); void setNoReturn(boolean isNoReturn); boolean isInlineAllowed(); boolean isInLine(); boolean isNoReturn(); String getCallFixupName(); void setCallFixupName(String callFixupName); void setSelectedParameterRow(int[] selectedRows); int[] getSelectedParameterRows(); void addParameter(); void removeParameters(); void moveSelectedParameterUp(); void moveSelectedParameterDown(); List<ParamInfo> getParameters(); boolean canRemoveParameters(); boolean canMoveParameterUp(); boolean canMoveParameterDown(); void setParameterName(ParamInfo param, String newName); void setParameterFormalDataType(ParamInfo param, DataType formalDataType); VariableStorage getReturnStorage(); Function getFunction(); void setReturnStorage(VariableStorage storage); void setParameterStorage(ParamInfo param, VariableStorage storage); void setUseCustomizeStorage(boolean b); boolean canCustomizeStorage(); boolean apply(); void setFunctionData(FunctionDefinitionDataType functionDefinition); boolean isInParsingMode(); void setSignatureFieldText(String text); void resetSignatureTextField(); void parseSignatureFieldText(); int getFunctionNameStartPosition(); void setModelChanged(boolean b); static final String PARSING_MODE_STATUS_TEXT; }### Answer:
@Test public void testRemoveParameters() throws Exception { ProgramBuilder builder = new ProgramBuilder(); builder.createMemory("block2", "1000", 1000); program = builder.getProgram(); Parameter param = new ParameterImpl("a", new IntegerDataType(), program); Function fun = builder.createEmptyFunction("bob", "1000", 20, new VoidDataType(), param); assertEquals(1, fun.getParameterCount()); model = new FunctionEditorModel(null , fun); model.setModelChangeListener(new MyModelChangeListener()); model.setSelectedParameterRow(new int[] { 1 }); model.removeParameters(); model.apply(); assertEquals(0, fun.getParameterCount()); }