/**
 * Copyright © 2016-2022 The Thingsboard Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.thingsboard.rule.engine.rest;


import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.willCallRealMethod;
import static org.mockito.Mockito.mock;

public class TbHttpClientTest {

    EventLoopGroup eventLoop;
    TbHttpClient client;

    @Before
    public void setUp() throws Exception {
        client = mock(TbHttpClient.class);
        willCallRealMethod().given(client).getSharedOrCreateEventLoopGroup(any());
    }

    @After
    public void tearDown() throws Exception {
        if (eventLoop != null) {
            eventLoop.shutdownGracefully();
        }
    }

    @Test
    public void givenSharedEventLoop_whenGetEventLoop_ThenReturnShared() {
        eventLoop = mock(EventLoopGroup.class);
        assertThat(client.getSharedOrCreateEventLoopGroup(eventLoop), is(eventLoop));
    }

    @Test
    public void givenNull_whenGetEventLoop_ThenReturnShared() {
        eventLoop = client.getSharedOrCreateEventLoopGroup(null);
        assertThat(eventLoop, instanceOf(NioEventLoopGroup.class));
    }
}
@@ -810,16 +810,438 @@
 it.Test;
+%0Aimport org.thingsboard.rule.engine.api.TbContext;%0Aimport org.thingsboard.rule.engine.credentials.AnonymousCredentials;%0Aimport org.thingsboard.rule.engine.credentials.ClientCredentials;%0Aimport org.thingsboard.server.common.data.id.DeviceId;%0Aimport org.thingsboard.server.common.data.id.EntityId;%0Aimport org.thingsboard.server.common.msg.TbMsg;%0Aimport org.thingsboard.server.common.msg.TbMsgMetaData;%0A%0Aimport java.util.Map;
 %0A%0Aimport
@@ -1514,20 +1514,195 @@
 Mockito.
-mock
+doCallRealMethod;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.times;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when
 ;%0A%0Apubli
@@ -2563,10 +2563,741 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testProcessMessageWithJsonInUrlVariable() throws Exception%7B%0A        var config = mock(TbRestApiCallNodeConfiguration.class);%0A        when(config.getCredentials()).thenReturn(new AnonymousCredentials());%0A        when(config.getRequestMethod()).thenReturn(%22GET%22);%0A        when(config.getRestEndpointUrlPattern())%0A                .thenReturn(%22http://localhost/api?data=%5B%7B%5C%5C%5C%22test%5C%5C%5C%22:%5C%5C%5C%22test%5C%5C%5C%22%7D%5D%22);%0A%0A        var httpClient = new TbHttpClient(config, eventLoop);%0A        var ctx = mock(TbContext.class);%0A        var msg = TbMsg.newMsg(%0A                %22Main%22, %22GET%22, new DeviceId(EntityId.NULL_UUID),%0A                TbMsgMetaData.EMPTY, %22%22%0A        );%0A%0A%0A        httpClient.processMessage(ctx, msg);%0A    %7D
 %0A%7D

add corresponding test