use of org.mule.runtime.extension.api.runtime.config.ConfigurationFactory in project mule by mulesoft.
the class ExtensionsTestUtils method mockConfigurationInstance.
public static void mockConfigurationInstance(ConfigurationModel configurationModel, Object config) {
ConfigurationFactory configurationFactory = mock(ConfigurationFactory.class);
when(configurationFactory.newInstance()).thenReturn(config);
when(configurationFactory.getObjectType()).thenReturn((Class) config.getClass());
when(configurationModel.getModelProperty(any())).thenAnswer(invocationOnMock -> {
Class<? extends ModelProperty> propertyType = (Class<? extends ModelProperty>) invocationOnMock.getArguments()[0];
if (ConfigurationFactoryModelProperty.class.equals(propertyType)) {
return of(new ConfigurationFactoryModelProperty(configurationFactory));
}
return empty();
});
}
Aggregations