Advertisement
Guest User

tests

a guest
Sep 14th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. package mapdecoder;
  2.  
  3. import org.junit.Test;
  4.  
  5. import java.util.Map;
  6.  
  7. import static org.junit.Assert.*;
  8.  
  9. public class MyMapDecoderTest {
  10.  
  11.     @Test
  12.     public void testSample1() {
  13.         String entry = "one=1&two=2";
  14.         MyMapDecoder myMapDecoder = new MyMapDecoder();
  15.         Map<String, String> result= myMapDecoder.decode(entry);
  16.  
  17.         assertEquals("1", result.get("one"));
  18.         assertEquals("2", result.get("two"));
  19.     }
  20.  
  21.     @Test
  22.     public void testNullInput() {
  23.         String entry = null;
  24.         MyMapDecoder myMapDecoder = new MyMapDecoder();
  25.         Map<String, String> result = myMapDecoder.decode(entry);
  26.  
  27.         assertEquals(null, result);
  28.     }
  29.  
  30.     @Test
  31.     public void testEmptyString() {
  32.         String entry = "";
  33.         MyMapDecoder myMapDecoder = new MyMapDecoder();
  34.         Map<String, String> emptyMap = myMapDecoder.decode(entry);
  35.         assertNotNull(emptyMap);
  36.         assertEquals(0, emptyMap.size());
  37.     }
  38.  
  39.     @Test(expected = IllegalArgumentException.class)
  40.     public void testException1() {
  41.         String entry = "one=1&&two=2";
  42.         MyMapDecoder myMapDecoder = new MyMapDecoder();
  43.  
  44.         Map<String, String> result = myMapDecoder.decode(entry);
  45.     }
  46.  
  47.     @Test(expected = IllegalArgumentException.class)
  48.     public void testException2() {
  49.         String entry = "one=1=&two=2";
  50.         MyMapDecoder myMapDecoder = new MyMapDecoder();
  51.  
  52.         Map<String, String> result = myMapDecoder.decode(entry);
  53.     }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement