OnDuplicateUpdateContext { public Object getValue(final int index) { ExpressionSegment valueExpression = valueExpressions.get(index); return valueExpression instanceof ParameterMarkerExpressionSegment ? parameters.get(getParameterIndex(valueExpression)) : ((LiteralExpressionSegment) valueExpression).getLiterals(); } OnDuplicateUpdateContext(final Collection<AssignmentSegment> assignments, final List<Object> parameters, final int parametersOffset); Object getValue(final int index); ColumnSegment getColumn(final int index);  }
@Test public void assertGetValueWhenParameterMarker() { Collection<AssignmentSegment> assignments = makeParameterMarkerExpressionAssignmentSegment(); String parameterValue1 = "test1"; String parameterValue2 = "test2"; List<Object> parameters = Lists.newArrayList(parameterValue1, parameterValue2); int parametersOffset = 0; OnDuplicateUpdateContext onDuplicateUpdateContext = new OnDuplicateUpdateContext(assignments, parameters, parametersOffset); Object valueFromInsertValueContext1 = onDuplicateUpdateContext.getValue(0); assertThat(valueFromInsertValueContext1, is(parameterValue1)); Object valueFromInsertValueContext2 = onDuplicateUpdateContext.getValue(1); assertThat(valueFromInsertValueContext2, is(parameterValue2)); }
@Test public void assertGetValueWhenLiteralExpressionSegment() { Object literalObject = new Object(); Collection<AssignmentSegment> assignments = makeLiteralExpressionSegment(literalObject); List<Object> parameters = Collections.emptyList(); OnDuplicateUpdateContext onDuplicateUpdateContext = new OnDuplicateUpdateContext(assignments, parameters, 0); Object valueFromInsertValueContext = onDuplicateUpdateContext.getValue(0); assertThat(valueFromInsertValueContext, is(literalObject)); }