@Test
public void testGetData() throws Exception {

	DDMDataProviderRequest.Builder builder =
		DDMDataProviderRequest.Builder.newBuilder();
	DDMDataProviderRequest ddmDataProviderRequest = builder.withParameter(
		"dataProviderInstanceId", "1"
	).build();
	when(
		_ddmDataProviderInstanceService.getDataProviderInstance(1)
	).thenReturn(
		_ddmDataProviderInstance
	);
	when(
		_ddmDataProviderInstance.getType()
	).thenReturn(
		"rest"
	);
	when(
		_ddmDataProviderTracker.getDDMDataProvider("rest")
	).thenReturn(
		_ddmDataProvider
	);
	when(
		_ddmDataProvider.getSettings()
	).thenReturn(
		(Class)TestDDMDataProviderParameterSettings.class
	);
	DDMForm ddmForm = DDMFormFactory.create(_ddmDataProvider.getSettings());
	DDMFormValues ddmFormValues = DDMFormValuesTestUtil.createDDMFormValues(
		ddmForm);
	ddmFormValues.addDDMFormFieldValue(
		DDMFormValuesTestUtil.createUnlocalizedDDMFormFieldValue(
			"url", "http://someservice.com/countries/api/"));
	DDMFormFieldValue outputParamaters =
		DDMFormValuesTestUtil.createUnlocalizedDDMFormFieldValue(
			"outputParameters", StringPool.BLANK);
	ddmFormValues.addDDMFormFieldValue(outputParamaters);
	outputParamaters.addNestedDDMFormFieldValue(
		DDMFormValuesTestUtil.createUnlocalizedDDMFormFieldValue(
			"outputParameterName", "Country Id"));
	outputParamaters.addNestedDDMFormFieldValue(
		DDMFormValuesTestUtil.createUnlocalizedDDMFormFieldValue(
			"outputParameterPath", "countryId"));
	outputParamaters.addNestedDDMFormFieldValue(
		DDMFormValuesTestUtil.createUnlocalizedDDMFormFieldValue(
			"outputParameterType", "[\"number\"]"));
	String countryIdOutputParameterId = StringUtil.randomString();
	outputParamaters.addNestedDDMFormFieldValue(
		DDMFormValuesTestUtil.createUnlocalizedDDMFormFieldValue(
			"outputParameterId", countryIdOutputParameterId));
	outputParamaters =
		DDMFormValuesTestUtil.createUnlocalizedDDMFormFieldValue(
			"outputParameters", StringPool.BLANK);
	ddmFormValues.addDDMFormFieldValue(outputParamaters);
	outputParamaters.addNestedDDMFormFieldValue(
		DDMFormValuesTestUtil.createUnlocalizedDDMFormFieldValue(
			"outputParameterName", "Country Name"));
	outputParamaters.addNestedDDMFormFieldValue(
		DDMFormValuesTestUtil.createUnlocalizedDDMFormFieldValue(
			"outputParameterPath", "countryName"));
	outputParamaters.addNestedDDMFormFieldValue(
		DDMFormValuesTestUtil.createUnlocalizedDDMFormFieldValue(
			"outputParameterType", "[\"string\"]"));
	String countryNameOutputParameterId = StringUtil.randomString();
	outputParamaters.addNestedDDMFormFieldValue(
		DDMFormValuesTestUtil.createUnlocalizedDDMFormFieldValue(
			"outputParameterId", countryNameOutputParameterId));
	DDMFormValuesDeserializerDeserializeResponse
		ddmFormValuesDeserializerDeserializeResponse =
			DDMFormValuesDeserializerDeserializeResponse.Builder.newBuilder(
				ddmFormValues
			).build();
	when(
		_ddmFormValuesDeserializer.deserialize(
			Matchers.any(DDMFormValuesDeserializerDeserializeRequest.class))
	).thenReturn(
		ddmFormValuesDeserializerDeserializeResponse
	);
	DDMDataProviderResponse ddmDataProviderResponse =
		_ddmDataProviderInstanceOutputParametersDataProvider.getData(
			ddmDataProviderRequest);
	Optional<List<KeyValuePair>> outputParameterNamesOptional =
		ddmDataProviderResponse.getOutputOptional(
			"outputParameterNames", List.class);
	Assert.assertTrue(outputParameterNamesOptional.isPresent());
	List<KeyValuePair> keyValuePairs = new ArrayList<KeyValuePair>() {
		{
			add(new KeyValuePair(countryIdOutputParameterId, "Country Id"));
			add(
				new KeyValuePair(
					countryNameOutputParameterId, "Country Name"));
		}
	};
	Assert.assertEquals(
		keyValuePairs.toString(), keyValuePairs,
		outputParameterNamesOptional.get());
}