The leader of the tiny South Pacific nation of the Cook Islands has flown to China to seal a controversial security deal, in defiance of warnings from its partner New Zealand.