1 package de.dlr.shepard.data.timeseries.utilities;
2
3 import static org.junit.jupiter.api.Assertions.assertEquals;
4 import static org.junit.jupiter.api.Assertions.assertThrows;
5
6 import de.dlr.shepard.data.timeseries.model.enums.DataPointValueType;
7 import java.util.ArrayList;
8 import java.util.NoSuchElementException;
9 import org.junit.jupiter.api.Test;
10
11 public class ObjectTypeEvaluatorTest {
12
13 @Test
14 void testDetermineType() throws Exception {
15 assertEquals(DataPointValueType.Boolean, ObjectTypeEvaluator.determineType(true).get());
16 assertEquals(DataPointValueType.Boolean, ObjectTypeEvaluator.determineType(Boolean.valueOf("true")).get());
17 assertEquals(DataPointValueType.Double, ObjectTypeEvaluator.determineType(2.5).get());
18 assertThrows(NoSuchElementException.class, () -> ObjectTypeEvaluator.determineType(2.5F).get());
19 assertEquals(DataPointValueType.Double, ObjectTypeEvaluator.determineType(Double.parseDouble("2.5")).get());
20 assertThrows(NoSuchElementException.class, () -> ObjectTypeEvaluator.determineType(Float.parseFloat("2.5")).get());
21 assertEquals(DataPointValueType.Double, ObjectTypeEvaluator.determineType(2.5).get());
22 assertEquals(DataPointValueType.Integer, ObjectTypeEvaluator.determineType(5).get());
23 assertEquals(DataPointValueType.String, ObjectTypeEvaluator.determineType("5").get());
24 assertThrows(NoSuchElementException.class, () -> ObjectTypeEvaluator.determineType(new ArrayList<>()).get());
25 }
26 }