@Test
    public void testCreateStructureFromStructure() {

		long startOffset = UNDEFINED_AREA;
		long offset = startOffset;
		DataType floatPtr = program.getDataTypeManager().getPointer(new FloatDataType());
		DataType stringPtr = program.getDataTypeManager().getPointer(new StringDataType());
		int defaultPtrLen = program.getAddressFactory().getDefaultAddressSpace().getPointerSize();

		offset = createData(offset, new ByteDataType());
		offset = createData(offset, floatPtr);
		offset = createData(offset, 10, new StringDataType());
		offset = createArray(offset, 8, 4, stringPtr);

		int structLen = (int) (offset - startOffset);
		Address address = addr(startOffset);
		Structure structure = StructureFactory.createStructureDataType(program, address, structLen,
			"TestStructA", true);
		CreateStructureCmd cmd = new CreateStructureCmd(structure, address);
		cmd.applyTo(program);

		Data d = program.getListing().getDataAt(address);
		assertNotNull(d);
		assertTrue(d.isDefined());

		assertTrue(d.getDataType() instanceof Structure);
		assertEquals(structLen, d.getLength());

		Structure struct = (Structure) d.getDataType();
		assertEquals(structLen, struct.getLength());
		assertEquals(4, struct.getNumComponents());

		DataTypeComponent comp = struct.getComponent(0);
		assertEquals(1, comp.getLength());
		assertTrue(comp.getDataType() instanceof ByteDataType);

		comp = struct.getComponent(1);
		assertEquals(defaultPtrLen, comp.getLength());
		assertTrue(floatPtr.isEquivalent(comp.getDataType()));

		comp = struct.getComponent(2);
		assertEquals(10, comp.getLength());
		assertTrue(comp.getDataType() instanceof StringDataType);

		comp = struct.getComponent(3);
		assertEquals(8 * defaultPtrLen, comp.getLength());
		assertTrue(comp.getDataType() instanceof Array);
		Array a = (Array) comp.getDataType();
		assertEquals(defaultPtrLen, a.getElementLength());
		assertEquals(8, a.getNumElements());
		assertTrue(a.getDataType().isEquivalent(stringPtr));

		DataType structA =
			program.getDataTypeManager().getDataType(CategoryPath.ROOT, "TestStructA");
		assertEquals(struct, structA);
	}
This test is the same as {@link #testCreateStructure()} with the 
exception that this test passes an already created structure to the 
command object.
Ghidra/Features/Base/src/test/java/ghidra/app/cmd/data/CreateStructureCmdTest.java