package test.pete.executables;

import static org.junit.Assert.assertEquals;

import java.nio.file.Paths;

import org.junit.Test;

import pete.executables.DirectoryAnalyzer;
import pete.metrics.installability.deployability.DeploymentPackageAnalyzer;
import pete.metrics.installability.server.AverageInstallationTimeCalculator;
import pete.reporting.Report;

public class DirectoryAnalyzerTests {

	private DirectoryAnalyzer sut;

	@Test
	public void testDeployability() {
		sut = new DirectoryAnalyzer(new DeploymentPackageAnalyzer());
		Report report = sut.analyzeDirectory(Paths
				.get("src/test/resources/installability/deployment"));
		int de = report.getSummedVariable("DE");
		assertEquals("DE should be 214, but was " + de, 214, de);
	}

	@Test
	public void testServerInstallability() {
		sut = new DirectoryAnalyzer(new AverageInstallationTimeCalculator());
		Report report = sut.analyzeDirectory(Paths
				.get("src/test/resources/installability/server/"));

		String ait = report.getEntries().get(0).getVariableValue("AIT");
		assertEquals("AIT should be 2,88, but was ", "2,88", ait);

		String esr = report.getEntries().get(0).getVariableValue("ESR");
		assertEquals("ESR should be 1,00, but was " + esr, "1,00", esr);
	}

}

@@ -1230,10 +1230,392 @@
 r);%0A%09%7D%0A%0A
+%09@Test%0A%09public void testOnlyRelevantFilesAreListed() %7B%0A%09%09sut = new DirectoryAnalyzer(new AverageInstallationTimeCalculator());%0A%09%09Report report = sut.analyzeDirectory(Paths%0A%09%09%09%09.get(%22src/test/resources/installability/server/%22));%0A%0A%09%09int numberOfEntries = report.getEntries().size();%0A%09%09assertEquals(%22Should only list one file, but was %22 + numberOfEntries,%0A%09%09%09%091, numberOfEntries);%0A%09%7D%0A%0A
 %7D%0A

Test for correct number of entries