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

org.conqat.engine.sourcecode.coverage.ClusteredTestDetails Maven / Gradle / Ivy

There is a newer version: 2025.1.0
Show newest version
/*
 * Copyright (c) CQSE GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.conqat.engine.sourcecode.coverage;

import org.conqat.lib.commons.uniformpath.UniformPath;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * {@link TestDetails} with additional information about which cluster of tests
 * the test case belongs to during prioritization.
 */
public class ClusteredTestDetails extends TestDetails implements Comparable {

	private static final long serialVersionUID = 1L;

	/** The name of the JSON property name for {@link #uniformPath}. */
	protected static final String UNIFORM_PATH_PROPERTY = "uniformPath";

	/** The name of the JSON property name for {@link #clusterId}. */
	private static final String CLUSTER_ID_PROPERTY = "clusterId";

	/** The uniform path the test (unescaped and without -test- prefix). */
	@JsonProperty(UNIFORM_PATH_PROPERTY)
	public String uniformPath;

	/**
	 * A unique identifier for the cluster this test should be prioritized within.
	 * May not be null.
	 */
	@JsonProperty(CLUSTER_ID_PROPERTY)
	public final String clusterId;

	@JsonCreator
	public ClusteredTestDetails(@JsonProperty(UNIFORM_PATH_PROPERTY) String uniformPath,
			@JsonProperty(CONTENT_PROPERTY) String content,
			@JsonProperty(LAST_CHANGED_TIMESTAMP_PROPERTY) long lastChangedTimestamp,
			@JsonProperty(CLUSTER_ID_PROPERTY) String clusterId) {
		super(content, lastChangedTimestamp);
		this.uniformPath = uniformPath;
		this.clusterId = clusterId;
	}

	/** {@inheritDoc} */
	@Override
	public int compareTo(ClusteredTestDetails other) {
		return uniformPath.compareTo(other.uniformPath);
	}

	/** Compute the test execution path. */
	public String getUniformPath() {
		return TestUniformPathUtils.convertToTestUniformPath(uniformPath).toString();
	}

	/** Compute the test execution path. */
	public UniformPath toUniformPath() {
		return TestUniformPathUtils.convertToTestUniformPath(uniformPath);
	}

	@Override
	public String toString() {
		return uniformPath;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy