コード例 #1
0
 /**
  * Convert the value as loaded from the SQL table into the expected variable value type (column
  * type may not match exactly the variable value type).
  *
  * @param variable
  * @param value
  * @return
  */
 private Value convertValue(Variable variable, Value value) {
   if (value.getValueType() != variable.getValueType()) {
     return variable.isRepeatable()
         ? convertToSequence(variable, value)
         : variable.getValueType().convert(value);
   }
   if (variable.isRepeatable() && !value.isSequence()) {
     return convertToSequence(variable, value);
   }
   return value;
 }
コード例 #2
0
  @Test
  public void test_engine_method() {
    JavascriptValueSource source = new JavascriptValueSource(DateTimeType.get(), "now()");
    source.initialise();

    Value value = source.getValue(mockValueSet);
    assertThat(value).isNotNull();
    assertThat(value.isNull()).isFalse();
    assertThat(value.getValueType()).isEqualTo(DateTimeType.get());

    Date dateValue = (Date) value.getValue();
    // Make sure both dates are within 1 second of one-another
    assertThat(System.currentTimeMillis() - dateValue.getTime()).isLessThan(1000);
  }