package com.ic.invoicecapture.connection.response.validators;

public class ValidatorFactory {

  private ValidatorComposite buildCommonComposite() {
    ValidatorComposite composite = new ValidatorComposite();
    composite.addValidatorLast(new SpecificStatusCodeValidator(401,
        "Invalid API token supplied, was rejected by the server"));
    composite.addValidatorLast(new StatusCodeValidator());
    composite.addValidatorLast(new JsonValidator());
    return composite;
  }

  public IValidator buildCompanyReturnValidator() {
    return buildCommonComposite();
  }
  
  public IValidator buildCustomerValidator() {
    return buildCommonComposite()
        .addValidatorFirst(new GidConflictValidator("Customer already exists with the same VAT number"));
        
  }
}

@@ -570,19 +570,17 @@
 ();%0A  %7D%0A
-  
 %0A
+
   public
@@ -679,16 +679,29 @@
 orFirst(
+%0A            
 new GidC
@@ -765,25 +765,24 @@
 AT number%22))
-;
 %0A        %0A  
@@ -778,15 +778,147 @@
         
+.addValidatorFirst(new SpecificStatusCodeValidator(422,%0A            %22Invalid json sent to the server (probably a library error)%22));%0A
 %0A  %7D%0A%7D%0A

add http 422 validator