package fabricator.j.tests;

import org.testng.annotations.Test;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import static org.testng.Assert.assertTrue;

public class JavaInternetTestSuite extends JavaBaseTest {

    @Test
    public void testUrl() {
        final HashMap<String, Object> stringStringHashMap = new HashMap<>();
        stringStringHashMap.put("hello", "test");
        stringStringHashMap.put("hello2", "test2");
        stringStringHashMap.put("hello3", "test 3");
        final String url = internet.urlBuilder().host("test.ru").paramsInJava(stringStringHashMap).toString();
        assertTrue(url.matches("^(.*:)//([A-Za-z0-9\\-\\.]+)(:[0-9]+)?(.*)$"));
        String params = url.split("/")[3];
        List<String> paramsList = Arrays.asList(params.replaceAll("getEntity\\?","").split("&"));
        assertTrue(paramsList.contains("hello=test"));
        assertTrue(paramsList.contains("hello2=test2"));
        assertTrue(paramsList.contains("hello3=test+3"));
    }
}

@@ -132,16 +132,48 @@
 il.List;
+%0Aimport java.util.regex.Pattern;
 %0A%0Aimport
@@ -270,16 +270,211 @@
 Test %7B%0A%0A
+    private static final Pattern URL_PATTERN = Pattern.compile(%22%5E(.*:)//(%5BA-Za-z0-9%5C%5C-%5C%5C.%5D+)(:%5B0-9%5D+)?(.*)$%22);%0A    private static final Pattern PARAMS_PATTERN = Pattern.compile(%22getEntity%5C%5C?%22);%0A%0A
     @Tes
@@ -865,19 +865,40 @@
 ertTrue(
+URL_PATTERN.matcher(
 url
+)
 .matches
@@ -902,53 +902,8 @@
 hes(
-%22%5E(.*:)//(%5BA-Za-z0-9%5C%5C-%5C%5C.%5D+)(:%5B0-9%5D+)?(.*)$%22
 ));%0A
@@ -993,22 +993,46 @@
 .asList(
+PARAMS_PATTERN.matcher(
 params
+)
 .replace
@@ -1040,23 +1040,8 @@
 ll(%22
-getEntity%5C%5C?%22,%22
 %22).s

use pattern matcher in JavaInternetTestSuite for better performance