Actually the Sea Trials are a requirement of the Classification Society. The shipyard carries out the trials and the Class surveyors and owners representives witness it. The purchase decision is already made a long time ago
General maintanence like painting is done by the ship staff. Also overhauling of the engine, generators etc. Sometimes service is provided by the individual manufacturers of the various equipments. The shipyard provides a 1 year guarantee for the structure.