public class Dvd
extends java.lang.Object
ShoppingCart.xml
specification.
The specification language supports the built-in basic types: Void, Byte,
Boolean, Character, Integer, Short, Long, Float, Double and String; and
the complex types List[T], Set[T], Map[K,V] and Pair[K,V]. If a
specification declares variables of any other type, this is treated as a
symbolic type, but it is uninterpreted, in the sense that nothing is known
about its structure. It is possible to associate other values with such
symbolic types through the use of Maps in the expression language. The
only necessary feature of symbolic types is that instances must be able
to be distinguished. This is achieved using an ID, which by convention
is the first three letters of the type-name, in lower case, followed by
an incrementing digit, starting from 1.
During verification, symbolic types are modelled as instances of the model type Entity, which records the ID name and the symbolic type name. During testing, we expect these symbolic types to translate into domain-specific object types in the application, having the same type name. Testing will need to create instances of these domain types, which we refer to as witness-types, since they must provide witness-values for use during testing. Any witness-type must provide a default constructor, and a constructor that accepts a String ID value. It must also define the hashCode() method to hash on the ID value, and the equals() method to compare two ID values for equality. Apart from this, it may offer whatever methods are needed (typically, to encode internally properties expressed in the model through Maps).
The Dvd class shows how to provide such a witness-type, which requires:
a default constructor that generates the first witness value; a
constructor-from-String that accepts a String ID value; an equals()
method that compares a pair of IDs; and a hashCode() method that hashes
on the ID. The directory path to witness-types must be known to the
generated test-driver. Here, we have copied Dvd to the folders
client/pojo
, client/rs
and
client/ws
to make it available to generated POJO, SOAP and
REST test-drivers which expect to find it there.
Constructor and Description |
---|
Dvd()
The default constructor, which always creates the first Dvd in the
monotonic sequence, with the identifier: "dvd1".
|
Dvd(java.lang.String identifier)
The from-String constructor that is required for a witness-type.
|
public Dvd()
public Dvd(java.lang.String identifier)
identifier
- a String identifier.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object