InsertValueContext { public Object getValue(final int index) { ExpressionSegment valueExpression = valueExpressions.get(index); return valueExpression instanceof ParameterMarkerExpressionSegment ? parameters.get(getParameterIndex(valueExpression)) : ((LiteralExpressionSegment) valueExpression).getLiterals(); } InsertValueContext(final Collection<ExpressionSegment> assignments, final List<Object> parameters, final int parametersOffset); Object getValue(final int index); int getParameterIndex(final int index);  }
@Test public void assertGetValueWhenParameterMarker() { Collection<ExpressionSegment> assignments = makeParameterMarkerExpressionSegment(); String parameterValue = "test"; List<Object> parameters = Collections.singletonList(parameterValue); int parametersOffset = 0; InsertValueContext insertValueContext = new InsertValueContext(assignments, parameters, parametersOffset); Object valueFromInsertValueContext = insertValueContext.getValue(0); assertThat(valueFromInsertValueContext, is(parameterValue)); }
@Test public void assertGetValueWhenLiteralExpressionSegment() { Object literalObject = new Object(); Collection<ExpressionSegment> assignments = makeLiteralExpressionSegment(literalObject); List<Object> parameters = Collections.emptyList(); InsertValueContext insertValueContext = new InsertValueContext(assignments, parameters, 0); Object valueFromInsertValueContext = insertValueContext.getValue(0); assertThat(valueFromInsertValueContext, is(literalObject)); }