2 * Copyright (c) 2010-2020 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.luftdateninfo.internal;
15 import static org.junit.jupiter.api.Assertions.*;
17 import java.util.List;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.junit.jupiter.api.BeforeEach;
22 import org.junit.jupiter.api.Test;
23 import org.openhab.binding.luftdateninfo.internal.dto.SensorDataValue;
24 import org.openhab.binding.luftdateninfo.internal.handler.HTTPHandler;
25 import org.openhab.binding.luftdateninfo.internal.util.FileReader;
28 * The {@link HTTPHandlerEvalTest} test all evaluations on SensorDataValues
30 * @author Bernd Weymann - Initial contribution
33 public class HTTPHandlerEvalTest {
35 private @Nullable List<SensorDataValue> conditions;
36 private @Nullable List<SensorDataValue> particulate;
37 private @Nullable List<SensorDataValue> noise;
38 private HTTPHandler http = new HTTPHandler();
42 String conditionsStr = FileReader.readFileInString("src/test/resources/condition-result-no-pressure.json");
43 assertNotNull(conditionsStr);
44 conditions = http.getLatestValues(conditionsStr);
46 String particulateStr = FileReader.readFileInString("src/test/resources/pm-result.json");
47 assertNotNull(particulateStr);
48 particulate = http.getLatestValues(particulateStr);
50 String noiseStr = FileReader.readFileInString("src/test/resources/noise-result.json");
51 assertNotNull(noiseStr);
52 noise = http.getLatestValues(noiseStr);
56 public void testIsCondition() {
57 assertTrue(http.isCondition(conditions));
58 assertFalse(http.isCondition(particulate));
59 assertFalse(http.isCondition(noise));
60 assertFalse(http.isCondition(null));
64 public void testIsParticulate() {
65 assertFalse(http.isParticulate(conditions));
66 assertTrue(http.isParticulate(particulate));
67 assertFalse(http.isParticulate(noise));
68 assertFalse(http.isParticulate(null));
72 public void testIsNoise() {
73 assertFalse(http.isNoise(conditions));
74 assertFalse(http.isNoise(particulate));
75 assertTrue(http.isNoise(noise));
76 assertFalse(http.isNoise(null));