expectedDisplayVersion.put(testArchiveFiles[4], "1.234 (9.990)");
for (String availableArchiveFile : testArchiveFiles) {
//create the object under test as a partial mock because only one
//public method will be tested, while the rest will be mocked.
TomcatWarComponent objectUnderTest = mock(TomcatWarComponent.class);
//tell the method story as it happens: mock dependencies and configure
//those dependencies to get the method under test to completion.
File archiveUsedInTest = new File(this.getClass().getResource(availableArchiveFile).getFile());
File deploymentFolderUsedInTest = new File(this.getClass().getResource("/").getFile() + "deploymentFolder");
ZipUtil.unzipFile(archiveUsedInTest, deploymentFolderUsedInTest);
@SuppressWarnings("unchecked")
ResourceContext<TomcatVHostComponent> mockResourceContext = mock(ResourceContext.class);
when(objectUnderTest.getResourceContext()).thenReturn(mockResourceContext);
Configuration mockConfiguration = mock(Configuration.class);
when(mockResourceContext.getPluginConfiguration()).thenReturn(mockConfiguration);
when(mockConfiguration.getSimpleValue(eq("filename"), isNull(String.class))).thenReturn(
deploymentFolderUsedInTest.getAbsolutePath());
PackageType mockPackageType = mock(PackageType.class);
when(objectUnderTest.discoverDeployedPackages(any(PackageType.class))).thenCallRealMethod();
//run code under test
Set<ResourcePackageDetails> actualResult = objectUnderTest.discoverDeployedPackages(mockPackageType);
//verify the results (Assert and mock verification)
Assert.assertEquals(actualResult.size(), 1);
ResourcePackageDetails actualResourcePackageDetails = (ResourcePackageDetails) actualResult.toArray()[0];