@Test public void testConvertTimeAlertRequestToTimeAlert() { TimeAlertRequest req = new TimeAlertRequest(); req.setAlertName("timealert"); req.setDescription("timealertdesc"); req.setTimeZone("GMT - 5"); req.setCron("0 23 */2 * *"); ScalingPolicyRequest scalingPolicyRequest = getScalingPolicyRequest(); req.setScalingPolicy(scalingPolicyRequest); when(scalingPolicyRequestConverter.convert(any(ScalingPolicyRequest.class))).thenCallRealMethod(); TimeAlert timeAlert = underTest.convert(req); assertEquals("TimeAlert Name should match", timeAlert.getName(), "timealert"); assertEquals("TimeAlert Desc should match", timeAlert.getDescription(), "timealertdesc"); assertEquals("TimeAlert Cron should match", timeAlert.getCron(), "0 23 */2 * *"); assertEquals("TimeAlert Timezone should match", timeAlert.getTimeZone(), "GMT - 5"); assertEquals("TimeAlert Hostgroup should match", timeAlert.getScalingPolicy().getHostGroup(), "compute"); assertEquals("TimeAlert Adjustment Type should match", timeAlert.getScalingPolicy().getAdjustmentType(), NODE_COUNT); assertEquals("TimeAlert Adjustment should match", timeAlert.getScalingPolicy().getScalingAdjustment(), 10); }
@Override public TimeAlert convert(TimeAlertRequest source) { TimeAlert alarm = new TimeAlert(); alarm.setName(source.getAlertName()); alarm.setDescription(source.getDescription()); alarm.setCron(source.getCron()); alarm.setTimeZone(source.getTimeZone()); if (source.getScalingPolicy() != null) { alarm.setScalingPolicy(scalingPolicyRequestConverter.convert(source.getScalingPolicy())); } return alarm; }
TimeAlertRequestConverter extends AbstractConverter<TimeAlertRequest, TimeAlert> { @Override public TimeAlert convert(TimeAlertRequest source) { TimeAlert alarm = new TimeAlert(); alarm.setName(source.getAlertName()); alarm.setDescription(source.getDescription()); alarm.setCron(source.getCron()); alarm.setTimeZone(source.getTimeZone()); if (source.getScalingPolicy() != null) { alarm.setScalingPolicy(scalingPolicyRequestConverter.convert(source.getScalingPolicy())); } return alarm; } }
TimeAlertRequestConverter extends AbstractConverter<TimeAlertRequest, TimeAlert> { @Override public TimeAlert convert(TimeAlertRequest source) { TimeAlert alarm = new TimeAlert(); alarm.setName(source.getAlertName()); alarm.setDescription(source.getDescription()); alarm.setCron(source.getCron()); alarm.setTimeZone(source.getTimeZone()); if (source.getScalingPolicy() != null) { alarm.setScalingPolicy(scalingPolicyRequestConverter.convert(source.getScalingPolicy())); } return alarm; }  }
TimeAlertRequestConverter extends AbstractConverter<TimeAlertRequest, TimeAlert> { @Override public TimeAlert convert(TimeAlertRequest source) { TimeAlert alarm = new TimeAlert(); alarm.setName(source.getAlertName()); alarm.setDescription(source.getDescription()); alarm.setCron(source.getCron()); alarm.setTimeZone(source.getTimeZone()); if (source.getScalingPolicy() != null) { alarm.setScalingPolicy(scalingPolicyRequestConverter.convert(source.getScalingPolicy())); } return alarm; }  @Override TimeAlert convert(TimeAlertRequest source); @Override TimeAlertRequest convert(TimeAlert source); }
TimeAlertRequestConverter extends AbstractConverter<TimeAlertRequest, TimeAlert> { @Override public TimeAlert convert(TimeAlertRequest source) { TimeAlert alarm = new TimeAlert(); alarm.setName(source.getAlertName()); alarm.setDescription(source.getDescription()); alarm.setCron(source.getCron()); alarm.setTimeZone(source.getTimeZone()); if (source.getScalingPolicy() != null) { alarm.setScalingPolicy(scalingPolicyRequestConverter.convert(source.getScalingPolicy())); } return alarm; }  @Override TimeAlert convert(TimeAlertRequest source); @Override TimeAlertRequest convert(TimeAlert source);  }