The black plastic cap is a Ducati CAN BUS 4-pin connector shell. Or it could be a CAN BUS connector cover? Ducati uses that to communicate and update there motorcycles ECU. You can also charge/tender the bike's battery through that connector. Maybe the last owner removed the shell to gain easy access to the 4 pins of the connector. Not sure about that wire harness though?

Amazon.com: for Ducati 4 pin Male to OBD2 Female obdii Diagnostic Adapter Connector for Ducati Panigale Motorbikes : Automotive
Buy for Ducati 4 pin Male to OBD2 Female obdii Diagnostic Adapter Connector for Ducati Panigale Motorbikes: Code Readers & Scan Tools - Amazon.com ✓ FREE DELIVERY possible on eligible purchases
www.amazon.com

Amazon.com: Tecmate Optimate Cable O-47, Adapter, Ducati Port to SAE Plug : Automotive
Buy Tecmate Optimate Cable O-47, Adapter, Ducati Port to SAE Plug: Battery Accessories - Amazon.com ✓ FREE DELIVERY possible on eligible purchases
www.amazon.com