PipelineFunctionParameterResolverFactory { static ParameterResolver forTripleStringOrPlaceholderParameter() { return TRIPLE_STRING_OR_PLACEHOLDER_PARAMETER_RESOLVER; } private  PipelineFunctionParameterResolverFactory();   }
@Test public void tripleParameterResolverAcceptsThreeDoubleQuotedStringParameters() { final PipelineFunctionParameterResolverFactory.ParameterResolver parameterResolver = PipelineFunctionParameterResolverFactory.forTripleStringOrPlaceholderParameter(); final String firstParameter = KNOWN_VALUE + 1; final String secondParameter = KNOWN_VALUE + 2; final String thirdParameter = KNOWN_VALUE + 3; final String parameters = "(\"" + firstParameter + "\", \"" + secondParameter + "\", \"" + thirdParameter + "\")"; final List<PipelineElement> resolvedParameters = parameterResolver.apply(parameters, expressionResolver, DUMMY); assertThat(resolvedParameters.get(0)).contains(firstParameter); assertThat(resolvedParameters.get(1)).contains(secondParameter); assertThat(resolvedParameters.get(2)).contains(thirdParameter); verifyNoInteractions(expressionResolver); }
@Test public void tripleParameterResolverAcceptsMixOfDoubleQuotedAndSingleQuotedStringParameters() { final PipelineFunctionParameterResolverFactory.ParameterResolver parameterResolver = PipelineFunctionParameterResolverFactory.forTripleStringOrPlaceholderParameter(); final String firstParameter = KNOWN_VALUE + 1; final String secondParameter = KNOWN_VALUE + 2; final String thirdParameter = KNOWN_VALUE + 3; final String parameters = "(\"" + firstParameter + "\", '" + secondParameter + "', \"" + thirdParameter + "\")"; final List<PipelineElement> resolvedParameters = parameterResolver.apply(parameters, expressionResolver, DUMMY); assertThat(resolvedParameters.get(0)).contains(firstParameter); assertThat(resolvedParameters.get(1)).contains(secondParameter); assertThat(resolvedParameters.get(2)).contains(thirdParameter); verifyNoInteractions(expressionResolver); }
@Test public void tripleParameterResolverAcceptsMixOfDoubleQuotedAndSingleQuotedStringParametersAndPlaceholders() { final PipelineFunctionParameterResolverFactory.ParameterResolver parameterResolver = PipelineFunctionParameterResolverFactory.forTripleStringOrPlaceholderParameter(); final String firstParameter = KNOWN_VALUE + 1; final String secondParameter = KNOWN_VALUE + 2; final String thirdParameter = KNOWN_VALUE + 3; final String parameters = "(\"" + firstParameter + "\", '" + secondParameter + "', " + KNOWN_PLACEHOLDER + ")"; when(expressionResolver.resolveAsPipelineElement(KNOWN_PLACEHOLDER)) .thenReturn(PipelineElement.resolved(thirdParameter)); final List<PipelineElement> resolvedParameters = parameterResolver.apply(parameters, expressionResolver, DUMMY); assertThat(resolvedParameters.get(0)).contains(firstParameter); assertThat(resolvedParameters.get(1)).contains(secondParameter); assertThat(resolvedParameters.get(2)).contains(thirdParameter); verify(expressionResolver).resolveAsPipelineElement(KNOWN_PLACEHOLDER); }
@Test public void tripleParameterResolverFailsIfLessParametersAreGiven() { final PipelineFunctionParameterResolverFactory.ParameterResolver parameterResolver = PipelineFunctionParameterResolverFactory.forTripleStringOrPlaceholderParameter(); final String parametersList = "(\"" + KNOWN_VALUE + "\", \"" + KNOWN_VALUE + "\")"; assertThatExceptionOfType(PlaceholderFunctionSignatureInvalidException.class) .isThrownBy(() -> parameterResolver.apply(parametersList, expressionResolver, DUMMY)); verifyNoInteractions(expressionResolver); }
@Test public void tripleParameterResolverFailsIfMoreParametersAreGiven() { final PipelineFunctionParameterResolverFactory.ParameterResolver parameterResolver = PipelineFunctionParameterResolverFactory.forTripleStringOrPlaceholderParameter(); final String parametersList = "(\"One\", \"Two\", \"Three\", \"Fail\")"; assertThatExceptionOfType(PlaceholderFunctionSignatureInvalidException.class) .isThrownBy(() -> parameterResolver.apply(parametersList, expressionResolver, DUMMY)); verifyNoInteractions(expressionResolver); }