@Test public void removeOldLaunchConfiguration() { CloudContext cloudContext = new CloudContext(1L, "cloudContext", "AWS", USER_ID, WORKSPACE_ID); String launchConfigurationName = "old"; underTest.removeOldLaunchConfiguration(new LaunchConfiguration().withLaunchConfigurationName(launchConfigurationName), autoScalingClient, cloudContext); ArgumentCaptor<DeleteLaunchConfigurationRequest> captor = ArgumentCaptor.forClass(DeleteLaunchConfigurationRequest.class); verify(autoScalingClient, times(1)).deleteLaunchConfiguration(captor.capture()); assertEquals(launchConfigurationName, captor.getValue().getLaunchConfigurationName()); verify(resourceNotifier, times(1)).notifyDeletion(any(CloudResource.class), eq(cloudContext)); }
public void removeOldLaunchConfiguration(LaunchConfiguration oldLaunchConfiguration, AmazonAutoScalingClient autoScalingClient, CloudContext cloudContext) { autoScalingClient.deleteLaunchConfiguration( new DeleteLaunchConfigurationRequest().withLaunchConfigurationName(oldLaunchConfiguration.getLaunchConfigurationName())); CloudResource cloudResource = CloudResource.builder() .name(oldLaunchConfiguration.getLaunchConfigurationName()) .type(ResourceType.AWS_LAUNCHCONFIGURATION) .build(); resourceNotifier.notifyDeletion(cloudResource, cloudContext); }
LaunchConfigurationHandler { public void removeOldLaunchConfiguration(LaunchConfiguration oldLaunchConfiguration, AmazonAutoScalingClient autoScalingClient, CloudContext cloudContext) { autoScalingClient.deleteLaunchConfiguration( new DeleteLaunchConfigurationRequest().withLaunchConfigurationName(oldLaunchConfiguration.getLaunchConfigurationName())); CloudResource cloudResource = CloudResource.builder() .name(oldLaunchConfiguration.getLaunchConfigurationName()) .type(ResourceType.AWS_LAUNCHCONFIGURATION) .build(); resourceNotifier.notifyDeletion(cloudResource, cloudContext); } }
LaunchConfigurationHandler { public void removeOldLaunchConfiguration(LaunchConfiguration oldLaunchConfiguration, AmazonAutoScalingClient autoScalingClient, CloudContext cloudContext) { autoScalingClient.deleteLaunchConfiguration( new DeleteLaunchConfigurationRequest().withLaunchConfigurationName(oldLaunchConfiguration.getLaunchConfigurationName())); CloudResource cloudResource = CloudResource.builder() .name(oldLaunchConfiguration.getLaunchConfigurationName()) .type(ResourceType.AWS_LAUNCHCONFIGURATION) .build(); resourceNotifier.notifyDeletion(cloudResource, cloudContext); }  }
LaunchConfigurationHandler { public void removeOldLaunchConfiguration(LaunchConfiguration oldLaunchConfiguration, AmazonAutoScalingClient autoScalingClient, CloudContext cloudContext) { autoScalingClient.deleteLaunchConfiguration( new DeleteLaunchConfigurationRequest().withLaunchConfigurationName(oldLaunchConfiguration.getLaunchConfigurationName())); CloudResource cloudResource = CloudResource.builder() .name(oldLaunchConfiguration.getLaunchConfigurationName()) .type(ResourceType.AWS_LAUNCHCONFIGURATION) .build(); resourceNotifier.notifyDeletion(cloudResource, cloudContext); }  List<LaunchConfiguration> getLaunchConfigurations(AmazonAutoScalingClient autoScalingClient, Collection<AutoScalingGroup> scalingGroups); String createNewLaunchConfiguration(String imageName, AmazonAutoScalingClient autoScalingClient,
            LaunchConfiguration oldLaunchConfiguration, CloudContext cloudContext, String encryptedImageName); void removeOldLaunchConfiguration(LaunchConfiguration oldLaunchConfiguration, AmazonAutoScalingClient autoScalingClient,
            CloudContext cloudContext); }
LaunchConfigurationHandler { public void removeOldLaunchConfiguration(LaunchConfiguration oldLaunchConfiguration, AmazonAutoScalingClient autoScalingClient, CloudContext cloudContext) { autoScalingClient.deleteLaunchConfiguration( new DeleteLaunchConfigurationRequest().withLaunchConfigurationName(oldLaunchConfiguration.getLaunchConfigurationName())); CloudResource cloudResource = CloudResource.builder() .name(oldLaunchConfiguration.getLaunchConfigurationName()) .type(ResourceType.AWS_LAUNCHCONFIGURATION) .build(); resourceNotifier.notifyDeletion(cloudResource, cloudContext); }  List<LaunchConfiguration> getLaunchConfigurations(AmazonAutoScalingClient autoScalingClient, Collection<AutoScalingGroup> scalingGroups); String createNewLaunchConfiguration(String imageName, AmazonAutoScalingClient autoScalingClient,
            LaunchConfiguration oldLaunchConfiguration, CloudContext cloudContext, String encryptedImageName); void removeOldLaunchConfiguration(LaunchConfiguration oldLaunchConfiguration, AmazonAutoScalingClient autoScalingClient,
            CloudContext cloudContext);  }