Skip to content
This repository was archived by the owner on Oct 6, 2022. It is now read-only.

Not able to try body-transformer with simple stub #13

Open
dotIN opened this issue May 11, 2016 · 5 comments
Open

Not able to try body-transformer with simple stub #13

dotIN opened this issue May 11, 2016 · 5 comments

Comments

@dotIN
Copy link

dotIN commented May 11, 2016

Hi,
Created a simple stub in mappings folder , copied from one of the examples you provided, used the below Command to start & on startup see the below error.

NOTE : Java version 1.8, I am using wiremock-body-transformer-1.0.4 since I had trouble using the latest version.

{
"request": {
"method": "GET",
"url": "/local-transform"
},
"response": {
"status": 200,
"body": "{"name": "$(var)"}",
"transformers": ["body-transformer"]
}
}

java -cp "wiremock-body-transformer-1.0.4.jar;wiremock-1.57-standalone.jar" com.github.tomakehurst.wiremock.standalone.WireMockServerRunner --verbose --extensions com.opentable.extension.BodyTransformer --port 9999

ERROR
2016-05-11 16:30:18.492 Verbose logging enabled
Exception in thread "main" java.lang.RuntimeException: Unable to bind JSON to object. Reason: Unrecognized field "transformers" (class com.github.tomakehurst.wiremock.http.ResponseDefinition), not mar
ked as ignorable (11 known properties: "fixedDelayMilliseconds", "body", "fault", "headers", "bodyFileName", "proxyBaseUrl", "base64Body", "status", "responseTransformers", "additionalProxyRequestHead
ers", "originalRequest" [truncated]])
at [Source: {
"request": {
"method": "GET",
"url": "/local-transform"
},
"response": {
"status": 200,
"body": "{"name": "$(var)"}",
"transformers": ["body-transformer"]
}
}; line: 9, column: 26](through reference chain: com.github.tomakehurst.wiremock.stubbing.StubMapping["response"]->com.github.tomakehurst.wiremock.http.ResponseDefinition["transformers"]) JSON:{
"request": {
"method": "GET",
"url": "/local-transform"
},
"response": {
"status": 200,
"body": "{"name": "$(var)"}",
"transformers": ["body-transformer"]
}
}
at com.github.tomakehurst.wiremock.common.Json.read(Json.java:33)
at com.github.tomakehurst.wiremock.stubbing.StubMapping.buildFrom(StubMapping.java:56)
at com.github.tomakehurst.wiremock.stubbing.JsonStubMappingCreator.addMappingFrom(JsonStubMappingCreator.java:28)
at com.github.tomakehurst.wiremock.standalone.JsonFileMappingsLoader.loadMappingsInto(JsonFileMappingsLoader.java:39)
at com.github.tomakehurst.wiremock.core.WireMockApp.loadMappingsUsing(WireMockApp.java:87)
at com.github.tomakehurst.wiremock.core.WireMockApp.loadDefaultMappings(WireMockApp.java:83)
at com.github.tomakehurst.wiremock.core.WireMockApp.(WireMockApp.java:75)
at com.github.tomakehurst.wiremock.WireMockServer.(WireMockServer.java:78)
at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.run(WireMockServerRunner.java:62)
at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.main(WireMockServerRunner.java:108)
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "transformers" (class com.github.tomakehurst.wiremock.http.ResponseDefinition), not marked as ignorable
(11 known properties: "fixedDelayMilliseconds", "body", "fault", "headers", "bodyFileName", "proxyBaseUrl", "base64Body", "status", "responseTransformers", "additionalProxyRequestHeaders", "originalRe
quest" [truncated]])
at [Source: {
"request": {
"method": "GET",
"url": "/local-transform"
},
"response": {
"status": 200,
"body": "{"name": "$(var)"}",
"transformers": ["body-transformer"]
}
}; line: 9, column: 26](through reference chain: com.github.tomakehurst.wiremock.stubbing.StubMapping["response"]->com.github.tomakehurst.wiremock.http.ResponseDefinition["transformers"])
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:51)
at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:744)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:915)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1306)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1284)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:243)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:118)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:538)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:99)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:238)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:118)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3066)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2161)
at com.github.tomakehurst.wiremock.common.Json.read(Json.java:31)
... 9 more

@KRoLer
Copy link

KRoLer commented Jun 2, 2016

Hi @dotIN,

Try to use responseTransformers instead of transformers. It might helps to solve your issue.
Or switch to the newest version wiremock-1.58-standalone.jar

@tranhungt
Copy link
Contributor

@dotIN are you still having issues?
Perhaps try our new release v1.1.1 to use with the latest wiremock 2.1.12 and see if that clears up your problems.

@lthur
Copy link

lthur commented Nov 3, 2016

Hi! How are you?
I'm facing almost the same issue.

I'm using the same versions that you provide on your Readme, and I tried to execute the same example that is present in the Readme and I have no success!

This is the response that I have

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
        <title>Error 500 </title>
    </head>
    <body>
        <h2>HTTP ERROR: 500</h2>
        <p>Problem accessing /transform. Reason:

            <pre>    java.lang.NoClassDefFoundError: net/minidev/asm/FieldFilter</pre>
        </p>
        <hr />
        <i>
            <small>Powered by Jetty://</small>
        </i>
    </body>
</html>

I provide here the versions that I'm using to be more clear
body-transformer 1.1.1
wiremock-standalone 2.1.12
Java 8

This is my mapping (present on the readme)

{
    "request": {
        "method": "POST",
        "urlPath": "/transform",
        "bodyPatterns": [
            {
                "matchesJsonPath": "$.name"
            }
        ]
    },
    "response": {
        "status": 200,
        "body": "{\"responseName\": \"$(name)\"}",
        "headers": {
            "Content-Type": "application/json"
        },
        "transformers": ["body-transformer"]
    }
}

And I'm doing a POST request to /transform with body

{
    "name": "Joe"
}

I have that 500 as response.
What I'm doing wrong?

Thank you!

@tranhungt
Copy link
Contributor

@lthur looks like you don't have the required net/minidev/asm/FieldFilter package in your path.
That seems to be a dependency required from wiremock that should've been installed in the wiremock package. Not sure why it's not there for you.

Try to download the com.jayway.jsonpath:json-path jar, which includes the net.minidev package, and include it into your classpath when you run the java -jar command and see if that works.

@tranhungt
Copy link
Contributor

tranhungt commented Nov 16, 2016

@lthur I've just upgraded body transformer to version 1.1.3 to use the newest wiremock version - 2.3.1. Give it a try and let me know if you're still running into problems.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants