I have two hashmap list and want to check the value present against the given key is same.
List<Map<String, String>> listMap1 = new ArrayList<>();
Map<String, String> map1 = new HashMap<>();
map1.put("Car", "Toyota");
map1.put("Bike", "BMW");
map1.put("ElectricCar", "Tesla");
listMap1.add(map1);
System.out.println(listMap1);
List<Map<String, String>> listMap2 = new ArrayList<>();
Map<String, String> map2 = new HashMap<>();
map2.put("Car", "Toyota");
map2.put("MotorBike", "TVS");
map2.put("ElectricCar", "Tesla");
listMap2.add(map2);
System.out.println(listMap2);
using below approach I am able to verify with single key
SoftAssertions.assertSoftly(softAssertions -> softAssertions.assertThat(listMap2)
.extracting("Car")
.contains(listMap1.stream().map(m -> m.get("Car")).toArray()));