CookbookConfigurationToscaConverter { public List<TNodeType> convertCookbookConfigurationToToscaNode(ChefCookbookConfiguration cookbookConfiguration, int counter) { List<TNodeType> nodeTypes = new ArrayList<>(); String cookbookName = cookbookConfiguration.getName(); String version = cookbookConfiguration.getVersion(); String namespace = buildNamespaceForCookbookConfigs(cookbookName, version); TNodeType.Builder configurationNodeType = new TNodeType.Builder(cookbookName + WineryVersion.WINERY_VERSION_SEPARATOR + WineryVersion.WINERY_VERSION_PREFIX + counter); configurationNodeType.setTargetNamespace(namespace); TRequirementDefinition platform = convertPlatformToRequirement(cookbookConfiguration.getSupports(), namespace); configurationNodeType.addRequirementDefinitions(platform); TCapabilityDefinition installedPackage; List<TCapabilityDefinition> installedPackages = convertInstalledPackagesToCapabilities(cookbookConfiguration.getInstalledPackages(), namespace); for (int i = 0; i < installedPackages.size(); i++) { installedPackage = installedPackages.get(i); configurationNodeType.addCapabilityDefinitions(installedPackage); } TRequirementDefinition requiredPackage; List<TRequirementDefinition> requiredPackages = convertRequiredPackagesToRequirements(cookbookConfiguration.getRequiredPackages(), namespace); for (int i = 0; i < requiredPackages.size(); i++) { requiredPackage = requiredPackages.get(i); configurationNodeType.addRequirementDefinitions(requiredPackage); } TNodeType tNodeType = new TNodeType(configurationNodeType); TNodeType platformNodeType = convertPlatformToNodeType(cookbookConfiguration.getSupports(), namespace); nodeTypes.add(tNodeType); nodeTypes.add(platformNodeType); return nodeTypes; }  List<TNodeType> convertCookbookConfigurationToToscaNode(ChefCookbookConfiguration cookbookConfiguration, int counter); void saveToscaNodeType(TNodeType tNodeType);  }
@Test public void createMyAppNode() { List<TNodeType> nodeTypes; ChefCookbookConfiguration cookbookConfiguration = new ChefCookbookConfiguration(); cookbookConfiguration.setName("myapp"); cookbookConfiguration.setVersion("1.0.0"); cookbookConfiguration.setSupports(new Platform("ubuntu", "16.04")); cookbookConfiguration.addRequiredPackage(new ChefPackage("openjdk-8-jdk")); cookbookConfiguration.addRequiredPackage(new ChefPackage("openjdk-8-jre-headless")); cookbookConfiguration.addInstalledPackage(new ChefPackage("myapp", "1.1")); cookbookConfiguration.addInstalledPackage(new ChefPackage("myappaddon", "1.2")); nodeTypes = new CookbookConfigurationToscaConverter().convertCookbookConfigurationToToscaNode(cookbookConfiguration, 1); assertEquals(2, nodeTypes.size()); assertEquals(true, nodeTypes.get(0).getCapabilityDefinitions().getCapabilityDefinition().get(0).getCapabilityType().toString().endsWith("myapp-1.1")); assertEquals(true, nodeTypes.get(0).getCapabilityDefinitions().getCapabilityDefinition().get(1).getCapabilityType().toString().endsWith("myappaddon-1.2")); assertEquals(true, nodeTypes.get(0).getRequirementDefinitions().getRequirementDefinition().get(1).getRequirementType().toString().endsWith("openjdk-8-jdk")); assertEquals(true, nodeTypes.get(0).getRequirementDefinitions().getRequirementDefinition().get(2).getRequirementType().toString().endsWith("openjdk-8-jre-headless")); assertEquals(true, nodeTypes.get(1).getCapabilityDefinitions().getCapabilityDefinition().get(0).getCapabilityType().toString().endsWith("ubuntu_16.04" + WineryVersion.WINERY_VERSION_SEPARATOR + WineryVersion.WINERY_VERSION_PREFIX + "1")); }