I have a property.yml file in my project, as follows:
propertyA : "valueA"
propertyB: "valueB"
propertyC: "valueC"
I am using the following java code for deserialization from the above yml file:
File configFile = new File(classLoader.getResource("property.yml".getFile());
ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory());
config = yamlMapper.readValue(configFile, MyPOJO.class);
Now, I need to write unit tests. My code has a validation that if any of the propertyA, propertyB and propertyC is missing in the yml file, the code should throw an exception.
Is there a way I can ask the mapper to ignore certain fields during deserialization (assuming that is absent in property.yml) and perform my testing?
property.yml actually contains huge no. of properties(= n, say). It is not feasible to generate n property.yml files for testing, whereas in each of them, one property would be missing.