### Question:
DerivativeService { public Derivative getDerivative(PID pid, DatastreamType dsType) { notNull(pid); notNull(dsType); String id = pid.getId(); String hashedPath = idToPath(id, HASHED_PATH_DEPTH, HASHED_PATH_SIZE); Path derivPath = Paths.get(derivativeDir, dsType.getId(), hashedPath, id + "." + dsType.getExtension()); File derivFile = derivPath.toFile(); if (!derivFile.exists()) { return null; } return new Derivative(dsType, derivFile); } DerivativeService(); Derivative getDerivative(PID pid, DatastreamType dsType); List<Derivative> getDerivatives(PID pid); static List<DatastreamType> listDerivativeTypes(); static boolean isDerivative(String dsName); void setDerivativeDir(String derivativeDir);  }### Answer:
@Test public void testGetDerivative() throws Exception { File originalDerivFile = createDerivative(pid, THUMBNAIL_SMALL); Derivative deriv = derivativeService.getDerivative(pid, THUMBNAIL_SMALL); assertEquals(originalDerivFile, deriv.getFile()); assertEquals(THUMBNAIL_SMALL, deriv.getType()); }
@Test public void testGetDerivativeNotExist() throws Exception { Derivative deriv = derivativeService.getDerivative(pid, THUMBNAIL_SMALL); assertNull(deriv); }