@Test (expected=WebHookPayloadContentAssemblyException.class) public void testForNullPointerWithoutBody() throws WebHookPayloadContentAssemblyException{ WebHookPayloadTailoredJson whp = new WebHookPayloadTailoredJson(null, variableResolverManager); ExtraParameters extraParameters = new ExtraParameters(); extraParameters.addAll("params", new TreeMap<String,String>()); extraParameters.addAll("teamcity", new TreeMap<String,String>()); Map<String,String> templates = new TreeMap<>(); templates.put(WebHookPayloadDefaultTemplates.HTML_BUILDSTATUS_TEMPLATE, "test template"); WebHookMockingFramework framework = WebHookMockingFrameworkImpl.create(BuildStateEnum.BUILD_FINISHED, extraParameters); VariableResolverFactory variableResolverFactory = variableResolverManager.getVariableResolverFactory(PayloadTemplateEngineType.LEGACY); WebHookPayloadContent content = new WebHookPayloadContent(variableResolverFactory, framework.getServer(), framework.getRunningBuild(), sFinishedBuild, BuildStateEnum.BUILD_FINISHED, extraParameters, templates); whp.getStatusAsString(content, null); }
@Override protected String getStatusAsString(WebHookPayloadContent content, WebHookTemplateContent webHookTemplate) { try { return content.getExtraParameters(getVariableResolverFactory()).get("body"); } catch (NullPointerException npe){ throw new WebHookPayloadContentAssemblyException("Failure building message content :: Unable to retreive 'body' content."); } }
WebHookPayloadTailoredJson extends WebHookPayloadGeneric implements WebHookPayload { @Override protected String getStatusAsString(WebHookPayloadContent content, WebHookTemplateContent webHookTemplate) { try { return content.getExtraParameters(getVariableResolverFactory()).get("body"); } catch (NullPointerException npe){ throw new WebHookPayloadContentAssemblyException("Failure building message content :: Unable to retreive 'body' content."); } } }
WebHookPayloadTailoredJson extends WebHookPayloadGeneric implements WebHookPayload { @Override protected String getStatusAsString(WebHookPayloadContent content, WebHookTemplateContent webHookTemplate) { try { return content.getExtraParameters(getVariableResolverFactory()).get("body"); } catch (NullPointerException npe){ throw new WebHookPayloadContentAssemblyException("Failure building message content :: Unable to retreive 'body' content."); } } WebHookPayloadTailoredJson(WebHookPayloadManager manager, WebHookVariableResolverManager variableResolverManager); }
WebHookPayloadTailoredJson extends WebHookPayloadGeneric implements WebHookPayload { @Override protected String getStatusAsString(WebHookPayloadContent content, WebHookTemplateContent webHookTemplate) { try { return content.getExtraParameters(getVariableResolverFactory()).get("body"); } catch (NullPointerException npe){ throw new WebHookPayloadContentAssemblyException("Failure building message content :: Unable to retreive 'body' content."); } } WebHookPayloadTailoredJson(WebHookPayloadManager manager, WebHookVariableResolverManager variableResolverManager); @Override void register(); @Override String getFormatDescription(); @Override String getFormatShortName(); @Override String getFormatToolTipText(); @Override String getContentType(); @Override Integer getRank(); @Override void setRank(Integer rank); @Override String getCharset(); @Override WebHookStringRenderer getWebHookStringRenderer(); @Override PayloadTemplateEngineType getTemplateEngineType(); }
WebHookPayloadTailoredJson extends WebHookPayloadGeneric implements WebHookPayload { @Override protected String getStatusAsString(WebHookPayloadContent content, WebHookTemplateContent webHookTemplate) { try { return content.getExtraParameters(getVariableResolverFactory()).get("body"); } catch (NullPointerException npe){ throw new WebHookPayloadContentAssemblyException("Failure building message content :: Unable to retreive 'body' content."); } } WebHookPayloadTailoredJson(WebHookPayloadManager manager, WebHookVariableResolverManager variableResolverManager); @Override void register(); @Override String getFormatDescription(); @Override String getFormatShortName(); @Override String getFormatToolTipText(); @Override String getContentType(); @Override Integer getRank(); @Override void setRank(Integer rank); @Override String getCharset(); @Override WebHookStringRenderer getWebHookStringRenderer(); @Override PayloadTemplateEngineType getTemplateEngineType(); static final String FORMAT_SHORT_NAME; }