Feature/early mismatch#1451
Conversation
|
I understand the code, and this works, however it needs deep understanding of the code. A better approach could be to introduce an enum public enum MatcherType
{
Path = 0,
Url = 1,
// ...
}And pass this to the Also this logic could be added to the Mapping + MappingModel. |
|
@StefH I agree that design with delegate is a bit complicated for an arbitrary user. I do like the idea with type discriminator for RequestMatchers! But i don't think that My concern is that I would make RequestMatcherType as the Value Object with predefined instances rather than enum. It would allow instantiate new types outside of library's source code. The part about logic addition to Mapping + MappingModel is unclear to me |
|
I think this design could be a possible solution:
It's also possible to define the mappings using a MappingModel (which can you can post as json) to WireMock.Net (https://wiremock.org/dotnet/request-matching/#json-example) |
Add `RequestMatcherType` to request matchers for improved type identification Closes wiremock#1442
Replace `EarlyMatcherSelector` with `EarlyMatcherType` for improved clarity and consistency Closes wiremock#1442
Add EarlyMatcherType support in request models and mapping conversion Closes wiremock#1442
add unit tests for EarlyMatcherType in mapping conversion and serialization Closes wiremock#1442
|
@StefH I investigated the code and decided to implement the idea with
|
Replaced inline `EarlyMatcherType` logic with the new `RequestMessageEarlyMatcher` class to support cases when several matchers of the same type are present. For instance - Header, Cookie, Param Closes wiremock#1442
add unit tests for early mismatch scenarios with several matchers of same type. Currently, headers and parameters Closes wiremock#1442
use fully qualified enum for EarlyMatcherType in serialization Closes wiremock#1442
- removed unused method - added missing curly brackets Closes wiremock#1442
Description
WireMock.RequestBuilders.IRequestBuilder.WithEarlyMismatchWireMockServerTests.GrpcandRequestMessageCompositeMatcherTests)Method
WithEarlyMismatchsets selector which chooses matcher to return immediate mismatch during mapping processing.Selector is a
Funcdelegate run on available matchers.References
Closes #1442