DDMDataProviderInstanceSettingsImpl implements DDMDataProviderInstanceSettings { @Override public <T> T getSettings( DDMDataProviderInstance ddmDataProviderInstance, Class<T> clazz) { DDMDataProvider ddmDataProvider = ddmDataProviderTracker.getDDMDataProvider( ddmDataProviderInstance.getType()); DDMForm ddmForm = DDMFormFactory.create(ddmDataProvider.getSettings()); DDMFormValues ddmFormValues = deserialize( ddmDataProviderInstance.getDefinition(), ddmForm); return (T)DDMFormInstanceFactory.create(clazz, ddmFormValues); }  @Override T getSettings(
		DDMDataProviderInstance ddmDataProviderInstance, Class<T> clazz);  }
@Test public void testGetSettings() throws Exception { when( _ddmDataProviderTracker.getDDMDataProvider(Matchers.anyString()) ).thenReturn( _ddmDataProvider ); when( _ddmDataProvider.getSettings() ).thenReturn( (Class)TestDataProviderInstanceSettings.class ); DDMFormValues ddmFormValues = _createDDMFormValues(); DDMFormValuesDeserializerDeserializeResponse ddmFormValuesDeserializerDeserializeResponse = DDMFormValuesDeserializerDeserializeResponse.Builder.newBuilder( ddmFormValues ).build(); when( _ddmFormValuesDeserializer.deserialize(Mockito.any()) ).thenReturn( ddmFormValuesDeserializerDeserializeResponse ); TestDataProviderInstanceSettings testDataProviderInstanceSettings = _ddmDataProviderInstanceSettingsImpl.getSettings( _ddmDataProviderInstance, TestDataProviderInstanceSettings.class); Assert.assertEquals( "string value", testDataProviderInstanceSettings.prop1()); Assert.assertEquals( Integer.valueOf(1), testDataProviderInstanceSettings.prop2()); Assert.assertEquals(true, testDataProviderInstanceSettings.prop3()); }
@Test(expected = IllegalStateException.class) public void testGetSettingsCatchException() throws Exception { when( _ddmDataProviderTracker.getDDMDataProvider(Matchers.anyString()) ).thenThrow( IllegalStateException.class ); _ddmDataProviderInstanceSettingsImpl.getSettings( _ddmDataProviderInstance, DDMRESTDataProviderSettings.class); }