com.liferay.jenkins.results.parser.test.clazz.group.JUnitSegmentTestClassGroup Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.jenkins.results.parser
Show all versions of com.liferay.jenkins.results.parser
Liferay Jenkins Results Parser
/**
* 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 java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONObject;
/**
* @author Michael Hashimoto
*/
public class JUnitSegmentTestClassGroup extends SegmentTestClassGroup {
@Override
public String getTestCasePropertiesContent() {
StringBuilder sb = new StringBuilder();
sb.append(super.getTestCasePropertiesContent());
List axisIndexes = new ArrayList<>();
for (int axisIndex = 0; axisIndex < getAxisCount(); axisIndex++) {
axisIndexes.add(String.valueOf(axisIndex));
AxisTestClassGroup axisTestClassGroup = getAxisTestClassGroup(
axisIndex);
List testClassFiles = axisTestClassGroup.getTestClassFiles();
sb.append("TEST_CLASS_GROUP_");
sb.append(axisIndex);
sb.append("=");
for (File testClassFile : testClassFiles) {
Matcher matcher = _pattern.matcher(testClassFile.toString());
if (!matcher.find()) {
continue;
}
String classFileName = matcher.group("classFileName");
sb.append(classFileName.replace(".java", ".class"));
sb.append(",");
}
if (!testClassFiles.isEmpty()) {
sb.setLength(sb.length() - 1);
}
sb.append("\n");
}
sb.append("TEST_CLASS_GROUPS=");
sb.append(JenkinsResultsParserUtil.join(" ", axisIndexes));
sb.append("\n");
return sb.toString();
}
protected JUnitSegmentTestClassGroup(
BatchTestClassGroup batchTestClassGroup) {
super(batchTestClassGroup);
}
protected JUnitSegmentTestClassGroup(
BatchTestClassGroup batchTestClassGroup, JSONObject jsonObject) {
super(batchTestClassGroup, jsonObject);
}
private static final Pattern _pattern = Pattern.compile(
".*/(?com/.*)");
}