### Question:
JCaptchaResourceReferenceSerializer implements
    ResourceReferenceSerializer<JCaptchaResourceReference, ExtendedURL> { @Override public ExtendedURL serialize(JCaptchaResourceReference resource) throws SerializeResourceReferenceException, UnsupportedResourceReferenceException { List<String> segments = new ArrayList<>(); segments.add("jcaptcha"); segments.add(resource.getCaptchaType()); segments.add(resource.getEngine()); ExtendedURL extendedURL = new ExtendedURL(segments, resource.getParameters()); return this.extendedURLNormalizer.normalize(extendedURL); }  @Override ExtendedURL serialize(JCaptchaResourceReference resource);  }### Answer:
@Test public void serialize() throws UnsupportedResourceReferenceException, SerializeResourceReferenceException { JCaptchaResourceReference jCaptchaResourceReference = new JCaptchaResourceReference("fooType", "barEngine"); ExtendedURL extendedURL = jCaptchaResourceReferenceSerializer.serialize(jCaptchaResourceReference); verify(extendedURLNormalizer, times(1)).normalize(any()); List<String> segments = extendedURL.getSegments(); assertEquals(3, segments.size()); assertEquals("jcaptcha", segments.get(0)); assertEquals("fooType", segments.get(1)); assertEquals("barEngine", segments.get(2)); assertTrue(extendedURL.getParameters().isEmpty()); }
@Test public void serializeWithParameters() throws UnsupportedResourceReferenceException, SerializeResourceReferenceException { JCaptchaResourceReference jCaptchaResourceReference = new JCaptchaResourceReference("bar", "foo"); jCaptchaResourceReference.addParameter("myCustomParam", "someValue"); ExtendedURL extendedURL = jCaptchaResourceReferenceSerializer.serialize(jCaptchaResourceReference); verify(extendedURLNormalizer, times(1)).normalize(any()); List<String> segments = extendedURL.getSegments(); assertEquals(3, segments.size()); assertEquals("jcaptcha", segments.get(0)); assertEquals("bar", segments.get(1)); assertEquals("foo", segments.get(2)); Map<String, List<String>> parameters = extendedURL.getParameters(); assertEquals(1, parameters.size()); assertTrue(parameters.containsKey("myCustomParam")); assertEquals(Arrays.asList("someValue"), parameters.get("myCustomParam")); }