PowerMockito.whenNew(MessageDigestGenerator.class).withParameterTypes(String.class).withArguments(anyString())
.thenReturn(mockMessageDigestGenerator);
when(mockMessageDigestGenerator.calcDigestString(any(File.class))).thenReturn("abcd1234");
//create object to test and inject required dependencies
JarContentDelegate objectUnderTest = new JarContentDelegate(mockDirectory, "jar");
//run code under test
Set<ResourcePackageDetails> resultSet = objectUnderTest.discoverDeployedPackages();
//verify the results (Assert and mock verification)
Assert.assertEquals(resultSet.size(), 1);
ResourcePackageDetails resultPackageDetails = (ResourcePackageDetails) resultSet.toArray()[0];