@Test public void testFindTemplateWithNoDimention() { TemplateFinder templateFinder = new TemplateFinder(webHookTemplateManager, projectIdResolver); WebHookTemplateConfig e = templateFinder.findTemplateById("slack.com-compact").getTemplateConfig(); assertEquals("slack.com-compact", e.getId()); }
public WebHookTemplateConfigWrapper findTemplateById(String templateLocator) { if (StringUtil.isEmpty(templateLocator)) { throw new BadRequestException("Empty template locator is not supported."); } final Locator locator = new Locator(templateLocator, "id", "name", "type", Locator.LOCATOR_SINGLE_VALUE_UNUSED_NAME); if (locator.isSingleValue()) { WebHookTemplateConfig template = null; @NotNull final String singleValue = locator.getSingleValue(); template = myTemplateManager.getTemplateConfig(singleValue, TemplateState.BEST); if (template != null) { return new WebHookTemplateConfigWrapper( template, myProjectIdResolver.getExternalProjectId(template.getProjectInternalId()), myTemplateManager.getTemplateState(template.getId(), TemplateState.BEST), WebHookTemplateStates.build(template) ); } throw new NotFoundException( "No template found by id '" + singleValue + "'."); } else if (locator.getSingleDimensionValue("id") != null){ WebHookTemplateConfig template = null; @NotNull final String templateId = locator.getSingleDimensionValue("id"); @NotNull final TemplateState templateState = getTemplateStateDimension(locator); template = myTemplateManager.getTemplateConfig(templateId, templateState); if (template != null) { return new WebHookTemplateConfigWrapper( template, myProjectIdResolver.getExternalProjectId(template.getProjectInternalId()), myTemplateManager.getTemplateState(template.getId(), templateState), WebHookTemplateStates.build(template) ); } throw new NotFoundException( "No template found by id '" + templateId + "' and state '"+ templateState.toString() +"'."); } else if (locator.getSingleDimensionValue("name") != null){ WebHookTemplateConfig template = null; @NotNull final String templateName = locator.getSingleDimensionValue("name"); @NotNull final TemplateState templateState = getTemplateStateDimension(locator); template = myTemplateManager.getTemplateConfig(templateName, templateState); if (template != null) { return new WebHookTemplateConfigWrapper( template, myProjectIdResolver.getExternalProjectId(template.getProjectInternalId()), myTemplateManager.getTemplateState(template.getId(), templateState), WebHookTemplateStates.build(template) ); } throw new NotFoundException( "No template found by name '" + templateName + "' and state '"+ templateState.toString() +"'."); } throw new BadRequestException("Sorry: Searching for multiple template is not supported."); }
TemplateFinder { public WebHookTemplateConfigWrapper findTemplateById(String templateLocator) { if (StringUtil.isEmpty(templateLocator)) { throw new BadRequestException("Empty template locator is not supported."); } final Locator locator = new Locator(templateLocator, "id", "name", "type", Locator.LOCATOR_SINGLE_VALUE_UNUSED_NAME); if (locator.isSingleValue()) { WebHookTemplateConfig template = null; @NotNull final String singleValue = locator.getSingleValue(); template = myTemplateManager.getTemplateConfig(singleValue, TemplateState.BEST); if (template != null) { return new WebHookTemplateConfigWrapper( template, myProjectIdResolver.getExternalProjectId(template.getProjectInternalId()), myTemplateManager.getTemplateState(template.getId(), TemplateState.BEST), WebHookTemplateStates.build(template) ); } throw new NotFoundException( "No template found by id '" + singleValue + "'."); } else if (locator.getSingleDimensionValue("id") != null){ WebHookTemplateConfig template = null; @NotNull final String templateId = locator.getSingleDimensionValue("id"); @NotNull final TemplateState templateState = getTemplateStateDimension(locator); template = myTemplateManager.getTemplateConfig(templateId, templateState); if (template != null) { return new WebHookTemplateConfigWrapper( template, myProjectIdResolver.getExternalProjectId(template.getProjectInternalId()), myTemplateManager.getTemplateState(template.getId(), templateState), WebHookTemplateStates.build(template) ); } throw new NotFoundException( "No template found by id '" + templateId + "' and state '"+ templateState.toString() +"'."); } else if (locator.getSingleDimensionValue("name") != null){ WebHookTemplateConfig template = null; @NotNull final String templateName = locator.getSingleDimensionValue("name"); @NotNull final TemplateState templateState = getTemplateStateDimension(locator); template = myTemplateManager.getTemplateConfig(templateName, templateState); if (template != null) { return new WebHookTemplateConfigWrapper( template, myProjectIdResolver.getExternalProjectId(template.getProjectInternalId()), myTemplateManager.getTemplateState(template.getId(), templateState), WebHookTemplateStates.build(template) ); } throw new NotFoundException( "No template found by name '" + templateName + "' and state '"+ templateState.toString() +"'."); } throw new BadRequestException("Sorry: Searching for multiple template is not supported."); } }
TemplateFinder { public WebHookTemplateConfigWrapper findTemplateById(String templateLocator) { if (StringUtil.isEmpty(templateLocator)) { throw new BadRequestException("Empty template locator is not supported."); } final Locator locator = new Locator(templateLocator, "id", "name", "type", Locator.LOCATOR_SINGLE_VALUE_UNUSED_NAME); if (locator.isSingleValue()) { WebHookTemplateConfig template = null; @NotNull final String singleValue = locator.getSingleValue(); template = myTemplateManager.getTemplateConfig(singleValue, TemplateState.BEST); if (template != null) { return new WebHookTemplateConfigWrapper( template, myProjectIdResolver.getExternalProjectId(template.getProjectInternalId()), myTemplateManager.getTemplateState(template.getId(), TemplateState.BEST), WebHookTemplateStates.build(template) ); } throw new NotFoundException( "No template found by id '" + singleValue + "'."); } else if (locator.getSingleDimensionValue("id") != null){ WebHookTemplateConfig template = null; @NotNull final String templateId = locator.getSingleDimensionValue("id"); @NotNull final TemplateState templateState = getTemplateStateDimension(locator); template = myTemplateManager.getTemplateConfig(templateId, templateState); if (template != null) { return new WebHookTemplateConfigWrapper( template, myProjectIdResolver.getExternalProjectId(template.getProjectInternalId()), myTemplateManager.getTemplateState(template.getId(), templateState), WebHookTemplateStates.build(template) ); } throw new NotFoundException( "No template found by id '" + templateId + "' and state '"+ templateState.toString() +"'."); } else if (locator.getSingleDimensionValue("name") != null){ WebHookTemplateConfig template = null; @NotNull final String templateName = locator.getSingleDimensionValue("name"); @NotNull final TemplateState templateState = getTemplateStateDimension(locator); template = myTemplateManager.getTemplateConfig(templateName, templateState); if (template != null) { return new WebHookTemplateConfigWrapper( template, myProjectIdResolver.getExternalProjectId(template.getProjectInternalId()), myTemplateManager.getTemplateState(template.getId(), templateState), WebHookTemplateStates.build(template) ); } throw new NotFoundException( "No template found by name '" + templateName + "' and state '"+ templateState.toString() +"'."); } throw new BadRequestException("Sorry: Searching for multiple template is not supported."); } TemplateFinder(@NotNull final WebHookTemplateManager templateManager, @NotNull final ProjectIdResolver projectIdResolver); }
TemplateFinder { public WebHookTemplateConfigWrapper findTemplateById(String templateLocator) { if (StringUtil.isEmpty(templateLocator)) { throw new BadRequestException("Empty template locator is not supported."); } final Locator locator = new Locator(templateLocator, "id", "name", "type", Locator.LOCATOR_SINGLE_VALUE_UNUSED_NAME); if (locator.isSingleValue()) { WebHookTemplateConfig template = null; @NotNull final String singleValue = locator.getSingleValue(); template = myTemplateManager.getTemplateConfig(singleValue, TemplateState.BEST); if (template != null) { return new WebHookTemplateConfigWrapper( template, myProjectIdResolver.getExternalProjectId(template.getProjectInternalId()), myTemplateManager.getTemplateState(template.getId(), TemplateState.BEST), WebHookTemplateStates.build(template) ); } throw new NotFoundException( "No template found by id '" + singleValue + "'."); } else if (locator.getSingleDimensionValue("id") != null){ WebHookTemplateConfig template = null; @NotNull final String templateId = locator.getSingleDimensionValue("id"); @NotNull final TemplateState templateState = getTemplateStateDimension(locator); template = myTemplateManager.getTemplateConfig(templateId, templateState); if (template != null) { return new WebHookTemplateConfigWrapper( template, myProjectIdResolver.getExternalProjectId(template.getProjectInternalId()), myTemplateManager.getTemplateState(template.getId(), templateState), WebHookTemplateStates.build(template) ); } throw new NotFoundException( "No template found by id '" + templateId + "' and state '"+ templateState.toString() +"'."); } else if (locator.getSingleDimensionValue("name") != null){ WebHookTemplateConfig template = null; @NotNull final String templateName = locator.getSingleDimensionValue("name"); @NotNull final TemplateState templateState = getTemplateStateDimension(locator); template = myTemplateManager.getTemplateConfig(templateName, templateState); if (template != null) { return new WebHookTemplateConfigWrapper( template, myProjectIdResolver.getExternalProjectId(template.getProjectInternalId()), myTemplateManager.getTemplateState(template.getId(), templateState), WebHookTemplateStates.build(template) ); } throw new NotFoundException( "No template found by name '" + templateName + "' and state '"+ templateState.toString() +"'."); } throw new BadRequestException("Sorry: Searching for multiple template is not supported."); } TemplateFinder(@NotNull final WebHookTemplateManager templateManager, @NotNull final ProjectIdResolver projectIdResolver); static String getLocator(final WebHookTemplateConfig template); static String getProjectLocator(final String projectId); static String getTemplateTextLocator(final String id); WebHookTemplateConfigWrapper findTemplateById(String templateLocator); WebHookTemplateItemConfigWrapper findTemplateByIdAndTemplateContentById(String templateLocator, String templateContentLocator); }
TemplateFinder { public WebHookTemplateConfigWrapper findTemplateById(String templateLocator) { if (StringUtil.isEmpty(templateLocator)) { throw new BadRequestException("Empty template locator is not supported."); } final Locator locator = new Locator(templateLocator, "id", "name", "type", Locator.LOCATOR_SINGLE_VALUE_UNUSED_NAME); if (locator.isSingleValue()) { WebHookTemplateConfig template = null; @NotNull final String singleValue = locator.getSingleValue(); template = myTemplateManager.getTemplateConfig(singleValue, TemplateState.BEST); if (template != null) { return new WebHookTemplateConfigWrapper( template, myProjectIdResolver.getExternalProjectId(template.getProjectInternalId()), myTemplateManager.getTemplateState(template.getId(), TemplateState.BEST), WebHookTemplateStates.build(template) ); } throw new NotFoundException( "No template found by id '" + singleValue + "'."); } else if (locator.getSingleDimensionValue("id") != null){ WebHookTemplateConfig template = null; @NotNull final String templateId = locator.getSingleDimensionValue("id"); @NotNull final TemplateState templateState = getTemplateStateDimension(locator); template = myTemplateManager.getTemplateConfig(templateId, templateState); if (template != null) { return new WebHookTemplateConfigWrapper( template, myProjectIdResolver.getExternalProjectId(template.getProjectInternalId()), myTemplateManager.getTemplateState(template.getId(), templateState), WebHookTemplateStates.build(template) ); } throw new NotFoundException( "No template found by id '" + templateId + "' and state '"+ templateState.toString() +"'."); } else if (locator.getSingleDimensionValue("name") != null){ WebHookTemplateConfig template = null; @NotNull final String templateName = locator.getSingleDimensionValue("name"); @NotNull final TemplateState templateState = getTemplateStateDimension(locator); template = myTemplateManager.getTemplateConfig(templateName, templateState); if (template != null) { return new WebHookTemplateConfigWrapper( template, myProjectIdResolver.getExternalProjectId(template.getProjectInternalId()), myTemplateManager.getTemplateState(template.getId(), templateState), WebHookTemplateStates.build(template) ); } throw new NotFoundException( "No template found by name '" + templateName + "' and state '"+ templateState.toString() +"'."); } throw new BadRequestException("Sorry: Searching for multiple template is not supported."); } TemplateFinder(@NotNull final WebHookTemplateManager templateManager, @NotNull final ProjectIdResolver projectIdResolver); static String getLocator(final WebHookTemplateConfig template); static String getProjectLocator(final String projectId); static String getTemplateTextLocator(final String id); WebHookTemplateConfigWrapper findTemplateById(String templateLocator); WebHookTemplateItemConfigWrapper findTemplateByIdAndTemplateContentById(String templateLocator, String templateContentLocator);  }