Package randoop.condition.specification
Class OperationSpecification
- java.lang.Object
-
- randoop.condition.specification.OperationSpecification
-
public class OperationSpecification extends Object
A specification of a constructor or method, aka, an operation. Consists of thejava.lang.reflect.AccessibleObject
for the operation, and lists ofPrecondition
,Postcondition
, andThrowsCondition
objects that describe contracts on the operation.Method
SpecificationCollection.create(java.util.List)
reads specifications from JSON files. A user specifies JSON files using the--specifications
command-line option. The JSON should include a JSON object labeled by the name of each field of this class, as in{ "operation": { "classname": "net.Connection", "name": "send", "parameterTypes": [ "int" ] }, "identifiers": { "parameters": [ "signalValue" ], "receiverName": "receiver", "returnName": "result" }, "pre": [ { "description": "the signalValue must be positive", "guard": { "conditionText":
Method"signalValue > 0"
, "description": "the signalValue must be positive" } } ], "post": [], "throws": [], }SpecificationCollection.getExecutableSpecification(java.lang.reflect.Executable)
translates specifications to anExecutableSpecification
object that allows the underlying Boolean expressions to be evaluated.
-
-
Field Summary
Fields Modifier and Type Field Description private Identifiers
identifiers
The identifier names used in the specifications.private OperationSignature
operation
The reflection object for the operation.private List<Postcondition>
postSpecifications
The list of post-conditions for the operation.private List<Precondition>
preSpecifications
The list of pre-conditions for the operation.private List<ThrowsCondition>
throwsSpecifications
The specification of expected exceptions for the operation.
-
Constructor Summary
Constructors Modifier Constructor Description private
OperationSpecification()
Gson serialization requires a default constructor.OperationSpecification(OperationSignature operation, Identifiers identifiers)
Creates anOperationSpecification
for the given operation with no specifications.OperationSpecification(OperationSignature operation, Identifiers identifiers, List<Precondition> preSpecifications, List<Postcondition> postSpecifications, List<ThrowsCondition> throwsSpecifications)
Creates anOperationSpecification
for the given operation with the given specifications.
-
Method Summary
-
-
-
Field Detail
-
operation
private final OperationSignature operation
The reflection object for the operation.
-
identifiers
private final Identifiers identifiers
The identifier names used in the specifications.
-
preSpecifications
@SerializedName("pre") private final List<Precondition> preSpecifications
The list of pre-conditions for the operation.
-
postSpecifications
@SerializedName("post") private final List<Postcondition> postSpecifications
The list of post-conditions for the operation.
-
throwsSpecifications
@SerializedName("throws") private final List<ThrowsCondition> throwsSpecifications
The specification of expected exceptions for the operation.
-
-
Constructor Detail
-
OperationSpecification
private OperationSpecification()
Gson serialization requires a default constructor.
-
OperationSpecification
public OperationSpecification(OperationSignature operation, Identifiers identifiers)
Creates anOperationSpecification
for the given operation with no specifications.- Parameters:
operation
- theOperationSignature
object, must be non-nullidentifiers
- theIdentifiers
object, must be non-null
-
OperationSpecification
public OperationSpecification(OperationSignature operation, Identifiers identifiers, List<Precondition> preSpecifications, List<Postcondition> postSpecifications, List<ThrowsCondition> throwsSpecifications)
Creates anOperationSpecification
for the given operation with the given specifications.- Parameters:
operation
- the reflection object for the operation, must be non-nullidentifiers
- the identifiers used in the specificationspreSpecifications
- the list of param specifications for the operationpostSpecifications
- the list of return specifications for the operationthrowsSpecifications
- the list of specifications for the operation
-
-
Method Detail
-
getOperation
public OperationSignature getOperation()
Return theOperationSignature
for the operation.- Returns:
- the reflection object for the operation
-
getIdentifiers
public Identifiers getIdentifiers()
Return theIdentifiers
for this specification.- Returns:
- the identifiers for this specification
-
getPreconditions
public List<Precondition> getPreconditions()
Return the list ofPrecondition
objects for thisOperationSpecification
.- Returns:
- the list of
Precondition
objects for this specification
-
getPostconditions
public List<Postcondition> getPostconditions()
Return the list ofPostcondition
objects for thisOperationSpecification
.- Returns:
- the list of
Postcondition
objects for this specification
-
getThrowsConditions
public List<ThrowsCondition> getThrowsConditions()
Return the list ofThrowsCondition
objects for thisOperationSpecification
.- Returns:
- the list of specifications for this operation specification, is non-null
-
addParamSpecifications
public void addParamSpecifications(List<Precondition> specifications)
AddsPrecondition
objects from the list to thisOperationSpecification
.- Parameters:
specifications
- the list ofPrecondition
objects
-
addReturnSpecifications
public void addReturnSpecifications(List<Postcondition> specifications)
AddsPostcondition
objects from the list to thisOperationSpecification
.- Parameters:
specifications
- the list ofPostcondition
objects
-
addThrowsConditions
public void addThrowsConditions(List<ThrowsCondition> specifications)
AddsThrowsCondition
objects from the list to thisOperationSpecification
.- Parameters:
specifications
- the list ofThrowsCondition
objects
-
isEmpty
public boolean isEmpty()
Indicates whether thisOperationSpecification
contains any pre-, post-, or throws-specifications.- Returns:
true
if there are no pre-, post-, or throws-specifications, false otherwise
-
-