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

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

The 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 java.io.Serializable;

import org.conqat.lib.commons.test.IndexValueClass;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

/**
 * Base class for coverage probes. Probes are generic coverage "indicators" associated with a source
 * line (the start line of the corresponding statement). Probes can be of different types. For
 * example in case of branch coverage a probe may indicate for an if condition how many times it was
 * evaluated to true and how often to false.
 */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
@JsonSubTypes({ @JsonSubTypes.Type(value = DecisionProbe.class, name = "decision"),
		@JsonSubTypes.Type(value = SimpleStatementCoverageProbe.class, name = "statement"), })
@IndexValueClass(containedInBackup = true)
public abstract class CoverageProbeBase implements Serializable {

	private static final long serialVersionUID = 1L;

	/** 1-based line number of the associated statement */
	@JsonProperty("line")
	private int line;

	public CoverageProbeBase(int line) {
		this.line = line;
	}

	public int getLine() {
		return line;
	}

	public void setLine(int line) {
		this.line = line;
	}

	/** Returns the number of coverable entities for this probe. */
	public abstract int getCoverableCount();

	/** Returns the number of covered entities for this probe. */
	public abstract int getCoveredCount();

	/**
	 * Merges the given probe into this probe.
	 *
	 * @return whether the merge was safe, i.e. if this returns true we are sure that the
	 *         result of the merge was correct, otherwise this might be off.
	 */
	public abstract boolean mergeWith(CoverageProbeBase otherProbe);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy