@Test public void createNewLaunchConfiguration() { String lName = "lName"; when(launchConfigurationMapper.mapExistingLaunchConfigToRequest(any(LaunchConfiguration.class))) .thenReturn(new CreateLaunchConfigurationRequest().withLaunchConfigurationName(lName)); CloudContext cloudContext = new CloudContext(1L, "cloudContext", "AWS", USER_ID, WORKSPACE_ID); String imageName = "imageName"; String launchConfigurationName = underTest.createNewLaunchConfiguration(imageName, autoScalingClient, new LaunchConfiguration().withLaunchConfigurationName(lName), cloudContext, null); ArgumentCaptor<CreateLaunchConfigurationRequest> captor = ArgumentCaptor.forClass(CreateLaunchConfigurationRequest.class); verify(autoScalingClient).createLaunchConfiguration(captor.capture()); assertTrue(captor.getValue().getLaunchConfigurationName().startsWith(lName)); assertTrue(captor.getValue().getLaunchConfigurationName().endsWith(imageName)); assertEquals(lName + '-' + imageName, launchConfigurationName); verify(resourceNotifier, times(1)).notifyAllocation(any(CloudResource.class), eq(cloudContext)); }
public String createNewLaunchConfiguration(String imageName, AmazonAutoScalingClient autoScalingClient, LaunchConfiguration oldLaunchConfiguration, CloudContext cloudContext, String encryptedImageName) { String selectedImageName = StringUtils.isBlank(encryptedImageName) ? imageName : encryptedImageName; CreateLaunchConfigurationRequest createLaunchConfigurationRequest = getCreateLaunchConfigurationRequest(selectedImageName, oldLaunchConfiguration); LOGGER.debug("Create LaunchConfiguration {} with image {}", createLaunchConfigurationRequest.getLaunchConfigurationName(), selectedImageName); autoScalingClient.createLaunchConfiguration(createLaunchConfigurationRequest); CloudResource cloudResource = CloudResource.builder() .type(ResourceType.AWS_LAUNCHCONFIGURATION) .params(Collections.emptyMap()) .name(createLaunchConfigurationRequest.getLaunchConfigurationName()) .build(); resourceNotifier.notifyAllocation(cloudResource, cloudContext); return createLaunchConfigurationRequest.getLaunchConfigurationName(); }
LaunchConfigurationHandler { public String createNewLaunchConfiguration(String imageName, AmazonAutoScalingClient autoScalingClient, LaunchConfiguration oldLaunchConfiguration, CloudContext cloudContext, String encryptedImageName) { String selectedImageName = StringUtils.isBlank(encryptedImageName) ? imageName : encryptedImageName; CreateLaunchConfigurationRequest createLaunchConfigurationRequest = getCreateLaunchConfigurationRequest(selectedImageName, oldLaunchConfiguration); LOGGER.debug("Create LaunchConfiguration {} with image {}", createLaunchConfigurationRequest.getLaunchConfigurationName(), selectedImageName); autoScalingClient.createLaunchConfiguration(createLaunchConfigurationRequest); CloudResource cloudResource = CloudResource.builder() .type(ResourceType.AWS_LAUNCHCONFIGURATION) .params(Collections.emptyMap()) .name(createLaunchConfigurationRequest.getLaunchConfigurationName()) .build(); resourceNotifier.notifyAllocation(cloudResource, cloudContext); return createLaunchConfigurationRequest.getLaunchConfigurationName(); } }
LaunchConfigurationHandler { public String createNewLaunchConfiguration(String imageName, AmazonAutoScalingClient autoScalingClient, LaunchConfiguration oldLaunchConfiguration, CloudContext cloudContext, String encryptedImageName) { String selectedImageName = StringUtils.isBlank(encryptedImageName) ? imageName : encryptedImageName; CreateLaunchConfigurationRequest createLaunchConfigurationRequest = getCreateLaunchConfigurationRequest(selectedImageName, oldLaunchConfiguration); LOGGER.debug("Create LaunchConfiguration {} with image {}", createLaunchConfigurationRequest.getLaunchConfigurationName(), selectedImageName); autoScalingClient.createLaunchConfiguration(createLaunchConfigurationRequest); CloudResource cloudResource = CloudResource.builder() .type(ResourceType.AWS_LAUNCHCONFIGURATION) .params(Collections.emptyMap()) .name(createLaunchConfigurationRequest.getLaunchConfigurationName()) .build(); resourceNotifier.notifyAllocation(cloudResource, cloudContext); return createLaunchConfigurationRequest.getLaunchConfigurationName(); }  }
LaunchConfigurationHandler { public String createNewLaunchConfiguration(String imageName, AmazonAutoScalingClient autoScalingClient, LaunchConfiguration oldLaunchConfiguration, CloudContext cloudContext, String encryptedImageName) { String selectedImageName = StringUtils.isBlank(encryptedImageName) ? imageName : encryptedImageName; CreateLaunchConfigurationRequest createLaunchConfigurationRequest = getCreateLaunchConfigurationRequest(selectedImageName, oldLaunchConfiguration); LOGGER.debug("Create LaunchConfiguration {} with image {}", createLaunchConfigurationRequest.getLaunchConfigurationName(), selectedImageName); autoScalingClient.createLaunchConfiguration(createLaunchConfigurationRequest); CloudResource cloudResource = CloudResource.builder() .type(ResourceType.AWS_LAUNCHCONFIGURATION) .params(Collections.emptyMap()) .name(createLaunchConfigurationRequest.getLaunchConfigurationName()) .build(); resourceNotifier.notifyAllocation(cloudResource, cloudContext); return createLaunchConfigurationRequest.getLaunchConfigurationName(); }  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 String createNewLaunchConfiguration(String imageName, AmazonAutoScalingClient autoScalingClient, LaunchConfiguration oldLaunchConfiguration, CloudContext cloudContext, String encryptedImageName) { String selectedImageName = StringUtils.isBlank(encryptedImageName) ? imageName : encryptedImageName; CreateLaunchConfigurationRequest createLaunchConfigurationRequest = getCreateLaunchConfigurationRequest(selectedImageName, oldLaunchConfiguration); LOGGER.debug("Create LaunchConfiguration {} with image {}", createLaunchConfigurationRequest.getLaunchConfigurationName(), selectedImageName); autoScalingClient.createLaunchConfiguration(createLaunchConfigurationRequest); CloudResource cloudResource = CloudResource.builder() .type(ResourceType.AWS_LAUNCHCONFIGURATION) .params(Collections.emptyMap()) .name(createLaunchConfigurationRequest.getLaunchConfigurationName()) .build(); resourceNotifier.notifyAllocation(cloudResource, cloudContext); return createLaunchConfigurationRequest.getLaunchConfigurationName(); }  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);  }