@Test public void GsonBuildSerialisationWithTemplatesAndAuthTest() throws JDOMException, IOException { framework = WebHookMockingFrameworkImpl.create(BuildStateEnum.BUILD_FINISHED, extraParameters); framework.loadWebHookProjectSettingsFromConfigXml(new File("../tcwebhooks-core/src/test/resources/project-settings-test-all-states-enabled-with-branch-and-auth.xml")); ProjectWebHooksBean webhooksConfig = ProjectWebHooksBean.build(framework.getWebHookProjectSettings() ,framework.getServer().getProjectManager().findProjectById("project01"), framework.getWebHookPayloadManager().getRegisteredFormatsAsCollection(), framework.getWebHookTemplateResolver().findWebHookTemplatesForProject(framework.getServer().getProjectManager().findProjectById("project01"))); RegisteredWebHookTemplateBean template = RegisteredWebHookTemplateBean.build(framework.getWebHookTemplateResolver().findWebHookTemplatesForProject(framework.getServer().getProjectManager().findProjectById("project01")), framework.getWebHookPayloadManager().getRegisteredFormats(), framework.getWebHookSettingsManager(), framework.getServer().getProjectManager()); ProjectHistoryBean history = ProjectHistoryResolver.getProjectHistory(framework.getServer().getProjectManager().findProjectById("project01")); RegisteredWebhookAuthenticationTypesBean authBean = RegisteredWebhookAuthenticationTypesBean.build(framework.getWebHookAuthenticatorProvider()); System.out.println(ProjectWebHooksBeanGsonSerialiser.serialise(history)); System.out.println(RegisteredWebHookTemplateBeanGsonSerialiser.serialise(template)); System.out.println(ProjectWebHooksBeanGsonSerialiser.serialise(TemplatesAndProjectWebHooksBean.build(template, webhooksConfig, authBean))); }
public static ProjectWebHooksBean build(WebHookProjectSettings projSettings, SProject project, Collection<WebHookPayload> registeredPayloads, List<WebHookPayloadTemplate> templateList){ ProjectWebHooksBean bean = new ProjectWebHooksBean(project, projSettings.isEnabled()); List<SBuildType> projectBuildTypes = TeamCityIdResolver.getOwnBuildTypes(project); WebHookConfig newBlankConfig = new WebHookConfig(project.getProjectId(), project.getExternalId(), "", true, new BuildState().setAllEnabled(), null, true, true, null, null); newBlankConfig.setUniqueKey("new"); addWebHookConfigHolder(bean, projectBuildTypes, newBlankConfig, registeredPayloads, templateList); for (WebHookConfig config : projSettings.getWebHooksAsList()){ addWebHookConfigHolder(bean, projectBuildTypes, config, registeredPayloads, templateList); } return bean; }
ProjectWebHooksBean { public static ProjectWebHooksBean build(WebHookProjectSettings projSettings, SProject project, Collection<WebHookPayload> registeredPayloads, List<WebHookPayloadTemplate> templateList){ ProjectWebHooksBean bean = new ProjectWebHooksBean(project, projSettings.isEnabled()); List<SBuildType> projectBuildTypes = TeamCityIdResolver.getOwnBuildTypes(project); WebHookConfig newBlankConfig = new WebHookConfig(project.getProjectId(), project.getExternalId(), "", true, new BuildState().setAllEnabled(), null, true, true, null, null); newBlankConfig.setUniqueKey("new"); addWebHookConfigHolder(bean, projectBuildTypes, newBlankConfig, registeredPayloads, templateList); for (WebHookConfig config : projSettings.getWebHooksAsList()){ addWebHookConfigHolder(bean, projectBuildTypes, config, registeredPayloads, templateList); } return bean; } }
ProjectWebHooksBean { public static ProjectWebHooksBean build(WebHookProjectSettings projSettings, SProject project, Collection<WebHookPayload> registeredPayloads, List<WebHookPayloadTemplate> templateList){ ProjectWebHooksBean bean = new ProjectWebHooksBean(project, projSettings.isEnabled()); List<SBuildType> projectBuildTypes = TeamCityIdResolver.getOwnBuildTypes(project); WebHookConfig newBlankConfig = new WebHookConfig(project.getProjectId(), project.getExternalId(), "", true, new BuildState().setAllEnabled(), null, true, true, null, null); newBlankConfig.setUniqueKey("new"); addWebHookConfigHolder(bean, projectBuildTypes, newBlankConfig, registeredPayloads, templateList); for (WebHookConfig config : projSettings.getWebHooksAsList()){ addWebHookConfigHolder(bean, projectBuildTypes, config, registeredPayloads, templateList); } return bean; } protected  ProjectWebHooksBean(SProject project, boolean projectWebHooksEnabled); }
ProjectWebHooksBean { public static ProjectWebHooksBean build(WebHookProjectSettings projSettings, SProject project, Collection<WebHookPayload> registeredPayloads, List<WebHookPayloadTemplate> templateList){ ProjectWebHooksBean bean = new ProjectWebHooksBean(project, projSettings.isEnabled()); List<SBuildType> projectBuildTypes = TeamCityIdResolver.getOwnBuildTypes(project); WebHookConfig newBlankConfig = new WebHookConfig(project.getProjectId(), project.getExternalId(), "", true, new BuildState().setAllEnabled(), null, true, true, null, null); newBlankConfig.setUniqueKey("new"); addWebHookConfigHolder(bean, projectBuildTypes, newBlankConfig, registeredPayloads, templateList); for (WebHookConfig config : projSettings.getWebHooksAsList()){ addWebHookConfigHolder(bean, projectBuildTypes, config, registeredPayloads, templateList); } return bean; } protected  ProjectWebHooksBean(SProject project, boolean projectWebHooksEnabled); Collection<WebhookConfigAndBuildTypeListHolder> getWebHookList(); static ProjectWebHooksBean buildWithoutNew(WebHookProjectSettings projSettings, SProject project, Collection<WebHookPayload> registeredPayloads, List<WebHookPayloadTemplate> templateList); static ProjectWebHooksBean build(WebHookProjectSettings projSettings, SProject project, Collection<WebHookPayload> registeredPayloads, List<WebHookPayloadTemplate> templateList); static ProjectWebHooksBean build(WebHookProjectSettings projSettings, SBuildType sBuildType, SProject project, Collection<WebHookPayload> registeredPayloads, List<WebHookPayloadTemplate> templateList); static ProjectWebHooksBean buildWithoutNew(WebHookProjectSettings projSettings, SBuildType sBuildType, SProject project, Collection<WebHookPayload> registeredPayloads, List<WebHookPayloadTemplate> templateList); static ProjectWebHooksBean buildWithoutNew(
			List<WebHookConfigEnhanced> webHookConfigs,
			SProject project,
			Collection<WebHookPayload> registeredFormats,
			List<WebHookPayloadTemplate> templateList,
			boolean iswebHooksEnabledForProject); }
