All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.liferay.jenkins.results.parser.test.clazz.group.JSUnitModulesBatchTestClassGroup Maven / Gradle / Ivy

There is a newer version: 1.0.1492
Show newest version
/**
 * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
 */

package com.liferay.jenkins.results.parser.test.clazz.group;

import com.liferay.jenkins.results.parser.JenkinsResultsParserUtil;
import com.liferay.jenkins.results.parser.PortalGitWorkingDirectory;
import com.liferay.jenkins.results.parser.PortalTestClassJob;
import com.liferay.jenkins.results.parser.job.property.JobProperty;
import com.liferay.jenkins.results.parser.test.clazz.TestClass;
import com.liferay.jenkins.results.parser.test.clazz.TestClassFactory;

import java.io.File;
import java.io.IOException;

import java.nio.file.PathMatcher;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.json.JSONObject;

/**
 * @author Michael Hashimoto
 */
public class JSUnitModulesBatchTestClassGroup
	extends ModulesBatchTestClassGroup {

	public boolean testGitrepoJSUnit() {
		JobProperty jobProperty = getJobProperty("test.gitrepo.js.unit");

		String jobPropertyValue = jobProperty.getValue();

		if (!JenkinsResultsParserUtil.isNullOrEmpty(jobPropertyValue) &&
			jobPropertyValue.equals("true")) {

			recordJobProperty(jobProperty);

			return true;
		}

		return false;
	}

	protected JSUnitModulesBatchTestClassGroup(
		JSONObject jsonObject, PortalTestClassJob portalTestClassJob) {

		super(jsonObject, portalTestClassJob);
	}

	protected JSUnitModulesBatchTestClassGroup(
		String batchName, PortalTestClassJob portalTestClassJob) {

		super(batchName, portalTestClassJob);
	}

	@Override
	protected void setAxisTestClassGroups() {
		super.setAxisTestClassGroups();

		TestClass faroTestClass = null;
		AxisTestClassGroup originalAxisTestClassGroup = null;

		axisTestClassGroupLoop:
		for (AxisTestClassGroup axisTestClassGroup : axisTestClassGroups) {
			for (TestClass testClass : axisTestClassGroup.getTestClasses()) {
				String testClassName = testClass.getName();

				if (testClassName.contains("modules/dxp/apps/osb/osb-faro")) {
					faroTestClass = testClass;

					originalAxisTestClassGroup = axisTestClassGroup;

					break axisTestClassGroupLoop;
				}
			}
		}

		if (faroTestClass != null) {
			originalAxisTestClassGroup.removeTestClass(faroTestClass);

			AxisTestClassGroup faroAxisTestClassGroup =
				TestClassGroupFactory.newAxisTestClassGroup(this);

			faroAxisTestClassGroup.addTestClass(faroTestClass);

			axisTestClassGroups.add(faroAxisTestClassGroup);
		}
	}

	@Override
	protected void setTestClasses() throws IOException {
		List moduleDirs = new ArrayList<>();

		PortalGitWorkingDirectory portalGitWorkingDirectory =
			getPortalGitWorkingDirectory();

		List excludesPathMatchers = getPathMatchers(
			getExcludesJobProperties());

		moduleDirs.addAll(
			portalGitWorkingDirectory.getModuleDirsList(
				excludesPathMatchers, getIncludesPathMatchers()));

		for (File moduleDir : moduleDirs) {
			TestClass testClass = TestClassFactory.newTestClass(
				this, moduleDir);

			if (!testClass.hasTestClassMethods()) {
				continue;
			}

			testClasses.add(testClass);
		}

		Collections.sort(testClasses);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy