### Question:
QueryStringDecoder extends AbstractDecoder { @Override public TEvent decode(String source) throws DecodeException { TEvent event = new TEvent(); decode(source, event, null); return null; }  @Override TEvent decode(String source); void decode(String text, TEvent event); @Override void decode(String source, TEvent event, @Nullable String target);  }### Answer:
@Test public void testWithTarget() throws Exception{ QueryStringDecoder decoder = new QueryStringDecoder(); decoder.includes = Sets.newHashSet("a", "c"); decoder.arrayValue = true; decoder.overwrite = true; TEvent event = new TEvent(); event.set("c", "5"); decoder.decode("a=1&b=2&c=3&c=4", event, "tgt"); Assert.assertEquals("1", event.get("tgt.a")); Assert.assertNull(event.get("tgt.b")); Object c = event.get("tgt.c"); Assert.assertTrue(c instanceof List); List lst = (List)c; Assert.assertTrue(lst.contains("3")); Assert.assertTrue(lst.contains("4")); }
@Test public void testNoOverwrite() throws Exception{ QueryStringDecoder decoder = new QueryStringDecoder(); decoder.overwrite = false; decoder.arrayValue = false; TEvent event = new TEvent(); event.set("a", 10); decoder.decode("a=1&b=2&c=3&c=4", event); Assert.assertEquals(10, event.get("a")); Assert.assertEquals("2", event.get("b")); }
@Test public void testQs() throws Exception { QueryStringDecoder decoder = new QueryStringDecoder(); source = "a=1&b=2&c=3"; TEvent event = new TEvent(); decoder.decode(source, event); Assert.assertEquals("1", event.get("a")); Assert.assertEquals("2", event.get("b")); Assert.assertEquals("3", event.get("c")); }
@Test public void testWithArray() throws Exception{ QueryStringDecoder decoder = new QueryStringDecoder(); decoder.arrayValue = true; decoder.excludes = Sets.newHashSet("b"); source = "a=1&b=2&c=3&c=4"; TEvent event = new TEvent(); decoder.decode(source, event); Assert.assertEquals("1", event.get("a")); Assert.assertNull(event.get("b")); Object c = event.get("c"); Assert.assertTrue(c instanceof List); List lst = (List)c; Assert.assertEquals("3", lst.get(0)); Assert.assertEquals("4", lst.get(1)); }