private void add(@NotNull Value value) {
   Assert.notNull(value, "Value cannot be null");
   if (summary.empty) summary.empty = false;
   if (value.isSequence()) {
     if (value.isNull()) {
       summary.frequencyDist.addValue(NULL_NAME);
     } else {
       //noinspection ConstantConditions
       for (Value v : value.asSequence().getValue()) {
         add(v);
       }
     }
   } else {
     summary.frequencyDist.addValue(value.isNull() ? NULL_NAME : value.toString());
   }
 }
示例#2
0
  @Test
  public void testNullValue() {
    Value value = TextType.get().nullValue();

    String xml = xstream.toXML(value);
    Value unmarshalled = (Value) xstream.fromXML(xml);

    assertThat(value).isEqualTo(unmarshalled);
    assertThat(unmarshalled.isNull()).isTrue();
  }
  @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);
  }
示例#4
0
 private Value convertToSequence(Variable variable, Value value) {
   return value.isNull()
       ? variable.getValueType().nullSequence()
       : variable.getValueType().sequenceOf(value.toString());
 }