### Question:
EqualToPredicate implements StreamPredicate { @Override public boolean apply(Collection<Attribute> attributes) { return Objects.nonNull(attributeName) && Objects.nonNull(value) && attributes.stream() .anyMatch(attr -> attr.getName().equals(attributeName) && value.equals(attr.getValue(value.getClass())) ); } EqualToPredicate();  EqualToPredicate(Attribute.Name attributeName);   EqualToPredicate(Attribute.Name attributeName, Object value); @Override boolean apply(Collection<Attribute> attributes);  }### Answer:
@Test public void testEqualToPredicateInitWithoutParams(){ EqualToPredicate equalToPredicate = new EqualToPredicate(); Collection<Attribute> attributes = Collections.emptyList(); assertFalse(equalToPredicate.apply(attributes)); }
@Test public void testEqualToPredicateInitWithOnlyAttrName(){ Attribute.Name attributeName = Attribute.Name.valueOf("test-attr"); EqualToPredicate equalToPredicate = new EqualToPredicate(attributeName); Collection<Attribute> attributes = Collections.emptyList(); assertFalse(equalToPredicate.apply(attributes)); }
@Test public void testEqualToPredicateInitWithAttrNameAndValueNonMatch(){ Attribute.Name attributeName = Attribute.Name.valueOf("test-attr"); EqualToPredicate equalToPredicate = new EqualToPredicate(attributeName, "test-attr-value"); Collection<Attribute> attributes = Collections.emptyList(); assertFalse(equalToPredicate.apply(attributes)); }
@Test public void testEqualToPredicateInitWithAttrNameAndValueMatch(){ Attribute.Name attributeName = Attribute.Name.valueOf("test-attr"); Object attributeValue = "test-attr-value"; EqualToPredicate equalToPredicate = new EqualToPredicate(attributeName, attributeValue); GraphAttribute graphAttribute = new GraphAttribute(attributeName, attributeValue, new MockMetadata()); List<Attribute> attributes = new ArrayList<Attribute>( Arrays.asList(graphAttribute)); assertTrue(equalToPredicate.apply(attributes)); }