Skip to content

Commit

Permalink
test (Core/URLParameter): Extends unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JPPortier committed Aug 12, 2024
1 parent 9c1162a commit 0e39610
Showing 1 changed file with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,63 @@ void encodeFormStringExplode() {
}

@Test
void encodeDynamicEnumStringNoExplode() {
void encodeFormStringArrayNoExplode() {
assertEquals(
Optional.of("foo=value1+with+space+and+%26%2C%2E,value2+with+space+and+%26%2C%2E"),
URLParameterUtils.encode(
new URLParameter(
"foo",
Arrays.asList("value1 with space and &,.", "value2 with space and &,."),
URLParameter.STYLE.FORM,
false)));
}

@Test
void encodeFormStringArrayExplode() {
assertEquals(
Optional.of("foo=value1+with+space+and+%26%2C%2E&foo=value2+with+space+and+%26%2C%2E"),
URLParameterUtils.encode(
new URLParameter(
"foo",
Arrays.asList("value1 with space and &,.", "value2 with space and &,."),
URLParameter.STYLE.FORM,
true)));
}

@Test
void encodeDynamicEnumNoExplode() {
assertEquals(
Optional.of("foo=ENUM1+value"),
URLParameterUtils.encode(
new URLParameter("foo", AnEnum.ENUM1, URLParameter.STYLE.FORM, false)));
}

@Test
void encodeDynamicEnumStringExplode() {
void encodeDynamicEnumExplode() {
assertEquals(
Optional.of("foo=ENUM1+value"),
URLParameterUtils.encode(
new URLParameter("foo", AnEnum.ENUM1, URLParameter.STYLE.FORM, true)));
}

@Test
void encodeDynamicEnumArrayNoExplode() {
assertEquals(
Optional.of("foo=ENUM1+value,ENUM2+value"),
URLParameterUtils.encode(
new URLParameter(
"foo", Arrays.asList(AnEnum.ENUM1, AnEnum.ENUM2), URLParameter.STYLE.FORM, false)));
}

@Test
void encodeDynamicEnumArrayExplode() {
assertEquals(
Optional.of("foo=ENUM1+value&foo=ENUM2+value"),
URLParameterUtils.encode(
new URLParameter(
"foo", Arrays.asList(AnEnum.ENUM1, AnEnum.ENUM2), URLParameter.STYLE.FORM, true)));
}

@Test
void encodeSimpleEmptyStringNoExplode() {
assertThrows(
Expand Down

0 comments on commit 0e39610

Please sign in to comment.