You can try like this
assertThat(result.values()).hasOnlyOneElementSatisfying(r -> {
assertThat(r).extracting(ObjectClass::getName).containsAnyOf("test1");
});
One sample example is given below
@Test
void sampleTest()
{
Map<String, Set<ObjectClass>> result = new HashMap<>();
Set<ObjectClass> objectClassSet = new HashSet<>();
objectClassSet.add(new ObjectClass("test1", new HashSet<>()));
objectClassSet.add(new ObjectClass("test2", new HashSet<>()));
objectClassSet.add(new ObjectClass("test3", new HashSet<>()));
result.put("something", objectClassSet);
assertThat(result.values()).hasOnlyOneElementSatisfying(r -> {
assertThat(r).extracting(ObjectClass::getName).containsAnyOf("test1");
});
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…