public void verifyCompleteTargetsConfig(List<RepositoryTargetListResource> targets) throws IOException { // check the nexus.xml Configuration config = getTest().getNexusConfigUtil().getNexusConfig(); List<CRepositoryTarget> repoTargets = config.getRepositoryTargets(); // check to see if the size matches Assert.assertTrue( repoTargets.size() == targets.size(), "Configuration had a different number: (" + repoTargets.size() + ") of targets then expected: (" + targets.size() + ")"); // look for the target by id for (Iterator<RepositoryTargetListResource> iter = targets.iterator(); iter.hasNext(); ) { RepositoryTargetListResource targetResource = iter.next(); boolean found = false; for (Iterator<CRepositoryTarget> iterInner = repoTargets.iterator(); iterInner.hasNext(); ) { CRepositoryTarget repositoryTarget = iterInner.next(); if (targetResource.getId().equals(repositoryTarget.getId())) { found = true; Assert.assertEquals(targetResource.getId(), repositoryTarget.getId()); Assert.assertEquals(targetResource.getContentClass(), repositoryTarget.getContentClass()); Assert.assertEquals(targetResource.getName(), repositoryTarget.getName()); break; } } if (!found) { Assert.fail( "Target with ID: " + targetResource.getId() + " could not be found in configuration."); } } }
@SuppressWarnings("unchecked") public void verifyTargetsConfig(List<RepositoryTargetResource> targetResources) throws IOException { // check the nexus.xml Configuration config = getTest().getNexusConfigUtil().getNexusConfig(); List<CRepositoryTarget> repoTargets = config.getRepositoryTargets(); // TODO: we can't check the size unless we reset the config after each run... // check to see if the size matches // Assert.assertTrue( "Configuration had a different number: (" + repoTargets.size() // + ") of targets then expected: (" + targetResources.size() + ")", // repoTargets.size() == targetResources.size() ); // look for the target by id for (Iterator<RepositoryTargetResource> iter = targetResources.iterator(); iter.hasNext(); ) { RepositoryTargetResource targetResource = iter.next(); boolean found = false; for (Iterator<CRepositoryTarget> iterInner = repoTargets.iterator(); iterInner.hasNext(); ) { CRepositoryTarget repositoryTarget = iterInner.next(); if (targetResource.getId().equals(repositoryTarget.getId())) { found = true; Assert.assertEquals(targetResource.getId(), repositoryTarget.getId()); Assert.assertEquals(targetResource.getContentClass(), repositoryTarget.getContentClass()); Assert.assertEquals(targetResource.getName(), repositoryTarget.getName()); // order doesn't matter Assert.assertEquals( new HashSet<String>(targetResource.getPatterns()), new HashSet<String>(repositoryTarget.getPatterns())); break; } } if (!found) { Assert.fail( "Target with ID: " + targetResource.getId() + " could not be found in configuration."); } } }