Package randoop.condition.specification
Class OperationSpecification
java.lang.Object
randoop.condition.specification.OperationSpecification
A specification of a constructor or method, aka, an operation. Consists of the
java.lang.reflect.AccessibleObject
for the operation, and lists of Precondition
, Postcondition
, and ThrowsCondition
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": "signalValue > 0"
,
"description": "the signalValue must be positive"
}
}
],
"post": [],
"throws": [],
}
Method SpecificationCollection.getExecutableSpecification(java.lang.reflect.Executable)
translates specifications to an ExecutableSpecification
object that
allows the underlying Boolean expressions to be evaluated.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Identifiers
The identifier names used in the specifications.private final OperationSignature
The reflection object for the operation.private final List<Postcondition>
The list of post-conditions for the operation.private final List<Precondition>
The list of pre-conditions for the operation.private final List<ThrowsCondition>
The specification of expected exceptions for the operation. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
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
Modifier and TypeMethodDescriptionvoid
addParamSpecifications
(List<Precondition> specifications) AddsPrecondition
objects from the list to thisOperationSpecification
.void
addReturnSpecifications
(List<Postcondition> specifications) AddsPostcondition
objects from the list to thisOperationSpecification
.void
addThrowsConditions
(List<ThrowsCondition> specifications) AddsThrowsCondition
objects from the list to thisOperationSpecification
.boolean
Return theIdentifiers
for this specification.Return theOperationSignature
for the operation.Return the list ofPostcondition
objects for thisOperationSpecification
.Return the list ofPrecondition
objects for thisOperationSpecification
.Return the list ofThrowsCondition
objects for thisOperationSpecification
.int
hashCode()
boolean
isEmpty()
Indicates whether thisOperationSpecification
contains any pre-, post-, or throws-specifications.toString()
-
Field Details
-
operation
The reflection object for the operation. -
identifiers
The identifier names used in the specifications. -
preSpecifications
The list of pre-conditions for the operation. -
postSpecifications
The list of post-conditions for the operation. -
throwsSpecifications
The specification of expected exceptions for the operation.
-
-
Constructor Details
-
OperationSpecification
private OperationSpecification()Gson serialization requires a default constructor. -
OperationSpecification
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 Details
-
getOperation
Return theOperationSignature
for the operation.- Returns:
- the reflection object for the operation
-
getIdentifiers
Return theIdentifiers
for this specification.- Returns:
- the identifiers for this specification
-
getPreconditions
Return the list ofPrecondition
objects for thisOperationSpecification
.- Returns:
- the list of
Precondition
objects for this specification
-
getPostconditions
Return the list ofPostcondition
objects for thisOperationSpecification
.- Returns:
- the list of
Postcondition
objects for this specification
-
getThrowsConditions
Return the list ofThrowsCondition
objects for thisOperationSpecification
.- Returns:
- the list of specifications for this operation specification, is non-null
-
addParamSpecifications
AddsPrecondition
objects from the list to thisOperationSpecification
.- Parameters:
specifications
- the list ofPrecondition
objects
-
addReturnSpecifications
AddsPostcondition
objects from the list to thisOperationSpecification
.- Parameters:
specifications
- the list ofPostcondition
objects
-
addThrowsConditions
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
-
equals
-
hashCode
public int hashCode() -
toString
-