@Test public void testGetAsElement() { Element e = webhookAllEnabled.getAsElement(); WebHookConfig whc = new WebHookConfig(e); assertTrue(whc.getParams().containsKey("color")); assertTrue(whc.getParams().containsKey("notify")); }
public Element getAsElement(){ Element el = new Element("webhook"); el.setAttribute("url", this.getUrl()); el.setAttribute(ATTR_ENABLED, String.valueOf(this.enabled)); el.setAttribute(ATTR_TEMPLATE, String.valueOf(this.payloadTemplate)); Element statesEl = new Element(EL_STATES); for (BuildStateEnum state : states.getStateSet()){ Element e = new Element(EL_STATE); e.setAttribute(ATTR_TYPE, state.getShortName()); e.setAttribute(ATTR_ENABLED, Boolean.toString(states.enabled(state))); statesEl.addContent(e); } el.addContent(statesEl); Element buildsEl = new Element(EL_BUILD_TYPES); buildsEl.setAttribute(ATTR_ENABLED_FOR_ALL, Boolean.toString(isEnabledForAllBuildsInProject())); buildsEl.setAttribute(ATTR_ENABLED_FOR_SUBPROJECTS, Boolean.toString(isEnabledForSubProjects())); for (String i : enabledBuildTypesSet){ Element e = new Element("build-type"); e.setAttribute("id", i); buildsEl.addContent(e); } el.addContent(buildsEl); if (this.filters != null && ! this.filters.isEmpty()){ Element filtersEl = new Element(EL_TRIGGER_FILTERS); for (WebHookFilterConfig f : this.filters){ filtersEl.addContent(f.getAsElement()); } el.addContent(filtersEl); } if (this.extraParameters.size() > 0){ Element paramsEl = new Element(EL_PARAMETERS); for (String i : this.extraParameters.keySet()){ paramsEl.addContent(this.getKeyAndValueAsElement(this.extraParameters, i, ATTR_PARAM)); } el.addContent(paramsEl); } if (this.templates.size() > 0){ Element templatesEl = new Element(EL_CUSTOM_TEMPLATES); for (CustomMessageTemplate t : this.templates.values()){ templatesEl.addContent(t.getAsElement()); } el.addContent(templatesEl); } if (this.authType != null && ! this.authType.isEmpty()){ Element authEl = new Element("auth"); authEl.setAttribute(ATTR_ENABLED, this.authEnabled.toString()); authEl.setAttribute(ATTR_TYPE, this.authType); authEl.setAttribute(ATTR_PREEMPTIVE, this.authPreemptive.toString() ); if (this.authParameters != null && ! this.authParameters.isEmpty()){ Element paramsEl = new Element("auth-parameters"); for (String i : this.authParameters.keySet()){ paramsEl.addContent(this.getKeyAndValueAsElement(this.authParameters, i, ATTR_PARAM)); } authEl.addContent(paramsEl); } el.addContent(authEl); } if (this.headers != null && ! this.headers.isEmpty()){ Element headersEl = new Element(EL_HEADERS); for (WebHookHeaderConfig h : this.headers){ headersEl.addContent(h.getAsElement()); } el.addContent(headersEl); } return el; }
WebHookConfig { public Element getAsElement(){ Element el = new Element("webhook"); el.setAttribute("url", this.getUrl()); el.setAttribute(ATTR_ENABLED, String.valueOf(this.enabled)); el.setAttribute(ATTR_TEMPLATE, String.valueOf(this.payloadTemplate)); Element statesEl = new Element(EL_STATES); for (BuildStateEnum state : states.getStateSet()){ Element e = new Element(EL_STATE); e.setAttribute(ATTR_TYPE, state.getShortName()); e.setAttribute(ATTR_ENABLED, Boolean.toString(states.enabled(state))); statesEl.addContent(e); } el.addContent(statesEl); Element buildsEl = new Element(EL_BUILD_TYPES); buildsEl.setAttribute(ATTR_ENABLED_FOR_ALL, Boolean.toString(isEnabledForAllBuildsInProject())); buildsEl.setAttribute(ATTR_ENABLED_FOR_SUBPROJECTS, Boolean.toString(isEnabledForSubProjects())); for (String i : enabledBuildTypesSet){ Element e = new Element("build-type"); e.setAttribute("id", i); buildsEl.addContent(e); } el.addContent(buildsEl); if (this.filters != null && ! this.filters.isEmpty()){ Element filtersEl = new Element(EL_TRIGGER_FILTERS); for (WebHookFilterConfig f : this.filters){ filtersEl.addContent(f.getAsElement()); } el.addContent(filtersEl); } if (this.extraParameters.size() > 0){ Element paramsEl = new Element(EL_PARAMETERS); for (String i : this.extraParameters.keySet()){ paramsEl.addContent(this.getKeyAndValueAsElement(this.extraParameters, i, ATTR_PARAM)); } el.addContent(paramsEl); } if (this.templates.size() > 0){ Element templatesEl = new Element(EL_CUSTOM_TEMPLATES); for (CustomMessageTemplate t : this.templates.values()){ templatesEl.addContent(t.getAsElement()); } el.addContent(templatesEl); } if (this.authType != null && ! this.authType.isEmpty()){ Element authEl = new Element("auth"); authEl.setAttribute(ATTR_ENABLED, this.authEnabled.toString()); authEl.setAttribute(ATTR_TYPE, this.authType); authEl.setAttribute(ATTR_PREEMPTIVE, this.authPreemptive.toString() ); if (this.authParameters != null && ! this.authParameters.isEmpty()){ Element paramsEl = new Element("auth-parameters"); for (String i : this.authParameters.keySet()){ paramsEl.addContent(this.getKeyAndValueAsElement(this.authParameters, i, ATTR_PARAM)); } authEl.addContent(paramsEl); } el.addContent(authEl); } if (this.headers != null && ! this.headers.isEmpty()){ Element headersEl = new Element(EL_HEADERS); for (WebHookHeaderConfig h : this.headers){ headersEl.addContent(h.getAsElement()); } el.addContent(headersEl); } return el; } }
WebHookConfig { public Element getAsElement(){ Element el = new Element("webhook"); el.setAttribute("url", this.getUrl()); el.setAttribute(ATTR_ENABLED, String.valueOf(this.enabled)); el.setAttribute(ATTR_TEMPLATE, String.valueOf(this.payloadTemplate)); Element statesEl = new Element(EL_STATES); for (BuildStateEnum state : states.getStateSet()){ Element e = new Element(EL_STATE); e.setAttribute(ATTR_TYPE, state.getShortName()); e.setAttribute(ATTR_ENABLED, Boolean.toString(states.enabled(state))); statesEl.addContent(e); } el.addContent(statesEl); Element buildsEl = new Element(EL_BUILD_TYPES); buildsEl.setAttribute(ATTR_ENABLED_FOR_ALL, Boolean.toString(isEnabledForAllBuildsInProject())); buildsEl.setAttribute(ATTR_ENABLED_FOR_SUBPROJECTS, Boolean.toString(isEnabledForSubProjects())); for (String i : enabledBuildTypesSet){ Element e = new Element("build-type"); e.setAttribute("id", i); buildsEl.addContent(e); } el.addContent(buildsEl); if (this.filters != null && ! this.filters.isEmpty()){ Element filtersEl = new Element(EL_TRIGGER_FILTERS); for (WebHookFilterConfig f : this.filters){ filtersEl.addContent(f.getAsElement()); } el.addContent(filtersEl); } if (this.extraParameters.size() > 0){ Element paramsEl = new Element(EL_PARAMETERS); for (String i : this.extraParameters.keySet()){ paramsEl.addContent(this.getKeyAndValueAsElement(this.extraParameters, i, ATTR_PARAM)); } el.addContent(paramsEl); } if (this.templates.size() > 0){ Element templatesEl = new Element(EL_CUSTOM_TEMPLATES); for (CustomMessageTemplate t : this.templates.values()){ templatesEl.addContent(t.getAsElement()); } el.addContent(templatesEl); } if (this.authType != null && ! this.authType.isEmpty()){ Element authEl = new Element("auth"); authEl.setAttribute(ATTR_ENABLED, this.authEnabled.toString()); authEl.setAttribute(ATTR_TYPE, this.authType); authEl.setAttribute(ATTR_PREEMPTIVE, this.authPreemptive.toString() ); if (this.authParameters != null && ! this.authParameters.isEmpty()){ Element paramsEl = new Element("auth-parameters"); for (String i : this.authParameters.keySet()){ paramsEl.addContent(this.getKeyAndValueAsElement(this.authParameters, i, ATTR_PARAM)); } authEl.addContent(paramsEl); } el.addContent(authEl); } if (this.headers != null && ! this.headers.isEmpty()){ Element headersEl = new Element(EL_HEADERS); for (WebHookHeaderConfig h : this.headers){ headersEl.addContent(h.getAsElement()); } el.addContent(headersEl); } return el; } @SuppressWarnings("unchecked")  WebHookConfig(Element e);  WebHookConfig(String projectInternalId, String projectExternalId, String url, Boolean enabled, BuildState states, String payloadTemplate, boolean buildTypeAllEnabled, boolean buildTypeSubProjects, Set<String> enabledBuildTypes, WebHookAuthConfig webHookAuthConfig); }
WebHookConfig { public Element getAsElement(){ Element el = new Element("webhook"); el.setAttribute("url", this.getUrl()); el.setAttribute(ATTR_ENABLED, String.valueOf(this.enabled)); el.setAttribute(ATTR_TEMPLATE, String.valueOf(this.payloadTemplate)); Element statesEl = new Element(EL_STATES); for (BuildStateEnum state : states.getStateSet()){ Element e = new Element(EL_STATE); e.setAttribute(ATTR_TYPE, state.getShortName()); e.setAttribute(ATTR_ENABLED, Boolean.toString(states.enabled(state))); statesEl.addContent(e); } el.addContent(statesEl); Element buildsEl = new Element(EL_BUILD_TYPES); buildsEl.setAttribute(ATTR_ENABLED_FOR_ALL, Boolean.toString(isEnabledForAllBuildsInProject())); buildsEl.setAttribute(ATTR_ENABLED_FOR_SUBPROJECTS, Boolean.toString(isEnabledForSubProjects())); for (String i : enabledBuildTypesSet){ Element e = new Element("build-type"); e.setAttribute("id", i); buildsEl.addContent(e); } el.addContent(buildsEl); if (this.filters != null && ! this.filters.isEmpty()){ Element filtersEl = new Element(EL_TRIGGER_FILTERS); for (WebHookFilterConfig f : this.filters){ filtersEl.addContent(f.getAsElement()); } el.addContent(filtersEl); } if (this.extraParameters.size() > 0){ Element paramsEl = new Element(EL_PARAMETERS); for (String i : this.extraParameters.keySet()){ paramsEl.addContent(this.getKeyAndValueAsElement(this.extraParameters, i, ATTR_PARAM)); } el.addContent(paramsEl); } if (this.templates.size() > 0){ Element templatesEl = new Element(EL_CUSTOM_TEMPLATES); for (CustomMessageTemplate t : this.templates.values()){ templatesEl.addContent(t.getAsElement()); } el.addContent(templatesEl); } if (this.authType != null && ! this.authType.isEmpty()){ Element authEl = new Element("auth"); authEl.setAttribute(ATTR_ENABLED, this.authEnabled.toString()); authEl.setAttribute(ATTR_TYPE, this.authType); authEl.setAttribute(ATTR_PREEMPTIVE, this.authPreemptive.toString() ); if (this.authParameters != null && ! this.authParameters.isEmpty()){ Element paramsEl = new Element("auth-parameters"); for (String i : this.authParameters.keySet()){ paramsEl.addContent(this.getKeyAndValueAsElement(this.authParameters, i, ATTR_PARAM)); } authEl.addContent(paramsEl); } el.addContent(authEl); } if (this.headers != null && ! this.headers.isEmpty()){ Element headersEl = new Element(EL_HEADERS); for (WebHookHeaderConfig h : this.headers){ headersEl.addContent(h.getAsElement()); } el.addContent(headersEl); } return el; } @SuppressWarnings("unchecked")  WebHookConfig(Element e);  WebHookConfig(String projectInternalId, String projectExternalId, String url, Boolean enabled, BuildState states, String payloadTemplate, boolean buildTypeAllEnabled, boolean buildTypeSubProjects, Set<String> enabledBuildTypes, WebHookAuthConfig webHookAuthConfig); Element getAsElement(); SortedMap<String,String> getParams(); boolean isEnabledForBuildType(SBuildType sBuildType); boolean isSpecificBuildTypeEnabled(SBuildType sBuildType); Set<String> getEnabledBuildTypesSet(); Boolean getEnabled(); void setEnabled(Boolean enabled); BuildState getBuildStates(); void setBuildStates(BuildState states); String getUrl(); void setUrl(String url); String getUniqueKey(); void setUniqueKey(String uniqueKey); String getEnabledListAsString(); String getWebHookEnabledAsChecked(); String getStateAllAsChecked(); String getStateBuildStartedAsChecked(); String getStateChangesLoadedAsChecked(); String getStateBuildFinishedAsChecked(); String getStateBeforeFinishedAsChecked(); String getStateResponsibilityChangedAsChecked(); String getStateBuildInterruptedAsChecked(); String getStateBuildSuccessfulAsChecked(); String getStateBuildFixedAsChecked(); String getStateBuildFailedAsChecked(); String getStateBuildBrokenAsChecked(); String getPayloadTemplate(); void setPayloadFormat(String payloadFormat); void setPayloadTemplate(String payloadTemplate); Boolean isEnabledForAllBuildsInProject(); void enableForAllBuildsInProject(Boolean allBuildTypesEnabled); Boolean isEnabledForSubProjects(); void enableForSubProjects(Boolean subProjectsEnabled); void clearAllEnabledBuildsInProject(); void enableBuildInProject(String buildTypeId); Map<String,String> getEnabledTemplates(); Boolean getAuthEnabled(); void setAuthEnabled(Boolean authEnabled); void setAuthParameters(Map<String, String> authParameters); void clearAuthParameters(); void setAuthType(String authType); void setAuthPreemptive(Boolean authPreemptive); WebHookAuthConfig getAuthenticationConfig(); List<WebHookFilterConfig> getTriggerFilters(); List<WebHookHeaderConfig> getHeaders(); void setHeaders(List<WebHookHeaderConfig> headers); WebHookConfig copy(); String getProjectInternalId(); void setProjectInternalId(String projectInternalId); String getProjectExternalId(); void setProjectExternalId(String projectExternalId); }
WebHookConfig { public Element getAsElement(){ Element el = new Element("webhook"); el.setAttribute("url", this.getUrl()); el.setAttribute(ATTR_ENABLED, String.valueOf(this.enabled)); el.setAttribute(ATTR_TEMPLATE, String.valueOf(this.payloadTemplate)); Element statesEl = new Element(EL_STATES); for (BuildStateEnum state : states.getStateSet()){ Element e = new Element(EL_STATE); e.setAttribute(ATTR_TYPE, state.getShortName()); e.setAttribute(ATTR_ENABLED, Boolean.toString(states.enabled(state))); statesEl.addContent(e); } el.addContent(statesEl); Element buildsEl = new Element(EL_BUILD_TYPES); buildsEl.setAttribute(ATTR_ENABLED_FOR_ALL, Boolean.toString(isEnabledForAllBuildsInProject())); buildsEl.setAttribute(ATTR_ENABLED_FOR_SUBPROJECTS, Boolean.toString(isEnabledForSubProjects())); for (String i : enabledBuildTypesSet){ Element e = new Element("build-type"); e.setAttribute("id", i); buildsEl.addContent(e); } el.addContent(buildsEl); if (this.filters != null && ! this.filters.isEmpty()){ Element filtersEl = new Element(EL_TRIGGER_FILTERS); for (WebHookFilterConfig f : this.filters){ filtersEl.addContent(f.getAsElement()); } el.addContent(filtersEl); } if (this.extraParameters.size() > 0){ Element paramsEl = new Element(EL_PARAMETERS); for (String i : this.extraParameters.keySet()){ paramsEl.addContent(this.getKeyAndValueAsElement(this.extraParameters, i, ATTR_PARAM)); } el.addContent(paramsEl); } if (this.templates.size() > 0){ Element templatesEl = new Element(EL_CUSTOM_TEMPLATES); for (CustomMessageTemplate t : this.templates.values()){ templatesEl.addContent(t.getAsElement()); } el.addContent(templatesEl); } if (this.authType != null && ! this.authType.isEmpty()){ Element authEl = new Element("auth"); authEl.setAttribute(ATTR_ENABLED, this.authEnabled.toString()); authEl.setAttribute(ATTR_TYPE, this.authType); authEl.setAttribute(ATTR_PREEMPTIVE, this.authPreemptive.toString() ); if (this.authParameters != null && ! this.authParameters.isEmpty()){ Element paramsEl = new Element("auth-parameters"); for (String i : this.authParameters.keySet()){ paramsEl.addContent(this.getKeyAndValueAsElement(this.authParameters, i, ATTR_PARAM)); } authEl.addContent(paramsEl); } el.addContent(authEl); } if (this.headers != null && ! this.headers.isEmpty()){ Element headersEl = new Element(EL_HEADERS); for (WebHookHeaderConfig h : this.headers){ headersEl.addContent(h.getAsElement()); } el.addContent(headersEl); } return el; } @SuppressWarnings("unchecked")  WebHookConfig(Element e);  WebHookConfig(String projectInternalId, String projectExternalId, String url, Boolean enabled, BuildState states, String payloadTemplate, boolean buildTypeAllEnabled, boolean buildTypeSubProjects, Set<String> enabledBuildTypes, WebHookAuthConfig webHookAuthConfig); Element getAsElement(); SortedMap<String,String> getParams(); boolean isEnabledForBuildType(SBuildType sBuildType); boolean isSpecificBuildTypeEnabled(SBuildType sBuildType); Set<String> getEnabledBuildTypesSet(); Boolean getEnabled(); void setEnabled(Boolean enabled); BuildState getBuildStates(); void setBuildStates(BuildState states); String getUrl(); void setUrl(String url); String getUniqueKey(); void setUniqueKey(String uniqueKey); String getEnabledListAsString(); String getWebHookEnabledAsChecked(); String getStateAllAsChecked(); String getStateBuildStartedAsChecked(); String getStateChangesLoadedAsChecked(); String getStateBuildFinishedAsChecked(); String getStateBeforeFinishedAsChecked(); String getStateResponsibilityChangedAsChecked(); String getStateBuildInterruptedAsChecked(); String getStateBuildSuccessfulAsChecked(); String getStateBuildFixedAsChecked(); String getStateBuildFailedAsChecked(); String getStateBuildBrokenAsChecked(); String getPayloadTemplate(); void setPayloadFormat(String payloadFormat); void setPayloadTemplate(String payloadTemplate); Boolean isEnabledForAllBuildsInProject(); void enableForAllBuildsInProject(Boolean allBuildTypesEnabled); Boolean isEnabledForSubProjects(); void enableForSubProjects(Boolean subProjectsEnabled); void clearAllEnabledBuildsInProject(); void enableBuildInProject(String buildTypeId); Map<String,String> getEnabledTemplates(); Boolean getAuthEnabled(); void setAuthEnabled(Boolean authEnabled); void setAuthParameters(Map<String, String> authParameters); void clearAuthParameters(); void setAuthType(String authType); void setAuthPreemptive(Boolean authPreemptive); WebHookAuthConfig getAuthenticationConfig(); List<WebHookFilterConfig> getTriggerFilters(); List<WebHookHeaderConfig> getHeaders(); void setHeaders(List<WebHookHeaderConfig> headers); WebHookConfig copy(); String getProjectInternalId(); void setProjectInternalId(String projectInternalId); String getProjectExternalId(); void setProjectExternalId(String projectExternalId);  }