<commit_before>import { AndroidToolsInfo } from '../lib/android-tools-info';
import { EOL } from 'os';
import { assert } from "chai";
import { ChildProcess } from '../lib/wrappers/child-process';
import { FileSystem } from '../lib/wrappers/file-system';
import { HostInfo } from '../lib/host-info';
import { Helpers } from '../lib/helpers';
import { Constants } from '../lib/constants';

interface ITestData {
	javacVersion: string;
	warnings?: string[];
}

describe("androidToolsInfo", () => {
	const additionalInformation = "You will not be able to build your projects for Android." + EOL
	+ "To be able to build for Android, verify that you have installed The Java Development Kit (JDK) and configured it according to system requirements as" + EOL +
	" described in " + Constants.SYSTEM_REQUIREMENTS_LINKS[process.platform];

	const getAndroidToolsInfo = (): AndroidToolsInfo => {
		const childProcess: ChildProcess = <any>{};
		const fs: FileSystem = <any>{};
		const hostInfo: HostInfo = <any>{};
		const helpers: Helpers = new Helpers(<any>{});
		return new AndroidToolsInfo(childProcess, fs, hostInfo, helpers);
	};

	describe("validateJavacVersion", () => {
		const testData: ITestData[] = [
			{
				javacVersion: "1.8.0"
			},
			{
				javacVersion: "1.8.0_152"
			},
			{
				javacVersion: "1.7.0",
				warnings: ["Javac version 1.7.0 is not supported. You have to install at least 1.8.0."]
			},
			{
				javacVersion: "1.7.0_132",
				warnings: ["Javac version 1.7.0_132 is not supported. You have to install at least 1.8.0."]
			},
			{
				javacVersion: null,
				warnings: ["Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable."]
			}
		];

		testData.forEach(({ javacVersion, warnings }) => {
			it(`returns correct result when version is ${javacVersion}`, () => {
				const androidToolsInfo = getAndroidToolsInfo();
				const actualWarnings = androidToolsInfo.validateJavacVersion(javacVersion);
				let expectedWarnings: NativeScriptDoctor.IWarning[] = [];
				if (warnings && warnings.length) {
					expectedWarnings = warnings.map(warning => {
						return {
							platforms: [Constants.ANDROID_PLATFORM_NAME],
							warning,<commit_msg>chore: Add tests for Java version 9 and 10<commit_after>import { AndroidToolsInfo } from '../lib/android-tools-info';
import { EOL } from 'os';
import { assert } from "chai";
import { ChildProcess } from '../lib/wrappers/child-process';
import { FileSystem } from '../lib/wrappers/file-system';
import { HostInfo } from '../lib/host-info';
import { Helpers } from '../lib/helpers';
import { Constants } from '../lib/constants';

interface ITestData {
	javacVersion: string;
	warnings?: string[];
}

describe("androidToolsInfo", () => {
	const additionalInformation = "You will not be able to build your projects for Android." + EOL
	+ "To be able to build for Android, verify that you have installed The Java Development Kit (JDK) and configured it according to system requirements as" + EOL +
	" described in " + Constants.SYSTEM_REQUIREMENTS_LINKS[process.platform];

	const getAndroidToolsInfo = (): AndroidToolsInfo => {
		const childProcess: ChildProcess = <any>{};
		const fs: FileSystem = <any>{};
		const hostInfo: HostInfo = <any>{};
		const helpers: Helpers = new Helpers(<any>{});
		return new AndroidToolsInfo(childProcess, fs, hostInfo, helpers);
	};

	describe("validateJavacVersion", () => {
		const testData: ITestData[] = [
			{
				javacVersion: "1.8.0"
			},
			{
				javacVersion: "1.8.0_152"
			},
			{
				javacVersion: "9"
			},
			{
				javacVersion: "9.0.1"
			},
			{
				javacVersion: "10"
			},
			{
				javacVersion: "10.0.1"
			},
			{
				javacVersion: "1.7.0",
				warnings: ["Javac version 1.7.0 is not supported. You have to install at least 1.8.0."]
			},
			{
				javacVersion: "1.7.0_132",
				warnings: ["Javac version 1.7.0_132 is not supported. You have to install at least 1.8.0."]
			},
			{
				javacVersion: null,
				warnings: ["Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable."]
			}
		];

		testData.forEach(({ javacVersion, warnings }) => {
			it(`returns correct result when version is ${javacVersion}`, () => {
				const androidToolsInfo = getAndroidToolsInfo();
				const actualWarnings = androidToolsInfo.validateJavacVersion(javacVersion);
				let expectedWarnings: NativeScriptDoctor.IWarning[] = [];
				if (warnings && warnings.length) {
					expectedWarnings = warnings.map(warning => {
						return {
							platforms: [Constants.ANDROID_PLATFORM_NAME],
							warning,
{'fraction_non_alphanumeric': 0.136529778542249, 'fraction_numerical': 0.016985594495807353, 'mean_word_length': 3.665997993981946, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5256474', 'n_tokens_mistral': 1688, 'n_tokens_neox': 1458, 'n_words': 411}