package org.folio.util;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

import org.folio.rest.testing.UtilityClassTester;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

class StringUtilTest {
  @Test
  void isUtilityClass() {
    UtilityClassTester.assertUtilityClass(StringUtil.class);
  }

  @ParameterizedTest
  @CsvSource({
    "abc           , UTF-8     , abc                  ",
    "key=a-umlaut-ä, ISO-8859-1, key%3Da-umlaut-%E4   ",
    "key=a-umlaut-ä, UTF-8     , key%3Da-umlaut-%C3%A4",
  })
  void urlEncodeDecode(String source, String encoding, String encoded) {
    assertThat(StringUtil.urlEncode(source, encoding), is(encoded));
    assertThat(StringUtil.urlDecode(encoded, encoding), is(source));
  }

  @ParameterizedTest
  @CsvSource({
    "abc           , abc                  ",
    "key=a-umlaut-ä, key%3Da-umlaut-%C3%A4",
  })
  void urlEncodeDecode(String source, String encoded) {
    assertThat(StringUtil.urlEncode(source), is(encoded));
    assertThat(StringUtil.urlDecode(encoded), is(source));
  }

  @ParameterizedTest
  @CsvSource({
    " ,      , ''",
    "x,      , ''",
    " , UTF-8, ''",
  })
  void urlEncodeDecodeNull(String s, String encoding, String expected) {
    assertThat(StringUtil.urlEncode(null, encoding), is(expected));
    assertThat(StringUtil.urlDecode(null, encoding), is(expected));
  }

  @Test
  void urlEncodeDecodeNull() {
    assertThat(StringUtil.urlEncode(null), is(""));
    assertThat(StringUtil.urlDecode(null), is(""));
  }
}

@@ -1231,16 +1231,16 @@
    %22
-x,      
+ , UTF-8
 , ''
@@ -1243,36 +1243,36 @@
 , ''%22,%0A    %22
- , UTF-8, ''
+x,      ,   
 %22,%0A  %7D)%0A  vo
@@ -1372,28 +1372,25 @@
 l.urlEncode(
-null
+s
 , encoding),
@@ -1441,20 +1441,17 @@
 lDecode(
-null
+s
 , encodi

Fix unit test