org.javalite.test.jspec
Class Expectation<T>

java.lang.Object
  extended by org.javalite.test.jspec.Expectation<T>

public class Expectation<T>
extends Object

Author:
Igor Polevoy, Eric Nielsen

Constructor Summary
Expectation(T actual)
           
 
Method Summary
 void shouldBe(String booleanMethod)
          Invokes a boolean method and uses return value in comparison.
 void shouldBeA(Class clazz)
          Tests that the Tested value is a specific type.
 void shouldBeEqual(T expected)
          Tested value is equal expected.
 void shouldBeFalse()
          Tested value should be false.
 void shouldBeNull()
          Tested value should be null.
 void shouldBeTheSameAs(T expected)
          Tested value is the same reference value as expected.
 void shouldBeTrue()
          Tested value should be true.
 void shouldBeType(Class clazz)
          Tests that the Tested value is a specific type.
 void shouldContain(Object expected)
          Tests that an expected value is contained in the tested object.
 void shouldEqual(T expected)
          Alias to shouldBeEqual(Object).
 void shouldHave(String booleanMethod)
          This is for cases suh as: "hasErrors()": a(p).shouldHave("errors").
 void shouldNotBe(String booleanMethod)
          Invokes a boolean method and uses return value in comparison.
 void shouldNotBeEqual(T expected)
          Tested and expected values are not equal.
 void shouldNotBeNull()
          Tested reference should not be null.
 void shouldNotBeTheSameAs(T expected)
          Tested value is not the same reference value as expected.
 void shouldNotContain(Object expected)
          This method is exactly opposite (negated) of shouldContain(Object).
 void shouldNotHave(String booleanMethod)
          This is for cases suh as: "hasErrors()": a(p).shouldNotHave("errors").
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Expectation

public Expectation(T actual)
Method Detail

shouldEqual

public void shouldEqual(T expected)
Alias to shouldBeEqual(Object).

Parameters:
expected - expected value.

shouldBeEqual

public void shouldBeEqual(T expected)
Tested value is equal expected.

Parameters:
expected - expected value.

shouldHave

public void shouldHave(String booleanMethod)
This is for cases suh as: "hasErrors()": a(p).shouldHave("errors"). Invokes a boolean method and uses return value in comparison.

Parameters:
booleanMethod - name of boolean method as specified in Java Beans specification. Example: if method name is hasChildren(), then the string "children" needs to be passed. This results in readable code such as:
 a(bean).shouldHave("children");
 

shouldNotHave

public void shouldNotHave(String booleanMethod)
This is for cases suh as: "hasErrors()": a(p).shouldNotHave("errors"). Invokes a boolean method and uses return value in comparison.

Parameters:
booleanMethod - name of boolean method as specified in Java Beans specification. Example: if method name is hasChildren(), then the string "children" needs to be passed. This results in readable code such as:
 a(bean).shouldNotHave("children");
 

shouldBe

public void shouldBe(String booleanMethod)
Invokes a boolean method and uses return value in comparison.

Parameters:
booleanMethod - name of boolean method as specified in Java Beans specification. Example: if method name is isValid(), then the string "valid" needs to be passed. This results in readable code such as:
 a(bean).shouldBe("valid");
 

shouldNotBe

public void shouldNotBe(String booleanMethod)
Invokes a boolean method and uses return value in comparison.

Parameters:
booleanMethod - name of boolean method as specified in Java Beans specification. Example: if method name is isValid(), then the string "valid" needs to be passed. This results in readable code such as:
 a(bean).shouldNotBe("valid");
 

shouldNotBeEqual

public void shouldNotBeEqual(T expected)
Tested and expected values are not equal.

Parameters:
expected - expected value.

shouldNotBeNull

public void shouldNotBeNull()
Tested reference should not be null.


shouldBeType

public void shouldBeType(Class clazz)
Tests that the Tested value is a specific type.

Parameters:
clazz - type the the expected value should have (or super type). Lets say the super type is Car, and sub type is Toyota, then this test will pass:
     a(new Toyota()).shouldBeA(Car.class).
 
Think of this not in terms of direct typing but from a point of view of inheritance.

Synonym for shouldBeA(Class).


shouldBeA

public void shouldBeA(Class clazz)
Tests that the Tested value is a specific type.

Parameters:
clazz - type the the expected value should have (or super type). Lets say the super type is Car, and sub type is Toyota, then this test will pass:
     a(new Toyota()).shouldBeA(Car.class).
 
Think of this not in terms of direct typing but from a point of view of inheritance.

Synonym for shouldBeType(Class).


shouldBeFalse

public void shouldBeFalse()
Tested value should be false.


shouldBeTrue

public void shouldBeTrue()
Tested value should be true.


shouldBeNull

public void shouldBeNull()
Tested value should be null.


shouldBeTheSameAs

public void shouldBeTheSameAs(T expected)
Tested value is the same reference value as expected.

Parameters:
expected - expected reference.

shouldContain

public void shouldContain(Object expected)
Tests that an expected value is contained in the tested object. The tested object can be of the following types:

Parameters:
expected - value that is expected to be contained in a tested object.

shouldNotContain

public void shouldNotContain(Object expected)
This method is exactly opposite (negated) of shouldContain(Object).

Parameters:
expected - value that is expected to be NOT contained in a tested object.

shouldNotBeTheSameAs

public void shouldNotBeTheSameAs(T expected)
Tested value is not the same reference value as expected.

Parameters:
expected - expected reference.


Copyright © 2015 JavaLite. All rights reserved.