Class AddressValidatorServiceMock

java.lang.Object
de.calamanari.pk.servicestub.AddressValidatorServiceMock
All Implemented Interfaces:
AddressValidatorService

public class AddressValidatorServiceMock
extends java.lang.Object
implements AddressValidatorService
Address Validator Service Mock - SERVICE STUB (aka Mock) for AddressValidator Service
This is a very simple mock, always returning a predefined result, more sophisticated mocks create matching results for different input sets.
Mock frameworks (like http://code.google.com/p/mockito/) simplify mocking.
Author:
Karl Eilebrecht
  • Constructor Summary

    Constructors
    Constructor Description
    AddressValidatorServiceMock​(boolean validationResult)
    Creates a new mock object always returning the given validation result
  • Method Summary

    Modifier and Type Method Description
    void setValidationResult​(boolean validationResult)
    Sets the result to be returned
    boolean validateAddress​(java.lang.String street, java.lang.String zipCode, java.lang.String city)
    This service method validates the given address

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AddressValidatorServiceMock

      public AddressValidatorServiceMock​(boolean validationResult)
      Creates a new mock object always returning the given validation result
      Parameters:
      validationResult - result to be returned
  • Method Details

    • validateAddress

      public boolean validateAddress​(java.lang.String street, java.lang.String zipCode, java.lang.String city)
      Description copied from interface: AddressValidatorService
      This service method validates the given address
      Specified by:
      validateAddress in interface AddressValidatorService
      Parameters:
      street - address field
      zipCode - address field
      city - address field
      Returns:
      true of the given address exists, otherwise false
    • setValidationResult

      public void setValidationResult​(boolean validationResult)
      Sets the result to be returned
      Parameters:
      validationResult - result of the validation process