### Question:
ComponentResourceImpl implements ComponentResource { @Override public StreamingOutput getDependency(final String id) { final ComponentFamilyMeta.BaseMeta<?> component = componentDao.findById(id); final Supplier<InputStream> streamProvider; if (component != null) { final Path file = componentManagerService .manager() .findPlugin(component.getParent().getPlugin()) .orElseThrow(() -> new WebApplicationException(Response .status(Response.Status.NOT_FOUND) .type(APPLICATION_JSON_TYPE) .entity(new ErrorPayload(PLUGIN_MISSING, "No plugin matching the id: " + id)) .build())) .getContainerFile() .orElseThrow(() -> new WebApplicationException(Response .status(Response.Status.NOT_FOUND) .type(APPLICATION_JSON_TYPE) .entity(new ErrorPayload(PLUGIN_MISSING, "No dependency matching the id: " + id)) .build())); if (!Files.exists(file)) { return onMissingJar(id); } streamProvider = () -> { try { return Files.newInputStream(file); } catch (final IOException e) { throw new IllegalStateException(e); } }; } else { final Artifact artifact = Artifact.from(id); if (virtualDependenciesService.isVirtual(id)) { streamProvider = virtualDependenciesService.retrieveArtifact(artifact); if (streamProvider == null) { return onMissingJar(id); } } else { final Path file = componentManagerService.manager().getContainer().resolve(artifact.toPath()); if (!Files.exists(file)) { return onMissingJar(id); } streamProvider = () -> { try { return Files.newInputStream(file); } catch (final IOException e) { throw new IllegalStateException(e); } }; } } return output -> { final byte[] buffer = new byte[40960]; try (final InputStream stream = new BufferedInputStream(streamProvider.get(), buffer.length)) { int count; while ((count = stream.read(buffer)) >= 0) { if (count == 0) { continue; } output.write(buffer, 0, count); } } }; }  void clearCache(@Observes final DeployedComponent deployedComponent); @Override Dependencies getDependencies(final String[] ids); @Override StreamingOutput getDependency(final String id); @Override ComponentIndices getIndex(final String language, final boolean includeIconContent, final String query); @Override Response familyIcon(final String id); @Override Response icon(final String id); @Override Map<String, String> migrate(final String id, final int version, final Map<String, String> config); @Override // TODO: max ids.length ComponentDetailList getDetail(final String language, final String[] ids);  }### Answer:
@Test void getDependency(final TestInfo info, @TempDir final File folder) { final Function<String, File> download = id -> { final InputStream stream = base .path("component/dependency/{id}") .resolveTemplate("id", id) .request(APPLICATION_OCTET_STREAM_TYPE) .get(InputStream.class); final File file = new File(folder, info.getTestMethod().get().getName() + ".jar"); try (final OutputStream outputStream = new FileOutputStream(file)) { IO.copy(stream, outputStream); } catch (final IOException e) { throw new IllegalStateException(e); } return file; }; final Consumer<File> jarValidator = file -> { assertTrue(file.exists()); try (final JarFile jar = new JarFile(file)) { assertTrue(jar.entries().hasMoreElements()); } catch (final IOException e) { fail(e.getMessage()); } }; final File zipLock = download.apply("org.apache.tomee:ziplock:jar:7.0.5"); jarValidator.accept(zipLock); final File component = download.apply(client.getJdbcId()); jarValidator.accept(component); }