### Question:
RangerValidator { boolean isUnique(Long value, Set<Long> alreadySeen, String valueName, String collectionName, List<ValidationFailureDetails> failures) { return isUnique(value, null, alreadySeen, valueName, collectionName, failures); } protected  RangerValidator(ServiceStore store); void validate(Long id, Action action);  }### Answer:
@Test public void test_isValid_string() { String fieldName = "value-field-Name"; String collectionName = "value-collection-Name"; Set<String> alreadySeen = new HashSet<String>(); for (String value : new String[] { null, "", " " }) { assertFalse(_validator.isUnique(value, alreadySeen, fieldName, collectionName, _failures)); _utils.checkFailureForMissingValue(_failures, fieldName); } String value = "blah"; _failures.clear(); assertTrue(_validator.isUnique(value, alreadySeen, fieldName, collectionName, _failures)); assertTrue(_failures.isEmpty()); assertTrue(alreadySeen.contains(value)); _failures.clear(); assertFalse(_validator.isUnique(value, alreadySeen, fieldName, collectionName, _failures)); _utils.checkFailureForSemanticError(_failures, fieldName, value); value = "bLaH"; _failures.clear(); assertFalse(_validator.isUnique(value, alreadySeen, fieldName, collectionName, _failures)); _utils.checkFailureForSemanticError(_failures, fieldName, value); }
@Test public void test_isValid_long() { String fieldName = "field-Name"; String collectionName = "field-collection-Name"; Set<Long> alreadySeen = new HashSet<Long>(); Long value = null; assertFalse(_validator.isUnique(value, alreadySeen, fieldName, collectionName, _failures)); _utils.checkFailureForMissingValue(_failures, fieldName); value = 7L; _failures.clear(); assertTrue(_validator.isUnique(value, alreadySeen, fieldName, collectionName, _failures)); assertTrue(_failures.isEmpty()); assertTrue(alreadySeen.contains(value)); _failures.clear(); assertFalse(_validator.isUnique(value, alreadySeen, fieldName, collectionName, _failures)); _utils.checkFailureForSemanticError(_failures, fieldName, value.toString()); }
@Test public void test_isValid_integer() { String fieldName = "field-Name"; String collectionName = "field-collection-Name"; Set<Integer> alreadySeen = new HashSet<Integer>(); Integer value = null; assertFalse(_validator.isUnique(value, alreadySeen, fieldName, collectionName, _failures)); _utils.checkFailureForMissingValue(_failures, fieldName); value = 49; _failures.clear(); assertTrue(_validator.isUnique(value, alreadySeen, fieldName, collectionName, _failures)); assertTrue(_failures.isEmpty()); assertTrue(alreadySeen.contains(value)); _failures.clear(); assertFalse(_validator.isUnique(value, alreadySeen, fieldName, collectionName, _failures)); _utils.checkFailureForSemanticError(_failures, fieldName, value.toString()); }