BaselineExpression implements Expression { public static BaselineExpression create(String expressionLevelString) { if (expressionLevelString == null) { return null; } if (NO_DATA_CODES.contains(expressionLevelString)) { return new BaselineExpression(0.0); } if (expressionLevelString.contains(",")) { String[] vals = expressionLevelString.split(",", 5); checkArgument(vals.length == 5, String.format("Need 5 elements but got %s", expressionLevelString)); return new BaselineExpression(Double.parseDouble(vals[0]), Double.parseDouble(vals[1]), Double.parseDouble(vals[2]), Double.parseDouble(vals[3]), Double.parseDouble(vals[4])); } return new BaselineExpression(Double.parseDouble(expressionLevelString)); } BaselineExpression(double level);  BaselineExpression(double min,
                              double lowerQuartile,
                              double median,
                              double upperQuartile,
                              double max); private  BaselineExpression(double level, double[] quartiles); static BaselineExpression create(String expressionLevelString); double[] getQuartiles(); double getLevel(); boolean isGreaterThanOrEqual(double level); @Override boolean equals(Object object); @Override int hashCode(); @Override String toString(); @Override JsonObject toJson();  }
@Test public void createFromString() { assertThat(BaselineExpression.create("1.0")) .isEqualTo(new BaselineExpression(1.0)); assertThat(BaselineExpression.create("1.0, 2.0, 3.0, 4.0, 5.0")) .isEqualTo(new BaselineExpression(1.0, 2.0, 3.0, 4.0, 5.0)); }
@Test public void noDataCodesAreZero() { assertThat(BaselineExpression.create("-")) .isEqualTo(BaselineExpression.create("NT")) .isEqualTo(BaselineExpression.create("NA")) .isEqualTo(new BaselineExpression(0)); }
@Test public void nullStringReturnsNull() { assertThat(BaselineExpression.create(null)) .isNull(); }
@Test public void badData() { assertThatIllegalArgumentException().isThrownBy(() -> BaselineExpression.create("1.0, 2.0, 3.0, 4.0")); }