@Test(expected = IllegalArgumentException.class)
 public void testFindTempsGreaterThenFailOnEmptyList() {
   double[] temperatureSeries = {};
   double tempValue = 5;
   TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
   seriesAnalysis.findTempsGreaterThen(tempValue);
 }
 @Test
 public void testMax() {
   double arr[] = {-1.5, 0, 2.5, 100, -50.2};
   TemperatureSeriesAnalysis temperatureSeriesAnalysis = new TemperatureSeriesAnalysis(arr);
   double expected = 100;
   double actual = temperatureSeriesAnalysis.max();
   assertEquals(expected, actual, 0.0001);
 }
 @Test
 public void testFindTempClosestToZero_WithSingleElement() {
   double arr[] = {1};
   TemperatureSeriesAnalysis temperatureSeriesAnalysis = new TemperatureSeriesAnalysis(arr);
   double expected = 1;
   double result = temperatureSeriesAnalysis.findTempClosestToZero();
   assertEquals(result, expected, 0.001);
 }
  @Test(expected = InputMismatchException.class)
  public void testAddTempsFailOnTemperatureLessThenMinimum() {
    double[] temperatureSeries = {5.25};
    double[] tempValue = {-3.02, 54.02, -273.025, 5};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);

    seriesAnalysis.addTemps(tempValue);
  }
 @Test
 public void testAverage() {
   double arr[] = {-5.5, 0, 10.5, 3};
   TemperatureSeriesAnalysis temperatureSeriesAnalysis = new TemperatureSeriesAnalysis(arr);
   double expected = 2.0;
   double actual = temperatureSeriesAnalysis.average();
   assertEquals(expected, actual, 0.0001);
 }
 @Test
 public void testSummaryStatistics() {
   double arr[] = {3.0, 10.2, -20.4, -1.0, -5.3, 1.0, -5.1};
   TemperatureSeriesAnalysis tsa = new TemperatureSeriesAnalysis(arr);
   TempSummaryStatistics tss = tsa.summaryStatistics();
   double average = tsa.average();
   assertEquals(average, tss.getAvgTemp(), 0.001);
 }
 @Test
 public void testDeviation() {
   double arr[] = {-1.5, 0, 2.5, 100, -50.2};
   TemperatureSeriesAnalysis temperatureSeriesAnalysis = new TemperatureSeriesAnalysis(arr);
   double expected = 49.015124196517;
   double actual = temperatureSeriesAnalysis.deviation();
   assertEquals(expected, actual, 0.0001);
 }
 @Test
 public void testFindTempClosestToValue() {
   double arr[] = {3.0, 10.2, -20.4, -1.0, -5.3, 1.0, -5.1};
   TemperatureSeriesAnalysis tsa = new TemperatureSeriesAnalysis(arr);
   double expected = -5.1;
   double result = tsa.findTempClosestToValue(-5.2);
   assertEquals(expected, result, 0.001);
 }
 @Test
 public void testFindTempClosestToZero_WithPositiveAndNegativeTempsArrayList() {
   double arr[] = {3.0, 10.2, -20.4, 100.0, -5.3, 1.0, -200.9};
   TemperatureSeriesAnalysis temperatureSeriesAnalysis = new TemperatureSeriesAnalysis(arr);
   double expected = 1;
   double result = temperatureSeriesAnalysis.findTempClosestToZero();
   assertEquals(expected, result, 0.001);
 }
 @Test
 public void testFindTempClosestToZero_WithEquallyCloseTempsArrayList() {
   double arr[] = {3.0, 10.2, -20.4, -1.0, -5.3, 1.0, -200.9};
   TemperatureSeriesAnalysis tsa = new TemperatureSeriesAnalysis(arr);
   double expected = 1.0;
   double result = tsa.findTempClosestToZero();
   assertEquals(expected, result, 0.001);
 }
 @Test
 public void testFindTempClosestToZero_IsPositiveTempsArrayList() {
   double arr[] = {3, 10, 20, 100, 5, 1, 200};
   TemperatureSeriesAnalysis temperatureSeriesAnalysis = new TemperatureSeriesAnalysis(arr);
   double expected = 1;
   double result = temperatureSeriesAnalysis.findTempClosestToZero();
   assertEquals(expected, result, 0.001);
 }
 @Test
 public void testFindTempClosestToZero_WithZeroElement() {
   double arr[] = {3, 10, 0, 100, 5, 1, 200};
   TemperatureSeriesAnalysis temperatureSeriesAnalysis = new TemperatureSeriesAnalysis(arr);
   double expected = 0;
   double result = temperatureSeriesAnalysis.findTempClosestToZero();
   assertEquals(expected, result, 0.001);
 }
  @Test(expected = IllegalArgumentException.class)
  public void testAddTempsFailOnEmptyList() {
    double[] temperatureSeries = {2.03};
    double[] tempValue = {};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);

    seriesAnalysis.addTemps(tempValue);
  }
 @Test
 public void testFindTempsGreaterThen() {
   double arr[] = {3.0, 10.2, -20.4, -1.0, -5.3, 1.0, -5.1};
   TemperatureSeriesAnalysis tsa = new TemperatureSeriesAnalysis(arr);
   double[] expected = {3.0, 10.2};
   double[] result = tsa.findTempsGreaterThen(1.0);
   assertEquals(expected.length, result.length);
   for (int i = 0; i < expected.length; i++) assertEquals(expected[i], result[i], 0.001);
 }
  @Test
  public void testFindTempClozestToZeroArrayWithPositiveElements() {
    double[] temperatureSeries = {3.25, 2.1, 32, 6.02, 2.01};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 2.01;
    double actualResult = seriesAnalysis.findTempClosestToZero();

    assertEquals(expResult, actualResult, epsilon);
  }
  @Test
  public void testFindTempClozestToZeroArrayWithZeroElement() {
    double[] temperatureSeries = {-3.25, 3.1, -32, 5.03, -3.01, 0.0, 5.03, 6.214, -321.02};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 0;
    double actualResult = seriesAnalysis.findTempClosestToZero();

    assertEquals(expResult, actualResult, epsilon);
  }
 @Test
 public void testAddTemps_onEmptyTemps() {
   double arr[] = {3.0, 10.2, -20.4, -1.0, -5.3, 1.0, -5.1};
   double temps[] = {};
   TemperatureSeriesAnalysis tsa = new TemperatureSeriesAnalysis(arr);
   int expected = 7;
   int actual = tsa.addTemps(temps);
   assertEquals(expected, actual);
 }
  @Test
  public void testAverageArrayWithFourElements() {
    double[] temperatureSeries = {1.0, -5.0, 1.0, 5.0};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 0.5;
    double actualResult = seriesAnalysis.average();

    assertEquals(expResult, actualResult, epsilon);
  }
  @Test
  public void testMaxArrayWithPositiveElements() {
    double[] temperatureSeries = {31.3916, 123, 12.23, 5.24, 44.02};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 123;
    double actualResult = seriesAnalysis.max();

    assertEquals(expResult, actualResult, epsilon);
  }
  @Test
  public void testAverageArrayWithPositiveElements() {
    double[] temperatureSeries = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 4.5;
    double actualResult = seriesAnalysis.average();

    assertEquals(expResult, actualResult, epsilon);
  }
  @Test
  public void testFindTempClozestToZeroArrayWithSeveralEqualAbsValueElements() {
    double[] temperatureSeries = {-3.25, 6.1, -32, 3.25, -3.401, -3.25, 5.03, -31.002, 3.25};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 3.25;
    double actualResult = seriesAnalysis.findTempClosestToZero();

    assertEquals(expResult, actualResult, epsilon);
  }
  @Test
  public void testFindTempClozestToZeroArrayWithEqualAbsValueElementsPositiveValueFirst() {
    double[] temperatureSeries = {-3.25, 3.1, -32, 5.03, -3.01, 3.002, 5.03, -3.002, -321.02};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 3.002;
    double actualResult = seriesAnalysis.findTempClosestToZero();

    assertEquals(expResult, actualResult, epsilon);
  }
 @Test
 public void testAddTemps_increaseMoreThanX2() {
   double arr[] = {3.0, 10.2, -20.4, -1.0, -5.3, 1.0, -5.1};
   double temps[] = {3.3, -10.4, 33.89, 4.4, -2.3, 8.9, 4.2, 10.10};
   TemperatureSeriesAnalysis tsa = new TemperatureSeriesAnalysis(arr);
   int expected = 15;
   int actual = tsa.addTemps(temps);
   assertEquals(expected, actual);
 }
  @Test
  public void testFindTempClozestToZeroArrayWithNegativeElements() {
    double[] temperatureSeries = {-3.25, -3.1, -32, -5.03, -3.01};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = -3.01;
    double actualResult = seriesAnalysis.findTempClosestToZero();

    assertEquals(expResult, actualResult, epsilon);
  }
 @Test
 public void testTemperatureSeriesAnalysis() {
   TemperatureSeriesAnalysis temperatureSeriesAnalysis = new TemperatureSeriesAnalysis();
   TempSummaryStatistics tss = temperatureSeriesAnalysis.summaryStatistics();
   assertTrue(
       tss.getAvgTemp() == tss.getMinTemp()
           && tss.getAvgTemp() == tss.getMaxTemp()
           && tss.getAvgTemp() == tss.getDevTemp());
 }
  @Test
  public void testMaxArrayWithSigleElement() {
    double[] temperatureSeries = {31.3916};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 31.3916;
    double actualResult = seriesAnalysis.max();

    assertEquals(expResult, actualResult, epsilon);
  }
  @Test
  public void testAverageCheckForEpsilonError() {
    double[] temperatureSeries = {1.40215, -5.32102, 4.00012};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 0.027083;
    double actualResult = seriesAnalysis.average();

    assertEquals(expResult, actualResult, epsilon);
  }
  @Test
  public void testFindTempClozestToZeroArrayWithSingleElement() {
    double[] temperatureSeries = {3.25};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 3.25;
    double actualResult = seriesAnalysis.findTempClosestToZero();

    assertEquals(expResult, actualResult, epsilon);
  }
  @Test
  public void testDeviationArrayWithTheSameElements() {
    double[] temperatureSeries = {1.0, 1.0, 1.0, 1.0, 1.0};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 0.0;
    double actualResult = seriesAnalysis.deviation();

    assertEquals(expResult, actualResult, epsilon);
  }
  @Test
  public void testAverageArrayWithSingleElement() {
    double[] temperatureSeries = {1.0};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 1.0;
    double actualResult = seriesAnalysis.average();

    assertEquals(expResult, actualResult, epsilon);
  }