@Test public void testConvertWithNullTemplate() { int nodeCount = 2; InstanceGroupRequest request = new InstanceGroupRequest(); request.setName(NAME); request.setType(InstanceGroupType.MASTER); request.setNodeCount(nodeCount); Template template = mock(Template.class); SecurityGroupRequest securityGroupRequest = mock(SecurityGroupRequest.class); SecurityGroup securityGroup = mock(SecurityGroup.class); request.setSecurityGroup(securityGroupRequest); given(defaultInstanceGroupProvider.createDefaultTemplate(eq(MOCK), eq(ACCOUNT_ID))).willReturn(template); given(securityGroupConverter.convert(eq(securityGroupRequest))).willReturn(securityGroup); InstanceGroup result = underTest.convert(request, ACCOUNT_ID, MOCK.name(), NAME, HOSTNAME, DOMAINNAME); assertThat(result).isNotNull(); assertThat(result.getGroupName()).isEqualTo(NAME); assertThat(result.getInstanceGroupType()).isEqualTo(InstanceGroupType.MASTER); assertThat(result.getSecurityGroup()).isEqualTo(securityGroup); assertThat(result.getNodeCount()).isEqualTo(nodeCount); assertThat(result.getInstanceMetaData().size()).isEqualTo(nodeCount); for (InstanceMetaData instanceMetaData : result.getInstanceMetaData()) { assertThat(instanceMetaData.getInstanceGroup()).isEqualTo(result); } }
public InstanceGroup convert(InstanceGroupRequest source, String accountId, String cloudPlatformString, String stackName, String hostname, String domain) { InstanceGroup instanceGroup = new InstanceGroup(); CloudPlatform cloudPlatform = CloudPlatform.valueOf(cloudPlatformString); instanceGroup.setTemplate(source.getInstanceTemplate() == null ? defaultInstanceGroupProvider.createDefaultTemplate(cloudPlatform, accountId) : templateConverter.convert(source.getInstanceTemplate(), cloudPlatform, accountId)); instanceGroup.setSecurityGroup(securityGroupConverter.convert(source.getSecurityGroup())); String instanceGroupName = source.getName(); instanceGroup.setGroupName(instanceGroupName); instanceGroup.setInstanceGroupType(source.getType()); instanceGroup.setAttributes(defaultInstanceGroupProvider.createAttributes(cloudPlatform, stackName, instanceGroupName)); if (source.getNodeCount() > 0) { addInstanceMetadatas(source, instanceGroup, hostname, domain); } instanceGroup.setNodeCount(source.getNodeCount()); return instanceGroup; }
InstanceGroupRequestToInstanceGroupConverter { public InstanceGroup convert(InstanceGroupRequest source, String accountId, String cloudPlatformString, String stackName, String hostname, String domain) { InstanceGroup instanceGroup = new InstanceGroup(); CloudPlatform cloudPlatform = CloudPlatform.valueOf(cloudPlatformString); instanceGroup.setTemplate(source.getInstanceTemplate() == null ? defaultInstanceGroupProvider.createDefaultTemplate(cloudPlatform, accountId) : templateConverter.convert(source.getInstanceTemplate(), cloudPlatform, accountId)); instanceGroup.setSecurityGroup(securityGroupConverter.convert(source.getSecurityGroup())); String instanceGroupName = source.getName(); instanceGroup.setGroupName(instanceGroupName); instanceGroup.setInstanceGroupType(source.getType()); instanceGroup.setAttributes(defaultInstanceGroupProvider.createAttributes(cloudPlatform, stackName, instanceGroupName)); if (source.getNodeCount() > 0) { addInstanceMetadatas(source, instanceGroup, hostname, domain); } instanceGroup.setNodeCount(source.getNodeCount()); return instanceGroup; } }
InstanceGroupRequestToInstanceGroupConverter { public InstanceGroup convert(InstanceGroupRequest source, String accountId, String cloudPlatformString, String stackName, String hostname, String domain) { InstanceGroup instanceGroup = new InstanceGroup(); CloudPlatform cloudPlatform = CloudPlatform.valueOf(cloudPlatformString); instanceGroup.setTemplate(source.getInstanceTemplate() == null ? defaultInstanceGroupProvider.createDefaultTemplate(cloudPlatform, accountId) : templateConverter.convert(source.getInstanceTemplate(), cloudPlatform, accountId)); instanceGroup.setSecurityGroup(securityGroupConverter.convert(source.getSecurityGroup())); String instanceGroupName = source.getName(); instanceGroup.setGroupName(instanceGroupName); instanceGroup.setInstanceGroupType(source.getType()); instanceGroup.setAttributes(defaultInstanceGroupProvider.createAttributes(cloudPlatform, stackName, instanceGroupName)); if (source.getNodeCount() > 0) { addInstanceMetadatas(source, instanceGroup, hostname, domain); } instanceGroup.setNodeCount(source.getNodeCount()); return instanceGroup; }  }
InstanceGroupRequestToInstanceGroupConverter { public InstanceGroup convert(InstanceGroupRequest source, String accountId, String cloudPlatformString, String stackName, String hostname, String domain) { InstanceGroup instanceGroup = new InstanceGroup(); CloudPlatform cloudPlatform = CloudPlatform.valueOf(cloudPlatformString); instanceGroup.setTemplate(source.getInstanceTemplate() == null ? defaultInstanceGroupProvider.createDefaultTemplate(cloudPlatform, accountId) : templateConverter.convert(source.getInstanceTemplate(), cloudPlatform, accountId)); instanceGroup.setSecurityGroup(securityGroupConverter.convert(source.getSecurityGroup())); String instanceGroupName = source.getName(); instanceGroup.setGroupName(instanceGroupName); instanceGroup.setInstanceGroupType(source.getType()); instanceGroup.setAttributes(defaultInstanceGroupProvider.createAttributes(cloudPlatform, stackName, instanceGroupName)); if (source.getNodeCount() > 0) { addInstanceMetadatas(source, instanceGroup, hostname, domain); } instanceGroup.setNodeCount(source.getNodeCount()); return instanceGroup; }  InstanceGroup convert(InstanceGroupRequest source, String accountId, String cloudPlatformString, String stackName, String hostname, String domain); }
InstanceGroupRequestToInstanceGroupConverter { public InstanceGroup convert(InstanceGroupRequest source, String accountId, String cloudPlatformString, String stackName, String hostname, String domain) { InstanceGroup instanceGroup = new InstanceGroup(); CloudPlatform cloudPlatform = CloudPlatform.valueOf(cloudPlatformString); instanceGroup.setTemplate(source.getInstanceTemplate() == null ? defaultInstanceGroupProvider.createDefaultTemplate(cloudPlatform, accountId) : templateConverter.convert(source.getInstanceTemplate(), cloudPlatform, accountId)); instanceGroup.setSecurityGroup(securityGroupConverter.convert(source.getSecurityGroup())); String instanceGroupName = source.getName(); instanceGroup.setGroupName(instanceGroupName); instanceGroup.setInstanceGroupType(source.getType()); instanceGroup.setAttributes(defaultInstanceGroupProvider.createAttributes(cloudPlatform, stackName, instanceGroupName)); if (source.getNodeCount() > 0) { addInstanceMetadatas(source, instanceGroup, hostname, domain); } instanceGroup.setNodeCount(source.getNodeCount()); return instanceGroup; }  InstanceGroup convert(InstanceGroupRequest source, String accountId, String cloudPlatformString, String stackName, String hostname, String domain);  }