/**
   * <em> Remove consecutive spaces from an input string </em>
   *
   * <pre>
   * Input Data:
   * >Set INSTRING=”Multiple spaces    in middle of string”
   *
   * Procedure Call:
   *
   * > D MAXBLANK^XMWSOA07(.DATA,INSTRING)
   *
   * Expected Output:
   *
   * >ZW DATA
   * DATA="Multiple spaces  in middle of string"
   * </pre>
   *
   * @throws VistaWebServiceFault
   */
  @Test
  public void testRemoveConsecutiveSpaces() throws VistaWebServiceFault {
    String expectedResult = "Multiple spaces  in middle of string";

    when(this.getVistaLinkContext().makeRPCCall(new RPCIdentifier(""), null))
        .thenReturn(expectedResult);

    request.setInput("Multiple spaces    in middle of string");
    XMXUtil1MaxBlankResponse response = service.maxBlank(request);

    assertNotNull(response);
    assertEquals(expectedResult, response.getCorrectedResult());
  }
  /**
   * <em>Empty string passed into the function returns an error </em>
   *
   * <pre>
   * Input Data:
   * >Set INSTRING=””
   *
   * Procedure Call:
   *
   * > D MAXBLANK^XMWSOA07(.DATA,INSTRING)
   *
   * Expected Output:
   *
   * >ZW DATA
   * DATA="-1^Error in required input"
   * </pre>
   *
   * @throws VistaWebServiceFault
   */
  @Test
  public void testEmptyString() throws VistaWebServiceFault {
    String expectedResult = "-1^Error in required input";

    when(this.getVistaLinkContext().makeRPCCall(new RPCIdentifier(""), null))
        .thenReturn(expectedResult);

    request.setInput("");

    XMXUtil1MaxBlankResponse response = service.maxBlank(request);

    assertNotNull(response);
    assertNull(response.getCorrectedResult());
    assertNotNull(response.getErrors());
    assertEquals(expectedResult.split("\\^")[0], response.getStatus());
    assertEquals(expectedResult.split("\\^")[1], response.getErrors().get(0));
  }
  /*
   * (non-Javadoc)
   *
   * @see gov.va.oit.vistaevolution.mailman.ws.xmxutil1.endpoints.interfaces.
   * XMXUtil1MaxBlankEndpoint
   * #maxBlank(gov.va.oit.vistaevolution.mailman.ws.xmxutil1
   * .model.XMXUtil1MaxBlankRequest)
   */
  @Override
  public XMXUtil1MaxBlankResponse maxBlank(XMXUtil1MaxBlankRequest request)
      throws VistaWebServiceFault {

    LOG.debug(request);

    try {
      RPCIdentifier rpcIdentifier = new RPCIdentifier("EVOLUTION", "XMWSOA REDUCE SPACE");

      List<Object> params = new LinkedList<Object>();
      params.add(request.getInput());
      XMXUtil1MaxBlankResponse response =
          responseFactory.createMaxBlankResponse(
              vistaLinkContext.makeRPCCall(rpcIdentifier, params));
      LOG.debug(response);
      return response;
    } catch (NullPointerException e) {
      LOG.error(e);
      throw new VistaWebServiceFault(e);
    }
    //		LinkedList<Object> params = new LinkedList<Object>();
    //		params.add(request.getInput());
    //
    //		RPCIdentifier rpcId = new RPCIdentifier("EVOLUTION", "XMWSOA REDUCE SPACE");
    //		String rawResponse = getVistaLinkContext().makeRPCCall(rpcId, params);
    //
    //		LOG.debug(this.toString() + ": RPC responded with with:\n" + rawResponse);
    //
    //		XMXUtil1MaxBlankResponse response = new XMXUtil1MaxBlankResponse(rawResponse);
    //
    //		LOG.debug(this.toString() + " is responding to SOAP Request\n:" + request.toString() + "
    // \nWith Response XML:\n"
    //				+ response.toString());
    //
    //		return response;

  }