public XmlStringMatcher(MockServerLogger mockServerLogger, final String matcher) { this(mockServerLogger, string(matcher)); }
public RegexStringMatcher(MockServerLogger mockServerLogger, String matcher) { this.mockServerLogger = mockServerLogger; this.matcher = string(matcher); }
public static List<NottableString> deserializeNottableStrings(List<String> strings) { List<NottableString> nottableStrings = new LinkedList<>(); for (String string : strings) { nottableStrings.add(string(string)); } return nottableStrings; }
public static List<NottableString> strings(Collection<String> values) { List<NottableString> nottableValues = new ArrayList<>(); if (values != null) { for (String value : values) { nottableValues.add(string(value)); } } return nottableValues; }
public static List<NottableString> deserializeNottableStrings(String... strings) { List<NottableString> nottableStrings = new LinkedList<>(); for (String string : strings) { nottableStrings.add(string(string)); } return nottableStrings; }
public static List<NottableString> strings(String... values) { List<NottableString> nottableValues = new ArrayList<>(); if (values != null) { for (String value : values) { nottableValues.add(string(value)); } } return nottableValues; }
public KeyToMultiValue(NottableString name, Collection<NottableString> values) { this.name = name; if (values == null || values.isEmpty()) { this.values = Collections.singletonList(string(".*")); } else { this.values = new ArrayList<>(values); } this.hashCode = Objects.hash(this.name, this.values); }
/** * The HTTP method to match on such as "GET" or "POST" * * @param method the HTTP method such as "GET" or "POST" */ public HttpRequest withMethod(String method) { return withMethod(string(method)); }
/** * The path to match on such as "/some_mocked_path" any servlet context path is ignored for matching and should not be specified here * regex values are also supported such as ".*_path", see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html * for full details of the supported regex syntax * * @param path the path such as "/some_mocked_path" or a regex */ public HttpRequest withPath(String path) { withPath(string(path)); return this; }
@Override public synchronized NottableString get(Object key) { if (key instanceof String) { return get(string((String) key)); } else { List<NottableString> values = backingMap.get(key); if (values != null && values.size() > 0) { return values.get(0); } else { return null; } } }
public synchronized Collection<List<NottableString>> getAll(Object key) { List<List<NottableString>> values = new ArrayList<List<NottableString>>(); if (key instanceof NottableString) { for (Entry<NottableString, List<NottableString>> entry : entrySet()) { if (RegexStringMatcher.matches((NottableString) key, entry.getKey(), true)) { values.add(entry.getValue()); } } } else if (key instanceof String) { return getAll(string((String) key)); } return values; }
@Override public synchronized NottableString remove(Object key) { if (key instanceof NottableString) { for (Entry<NottableString, NottableString> entry : entrySet()) { if (RegexStringMatcher.matches((NottableString) key, entry.getKey(), true)) { return super.remove(entry.getKey()); } } } else if (key instanceof String) { return remove(string((String) key)); } return null; } }
@Override public synchronized NottableString get(Object key) { if (key instanceof NottableString) { for (Entry<NottableString, NottableString> entry : entrySet()) { if (RegexStringMatcher.matches((NottableString) key, entry.getKey(), true)) { return super.get(entry.getKey()); } } } else if (key instanceof String) { return get(string((String) key)); } return null; }
@Override public synchronized List<NottableString> get(Object key) { if (key instanceof NottableString) { for (Entry<NottableString, List<NottableString>> entry : entrySet()) { if (RegexStringMatcher.matches((NottableString) key, entry.getKey(), true)) { return entry.getValue(); } } } else if (key instanceof String) { return get(string((String) key)); } return null; }
public K withEntry(String name, String... values) { if (ArrayUtils.isNotEmpty(values)) { listMultimap.putAll(string(name), deserializeNottableStrings(values)); } return (K) this; }
public NottableString normaliseXmlNottableString(final NottableString input) throws IOException, SAXException, ParserConfigurationException, TransformerException { return string(normaliseXmlString(input.getValue()), input.isNot()); }
public K replaceEntry(String name, String... values) { if (ArrayUtils.isNotEmpty(values)) { remove(name); listMultimap.putAll(string(name), deserializeNottableStrings(values)); } return (K) this; }