### Question:
JCaptchaResourceReferenceResolver extends AbstractResourceReferenceResolver { @Override public ResourceReference resolve(ExtendedURL extendedURL, ResourceType resourceType, Map<String, Object> parameters) throws CreateResourceReferenceException, UnsupportedResourceReferenceException { JCaptchaResourceReference reference; List<String> segments = extendedURL.getSegments(); if (segments.size() > 1) { String type = segments.get(0); String engine = segments.get(1); reference = new JCaptchaResourceReference(type, engine); copyParameters(extendedURL, reference); } else { throw new CreateResourceReferenceException(String.format("Invalid JCaptcha URL format [%s]", extendedURL.toString())); } return reference; }  @Override ResourceReference resolve(ExtendedURL extendedURL, ResourceType resourceType,
        Map<String, Object> parameters);  }### Answer:
@Test public void resolve() throws CreateResourceReferenceException, UnsupportedResourceReferenceException { ExtendedURL extendedURL = new ExtendedURL(Arrays.asList("foo", "bar"), Collections.singletonMap("customValue", Arrays.asList("baz"))); JCaptchaResourceReference expectedReference = new JCaptchaResourceReference("foo", "bar"); expectedReference.addParameter("customValue", "baz"); assertEquals(expectedReference, jCaptchaResourceReferenceResolver.resolve(extendedURL, JCaptchaResourceReference.TYPE, Collections.emptyMap())); }
@Test public void resolveWrongUrl() { ExtendedURL extendedURL = new ExtendedURL(Arrays.asList("foo"), Collections.emptyMap()); CreateResourceReferenceException createResourceReferenceException = assertThrows(CreateResourceReferenceException.class, () -> { jCaptchaResourceReferenceResolver .resolve(extendedURL, JCaptchaResourceReference.TYPE, Collections.emptyMap()); }); assertEquals("Invalid JCaptcha URL format [/foo]", createResourceReferenceException.getMessage()); }