Skip to content

Commit

Permalink
Merge pull request #18 from avioconsulting/request_uri_query_params
Browse files Browse the repository at this point in the history
Include query params on request URI
  • Loading branch information
wied03 authored Sep 9, 2021
2 parents 266189a + 1c9fc7e commit 757852e
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# 2.0
(for Mule 4.x)

# 2.0.52
* Include query params properly on `requestUri` when invoking apikit flows

# 2.0.51
* Removed `pom` type that didn't belong on Groovy dependency

Expand Down
2 changes: 1 addition & 1 deletion connector-class-loader-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.avioconsulting.mule.testing</groupId>
<artifactId>connector-classloader-test</artifactId>
<version>2.0.51</version>
<version>2.0.52</version>
<packaging>mule-extension</packaging>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion implementation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.avioconsulting.mule</groupId>
<artifactId>testing</artifactId>
<version>2.0.51</version>
<version>2.0.52</version>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ trait HttpAttributeBuilder {
// apikit router in mule 4 depends on this
'content-type': mimeType
] + additionalHeaders
def uriWithQueryParams = url + '?' + queryParams.collect { kv ->
kv.key + '=' + URLEncoder.encode(kv.value as String,
'utf-8')
}.join('&')
def attrBuilderClass = appClassLoader.loadClass('org.mule.extension.http.api.HttpRequestAttributesBuilder')
attrBuilderClass.newInstance()
.headers(getMultiMap(headers))
Expand All @@ -58,7 +62,7 @@ trait HttpAttributeBuilder {
.scheme('http')
.method(method)
.requestPath(url)
.requestUri(url)
.requestUri(uriWithQueryParams)
.queryParams(getMultiMap(queryParams))
// has to be non-null
.localAddress('/localAddress')
Expand Down
2 changes: 1 addition & 1 deletion misc-dependency/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.avioconsulting.mule.testing</groupId>
<artifactId>misc-dependency</artifactId>
<version>2.0.51</version>
<version>2.0.52</version>
<packaging>mule-extension</packaging>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.avioconsulting.mule</groupId>
<artifactId>testing-parent-project</artifactId>
<version>2.0.51</version>
<version>2.0.52</version>
<packaging>pom</packaging>

<modules>
Expand Down
2 changes: 1 addition & 1 deletion test-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.avioconsulting.mule.testing</groupId>
<artifactId>test-api</artifactId>
<version>2.0.51</version>
<version>2.0.52</version>
<packaging>mule-extension</packaging>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.avioconsulting.mule</groupId>
<artifactId>tests-for-the-test</artifactId>
<version>2.0.51</version>
<version>2.0.52</version>
<packaging>mule-application</packaging>

<properties>
Expand Down
3 changes: 2 additions & 1 deletion test/src/main/mule/api-the-app-v1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ output application/json
output application/json
---
{
key: vars.foo + vars.bar
key: vars.foo + vars.bar,
requestUri: attributes.requestUri
}]]></ee:set-payload>
</ee:message>
</ee:transform>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ class ApikitFlowInvokeTest extends
'/resources',
queryParams) {
json {
outputOnly(SampleJacksonOutput)
outputOnly(Map)
}
} as SampleJacksonOutput
} as Map

// assert
assertThat result.result,
assertThat result.key,
is(equalTo(133))
assertThat result.requestUri,
is(equalTo('/the-APP/api/v1/resources?foo=123&bar=10'))
}

@Test
Expand Down

0 comments on commit 757852e

Please sign in to comment.