Exemplo n.º 1
0
  @Test
  public void testGetColumns() throws Exception {
    expect(timeSeriesRepo.getAvailableSeries()).andReturn(TS_DATA.keySet());

    control.replay();

    List<String> columns =
        gson.fromJson(
            dataSource.getResponse(null, null), new TypeToken<List<String>>() {}.getType());
    assertEquals(ImmutableList.copyOf(TS_DATA.keySet()), columns);
  }
Exemplo n.º 2
0
  @Test
  @SuppressWarnings("unchecked") // Needed because type information lost in vargs.
  public void testGetAllData() throws Exception {
    expect(timeSeriesRepo.getTimestamps()).andReturn(TIMESTAMPS);
    expect(timeSeriesRepo.get(TIME_SERIES_1)).andReturn(TS_DATA.get(TIME_SERIES_1));
    expect(timeSeriesRepo.get(TIME_SERIES_2)).andReturn(TS_DATA.get(TIME_SERIES_2));

    control.replay();

    String colString =
        Joiner.on(',').join(Arrays.asList(TIME_SERIES_1, TIME_SERIES_2, TIME_COLUMN));

    TimeSeriesDataSource.ResponseStruct response =
        gson.fromJson(
            dataSource.getResponse(colString, null), TimeSeriesDataSource.ResponseStruct.class);

    assertEquals(ImmutableList.of(TIME_COLUMN, TIME_SERIES_1, TIME_SERIES_2), response.names);
    Iterable<List<Number>> expectedData =
        Iterables2.zip(0, TIMESTAMPS, getSamples(TIME_SERIES_1), getSamples(TIME_SERIES_2));
    checkRows(expectedData, response.data);
  }