congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
RestData$Header
Code IndexAdd Tabnine to your IDE (free)

How to use
RestData$Header
in
smartrics.rest.client

Best Java code snippets using smartrics.rest.client.RestData$Header (Showing top 16 results out of 315)

origin: smartrics/RestFixture

@Override
public Object parse(String s) throws Exception {
  // parses a cell content as a map of headers.
  // syntax is name:value\n*
  List<Header> expected = new ArrayList<Header>();
  if (!"".equals(s.trim())) {
    String expStr = Tools.fromHtml(s.trim());
    String[] nvpArray = expStr.split("\n");
    for (String nvp : nvpArray) {
      try {
        String[] nvpEl = nvp.split(":", 2);
        expected.add(new Header(nvpEl[0].trim(), nvpEl[1].trim()));
      } catch (RuntimeException e) {
        throw new IllegalArgumentException("Each entry in the must be separated by \\n and each entry must be expressed as a name:value");
      }
    }
  }
  return expected;
}
origin: smartrics/RestFixture

@Override
public String handle(RunnerVariablesProvider variablesProvider, Config config, RestResponse response, Object expressionContext, String expression) {
  List<String> content = new ArrayList<String>();
  if (response != null) {
    for (Header e : response.getHeaders()) {
      String string = Tools.convertEntryToString(e.getName(), e.getValue(), ":");
      content.add(string);
    }
  }
  String value = null;
  if (content.size() > 0) {
    Pattern p = Pattern.compile(expression);
    for (String c : content) {
      Matcher m = p.matcher(c);
      if (m.find()) {
        int cc = m.groupCount();
        value = m.group(cc);
        break;
      }
    }
  }
  return value;
}
origin: smartrics/RestFixture

putPropertyOnJsObject(response, "transactionId", r.getTransactionId());
for (Header h : r.getHeaders()) {
  callMethodOnJsObject(response, "addHeader", h.getName(), h.getValue());
origin: smartrics/RestFixture

@Override
@SuppressWarnings("unchecked")
public boolean equals(Object expectedObj, Object actualObj) {
  if (expectedObj == null || actualObj == null) {
    return false;
  }
  // r1 and r2 are Map<String, String> containing either the header
  // from the HTTP response or the data value in the expected cell
  // equals checks for r1 being a subset of r2
  Collection<Header> expected = (Collection<Header>) expectedObj;
  Collection<Header> actual = (Collection<Header>) actualObj;
  for (Header k : expected) {
    Header aHdr = find(actual, k);
    if (aHdr == null) {
      addError("not found: [" + k.getName() + " : " + k.getValue() + "]");
    }
  }
  return getErrors().size() == 0;
}
origin: smartrics.restfixture/smartrics-RestClient

/**
 *
 * @param name
 *            the header name
 * @return the sub-list of headers with the same name
 */
public List<Header> getHeader(String name) {
  List<Header> headersWithTheSameName = new ArrayList<Header>();
  for (Header h : headers) {
    if (h.getName().equalsIgnoreCase(name)) {
      headersWithTheSameName.add(h);
    }
  }
  return headersWithTheSameName;
}
origin: smartrics.restfixture/smartrics-RestClient

/**
 * Adds an HTTP header to the current list.
 *
 * @param name
 *            the header name
 * @param value
 *            the header value
 * @return this RestData
 */
public RestData addHeader(String name, String value) {
  this.headers.add(new Header(name, value));
  return this;
}
origin: smartrics.restfixture/smartrics-RestClient

@Override
public int hashCode() {
  return getName().hashCode() + 37 * getValue().hashCode();
}
origin: smartrics.restfixture/smartrics-RestClient

/**
 * Adds a collection of HTTP headers to the current list of headers.
 * 
 * @param headers
 *            the list of headers
 * @return this RestData
 */
public RestData addHeaders(List<Header> headers) {
  for (Header e : headers) {
    addHeader(e.getName(), e.getValue());
  }
  return this;
}
origin: smartrics/RestFixture

@Override
@SuppressWarnings("unchecked")
public String toString(Object obj) {
  StringBuffer b = new StringBuffer();
  List<Header> list = (List<Header>) obj;
  for (Header h : list) {
    b.append(h.getName()).append(" : ").append(h.getValue()).append("\n");
  }
  return b.toString().trim();
}
origin: smartrics/RestFixture

private Header find(Collection<Header> actual, Header k) {
  for (Header h : actual) {
    boolean nameMatches = h.getName().equals(k.getName());
    boolean valueMatches = Tools.regex(h.getValue(), k.getValue());
    if (nameMatches && valueMatches) {
      return h;
    }
  }
  return null;
}
origin: smartrics.restfixture/smartrics-RestClient

public String getHeaderValue(String name) {
  List<Header> headers = getHeader(name);
  if(headers.size() > 0) {
    return headers.get(0).getValue();
  }
  return null;
}
 
origin: smartrics.restfixture/smartrics-RestClient

  public String getContentType() {
    List<smartrics.rest.client.RestData.Header> values = request.getHeader("Content-Type");
    String v = "text/xml";
    if (values.size() != 0)
      v = values.get(0).getValue();
    return v;
  }
};
origin: smartrics.restfixture/smartrics-RestClient

@Override
public boolean equals(Object o) {
  if (!(o instanceof Header))
    return false;
  Header h = (Header) o;
  return getName().equals(h.getName())
      && getValue().equals(h.getValue());
}
origin: smartrics.restfixture/smartrics-RestClient

  private void addHeaders(HttpMethod m, RestRequest request) {
    for (RestData.Header h : request.getHeaders()) {
      m.addRequestHeader(h.getName(), h.getValue());
    }
  }
}
origin: smartrics.restfixture/smartrics-RestClient

  @Override
  public String toString() {
    return String.format("%s:%s", getName(), getValue());
  }
}
origin: smartrics.restfixture/smartrics-RestClient

public String getContentType(RestRequest request) {
  List<smartrics.rest.client.RestData.Header> values = request.getHeader("Content-Type");
  String v = "text/xml";
  if (values.size() != 0)
    v = values.get(0).getValue();
  return v;
}
smartrics.rest.clientRestData$Header

Javadoc

Holds an Http Header.

Most used methods

  • <init>
  • getName
  • getValue

Popular in Java

  • Finding current android device location
  • scheduleAtFixedRate (ScheduledExecutorService)
  • scheduleAtFixedRate (Timer)
  • addToBackStack (FragmentTransaction)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now