### Question:
VerbDefinitionResolver { public Set<VerbDefinition> matchingVerbDefinitions(Activity activity) { Set<VerbDefinition> matches = Collections.newSetFromMap(new ConcurrentHashMap<VerbDefinition, Boolean>()); for (VerbDefinition verbDefinition : verbDefinitionSet) { VerbDefinition verbDefinitionCopy = SerializationUtil.cloneBySerialization(verbDefinition); if ( activity.getVerb().equals(verbDefinition.getValue())) { for ( ObjectCombination criteria : verbDefinitionCopy.getObjects()) { if (!filter(activity, criteria)) { verbDefinitionCopy.getObjects().remove(criteria); } } if ( verbDefinitionCopy.getObjects().size() > 0) { matches.add(verbDefinitionCopy); } } } return matches; } VerbDefinitionResolver();  VerbDefinitionResolver(Set<VerbDefinition> verbDefinitionSet); Set<VerbDefinition> matchingVerbDefinitions(Activity activity); List<ObjectCombination> matchingObjectCombinations(Activity activity); static boolean filter(Activity activity, ObjectCombination criteria); static boolean filterType(ActivityObject activityObject, boolean required, String pattern);  }### Answer:
@Test public void testMatchingVerbDefinitions() throws Exception { VerbDefinition definition = mapper.readValue(VerbDefinitionResolverTest.class.getResourceAsStream("/post.json"), VerbDefinition.class); VerbDefinitionResolver resolver = new VerbDefinitionResolver(Stream.of(definition).collect(Collectors.toSet())); Activity activity0 = mapper.readValue("{\"id\":\"1\",\"verb\":\"notpost\"}\n", Activity.class); Set<VerbDefinition> result0 = resolver.matchingVerbDefinitions(activity0); assert result0.size() == 0; Activity activity1 = mapper.readValue("{\"id\":\"1\",\"verb\":\"post\"}\n", Activity.class); Set<VerbDefinition> result1 = resolver.matchingVerbDefinitions(activity1); assert result1.size() == 1; assert result1.contains(definition); Activity activity2 = mapper.readValue("{\"id\":\"1\",\"verb\":\"post\",\"provider\":{\"id\":\"providerId\",\"objectType\":\"product\"}}\n", Activity.class); Set<VerbDefinition> result2 = resolver.matchingVerbDefinitions(activity2); assert result2.size() == 1; assert result2.contains(definition); Activity activity3 = mapper.readValue("{\"id\":\"1\",\"verb\":\"post\",\"provider\":{\"id\":\"providerId\",\"objectType\":\"application\"}}\n\n", Activity.class); Set<VerbDefinition> result3 = resolver.matchingVerbDefinitions(activity3); assert result3.size() == 1; assert result3.contains(definition); Activity activity4 = mapper.readValue("{\"id\":\"id\",\"verb\":\"post\",\"object\":{\"id\":\"objectId\",\"objectType\":\"task\"}}\n", Activity.class); Set<VerbDefinition> result4 = resolver.matchingVerbDefinitions(activity4); assert result4.size() == 1; assert result4.contains(definition); Activity activity5 = mapper.readValue("{\"id\":\"id\",\"verb\":\"post\",\"target\":{\"id\":\"targetId\",\"objectType\":\"group\"}}\n", Activity.class); Set<VerbDefinition> result5 = resolver.matchingVerbDefinitions(activity5); assert result5.size() == 1; assert result5.contains(definition); Activity activity6 = mapper.readValue("{\"id\":\"1\",\"verb\":\"post\",\"actor\":{\"id\":\"actorId\",\"objectType\":\"page\"}}\n", Activity.class); Set<VerbDefinition> result6 = resolver.matchingVerbDefinitions(activity6); assert result6.size() == 1; assert result6.contains(definition); }