Package com.google.visualization.datasource.datatable.value

Examples of com.google.visualization.datasource.datatable.value.NumberValue


public class AggregationPathTest extends TestCase {

  public void simpleTest() {
    AggregationPath path = new AggregationPath();
    path.add(new NumberValue(3));
    path.add(new NumberValue(4));
    List<Value> values = path.getValues();
    assertEquals(3.0, ((NumberValue) values.get(0)).getValue());
    assertEquals(4.0, ((NumberValue) values.get(1)).getValue());
  }
View Full Code Here


    assertEquals(4.0, ((NumberValue) values.get(1)).getValue());
  }

  public void testReverse() {
    AggregationPath path = new AggregationPath();
    path.add(new NumberValue(3));
    path.add(new NumberValue(4));
    path.reverse();
    List<Value> values = path.getValues();
    assertEquals(4.0, ((NumberValue) values.get(0)).getValue());
    assertEquals(3.0, ((NumberValue) values.get(1)).getValue());
  }
View Full Code Here

            new ScalarFunctionColumn(aggregationColumns,
                TimeComponentExtractor.getInstance(
                    TimeComponentExtractor.TimeComponent.SECOND)));

    ScalarFunctionColumnTitle titleMonthWithPivot =
        new ScalarFunctionColumnTitle(Lists.newArrayList(new NumberValue(3.14),
            BooleanValue.TRUE), new ScalarFunctionColumn(simpleColumns,
            TimeComponentExtractor.getInstance(
                TimeComponentExtractor.TimeComponent.MONTH)));

    ScalarFunctionColumnTitle titleDayWithPivotAndAgg =
        new ScalarFunctionColumnTitle(Lists.newArrayList(new NumberValue(3.14),
            BooleanValue.TRUE), new ScalarFunctionColumn(aggregationColumns,
            TimeComponentExtractor.getInstance(
                TimeComponentExtractor.TimeComponent.DAY)));

    ColumnDescription resultColumnDescriptionYear = titleYear.createColumnDescription(table);
View Full Code Here

  /**
   * Tests the functionality of {@code AggregationNode.containsChild}.
   */
  public void testContainsChild() {
    AggregationNode node = newAggregationNode();
    node.addChild(new NumberValue(3), columnsToAggregate, MockDataSource.getData(1));
    assertEquals(true, node.containsChild(new NumberValue(3)));
    assertEquals(false, node.containsChild(new NumberValue(4)));
  }
View Full Code Here

  /**
   * Tests the functionality of {@code AggregationNode.getChild}.
   */
  public void testGetChild() {
    AggregationNode node = newAggregationNode();
    addChildToNode(node, new NumberValue(3));
    assertNotNull(node.getChild(new NumberValue(3)));
    try {
      node.getChild(new NumberValue(4));
      fail();
    } catch (NoSuchElementException e) {
      // Expected behavior.
    }
  }
View Full Code Here

  /**
   * Tests the functionality of {@code AggregationNode.addChild}.
   */
  public void testAddChild() {
    AggregationNode node = newAggregationNode();
    addChildToNode(node, new NumberValue(3));
    try {
      addChildToNode(node, new NumberValue(3));
      fail();
    } catch (IllegalArgumentException e) {
      // Expected behavior.
    }
  }
View Full Code Here

  /**
   * Test all functionalities by aggregating two numbers.
   */
  public void testNumberAggregation() {
    ValueAggregator aggregator = new ValueAggregator(ValueType.NUMBER);
    aggregator.aggregate(new NumberValue(1));
    aggregator.aggregate(new NumberValue(3));

    assertEquals(new NumberValue(4.0), aggregator.getValue(AggregationType.SUM));
    assertEquals(new NumberValue(2.0), aggregator.getValue(AggregationType.AVG));
    assertEquals(new NumberValue(2), aggregator.getValue(AggregationType.COUNT));
    assertEquals(new NumberValue(1.0), aggregator.getValue(AggregationType.MIN));
    assertEquals(new NumberValue(3.0), aggregator.getValue(AggregationType.MAX));
  }
View Full Code Here

      fail();
    } catch (UnsupportedOperationException e) {
      // Expected behavior.
    }

    assertEquals(new NumberValue(2), aggregator.getValue(AggregationType.COUNT));
    assertEquals(new TextValue("a"), aggregator.getValue(AggregationType.MIN));
    assertEquals(new TextValue("b"), aggregator.getValue(AggregationType.MAX));

  }
View Full Code Here

  }

  public void testGetValueFromEmptyAggregation() {
    ValueAggregator aggregator = new ValueAggregator(ValueType.DATE);
    DateValue dateNull = DateValue.getNullValue();
    NumberValue numberNull = NumberValue.getNullValue();

    assertEquals(new NumberValue(0), aggregator.getValue(AggregationType.COUNT));

    assertEquals(dateNull, aggregator.getValue(AggregationType.MIN));
    assertEquals(dateNull, aggregator.getValue(AggregationType.MAX));

    assertEquals(numberNull, aggregator.getValue(AggregationType.AVG));
View Full Code Here

    TableRow row;

    row = new TableRow();
    row.addCell(new TableCell(new TextValue("aaa")));
    row.addCell(new TableCell(new NumberValue(222)));
    row.addCell(new TableCell(BooleanValue.TRUE, "T"));
    input.addRow(row);

    row = new TableRow();
    row.addCell(new TableCell(new TextValue("ccc")));
    row.addCell(new TableCell(new NumberValue(111)));
    row.addCell(new TableCell(BooleanValue.TRUE, "T"));
    input.addRow(row);

    row = new TableRow();
    row.addCell(new TableCell(new TextValue("bbb")));
    row.addCell(new TableCell(new NumberValue(333)));
    row.addCell(new TableCell(BooleanValue.FALSE, "F"));
    input.addRow(row);
  }
View Full Code Here

TOP

Related Classes of com.google.visualization.datasource.datatable.value.NumberValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.