SlaStatusConverter implements Converter<Integer, String> { @Override public String toWidgetValue(final Integer status) { if (status == null) { return constants.Unknown(); } switch (status) { case ProcessInstance.SLA_NA: return constants.SlaNA(); case ProcessInstance.SLA_PENDING: return constants.SlaPending(); case ProcessInstance.SLA_MET: return constants.SlaMet(); case ProcessInstance.SLA_ABORTED: return constants.SlaAborted(); case ProcessInstance.SLA_VIOLATED: return constants.SlaViolated(); default: return constants.Unknown(); } }  @Override Integer toModelValue(final String widgetValue); @Override String toWidgetValue(final Integer status); @Override Class<Integer> getModelType(); @Override Class<String> getComponentType(); static Map<String, String> getSLAComplianceAliasMap();  }
@Test public void testConvert() { Constants constants = Constants.INSTANCE; assertEquals(constants.Unknown(), new SlaStatusConverter().toWidgetValue(null)); assertEquals(constants.Unknown(), new SlaStatusConverter().toWidgetValue(Integer.MAX_VALUE)); assertEquals(constants.SlaNA(), new SlaStatusConverter().toWidgetValue(ProcessInstance.SLA_NA)); assertEquals(constants.SlaPending(), new SlaStatusConverter().toWidgetValue(ProcessInstance.SLA_PENDING)); assertEquals(constants.SlaMet(), new SlaStatusConverter().toWidgetValue(ProcessInstance.SLA_MET)); assertEquals(constants.SlaViolated(), new SlaStatusConverter().toWidgetValue(ProcessInstance.SLA_VIOLATED)); assertEquals(constants.SlaAborted(), new SlaStatusConverter().toWidgetValue(ProcessInstance.SLA_ABORTED)); assertEquals(constants.Unknown(), new SlaStatusConverter().toWidgetValue(5)); }