### Question:
ObjectValidator { public ValidationResult validate(String pid) { if (pid == null) { throw new NullPointerException("pid may not be null."); } ObjectInfo object = null; try { object = objectSource.getValidationObject(pid); } catch (ObjectSourceException e) { } if (object == null) { ValidationResult result = new ValidationResult(new BasicObjectInfo(pid)); result.addNote(ValidationResultNotation.objectNotFound(pid)); return result; } else { return validate(object); } } ObjectValidator(ObjectSource objectSource); ValidationResult validate(String pid); ValidationResult validate(ObjectInfo object);  }### Answer:
@Test(expected = NullPointerException.class) public void nullArgumentToValidatePid() { validator.validate((String) null); }
@Test public void gettingFromPidThrowsException() { objectSource.throwObjectSourceExceptionOnPid(SAMPLE_PID); ValidationResult expected = expectedResult(new BasicObjectInfo(SAMPLE_PID), ValidationResultNotation .objectNotFound(SAMPLE_PID)); ValidationResult actual = validator.validate(SAMPLE_PID); assertEquals("result", expected, actual); }
@Test public void pidReturnsNullObject() { ValidationResult expected = expectedResult(new BasicObjectInfo(SAMPLE_PID), ValidationResultNotation .objectNotFound(SAMPLE_PID)); ValidationResult actual = validator.validate(SAMPLE_PID); assertEquals("result", expected, actual); }
@Test public void simpleSuccessFromPid() { ValidationResult expected = expectedResult(OBJECT_SIMPLE_SAMPLE); ValidationResult actual = validator.validate(OBJECT_SIMPLE_SAMPLE.getPid()); assertEquals("result", expected, actual); }
@Test(expected = NullPointerException.class) public void nullArgumentToValidateObject() { validator.validate((ObjectInfo) null); }