Skip to content

Commit

Permalink
1390 - SF
Browse files Browse the repository at this point in the history
  • Loading branch information
ivicac committed Nov 13, 2024
1 parent eaea2d5 commit 00ac88e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,10 @@ private BodyPublisher getFormUrlEncodedBodyPublisher(Body body) {

private void processParameters(String prefix, Map<?, ?> parameters, FormBodyPublisher.Builder builder) {
parameters.forEach((key, value) -> {
String newKey = prefix.isEmpty() ? key.toString() : prefix + "[" + key + "]";
Validate.notNull(value, "Expected value for " + key);

String newKey = prefix.isEmpty() ? key.toString() : prefix + "[" + key + "]";

if (value instanceof Map<?, ?> nestedMap) {
processParameters(newKey, nestedMap, builder);
} else if (value instanceof List<?> list) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package com.bytechef.platform.component.definition;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.bytechef.component.definition.ActionContext;
Expand Down Expand Up @@ -51,7 +53,6 @@
import java.util.Map;
import java.util.Optional;
import javax.net.ssl.SSLSession;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
Expand Down Expand Up @@ -215,7 +216,7 @@ public void testCreateHTTPClient() {
assertTrue(httpClient.authenticator()
.isEmpty());

Assertions.assertNotNull(httpClient.sslContext());
assertNotNull(httpClient.sslContext());

//

Expand Down Expand Up @@ -352,7 +353,7 @@ public void testCreateHTTPClient() {
new ComponentConnection("componentName", 1, -1, Map.of(), Authorization.AuthorizationType.NONE.name()),
Mockito.mock(Context.class));

Assertions.assertNotNull(httpClient.followRedirects());
assertNotNull(httpClient.followRedirects());

//

Expand All @@ -363,7 +364,7 @@ public void testCreateHTTPClient() {
new ComponentConnection("componentName", 1, -1, Map.of(), Authorization.AuthorizationType.NONE.name()),
Mockito.mock(Context.class));

Assertions.assertNotNull(httpClient.followRedirects());
assertNotNull(httpClient.followRedirects());

//

Expand Down Expand Up @@ -411,7 +412,7 @@ public void testCreateHTTPRequest() {
@Disabled
@Test
public void testHandleResponse() {
Assertions.assertNull(
assertNull(
httpClientExecutor
.handleResponse(new TestHttpResponse(null), configuration)
.getBody());
Expand Down Expand Up @@ -502,15 +503,15 @@ public void testHandleResponseWithIncompatibleResponseType() {
Http.Response response =
httpClientExecutor.handleResponse(testHttpResponse, configurationBuilder.build());

Assertions.assertNull(response.getBody());
assertNull(response.getBody());

testHttpResponse = new TestHttpResponse(
"{\"key1\":\"value1\", \"key2\":\"value2\"}",
HttpHeaders.of(Map.of("content-type", List.of("application/json")), (s, s2) -> true), 404);

response = httpClientExecutor.handleResponse(testHttpResponse, configurationBuilder.build());

Assertions.assertNotNull(response.getBody());
assertNotNull(response.getBody());

assertEquals(Map.of("key1", "value1", "key2", "value2"), response.getBody());

Expand All @@ -520,7 +521,7 @@ public void testHandleResponseWithIncompatibleResponseType() {

response = httpClientExecutor.handleResponse(testHttpResponse, configurationBuilder.build());

Assertions.assertNull(response.getBody());
assertNull(response.getBody());

testHttpResponse = new TestHttpResponse(
"<root><key1>value1</key1><key2>value2</key2></root>",
Expand All @@ -530,7 +531,7 @@ public void testHandleResponseWithIncompatibleResponseType() {
testHttpResponse, configurationBuilder.responseType(Http.ResponseType.XML)
.build());

Assertions.assertNotNull(response.getBody());
assertNotNull(response.getBody());

assertEquals(Map.of("key1", "value1", "key2", "value2"), response.getBody());
}
Expand Down

0 comments on commit 00ac88e

Please sign in to comment.