### Question:
CreateFunctionCmd extends BackgroundCommand { private boolean createFunction(TaskMonitor monitor, String funcName, CodeBlockModel functionModel, Namespace nameSpace, Address entry, AddressSetView body, SourceType nameSource) throws DuplicateNameException, InvalidInputException, OverlappingFunctionException, CancelledException { FunctionManager functionMgr = program.getFunctionManager(); if (this.findEntryPoint) { Function functionContaining = functionMgr.getFunctionContaining(entry); if (functionContaining != null) { if (!recreateFunction) { long bodySize = functionContaining.getBody().getNumAddresses(); if (bodySize != 1) { return false; } } if (!functionContaining.getEntryPoint().equals(entry)) { entry = findFunctionEntry(entry); } } if (entry == null) { return false; } if (origBody != null && !origBody.isEmpty()) { Function func = program.getFunctionManager().getFunctionContaining(entry); if (func == null) { return false; } try { func.setBody(origBody); return true; } catch (OverlappingFunctionException e) { } } if (fixupFunctionBody(program, program.getListing().getInstructionAt(entry), monitor)) { return true; } } Function existingFunction = functionMgr.getFunctionAt(entry); if (existingFunction != null) { return handleExistingFunction(monitor, entry, existingFunction); } body = (body == null ? getFunctionBody(program, entry, false, monitor) : body); AddressSetView oldbody = body; body = removeExistingFunctionsFromBody(entry, body, monitor); if (body == null) { return false; } Map<Function, AddressSetView> bodyChangeMap = new HashMap<>(); if (body.isEmpty()) { body = subtractBodyFromExisting(entry, oldbody, bodyChangeMap, monitor); } return createFunction(nameSpace, funcName, entry, body, nameSource, bodyChangeMap, monitor); } CreateFunctionCmd(String name, AddressSetView entries, AddressSetView body,
			SourceType source, boolean findEntryPoint, boolean recreateFunction);  CreateFunctionCmd(String name, Address entry, AddressSetView body, SourceType source,
			boolean findEntryPoint, boolean recreateFunction);  CreateFunctionCmd(AddressSetView entries, boolean findEntryPoint);  CreateFunctionCmd(AddressSetView entries);  CreateFunctionCmd(AddressSetView entries, SourceType source);  CreateFunctionCmd(String name, Address entry, AddressSetView body, SourceType source);   CreateFunctionCmd(Address entry, List<Address> referringThunkAddresses);  CreateFunctionCmd(Address entry);  CreateFunctionCmd(Address entry, boolean findEntryPoint); @Override boolean applyTo(DomainObject obj, TaskMonitor monitor); Function getFunction(); static AddressSetView getFunctionBody(TaskMonitor monitor, Program program,
			Address entry); static AddressSetView getFunctionBody(Program program, Address entry); static AddressSetView getFunctionBody(Program program, Address entry,
			TaskMonitor monitor); static AddressSetView getFunctionBody(Program program, Address entry,
			boolean includeOtherFunctions, TaskMonitor monitor); static boolean fixupFunctionBody(Program program, Instruction start_inst,
			TaskMonitor monitor); static boolean fixupFunctionBody(Program program, Function func, TaskMonitor monitor);  }### Answer:
@Test public void testCreateFunction() { int transactionID = program.startTransaction("Perform the TEST"); CreateFunctionCmd createCmd = new CreateFunctionCmd(addr(0x1000)); createCmd.applyTo(program); createCmd = new CreateFunctionCmd(addr(0x1007)); createCmd.applyTo(program); program.endTransaction(transactionID, true); Function func1000 = func(addr(0x1000)); assertNotNull("Created normal function", func1000); assertEquals("Normal function body size", 7, func1000.getBody().getNumAddresses()); Function func1007 = func(addr(0x1007)); assertNotNull("Created thunk function", func1007); assertEquals("Thunk body length", true, func1007.isThunk()); }