Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mapdecoder;
- import org.junit.Test;
- import java.util.Map;
- import static org.junit.Assert.*;
- public class MyMapDecoderTest {
- @Test
- public void testSample1() {
- String entry = "one=1&two=2";
- MyMapDecoder myMapDecoder = new MyMapDecoder();
- Map<String, String> result= myMapDecoder.decode(entry);
- assertEquals("1", result.get("one"));
- assertEquals("2", result.get("two"));
- }
- @Test
- public void testNullInput() {
- String entry = null;
- MyMapDecoder myMapDecoder = new MyMapDecoder();
- Map<String, String> result = myMapDecoder.decode(entry);
- assertEquals(null, result);
- }
- @Test
- public void testEmptyString() {
- String entry = "";
- MyMapDecoder myMapDecoder = new MyMapDecoder();
- Map<String, String> emptyMap = myMapDecoder.decode(entry);
- assertNotNull(emptyMap);
- assertEquals(0, emptyMap.size());
- }
- @Test(expected = IllegalArgumentException.class)
- public void testException1() {
- String entry = "one=1&&two=2";
- MyMapDecoder myMapDecoder = new MyMapDecoder();
- Map<String, String> result = myMapDecoder.decode(entry);
- }
- @Test(expected = IllegalArgumentException.class)
- public void testException2() {
- String entry = "one=1=&two=2";
- MyMapDecoder myMapDecoder = new MyMapDecoder();
- Map<String, String> result = myMapDecoder.decode(entry);
- }
- }
Add Comment
Please, Sign In to add comment