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 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 result = myMapDecoder.decode(entry); assertEquals(null, result); } @Test public void testEmptyString() { String entry = ""; MyMapDecoder myMapDecoder = new MyMapDecoder(); Map 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 result = myMapDecoder.decode(entry); } @Test(expected = IllegalArgumentException.class) public void testException2() { String entry = "one=1=&two=2"; MyMapDecoder myMapDecoder = new MyMapDecoder(); Map result = myMapDecoder.decode(entry); } }