@Test
public void testMake() {

    TsDataCollector dc = new TsDataCollector();
    EnumSet<TsFrequency> defined = complementOf(of(Undefined));
    // defined with single value
    dc.clear();
    dc.addObservation(JAN2010, 10);
    defined.forEach(o -> assertThat(dc.make(o, None)).isEqualTo(data(o, 2010, 0, 10)));
    // monthly with missing values
    dc.clear();
    dc.addObservation(JAN2010, 10);
    dc.addObservation(APR2010, 40);
    assertThat(dc.make(Monthly, None)).isEqualTo(data(Monthly, 2010, 0, 10, Double.NaN, Double.NaN, 40));
    // quarterly
    dc.clear();
    dc.addObservation(JAN2010, 10);
    dc.addObservation(APR2010, 40);
    assertThat(dc.make(Quarterly, None)).isEqualTo(data(Quarterly, 2010, 0, 10, 40));
    // undefined to monthly
    dc.clear();
    dc.addObservation(JAN2010, 10);
    dc.addObservation(FEB2010, 20);
    assertThat(dc.make(Undefined, None)).isEqualTo(data(Monthly, 2010, 0, 10, 20));
    // undefined to monthly with missing values
    dc.clear();
    dc.addObservation(JAN2010, 10);
    dc.addObservation(FEB2010, 20);
    dc.addObservation(MAY2010, 50);
    assertThat(dc.make(Undefined, None)).isEqualTo(data(Monthly, 2010, 0, 10, 20, Double.NaN, Double.NaN, 50));
    // undefined to quarterly
    dc.clear();
    dc.addObservation(JAN2010, 10);
    dc.addObservation(APR2010, 40);
    assertThat(dc.make(Undefined, None)).isEqualTo(data(Quarterly, 2010, 0, 10, 40));
    // defined with aggregation
    dc.clear();
    dc.addObservation(JAN2010, 12);
    dc.addObservation(JAN2010, 13);
    dc.addObservation(JAN2010, 10);
    dc.addObservation(JAN2010, 11);
    defined.forEach(o -> {
        assertThat(dc.make(o, First)).isEqualTo(data(o, 2010, 0, 12));
        assertThat(dc.make(o, Last)).isEqualTo(data(o, 2010, 0, 11));
        assertThat(dc.make(o, Min)).isEqualTo(data(o, 2010, 0, 10));
        assertThat(dc.make(o, Max)).isEqualTo(data(o, 2010, 0, 13));
        assertThat(dc.make(o, Average)).isEqualTo(data(o, 2010, 0, 46d / 4));
        assertThat(dc.make(o, Sum)).isEqualTo(data(o, 2010, 0, 46));
    });
    // unordered daily to monthly
    dc.clear();
    dc.addObservation(asDate(LocalDate.of(2010, 2, 1)), 20);
    dc.addObservation(asDate(LocalDate.of(2010, 1, 3)), 10);
    dc.addObservation(asDate(LocalDate.of(2010, 1, 4)), 11);
    dc.addObservation(asDate(LocalDate.of(2010, 1, 1)), 12);
    dc.addObservation(asDate(LocalDate.of(2010, 1, 2)), 13);
    assertThat(dc.make(Monthly, First)).isEqualTo(data(Monthly, 2010, 0, 12, 20));
    assertThat(dc.make(Monthly, Last)).isEqualTo(data(Monthly, 2010, 0, 11, 20));
    assertThat(dc.make(Monthly, Min)).isEqualTo(data(Monthly, 2010, 0, 10, 20));
    assertThat(dc.make(Monthly, Max)).isEqualTo(data(Monthly, 2010, 0, 13, 20));
    assertThat(dc.make(Monthly, Average)).isEqualTo(data(Monthly, 2010, 0, 46d / 4, 20));
    assertThat(dc.make(Monthly, Sum)).isEqualTo(data(Monthly, 2010, 0, 46, 20));
}