WorldpayRiskScoreConverter extends AbstractConverter<RiskScore, WorldpayRiskScoreModel> { @Override public WorldpayRiskScoreModel convert(final RiskScore riskScore) { final WorldpayRiskScoreModel worldpayRiskScoreModel = modelService.create(WorldpayRiskScoreModel.class); populate(riskScore,worldpayRiskScoreModel); return worldpayRiskScoreModel; }  @Override WorldpayRiskScoreModel convert(final RiskScore riskScore); @Override void populate(final RiskScore riskScore, final WorldpayRiskScoreModel worldpayRiskScoreModel); @Required void setModelService(final ModelService modelService);  }
@Test public void convertShouldConvertRiskScoreIntoWorldpayRiskScoreModel() { final WorldpayRiskScoreModel result = testObj.convert(riskScoreMock); assertEquals(Double.valueOf(FINAL_SCORE), result.getFinalScore()); assertEquals(EXTENDED_RESPONSE, result.getExtendedResponse()); assertEquals(ID, result.getId()); assertEquals(MESSAGE, result.getMessage()); assertEquals(PROVIDER, result.getProvider()); assertEquals(Long.valueOf(RGID), result.getRgid()); assertEquals(Double.valueOf(TRISK), result.getTRisk()); assertEquals(Double.valueOf(TSCORE), result.getTScore()); assertEquals(VALUE, result.getValue()); }
@Test public void convertShouldNotConvertNullValues() { when(riskScoreMock.getFinalScore()).thenReturn(null); when(riskScoreMock.getRGID()).thenReturn(null); when(riskScoreMock.getTRisk()).thenReturn(null); when(riskScoreMock.getTScore()).thenReturn(null); final WorldpayRiskScoreModel result = testObj.convert(riskScoreMock); assertNull(result.getFinalScore()); assertNull(result.getRgid()); assertNull(result.getTRisk()); assertNull(result.getTScore()); }