question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to create custom StringValuePattern

See original GitHub issue

Hi,

I wanted to create my own custom StringValuePattern in my project but unfortunately I’m not able to do so due to this Map present in StringValuePatternJsonDeserializer which maps StringValuePatterns to json names (I’m getting JsonMappingException: null is not a valid comparison):

private static final Map<String, Class<? extends StringValuePattern>> PATTERNS =
        new ImmutableMap.Builder<String, Class<? extends StringValuePattern>>()
            .put("equalTo", EqualToPattern.class)
            .put("equalToJson", EqualToJsonPattern.class)
            .put("matchesJsonPath", MatchesJsonPathPattern.class)
            .put("equalToXml", EqualToXmlPattern.class)
            .put("matchesXPath", MatchesXPathPattern.class)
            .put("contains", ContainsPattern.class)
            .put("matches", RegexPattern.class)
            .put("doesNotMatch", NegativeRegexPattern.class)
            .put("anything", AnythingPattern.class)
            .build();

Am I missing something or is it really currently not possible to create custom StringValuePattern?

Why this json name is stored in private Map and not set as annotation on each StringValuePattern class?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
karolzmudacommented, Dec 20, 2017
  1. Is there any particular reason why StringValuePattern cannot be extensible or is it just the design decision? I think that some people may benefit from this option and it won’t hurt anybody in the process 😉

  2. Is it possible to combine Custom Request Matcher with standard MappingBuilder? In fact using MappingBuilder covers 95% of my matching rules and additionaly I would like only to test one particular request header with my custom rules including some custom logic. If I would have to include all this standard matching rules in Custom Request Matcher it would be really a lot of unnecessary work.

0reactions
tomakehurstcommented, Dec 20, 2017

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to create custom StringValuePattern #834 - GitHub
Hi, I wanted to create my own custom StringValuePattern in my project but unfortunately I'm not able to do so due to this...
Read more >
java - No such method exception when creating a wiremock stub
After I make a call to mockApiWithRequestBody, I am getting the exception: java.lang. ... getName(StringValuePattern.java:54) at ...
Read more >
Request Matching - WireMock
Multipart/form-data. Here's an example showing all attributes being matched using WireMock's in-built match operators. It is also possible to write custom ...
Read more >
WireMock Tutorial: Request Matching, Part Three
The previous part of my WireMock tutorial introduces several factory methods that help you to create new StringValuePattern objects.
Read more >
aws_lb_listener_rule | Resources | hashicorp/aws
A listener can't have multiple rules with the same priority. ... (Optional) Information for creating an action that returns a custom HTTP response....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found