Working on a Spring Boot application, one of the functionality will include software update. It will be described in a JSON
like this:
{
"DeviceProfile": {
"firmware": {
"name": "firmware_a",
"version": "2.0.24.3",
"url": " ",
"isPatch": true,
"patchdependency": "1.0.0"
},
"software": [
{
"name": "mySoftware1",
"version": "1.0.0",
"url": "http://www.example.com",
"action": "install"
},
{
"name": "mySoftware2",
"version": "1.1.0",
"url": "http://www.example.com",
"action": "install"
},
{
"name": "mySoftware3",
"version": "2.0.0",
"url": "http://www.example.com",
"action": "install"
}
],
"configuration": [
{
"url": "https://www.examples.com",
"type": "myConfigType_1",
"name": "myConfig_1”
},
{
"url": "https://www.examples.com",
"type": " myConfigType_2",
"name": "myConfig_2”
}
]
}
}
There are several conditions, that have to be fulfilled - the "configuration" list to contain exactly one element and its name to be a defined string. The name of each element in the software
part should start with a defined prefix. There can be other additional conditions also. So I was wondering which is the best way to do this. I can create a DeviceProfile
class to extract the data, using ObjectMapper
, and then implement check for every single condition, but I was wondering whether there is better way to do this. Please advise also for unit testing of the approach.