Hi Cristiano, You should be able to do this with a custom errorHandler() [1]. For that you'd create a custom converter and supply it with an errorHandler function. See also [2] and [3].
Hope this helps, David [1] https://osgi.org/javadoc/osgi.cmpn/7.0.0/org/osgi/util/converter/ConverterBuilder.html#errorHandler-org.osgi.util.converter.ConverterFunction- [2] https://osgi.org/specification/osgi.cmpn/7.0.0/util.converter.html#util.converter-customizing.converters [3] https://osgi.org/specification/osgi.cmpn/7.0.0/util.converter.html#d0e147674 On Wed, 19 Dec 2018 at 20:51, Cristiano <[email protected]> wrote: > Hello all, > > I'm using Converter to convert a JsonObject (a Map) to an Interface. > > I've created this test for a scenario where any bundle is informed: > > > IProvisioningConfiguration config = CONVERTER.convert(json) > > .to(IProvisioningConfiguration.class); > > > > assertThat(config).isNotNull(); > > assertThat(config.delay()).isEqualTo(5); > > assertThat(config.bundles()).isEmpty(); > > My problem is that I'm receiving a ConversionException when trying to > access a method from the interface which value was not supplied by the > source object map. > > > org.osgi.util.converter.ConversionException: No value for property: > > bundles > > at > > org.osgi.util.converter.ConvertingImpl$4.invoke(ConvertingImpl.java:802) > > at com.sun.proxy.$Proxy8.bundles(Unknown Source) > > at > > > br.com.c8tech.vxosgi.config.JsonConvertionUnitTest.testProvisioningConfigurationJsonConvertionToInterface(JsonConvertionUnitTest.java:102) > > Is there any way to work with optional values in the target interface > without get this exception ? > > > many thanks, > > Cristiano > >
