j.jenkins.getExtensionList(RunListener.class).remove(listener);
Map<AbstractBuild, Long> buildSizesProject2 = new TreeMap<AbstractBuild,Long>();
Map<String,Long> matrixConfigurationBuildsSize = new TreeMap<String,Long>();
MatrixProject project = (MatrixProject) j.jenkins.getItem("project1");
FreeStyleProject project2 = (FreeStyleProject) j.jenkins.getItem("project2");
AbstractBuild matrixBuild = project.getBuildByNumber(1);
Long matrixProjectBuildSize = getSize(readFileList(new File(matrixBuild.getRootDir(),"fileList"))) + matrixBuild.getRootDir().length();
for(AbstractBuild build: project2.getBuilds()){
File file = new File(build.getRootDir(),"fileList");
buildSizesProject2.put(build, getSize(readFileList(file)) + build.getRootDir().length());
}
for(MatrixConfiguration c: project.getActiveConfigurations()){
AbstractBuild build = c.getBuildByNumber(1);
File file = new File(build.getRootDir(),"fileList");
matrixConfigurationBuildsSize.put(c.getDisplayName(), getSize(readFileList(file)) + build.getRootDir().length());
}
BuildDiskUsageCalculationThread calculation = new BuildDiskUsageCalculationThread();
if(calculation.isExecuting()){
waitUntilThreadEnds(calculation);
}
calculation.execute(TaskListener.NULL);
waitUntilThreadEnds(calculation);
Long size = DiskUsageTestUtil.getBuildDiskUsageAction(project.getBuildByNumber(1)).getDiskUsage();
assertEquals("Build " + project.getBuildByNumber(1).getNumber() + " of project " + project.getDisplayName() + " has wrong build size.", matrixProjectBuildSize, size, 0);
for(AbstractBuild build: buildSizesProject2.keySet()){
Long sizeFreeStyle = DiskUsageTestUtil.getBuildDiskUsageAction(build).getDiskUsage();
assertEquals("Build " + build.getNumber() + " of project " + build.getProject().getDisplayName() + " has wrong build size.", buildSizesProject2.get(build), sizeFreeStyle, 0);
}
for(MatrixConfiguration conf: project.getActiveConfigurations()){
AbstractBuild build = conf.getBuildByNumber(1);
assertEquals("Configuration " + conf.getDisplayName() + " has wrong build size for build 1.", matrixConfigurationBuildsSize.get(conf.getDisplayName()), DiskUsageTestUtil.getBuildDiskUsageAction(build).getDiskUsage(), 0);
}
}