ProjectWebHooksBean { public static ProjectWebHooksBean build(WebHookProjectSettings projSettings, SProject project, Collection<WebHookPayload> registeredPayloads, List<WebHookPayloadTemplate> templateList){ ProjectWebHooksBean bean = new ProjectWebHooksBean(project, projSettings.isEnabled()); List<SBuildType> projectBuildTypes = TeamCityIdResolver.getOwnBuildTypes(project); WebHookConfig newBlankConfig = new WebHookConfig(project.getProjectId(), project.getExternalId(), "", true, new BuildState().setAllEnabled(), null, true, true, null, null); newBlankConfig.setUniqueKey("new"); addWebHookConfigHolder(bean, projectBuildTypes, newBlankConfig, registeredPayloads, templateList); for (WebHookConfig config : projSettings.getWebHooksAsList()){ addWebHookConfigHolder(bean, projectBuildTypes, config, registeredPayloads, templateList); } return bean; } protected  ProjectWebHooksBean(SProject project, boolean projectWebHooksEnabled); Collection<WebhookConfigAndBuildTypeListHolder> getWebHookList(); static ProjectWebHooksBean buildWithoutNew(WebHookProjectSettings projSettings, SProject project, Collection<WebHookPayload> registeredPayloads, List<WebHookPayloadTemplate> templateList); static ProjectWebHooksBean build(WebHookProjectSettings projSettings, SProject project, Collection<WebHookPayload> registeredPayloads, List<WebHookPayloadTemplate> templateList); static ProjectWebHooksBean build(WebHookProjectSettings projSettings, SBuildType sBuildType, SProject project, Collection<WebHookPayload> registeredPayloads, List<WebHookPayloadTemplate> templateList); static ProjectWebHooksBean buildWithoutNew(WebHookProjectSettings projSettings, SBuildType sBuildType, SProject project, Collection<WebHookPayload> registeredPayloads, List<WebHookPayloadTemplate> templateList); static ProjectWebHooksBean buildWithoutNew(
			List<WebHookConfigEnhanced> webHookConfigs,
			SProject project,
			Collection<WebHookPayload> registeredFormats,
			List<WebHookPayloadTemplate> templateList,
			boolean iswebHooksEnabledForProject);  }