### Question:
PackageHelperImpl implements PackageHelper { public void addThumbnail(final JcrPackage jcrPackage, Resource thumbnailResource) { if (jcrPackage == null) { log.error("JCR Package is null; no package thumbnail needed for null packages!"); return; } Node thumbnailNode = null; if (thumbnailResource != null) { thumbnailNode = thumbnailResource.adaptTo(Node.class); } try { boolean useDefault = thumbnailNode == null || !thumbnailNode.isNodeType(JcrConstants.NT_FILE); final Node dstParentNode = jcrPackage.getDefinition().getNode(); final Session session = dstParentNode.getSession(); if (useDefault) { log.debug("Using default ACS AEM Commons packager package icon."); if (session.nodeExists(DEFAULT_PACKAGE_THUMBNAIL_RESOURCE_PATH)) { thumbnailNode = session.getNode(DEFAULT_PACKAGE_THUMBNAIL_RESOURCE_PATH); } } if (thumbnailNode == null || !thumbnailNode.isNodeType(JcrConstants.NT_FILE)) { log.warn("Cannot find a specific OR a default package icon; no package icon will be used."); } else { JcrUtil.copy(thumbnailNode, dstParentNode, NN_THUMBNAIL); dstParentNode.getSession().save(); } } catch (RepositoryException e) { log.error("Could not add package thumbnail: {}", e); } }  void addThumbnail(final JcrPackage jcrPackage, Resource thumbnailResource); @SuppressWarnings("squid:S3776") Version getNextVersion(final JcrPackageManager jcrPackageManager,
            final String groupName, final String name,
            final String version); void removePackage(final JcrPackageManager jcrPackageManager,
            final String groupName, final String name,
            final String version); JcrPackage createPackage(final Collection<Resource> resources, final Session session,
            final String groupName, final String name, String version,
            final ConflictResolution conflictResolution,
            final Map<String, String> packageDefinitionProperties); @Override JcrPackage createPackageForPaths(final Collection<String> paths, final Session session,
            final String groupName, String name, final String version,
            final ConflictResolution conflictResolution,
            Map<String, String> packageDefinitionProperties); JcrPackage createPackageFromPathFilterSets(final Collection<PathFilterSet> pathFilterSets,
            final Session session,
            final String groupName, final String name, String version,
            final ConflictResolution conflictResolution,
            final Map<String, String> packageDefinitionProperties); List<String> getContents(final JcrPackage jcrPackage); String getSuccessJSON(final JcrPackage jcrPackage); String getPreviewJSON(final Collection<Resource> resources); String getPreviewJSONForPaths(Collection<String> paths); String getPathFilterSetPreviewJSON(final Collection<PathFilterSet> pathFilterSets); String getErrorJSON(final String msg);  }### Answer:
@Test public void testAddThumbnail() throws Exception { Resource thumbnailResource = mock(Resource.class); Node thumbnailNode = mock(Node.class); NodeType ntFile = mock(NodeType.class); when(thumbnailResource.adaptTo(Node.class)).thenReturn(thumbnailNode); when(thumbnailNode.isNodeType("nt:file")).thenReturn(true); when(thumbnailNode.getPrimaryNodeType()).thenReturn(ntFile); when(ntFile.getName()).thenReturn("nt:file"); when(thumbnailNode.getMixinNodeTypes()).thenReturn(new NodeType[0]); when(thumbnailNode.getProperties()).thenReturn(new PropertyIteratorAdapter(Collections.emptyIterator())); when(thumbnailNode.getNodes()).thenReturn(new NodeIteratorAdapter(Collections.emptyIterator())); when(packageOneDefNode.getSession()).thenReturn(mock(Session.class)); packageHelper.addThumbnail(packageOne, thumbnailResource); verify(packageOneDefNode, times(1)).addNode(eq("thumbnail.png"), eq("nt:file")); }