@Test public void testConvertTimeAlertToTimeAlertResponse() { TimeAlert timeAlert = new TimeAlert(); timeAlert.setName("timealert"); timeAlert.setDescription("timealertdesc"); timeAlert.setCron("0 23 */2 * *"); timeAlert.setTimeZone("GMT"); timeAlert.setId(20L); ScalingPolicy scalingPolicy = getScalingPolicy(); timeAlert.setScalingPolicy(scalingPolicy); when(scalingPolicyResponseConverter.convert(any(ScalingPolicy.class))).thenCallRealMethod(); TimeAlertResponse timeAlertResponse = underTest.convert(timeAlert); assertEquals("TimeAlert Name should match", timeAlertResponse.getAlertName(), "timealert"); assertEquals("TimeAlert Desc should match", timeAlertResponse.getDescription(), "timealertdesc"); assertEquals("TimeAlert Cron should match", timeAlertResponse.getCron(), "0 23 */2 * *"); assertEquals("TimeAlert Timezone should match", timeAlertResponse.getTimeZone(), "GMT"); assertEquals("TimeAlert Hostgroup should match", timeAlertResponse.getScalingPolicy().getHostGroup(), "compute"); assertEquals("TimeAlert Adjustment Type should match", timeAlertResponse.getScalingPolicy().getAdjustmentType(), NODE_COUNT); assertEquals("TimeAlert Adjustment should match", timeAlertResponse.getScalingPolicy().getScalingAdjustment(), 10); }
@Override public TimeAlertResponse convert(TimeAlert source) { TimeAlertResponse json = new TimeAlertResponse(); json.setCrn(source.getAlertCrn()); json.setAlertName(source.getName()); json.setCron(source.getCron()); json.setTimeZone(source.getTimeZone()); json.setDescription(source.getDescription()); if (source.getScalingPolicy() != null) { json.setScalingPolicy(scalingPolicyResponseConverter.convert(source.getScalingPolicy())); } return json; }
TimeAlertResponseConverter extends AbstractConverter<TimeAlertResponse, TimeAlert> { @Override public TimeAlertResponse convert(TimeAlert source) { TimeAlertResponse json = new TimeAlertResponse(); json.setCrn(source.getAlertCrn()); json.setAlertName(source.getName()); json.setCron(source.getCron()); json.setTimeZone(source.getTimeZone()); json.setDescription(source.getDescription()); if (source.getScalingPolicy() != null) { json.setScalingPolicy(scalingPolicyResponseConverter.convert(source.getScalingPolicy())); } return json; } }
TimeAlertResponseConverter extends AbstractConverter<TimeAlertResponse, TimeAlert> { @Override public TimeAlertResponse convert(TimeAlert source) { TimeAlertResponse json = new TimeAlertResponse(); json.setCrn(source.getAlertCrn()); json.setAlertName(source.getName()); json.setCron(source.getCron()); json.setTimeZone(source.getTimeZone()); json.setDescription(source.getDescription()); if (source.getScalingPolicy() != null) { json.setScalingPolicy(scalingPolicyResponseConverter.convert(source.getScalingPolicy())); } return json; }  }
TimeAlertResponseConverter extends AbstractConverter<TimeAlertResponse, TimeAlert> { @Override public TimeAlertResponse convert(TimeAlert source) { TimeAlertResponse json = new TimeAlertResponse(); json.setCrn(source.getAlertCrn()); json.setAlertName(source.getName()); json.setCron(source.getCron()); json.setTimeZone(source.getTimeZone()); json.setDescription(source.getDescription()); if (source.getScalingPolicy() != null) { json.setScalingPolicy(scalingPolicyResponseConverter.convert(source.getScalingPolicy())); } return json; }  @Override TimeAlertResponse convert(TimeAlert source); }
TimeAlertResponseConverter extends AbstractConverter<TimeAlertResponse, TimeAlert> { @Override public TimeAlertResponse convert(TimeAlert source) { TimeAlertResponse json = new TimeAlertResponse(); json.setCrn(source.getAlertCrn()); json.setAlertName(source.getName()); json.setCron(source.getCron()); json.setTimeZone(source.getTimeZone()); json.setDescription(source.getDescription()); if (source.getScalingPolicy() != null) { json.setScalingPolicy(scalingPolicyResponseConverter.convert(source.getScalingPolicy())); } return json; }  @Override TimeAlertResponse convert(TimeAlert source);  }