-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revised UriUtils and added test cases
- Loading branch information
Showing
3 changed files
with
115 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...-io-parent/aksw-commons-io-utils/src/test/java/org/aksw/commons/io/util/TestUriUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.aksw.commons.io.util; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import com.google.common.collect.ImmutableMultimap; | ||
import com.google.common.collect.Multimap; | ||
|
||
public class TestUriUtils { | ||
@Test | ||
public void test01() { | ||
Multimap<String, String> expected = ImmutableMultimap.<String, String>builder() | ||
.put("a", "b").put("c", "d").build(); | ||
// The actual map is a LinkedHashMultiMap so the order should always be as given | ||
Multimap<String, String> actual = UriUtils.parseQueryStringAsMultimap("a=b&c=d"); | ||
// The entry collections differ in type so we need array lists | ||
Assert.assertEquals(new ArrayList<>(expected.entries()), new ArrayList<>(actual.entries())); | ||
} | ||
|
||
/** null query string must result in empty list */ | ||
@Test | ||
public void testNullQueryStringResultsInEmptyList() { | ||
Assert.assertEquals(List.of(), UriUtils.parseQueryStringAsList(null)); | ||
} | ||
|
||
/** empty query string must result in empty list */ | ||
@Test | ||
public void testEmptyQueryStringResultsInEmptyList() { | ||
Assert.assertEquals(List.of(), UriUtils.parseQueryStringAsList("")); | ||
} | ||
|
||
/** empty list result in null query string */ | ||
@Test | ||
public void testEmptyListResultsInNullQueryString() { | ||
Assert.assertEquals(null, UriUtils.toQueryString(List.of())); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters