### Question:
OddsRatioScalePresentation extends RiskScalePresentation { @Override public AbstractValueModel getModel(String property) { if (property.equals(PROPERTY_ODDS_RATIO)) { return new OddsRatioValueModel(); } return super.getModel(property); } OddsRatioScalePresentation(ScaleCriterion criterion, OddsRatioToClinicalConverter converter); @Override AbstractValueModel getModel(String property); static final String PROPERTY_ODDS_RATIO; }### Answer:
@Test public void testRiskDifferenceModelShouldGiveCorrectValue() { Object actual = d_pm.getModel(OddsRatioScalePresentation.PROPERTY_RISK_DIFFERENCE).getValue(); Object expected = d_orc.getRiskDifference(convert(d_criterion.getScale())); assertEquals(expected, actual); }
@Test public void testRiskDifferenceModelShouldFireOnScaleChange() { ValueModel model = d_pm.getModel(OddsRatioScalePresentation.PROPERTY_RISK_DIFFERENCE); fi.smaa.jsmaa.model.Interval interval = new fi.smaa.jsmaa.model.Interval(0.8, 1.1); Object expected = d_orc.getRiskDifference(convert(interval)); assertValueModelFires(model, interval, expected); }
@Test public void testNNTModelShouldGiveCorrectValue() { Object actual = d_pm.getModel(OddsRatioScalePresentation.PROPERTY_NNT).getValue(); Object expected = d_orc.getNumberNeededToTreat(convert(d_criterion.getScale())); assertEquals(expected, actual); }
@Test public void testNNTModelShouldFireOnScaleChange() { ValueModel model = d_pm.getModel(OddsRatioScalePresentation.PROPERTY_NNT); fi.smaa.jsmaa.model.Interval interval = new fi.smaa.jsmaa.model.Interval(0.8, 1.1); Object expected = d_orc.getNumberNeededToTreat(convert(interval)); assertValueModelFires(model, interval, expected); }
@Test public void testNNTLabelModelShouldGiveCorrectValue() { Object actual = d_pm.getModel(OddsRatioScalePresentation.PROPERTY_NNT_LABEL).getValue(); Object expected = "NNT"; assertEquals(expected, actual); }
@Test public void testNNTLabelModelShouldFireOnScaleChange() { ValueModel model = d_pm.getModel(OddsRatioScalePresentation.PROPERTY_NNT_LABEL); Object expected = "NNH"; PropertyChangeListener mock = JUnitUtil.mockListener(model, "value", null, expected); model.addValueChangeListener(mock); d_criterion.setAscending(false); assertEquals(expected, model.getValue()); verify(mock); }