### Question:
DerivativeService { public List<Derivative> getDerivatives(PID pid) { notNull(pid); return listDerivativeTypes().stream() .map(derivType -> getDerivative(pid, derivType)) .filter(deriv -> deriv != null) .collect(Collectors.toList()); } 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 testGetDerivatives() throws Exception { File originalDerivFile1 = createDerivative(pid, THUMBNAIL_SMALL); File originalDerivFil21 = createDerivative(pid, JP2_ACCESS_COPY); List<Derivative> derivs = derivativeService.getDerivatives(pid); assertEquals(2, derivs.size()); Derivative thumbDeriv = findDerivative(derivs, THUMBNAIL_SMALL); Derivative jp2Deriv = findDerivative(derivs, JP2_ACCESS_COPY); assertNotNull(thumbDeriv); assertNotNull(jp2Deriv); assertEquals(originalDerivFile1, thumbDeriv.getFile()); assertEquals(originalDerivFil21, jp2Deriv.getFile()); }
@Test public void testGetDerivativesIgnoreNonDerivatives() throws Exception { File originalDerivFile1 = createDerivative(pid, THUMBNAIL_SMALL); createDerivative(pid, ORIGINAL_FILE); List<Derivative> derivs = derivativeService.getDerivatives(pid); assertEquals(1, derivs.size()); Derivative thumbDeriv = findDerivative(derivs, THUMBNAIL_SMALL); assertEquals(originalDerivFile1, thumbDeriv.getFile()); }