@Test public void getURL() throws UnsupportedResourceReferenceException, SerializeResourceReferenceException { ExtendedURL extendedURL = mock(ExtendedURL.class); when(serializer.serialize(any())).thenReturn(extendedURL); this.scriptService.getURL("myType", "myEngine", Collections.singletonMap("customParam", "customValue")); JCaptchaResourceReference jCaptchaResourceReference = new JCaptchaResourceReference("myType", "myEngine"); jCaptchaResourceReference.addParameter("customParam", "customValue"); verify(serializer, times(1)).serialize(jCaptchaResourceReference); verify(extendedURL, times(1)).serialize(); }
public String getURL(String type, String engine, Map<String, Object> params) { if (StringUtils.isEmpty(type) || StringUtils.isEmpty(engine)) { return null; } JCaptchaResourceReference resourceReference = new JCaptchaResourceReference(type, engine); if (params != null) { for (Map.Entry<String, Object> parameterEntry : params.entrySet()) { resourceReference.addParameter(parameterEntry.getKey(), parameterEntry.getValue()); } } ExtendedURL extendedURL; try { extendedURL = this.defaultResourceReferenceSerializer.serialize(resourceReference); } catch (SerializeResourceReferenceException | UnsupportedResourceReferenceException e) { this.logger.warn("Error while serializing JCaptcha URL for type [{}], engine = [{}]. Root cause = [{}]", type, engine, ExceptionUtils.getRootCauseMessage(e)); return null; } return extendedURL.serialize(); }
JCaptchaInternalScriptService implements ScriptService { public String getURL(String type, String engine, Map<String, Object> params) { if (StringUtils.isEmpty(type) || StringUtils.isEmpty(engine)) { return null; } JCaptchaResourceReference resourceReference = new JCaptchaResourceReference(type, engine); if (params != null) { for (Map.Entry<String, Object> parameterEntry : params.entrySet()) { resourceReference.addParameter(parameterEntry.getKey(), parameterEntry.getValue()); } } ExtendedURL extendedURL; try { extendedURL = this.defaultResourceReferenceSerializer.serialize(resourceReference); } catch (SerializeResourceReferenceException | UnsupportedResourceReferenceException e) { this.logger.warn("Error while serializing JCaptcha URL for type [{}], engine = [{}]. Root cause = [{}]", type, engine, ExceptionUtils.getRootCauseMessage(e)); return null; } return extendedURL.serialize(); } }
JCaptchaInternalScriptService implements ScriptService { public String getURL(String type, String engine, Map<String, Object> params) { if (StringUtils.isEmpty(type) || StringUtils.isEmpty(engine)) { return null; } JCaptchaResourceReference resourceReference = new JCaptchaResourceReference(type, engine); if (params != null) { for (Map.Entry<String, Object> parameterEntry : params.entrySet()) { resourceReference.addParameter(parameterEntry.getKey(), parameterEntry.getValue()); } } ExtendedURL extendedURL; try { extendedURL = this.defaultResourceReferenceSerializer.serialize(resourceReference); } catch (SerializeResourceReferenceException | UnsupportedResourceReferenceException e) { this.logger.warn("Error while serializing JCaptcha URL for type [{}], engine = [{}]. Root cause = [{}]", type, engine, ExceptionUtils.getRootCauseMessage(e)); return null; } return extendedURL.serialize(); }  }
JCaptchaInternalScriptService implements ScriptService { public String getURL(String type, String engine, Map<String, Object> params) { if (StringUtils.isEmpty(type) || StringUtils.isEmpty(engine)) { return null; } JCaptchaResourceReference resourceReference = new JCaptchaResourceReference(type, engine); if (params != null) { for (Map.Entry<String, Object> parameterEntry : params.entrySet()) { resourceReference.addParameter(parameterEntry.getKey(), parameterEntry.getValue()); } } ExtendedURL extendedURL; try { extendedURL = this.defaultResourceReferenceSerializer.serialize(resourceReference); } catch (SerializeResourceReferenceException | UnsupportedResourceReferenceException e) { this.logger.warn("Error while serializing JCaptcha URL for type [{}], engine = [{}]. Root cause = [{}]", type, engine, ExceptionUtils.getRootCauseMessage(e)); return null; } return extendedURL.serialize(); }  String getURL(String type, String engine, Map<String, Object> params); }
JCaptchaInternalScriptService implements ScriptService { public String getURL(String type, String engine, Map<String, Object> params) { if (StringUtils.isEmpty(type) || StringUtils.isEmpty(engine)) { return null; } JCaptchaResourceReference resourceReference = new JCaptchaResourceReference(type, engine); if (params != null) { for (Map.Entry<String, Object> parameterEntry : params.entrySet()) { resourceReference.addParameter(parameterEntry.getKey(), parameterEntry.getValue()); } } ExtendedURL extendedURL; try { extendedURL = this.defaultResourceReferenceSerializer.serialize(resourceReference); } catch (SerializeResourceReferenceException | UnsupportedResourceReferenceException e) { this.logger.warn("Error while serializing JCaptcha URL for type [{}], engine = [{}]. Root cause = [{}]", type, engine, ExceptionUtils.getRootCauseMessage(e)); return null; } return extendedURL.serialize(); }  String getURL(String type, String engine, Map<String, Object> params);  }