wiremock-spring-boot icon indicating copy to clipboard operation
wiremock-spring-boot copied to clipboard

add support for multiple property injection

Open rfelgent opened this issue 1 year ago • 10 comments

Hi @maciejwalkowiak

I would like to suggest one enhancement: introduction of multiple property mapping (instead of a single one):

This leads to a simplified setup, for example:

current, complex approach:

@EnableWireMock({
    @ConfigureWireMock(name = "product-aggregates-service", property = "app.client-apis.product-aggregates.base-path", configurationCustomizers = {WireMockCustomizer.class}),
    @ConfigureWireMock(name = "participations-service", property = "app.client-apis.participations.base-path", configurationCustomizers = {WireMockCustomizer.class}),
    @ConfigureWireMock(name = "businesspartners-service", property = "app.client-apis.businesspartners.base-path", configurationCustomizers = {WireMockCustomizer.class}),
    @ConfigureWireMock(name = "usageinformations-service", property = "app.client-apis.usage-informations.base-path", configurationCustomizers = {WireMockCustomizer.class})
})

new, simplified aproach:

@EnableWireMock({
    @ConfigureWireMock(name = "services",
         property = {
            "app.client-apis.product-aggregates.base-path"
            "app.client-apis.participations.base-path",      
            "app.client-apis.businesspartners.base-path",
            "app.client-apis.usage-informations.base-path"
         },
        configurationCustomizers = {WireMockCustomizer.class})
})

If you are convinced by that feature, I can try to make a PR

rfelgent avatar Feb 15 '24 08:02 rfelgent

The name maps to configured WireMockServer instance, with an idea that each instance's base url is bound to a single property. Do you mean in your example that all of these base paths would have the same url?

maciejwalkowiak avatar Feb 17 '24 15:02 maciejwalkowiak

Hi @maciejwalkowiak ,

sorry for the late response!

For the sake of simplified test setup, I want one WireMock instances for all 3rd party RESTful services that my app depends on.

So that I can inject one instance

@InjectWireMock("services")
private WireMockServer servicesWireMock;

instead of

@InjectWireMock("product-aggregates-service")
private WireMockServer productAggregatesWireMock;
@InjectWireMock("businesspartners-service")
private WireMockServer businessPartnersWireMock;
@InjectWireMock("participations-service")
private WireMockServer participationsWireMock;
@InjectWireMock("usageinformations-service")
private WireMockServer usageinformationsWireMock;

I am aware, that WireMock documentation recommends to have a dedicated WireMock instance for every RESTful service, but I do not need this high level of isolation. For my requirements, it is sufficient to isolate the different RESTFul services by path only.

Being that said and in relation to your question

Do you mean in your example that all of these base paths would have the same url?

I configure one base url (not really base path) pointing to one and the same host and the application code has some code snippet for the different paths.

I think this feature request makes it more easy to support "default instance" requirement: #19

rfelgent avatar Feb 26 '24 19:02 rfelgent

ping @maciejwalkowiak

rfelgent avatar Mar 04 '24 10:03 rfelgent

@rfelgent go for it!

maciejwalkowiak avatar Mar 04 '24 10:03 maciejwalkowiak

Hi @maciejwalkowiak

when will you find the time to Look at the pull request?

Greetingz

rfelgent avatar Mar 08 '24 07:03 rfelgent

Soonish, hopefully beginning of the next week

maciejwalkowiak avatar Mar 08 '24 14:03 maciejwalkowiak

ping @maciejwalkowiak :)

rfelgent avatar Mar 14 '24 12:03 rfelgent

ping @maciejwalkowiak

rfelgent avatar Mar 25 '24 09:03 rfelgent

@rfelgent Check PR. I've remembered about this PR, it just had to wait for its time. Pinging does not help 😉

maciejwalkowiak avatar Mar 29 '24 17:03 maciejwalkowiak

Hi @maciejwalkowiak,

What is the current status?

rfelgent avatar Jun 05 '24 08:06 rfelgent