Package com.base2art.jeqll

Source Code of com.base2art.jeqll.AggregableTest

package com.base2art.jeqll;

import com.base2art.jeqll.IQuery;
import com.base2art.jeqll.impl.IterableQuery;
import com.base2art.jeqll.projections.DoubleField;
import com.base2art.jeqll.sampleData.SampleDataRepository;
import com.base2art.jeqll.sampleData.WeatherObservation;
import static org.fest.assertions.Assertions.assertThat;
import org.junit.Test;

public class AggregableTest
{

  @Test
  public void shouldGetMinAndMax()
  {
    IQuery<WeatherObservation> query = new IterableQuery<>(SampleDataRepository.weatherObservations(), WeatherObservation.class);
    assertThat(query.max(new DoubleField("temp"))).isEqualTo(100.6);
    assertThat(query.min(new DoubleField("temp"))).isEqualTo(43.6);
  }

  @Test
  public void shouldGetAverageAndSum()
  {
    IQuery<WeatherObservation> query = new IterableQuery<>(SampleDataRepository.weatherObservations(), WeatherObservation.class);
    double actualSum = 43.6 + 44.6 + 45.6 + 46.6 + 47.6 + 100.6;
    assertThat(query.sum(new DoubleField("temp"))).isEqualTo(actualSum);
    assertThat(query.average(new DoubleField("temp"))).isEqualTo(actualSum / 6);
  }
}
TOP

Related Classes of com.base2art.jeqll.AggregableTest

TOP
Copyright © 2018 www.massapi.com. 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.