### Question:
PrimitiveValueSelectionStrategyFactory extends ExpressionCriteriaSelectionStrategyFactory { public static FilterCriterion criteriaToJsonPathExpressionCriterion(final String s) { final String str = s.trim(); if (str.length() < 3) { throw new IllegalArgumentException("Invalid criterion string " + s); } final int pos = str.indexOf(':'); if (pos < 1) { throw new IllegalArgumentException("Invalid criterion string " + s); } final String name = str.substring(0, pos).trim(); final String value = str.substring(pos + 1).trim(); if (name.isEmpty() || value.isEmpty()) { throw new IllegalArgumentException("Invalid criterion string " + s); } return new ExpressionFilterCriterion("$.[?(@." + name + " == '" + value.replace("'", "\\'") + "')]"); }  @Override FilterCriterion stringToFilterCriterion(final String s); static FilterCriterion criteriaToJsonPathExpressionCriterion(final String s);  }### Answer:
@Test public void testThatInstructionsWithMatchingNameAndValuePropsIsAccepted() { final Instructions instructions = instructions(1, "n1", "v1"); final FilterCriterion filter = criteriaToJsonPathExpressionCriterion("n1:v1"); assertTrue(filter.isValid(instructions)); }
@Test public void testThatInstructionsThatMatchesNameOnlyIsNotAccepted() { final Instructions instructions = instructions(1, "n1", "v2"); final FilterCriterion filter = criteriaToJsonPathExpressionCriterion("n1:v1"); assertFalse(filter.isValid(instructions)); }
@Test public void testThatInstructionsThatMatchesValueOnlyIsNotAccepted() { final Instructions instructions = instructions(1, "n2", "v1"); final FilterCriterion filter = criteriaToJsonPathExpressionCriterion("n1:v1"); assertFalse(filter.isValid(instructions)); }
@Test public void testThatInstructionsWithNoPropsIsNotAccepted() { final Instructions instructions = instructions(1); final FilterCriterion filter = criteriaToJsonPathExpressionCriterion("n1:v1"); assertFalse(filter.isValid(instructions)); }
@Test public void testThatEqualsDependsOnNameAndValue() { assertEquals(criteriaToJsonPathExpressionCriterion("n1:v1"), criteriaToJsonPathExpressionCriterion("n1:v1")); assertNotEquals(criteriaToJsonPathExpressionCriterion("n1:v1"), criteriaToJsonPathExpressionCriterion("n1:v2")); assertNotEquals(criteriaToJsonPathExpressionCriterion("n1:v1"), criteriaToJsonPathExpressionCriterion("n2:v1")); }
@Test public void testThatHashcodeEqualsForSameNameAndValue() { assertEquals(criteriaToJsonPathExpressionCriterion("n1:v1").hashCode(), criteriaToJsonPathExpressionCriterion("n1:v1").hashCode()); }