@Test public void testConvertLoadAlertRequestToLoadAlert() { LoadAlertRequest req = new LoadAlertRequest(); req.setAlertName("loadalert"); req.setDescription("loadalertdesc"); ScalingPolicyRequest scalingPolicyRequest = getScalingPolicyRequest(); req.setScalingPolicy(scalingPolicyRequest); when(scalingPolicyRequestConverter.convert(any(ScalingPolicyRequest.class))).thenCallRealMethod(); LoadAlert loadAlert = underTest.convert(req); assertEquals("LoadAlert Name should match", loadAlert.getName(), "loadalert"); assertEquals("LoadAlert Desc should match", loadAlert.getDescription(), "loadalertdesc"); assertEquals("LoadAlert Hostgroup should match", loadAlert.getScalingPolicy().getHostGroup(), "compute"); assertEquals("LoadAlert Adjustment Type should match", loadAlert.getScalingPolicy().getAdjustmentType(), LOAD_BASED); assertEquals("LoadAlert Adjustment should match", loadAlert.getScalingPolicy().getScalingAdjustment(), 10); }
@Override public LoadAlert convert(LoadAlertRequest source) { LoadAlert alert = new LoadAlert(); alert.setName(source.getAlertName()); alert.setDescription(source.getDescription()); if (source.getScalingPolicy() != null) { alert.setScalingPolicy(scalingPolicyRequestConverter.convert(source.getScalingPolicy())); } if (source.getLoadAlertConfiguration() != null) { alert.setLoadAlertConfiguration( loadAlertConfigurationRequestConverter.convert(source.getLoadAlertConfiguration())); } return alert; }
LoadAlertRequestConverter extends AbstractConverter<LoadAlertRequest, LoadAlert> { @Override public LoadAlert convert(LoadAlertRequest source) { LoadAlert alert = new LoadAlert(); alert.setName(source.getAlertName()); alert.setDescription(source.getDescription()); if (source.getScalingPolicy() != null) { alert.setScalingPolicy(scalingPolicyRequestConverter.convert(source.getScalingPolicy())); } if (source.getLoadAlertConfiguration() != null) { alert.setLoadAlertConfiguration( loadAlertConfigurationRequestConverter.convert(source.getLoadAlertConfiguration())); } return alert; } }
LoadAlertRequestConverter extends AbstractConverter<LoadAlertRequest, LoadAlert> { @Override public LoadAlert convert(LoadAlertRequest source) { LoadAlert alert = new LoadAlert(); alert.setName(source.getAlertName()); alert.setDescription(source.getDescription()); if (source.getScalingPolicy() != null) { alert.setScalingPolicy(scalingPolicyRequestConverter.convert(source.getScalingPolicy())); } if (source.getLoadAlertConfiguration() != null) { alert.setLoadAlertConfiguration( loadAlertConfigurationRequestConverter.convert(source.getLoadAlertConfiguration())); } return alert; }  }
LoadAlertRequestConverter extends AbstractConverter<LoadAlertRequest, LoadAlert> { @Override public LoadAlert convert(LoadAlertRequest source) { LoadAlert alert = new LoadAlert(); alert.setName(source.getAlertName()); alert.setDescription(source.getDescription()); if (source.getScalingPolicy() != null) { alert.setScalingPolicy(scalingPolicyRequestConverter.convert(source.getScalingPolicy())); } if (source.getLoadAlertConfiguration() != null) { alert.setLoadAlertConfiguration( loadAlertConfigurationRequestConverter.convert(source.getLoadAlertConfiguration())); } return alert; }  @Override LoadAlert convert(LoadAlertRequest source); }
LoadAlertRequestConverter extends AbstractConverter<LoadAlertRequest, LoadAlert> { @Override public LoadAlert convert(LoadAlertRequest source) { LoadAlert alert = new LoadAlert(); alert.setName(source.getAlertName()); alert.setDescription(source.getDescription()); if (source.getScalingPolicy() != null) { alert.setScalingPolicy(scalingPolicyRequestConverter.convert(source.getScalingPolicy())); } if (source.getLoadAlertConfiguration() != null) { alert.setLoadAlertConfiguration( loadAlertConfigurationRequestConverter.convert(source.getLoadAlertConfiguration())); } return alert; }  @Override LoadAlert convert(LoadAlertRequest source);  }