Commit 47f5554b authored by R.W.Majeed's avatar R.W.Majeed

Units are used by xml parsers. Units tested by

FileObservationProviderTest
parent eccf3776
......@@ -11,15 +11,15 @@ public class NumericValue extends AbstractValue {
public NumericValue(BigDecimal value){
this(value, Operator.Equal);
this(value, null);
}
public NumericValue(BigDecimal value, String units){
this(value, Operator.Equal);
this.units = units;
this(value, units, Operator.Equal);
}
public NumericValue(BigDecimal value, Operator operator){
public NumericValue(BigDecimal value, String units, Operator operator){
this.value = value;
this.units = units;
this.operator = operator;
}
......
......@@ -216,7 +216,7 @@ class XMLObservationParser extends AbstractObservationParser{
val = new StringValue(valueText);
break;
case Numeric:
val = new NumericValue(new BigDecimal(valueText), valueOp);
val = new NumericValue(new BigDecimal(valueText), valueUnit, valueOp);
break;
default:
throw new IllegalArgumentException("Unsupported fact type "+factType);
......
package de.sekmi.histream;
import java.io.BufferedReader;
import java.io.FileReader;
import org.junit.Test;
public class TestLoadFlatText {
@Test
public void loadFlatText() throws Exception{
BufferedReader buf = new BufferedReader(new FileReader("src/test/resources/fwh-flat.txt"));
//buf.lines().forEach(action);
buf.lines();
buf.close();
}
}
......@@ -72,17 +72,18 @@ public class FileObservationProviderTest {
(Observation o) -> {
Assert.assertEquals("T:type:str", o.getConceptId());
Assert.assertEquals(Value.Type.Text, o.getValue().getType());
Assert.assertEquals("abc123", o.getValue().getValue());
Assert.assertEquals("abc123", o.getValue().getValue());
},
(Observation o) -> {
Assert.assertEquals("T:type:int", o.getConceptId());
Assert.assertEquals(Value.Type.Numeric, o.getValue().getType());
Assert.assertEquals(123, o.getValue().getNumericValue().intValueExact());
Assert.assertEquals(123, o.getValue().getNumericValue().intValueExact());
},
(Observation o) -> {
Assert.assertEquals("T:type:dec", o.getConceptId());
Assert.assertEquals(Value.Type.Numeric, o.getValue().getType());
Assert.assertEquals(new BigDecimal("123.456"), o.getValue().getNumericValue());
Assert.assertEquals(new BigDecimal("123.456"), o.getValue().getNumericValue());
Assert.assertEquals("mm", o.getValue().getUnits());
},
(Observation o) -> {
Assert.assertEquals("T:group:1", o.getConceptId());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment