DamGenerator { public String generateDam(String adp) { originalAdp = normalizeComputeTypes(YamlParser.load(adp)); ApplicationFacade applicationFacade = new ApplicationFacade(originalAdp, configBag); applicationFacade.setAgreementGenerator(agreementGenerator); applicationFacade.generateDam(); String generatedDam = applicationFacade.templateToString(); template = YamlParser.load(generatedDam); customize(); return YamlParser.dump(template); } DamGenerator(DamGeneratorConfigBag configBag); String generateDam(String adp); void relationManagement(); void setAgreementGenerator(AgreementGenerator agreementGenerator); static final String TYPE; static final String POLICIES; static final String GROUPS; static final String MEMBERS; static final String ID; static final String APPLICATION; static final String TOPOLOGY_TEMPLATE; static final String NODE_TEMPLATES; static final String NODE_TYPES; static final String PROPERTIES; static final String BROOKLYN_POLICY_TYPE; static final String SEACLOUDS_APPLICATION_CONFIGURATION; static final String SEACLOUDS_MONITORING_INITIALIZATION; static final String REQUIREMENTS; static final String HOST; }
@Test(enabled = true) @SuppressWarnings("unchecked") public void testWebChatGenerationForPaaS() throws Exception { String adp = new Scanner(new File(Resources.getResource("webchat/paas/webchat_adp-paas.yml").toURI())).useDelimiter("\\Z").next(); dam = damGenerator.generateDam(adp); template = YamlParser.load(dam); testMetadataTemplate(template); String expectedDamString = new Scanner(new File(Resources.getResource("webchat/paas/webchat_dam-paas.yml").toURI())).useDelimiter("\\Z").next(); Map<String, Object> expectedDam = YamlParser.load(expectedDamString); assertNotNull(template); Map<String, Object> generatedTopologyTemplate = (Map<String, Object>) template.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> expectedTopologyTemplate = (Map<String, Object>) expectedDam.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> generatedNodeTemplates = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); Map<String, Object> expectedNodeTemplates = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); assertEquals(generatedNodeTemplates.size(), 4); assertEquals(generatedNodeTemplates.get("tomcat_server"), expectedNodeTemplates.get("tomcat_server")); assertEquals(generatedNodeTemplates.get("db"), expectedNodeTemplates.get("db")); assertEquals(generatedNodeTemplates.get("modacloudsDc_db"), expectedNodeTemplates.get("modacloudsDc_db")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_c3_xlarge_ap_southeast_2"), expectedNodeTemplates.get("Amazon_EC2_c3_xlarge_ap_southeast_2")); Map<String, Object> generatedGroups = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.GROUPS); Map<String, Object> expectedGroups = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.GROUPS); testSeaCloudsPolicy(generatedGroups); testMonitoringConfiguration(generatedGroups); testMonitorInitializationPolicy(generatedGroups, ImmutableList.of("tomcat_server")); assertEquals(generatedGroups.get("operation_db"), expectedGroups.get("operation_db")); assertEquals(generatedGroups.get("operation_tomcat_server"), expectedGroups.get("operation_tomcat_server")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_c3_xlarge_ap_southeast_2"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_c3_xlarge_ap_southeast_2")); assertEquals(generatedGroups.get("add_brooklyn_location_tomcat_server"), expectedGroups.get("add_brooklyn_location_tomcat_server")); }
@Test @SuppressWarnings("unchecked") public void testGroupsAsTopologyChild() throws Exception { String adp = new Scanner(new File(Resources.getResource("nuro/iaas/nuro_adp-iaas.yml").toURI())).useDelimiter("\\Z").next(); dam = damGenerator.generateDam(adp); template = YamlParser.load(dam); testMetadataTemplate(template); assertTrue(template.containsKey(DamGenerator.TOPOLOGY_TEMPLATE)); Map<String, Object> topologyTemplate = (Map<String, Object>) template.get(DamGenerator.TOPOLOGY_TEMPLATE); assertTrue(topologyTemplate.containsKey(DamGenerator.GROUPS)); Map<String, Object> topologyGroups = (Map<String, Object>) topologyTemplate.get(DamGenerator.GROUPS); assertNotNull(topologyGroups); assertEquals(topologyGroups.size(), 8); assertTrue(topologyGroups.containsKey("operation_www")); assertTrue(topologyGroups.containsKey("operation_db")); assertTrue(topologyGroups.containsKey("add_brooklyn_location_Amazon_EC2_m1_small_eu_central_1")); assertTrue(topologyGroups.containsKey("add_brooklyn_location_Amazon_EC2_m4_10xlarge_eu_west_1")); assertTrue(topologyGroups.containsKey("monitoringInformation")); assertTrue(topologyGroups.containsKey("sla_gen_info")); assertTrue(topologyGroups.containsKey("seaclouds_monitoring_configuration")); testSeaCloudsPolicy(topologyGroups); }
@Test @SuppressWarnings("unchecked") public void testNuroGenerationForIaaS() throws Exception { String adp = new Scanner(new File(Resources.getResource("nuro/iaas/nuro_adp-iaas.yml").toURI())).useDelimiter("\\Z").next(); dam = damGenerator.generateDam(adp); template = YamlParser.load(dam); testMetadataTemplate(template); String expectedDamString = new Scanner(new File(Resources.getResource("nuro/iaas/nuro_dam-iaas.yml").toURI())).useDelimiter("\\Z").next(); Map<String, Object> expectedDam = YamlParser.load(expectedDamString); assertNotNull(template); Map<String, Object> generatedTopologyTemplate = (Map<String, Object>) template.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> expectedTopologyTemplate = (Map<String, Object>) expectedDam.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> generatedNodeTemplates = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); Map<String, Object> expectedNodeTemplates = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); assertEquals(generatedNodeTemplates.size(), 6); assertEquals(generatedNodeTemplates.get("www"), expectedNodeTemplates.get("www")); assertEquals(generatedNodeTemplates.get("db"), expectedNodeTemplates.get("db")); assertEquals(generatedNodeTemplates.get("modacloudsDc_www"), expectedNodeTemplates.get("modacloudsDc_www")); assertEquals(generatedNodeTemplates.get("modacloudsDc_db"), expectedNodeTemplates.get("modacloudsDc_db")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_m1_small_eu_central_1"), expectedNodeTemplates.get("Amazon_EC2_m1_small_eu_central_1")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_m4_10xlarge_eu_west_1"), expectedNodeTemplates.get("Amazon_EC2_m4_10xlarge_eu_west_1")); Map<String, Object> generatedGroups = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.GROUPS); Map<String, Object> expectedGroups = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.GROUPS); testSeaCloudsPolicy(generatedGroups); testMonitoringConfiguration(generatedGroups); testMonitorInitializationPolicy(generatedGroups, ImmutableList.of("www")); assertEquals(generatedGroups.get("operation_www"), expectedGroups.get("operation_www")); assertEquals(generatedGroups.get("operation_db"), expectedGroups.get("operation_db")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_m1_small_eu_central_1"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_m1_small_eu_central_1")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_m4_10xlarge_eu_west_1"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_m4_10xlarge_eu_west_1")); }
@Test(enabled = true) @SuppressWarnings("unchecked") public void testNuroGenerationForPaaS() throws Exception { String adp = new Scanner(new File(Resources.getResource("nuro/paas/nuro_adp-paas.yml").toURI())).useDelimiter("\\Z").next(); dam = damGenerator.generateDam(adp); template = YamlParser.load(dam); testMetadataTemplate(template); String expectedDamString = new Scanner(new File(Resources.getResource("nuro/paas/nuro_dam-paas.yml").toURI())).useDelimiter("\\Z").next(); Map<String, Object> expectedDam = YamlParser.load(expectedDamString); assertNotNull(template); Map<String, Object> generatedTopologyTemplate = (Map<String, Object>) template.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> expectedTopologyTemplate = (Map<String, Object>) expectedDam.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> generatedNodeTemplates = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); Map<String, Object> expectedNodeTemplates = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); assertEquals(generatedNodeTemplates.size(), 4); assertEquals(generatedNodeTemplates.get("php"), expectedNodeTemplates.get("php")); assertEquals(generatedNodeTemplates.get("db"), expectedNodeTemplates.get("db")); assertEquals(generatedNodeTemplates.get("modacloudsDc_db"), expectedNodeTemplates.get("modacloudsDc_db")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_c3_2xlarge_ap_southeast_2"), expectedNodeTemplates.get("Amazon_EC2_c3_2xlarge_ap_southeast_2")); Map<String, Object> generatedGroups = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.GROUPS); Map<String, Object> expectedGroups = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.GROUPS); testSeaCloudsPolicy(generatedGroups); testMonitoringConfiguration(generatedGroups); testMonitorInitializationPolicy(generatedGroups, ImmutableList.of("php")); assertEquals(generatedGroups.get("operation_php"), expectedGroups.get("operation_php")); assertEquals(generatedGroups.get("operation_db"), expectedGroups.get("operation_db")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_c3_2xlarge_ap_southeast_2"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_c3_2xlarge_ap_southeast_2")); assertEquals(generatedGroups.get("add_brooklyn_location_php"), expectedGroups.get("add_brooklyn_location_php")); }
@Test(enabled = true) @SuppressWarnings("unchecked") public void testSplittedNuroGenerationForIaaS() throws Exception { String adp = new Scanner(new File(Resources.getResource("splitted-nuro/iaas/splittednuro_adp-iaas.yml").toURI())).useDelimiter("\\Z").next(); dam = damGenerator.generateDam(adp); template = YamlParser.load(dam); testMetadataTemplate(template); String expectedDamString = new Scanner(new File(Resources.getResource("splitted-nuro/iaas/splittednuro_dam-iaas.yml").toURI())).useDelimiter("\\Z").next(); Map<String, Object> expectedDam = YamlParser.load(expectedDamString); assertNotNull(template); Map<String, Object> generatedTopologyTemplate = (Map<String, Object>) template.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> expectedTopologyTemplate = (Map<String, Object>) expectedDam.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> generatedNodeTemplates = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); Map<String, Object> expectedNodeTemplates = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); assertEquals(generatedNodeTemplates.size(), 9); assertEquals(generatedNodeTemplates.get("nuro-gui"), expectedNodeTemplates.get("nuro-gui")); assertEquals(generatedNodeTemplates.get("modacloudsDc_nuro-gui"), expectedNodeTemplates.get("modacloudsDc_nuro-gui")); assertEquals(generatedNodeTemplates.get("nuro-api"), expectedNodeTemplates.get("nuro-api")); assertEquals(generatedNodeTemplates.get("modacloudsDc_nuro-api"), expectedNodeTemplates.get("modacloudsDc_nuro-api")); assertEquals(generatedNodeTemplates.get("db"), expectedNodeTemplates.get("db")); assertEquals(generatedNodeTemplates.get("modacloudsDc_db"), expectedNodeTemplates.get("modacloudsDc_db")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_m4_large_us_west_1"), expectedNodeTemplates.get("Amazon_EC2_m4_large_us_west_1")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_c3_large_ap_northeast_1"), expectedNodeTemplates.get("Amazon_EC2_c3_large_ap_northeast_1")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_r3_large_us_west_2"), expectedNodeTemplates.get("Amazon_EC2_r3_large_us_west_2")); Map<String, Object> generatedGroups = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.GROUPS); Map<String, Object> expectedGroups = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.GROUPS); testSeaCloudsPolicy(generatedGroups); testMonitoringConfiguration(generatedGroups); testMonitorInitializationPolicy(generatedGroups, ImmutableList.of("nuro-gui", "nuro-api")); assertEquals(generatedGroups.get("operation_db"), expectedGroups.get("operation_db")); assertEquals(generatedGroups.get("operation_nuro-api"), expectedGroups.get("operation_nuro-api")); assertEquals(generatedGroups.get("operation_nuro-gui"), expectedGroups.get("operation_nuro-gui")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_m4_large_us_west_1"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_m4_large_us_west_1")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_c3_large_ap_northeast_1"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_c3_large_ap_northeast_1")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_r3_large_us_west_2"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_r3_large_us_west_2")); }
@Test(enabled = true) @SuppressWarnings("unchecked") public void testSplittedNuroGenerationForPaaS() throws Exception { String adp = new Scanner(new File(Resources.getResource("splitted-nuro/paas/splittednuro_adp-paas.yml").toURI())).useDelimiter("\\Z").next(); dam = damGenerator.generateDam(adp); template = YamlParser.load(dam); testMetadataTemplate(template); String expectedDamString = new Scanner(new File(Resources.getResource("splitted-nuro/paas/splittednuro_dam-paas.yml").toURI())).useDelimiter("\\Z").next(); Map<String, Object> expectedDam = YamlParser.load(expectedDamString); assertNotNull(template); Map<String, Object> generatedTopologyTemplate = (Map<String, Object>) template.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> expectedTopologyTemplate = (Map<String, Object>) expectedDam.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> generatedNodeTemplates = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); Map<String, Object> expectedNodeTemplates = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); assertEquals(generatedNodeTemplates.size(), 6); assertEquals(generatedNodeTemplates.get("nuro-gui"), expectedNodeTemplates.get("nuro-gui")); assertEquals(generatedNodeTemplates.get("nuro-api"), expectedNodeTemplates.get("nuro-api")); assertEquals(generatedNodeTemplates.get("nuro-pma"), expectedNodeTemplates.get("nuro-pma")); assertEquals(generatedNodeTemplates.get("db"), expectedNodeTemplates.get("db")); assertEquals(generatedNodeTemplates.get("modacloudsDc_db"), expectedNodeTemplates.get("modacloudsDc_db")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_t2_small_eu_west_1"), expectedNodeTemplates.get("Amazon_EC2_t2_small_eu_west_1")); Map<String, Object> generatedGroups = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.GROUPS); Map<String, Object> expectedGroups = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.GROUPS); testSeaCloudsPolicy(generatedGroups); testMonitoringConfiguration(generatedGroups); testMonitorInitializationPolicy(generatedGroups, ImmutableList.of("nuro-gui", "nuro-api", "nuro-pma")); assertEquals(generatedGroups.get("operation_db"), expectedGroups.get("operation_db")); assertEquals(generatedGroups.get("operation_nuro-api"), expectedGroups.get("operation_nuro-api")); assertEquals(generatedGroups.get("operation_nuro-gui"), expectedGroups.get("operation_nuro-gui")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_t2_small_eu_west_1"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_t2_small_eu_west_1")); assertEquals(generatedGroups.get("add_brooklyn_location_nuro-api"), expectedGroups.get("add_brooklyn_location_nuro-api")); assertEquals(generatedGroups.get("add_brooklyn_location_nuro-gui"), expectedGroups.get("add_brooklyn_location_nuro-gui")); assertEquals(generatedGroups.get("add_brooklyn_location_nuro-pma"), expectedGroups.get("add_brooklyn_location_nuro-pma")); }
@Test @SuppressWarnings("unchecked") public void testSoftcareGenerationForIaaS() throws Exception { String adp = new Scanner(new File(Resources.getResource("softcare/iaas/softcare_adp-iaas.yml").toURI())).useDelimiter("\\Z").next(); dam = damGenerator.generateDam(adp); template = YamlParser.load(dam); testMetadataTemplate(template); String expectedDamString = new Scanner(new File(Resources.getResource("softcare/iaas/softcare_dam-iaas.yml").toURI())).useDelimiter("\\Z").next(); Map<String, Object> expectedDam = YamlParser.load(expectedDamString); assertNotNull(template); Map<String, Object> generatedTopologyTemplate = (Map<String, Object>) template.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> expectedTopologyTemplate = (Map<String, Object>) expectedDam.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> generatedNodeTemplates = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); Map<String, Object> expectedNodeTemplates = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); assertEquals(generatedNodeTemplates.size(), 15); assertEquals(generatedNodeTemplates.get("Softcare_dashboard"), expectedNodeTemplates.get("Softcare_dashboard")); assertEquals(generatedNodeTemplates.get("modacloudsDc_Softcare_dashboard"), expectedNodeTemplates.get("modacloudsDc_Softcare_dashboard")); assertEquals(generatedNodeTemplates.get("Forum"), expectedNodeTemplates.get("Forum")); assertEquals(generatedNodeTemplates.get("modacloudsDc_Forum"), expectedNodeTemplates.get("modacloudsDc_Forum")); assertEquals(generatedNodeTemplates.get("SoftcareWS"), expectedNodeTemplates.get("SoftcareWS")); assertEquals(generatedNodeTemplates.get("modacloudsDc_SoftcareWS"), expectedNodeTemplates.get("modacloudsDc_SoftcareWS")); assertEquals(generatedNodeTemplates.get("ForumDB"), expectedNodeTemplates.get("ForumDB")); assertEquals(generatedNodeTemplates.get("modacloudsDc_ForumDB"), expectedNodeTemplates.get("modacloudsDc_ForumDB")); assertEquals(generatedNodeTemplates.get("SoftcareDB"), expectedNodeTemplates.get("SoftcareDB")); assertEquals(generatedNodeTemplates.get("modacloudsDc_SoftcareDB"), expectedNodeTemplates.get("modacloudsDc_SoftcareDB")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_m3_medium_ap_southeast_2"), expectedNodeTemplates.get("Amazon_EC2_m3_medium_ap_southeast_2")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_t2_medium_us_east_1"), expectedNodeTemplates.get("Amazon_EC2_t2_medium_us_east_1")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_t2_large_us_west_1"), expectedNodeTemplates.get("Amazon_EC2_t2_large_us_west_1")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_m3_large_eu_central_1"), expectedNodeTemplates.get("Amazon_EC2_m3_large_eu_central_1")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_m4_large_us_west_1"), expectedNodeTemplates.get("Amazon_EC2_m4_large_us_west_1")); Map<String, Object> generatedGroups = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.GROUPS); Map<String, Object> expectedGroups = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.GROUPS); testSeaCloudsPolicy(generatedGroups); testMonitoringConfiguration(generatedGroups); testMonitorInitializationPolicy(generatedGroups, ImmutableList.of("Softcare_dashboard", "Forum", "SoftcareWS")); assertEquals(generatedGroups.size(), 14); assertEquals(generatedGroups.get("operation_ForumDB"), expectedGroups.get("operation_ForumDB")); assertEquals(generatedGroups.get("operation_SoftcareDB"), expectedGroups.get("operation_SoftcareDB")); assertEquals(generatedGroups.get("operation_Forum"), expectedGroups.get("operation_Forum")); assertEquals(generatedGroups.get("operation_SoftcareWS"), expectedGroups.get("operation_SoftcareWS")); assertEquals(generatedGroups.get("operation_Softcare_dashboard"), expectedGroups.get("operation_Softcare_dashboard")); assertEquals(generatedGroups.get("seaclouds_configuration_policy"), expectedGroups.get("seaclouds_configuration_policy")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_m3_medium_ap_southeast_2"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_m3_medium_ap_southeast_2")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_t2_medium_us_east_1"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_t2_medium_us_east_1")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_t2_large_us_west_1"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_t2_large_us_west_1")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_m3_large_eu_central_1"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_m3_large_eu_central_1")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_m4_large_us_west_1"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_m4_large_us_west_1")); }
@Test @SuppressWarnings("unchecked") public void testSoftcareGenerationForPaaS() throws Exception { String adp = new Scanner(new File(Resources.getResource("softcare/paas/softcare_adp-paas.yml").toURI())).useDelimiter("\\Z").next(); dam = damGenerator.generateDam(adp); template = YamlParser.load(dam); testMetadataTemplate(template); String expectedDamString = new Scanner(new File(Resources.getResource("softcare/paas/softcare_dam-paas.yml").toURI())).useDelimiter("\\Z").next(); Map<String, Object> expectedDam = YamlParser.load(expectedDamString); assertNotNull(template); Map<String, Object> generatedTopologyTemplate = (Map<String, Object>) template.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> expectedTopologyTemplate = (Map<String, Object>) expectedDam.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> generatedNodeTemplates = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); Map<String, Object> expectedNodeTemplates = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); assertEquals(generatedNodeTemplates.size(), 9); assertEquals(generatedNodeTemplates.get("Softcare_dashboard"), expectedNodeTemplates.get("Softcare_dashboard")); assertEquals(generatedNodeTemplates.get("Forum"), expectedNodeTemplates.get("Forum")); assertEquals(generatedNodeTemplates.get("SoftcareWS"), expectedNodeTemplates.get("SoftcareWS")); assertEquals(generatedNodeTemplates.get("ForumDB"), expectedNodeTemplates.get("ForumDB")); assertEquals(generatedNodeTemplates.get("modacloudsDc_ForumDB"), expectedNodeTemplates.get("modacloudsDc_ForumDB")); assertEquals(generatedNodeTemplates.get("SoftcareDB"), expectedNodeTemplates.get("SoftcareDB")); assertEquals(generatedNodeTemplates.get("modacloudsDc_SoftcareDB"), expectedNodeTemplates.get("modacloudsDc_SoftcareDB")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_t2_micro_eu_central_1"), expectedNodeTemplates.get("Amazon_EC2_t2_micro_eu_central_1")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_t2_micro_ap_northeast_1"), expectedNodeTemplates.get("Amazon_EC2_t2_micro_ap_northeast_1")); Map<String, Object> generatedGroups = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.GROUPS); Map<String, Object> expectedGroups = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.GROUPS); testSeaCloudsPolicy(generatedGroups); testMonitoringConfiguration(generatedGroups); testMonitorInitializationPolicy(generatedGroups, ImmutableList.of("Softcare_dashboard", "Forum", "SoftcareWS")); assertEquals(generatedGroups.size(), 14); assertEquals(generatedGroups.get("operation_ForumDB"), expectedGroups.get("operation_ForumDB")); assertEquals(generatedGroups.get("operation_SoftcareDB"), expectedGroups.get("operation_SoftcareDB")); assertEquals(generatedGroups.get("operation_Forum"), expectedGroups.get("operation_Forum")); assertEquals(generatedGroups.get("operation_SoftcareWS"), expectedGroups.get("operation_SoftcareWS")); assertEquals(generatedGroups.get("operation_Softcare_dashboard"), expectedGroups.get("operation_Softcare_dashboard")); assertEquals(generatedGroups.get("seaclouds_configuration_policy"), expectedGroups.get("seaclouds_configuration_policy")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_t2_micro_eu_central_1"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_t2_micro_eu_central_1")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_t2_micro_ap_northeast_1"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_t2_micro_ap_northeast_1")); assertEquals(generatedGroups.get("add_brooklyn_location_Forum"), expectedGroups.get("add_brooklyn_location_Forum")); assertEquals(generatedGroups.get("add_brooklyn_location_SoftcareWS"), expectedGroups.get("add_brooklyn_location_SoftcareWS")); assertEquals(generatedGroups.get("add_brooklyn_location_Softcare_dashboard"), expectedGroups.get("add_brooklyn_location_Softcare_dashboard")); }
@Test(enabled = true) @SuppressWarnings("unchecked") public void testWebChatGenerationForIaaS() throws Exception { String adp = new Scanner(new File(Resources.getResource("webchat/iaas/webchat_adp-iaas.yml").toURI())).useDelimiter("\\Z").next(); dam = damGenerator.generateDam(adp); template = YamlParser.load(dam); testMetadataTemplate(template); String expectedDamString = new Scanner(new File(Resources.getResource("webchat/iaas/webchat_dam-iaas.yml").toURI())).useDelimiter("\\Z").next(); Map<String, Object> expectedDam = YamlParser.load(expectedDamString); assertNotNull(template); Map<String, Object> generatedTopologyTemplate = (Map<String, Object>) template.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> expectedTopologyTemplate = (Map<String, Object>) expectedDam.get(DamGenerator.TOPOLOGY_TEMPLATE); Map<String, Object> generatedNodeTemplates = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); Map<String, Object> expectedNodeTemplates = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.NODE_TEMPLATES); assertEquals(generatedNodeTemplates.size(), 6); assertEquals(generatedNodeTemplates.get("Chat"), expectedNodeTemplates.get("Chat")); assertEquals(generatedNodeTemplates.get("MessageDatabase"), expectedNodeTemplates.get("MessageDatabase")); assertEquals(generatedNodeTemplates.get("modacloudsDc_Chat"), expectedNodeTemplates.get("modacloudsDc_Chat")); assertEquals(generatedNodeTemplates.get("modacloudsDc_MessageDatabase"), expectedNodeTemplates.get("modacloudsDc_MessageDatabase")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_c1_medium_sa_east_1"), expectedNodeTemplates.get("Amazon_EC2_c1_medium_sa_east_1")); assertEquals(generatedNodeTemplates.get("Amazon_EC2_c1_medium_us_west_2"), expectedNodeTemplates.get("Amazon_EC2_c1_medium_us_west_2")); Map<String, Object> generatedGroups = (Map<String, Object>) generatedTopologyTemplate.get(DamGenerator.GROUPS); Map<String, Object> expectedGroups = (Map<String, Object>) expectedTopologyTemplate.get(DamGenerator.GROUPS); testSeaCloudsPolicy(generatedGroups); testMonitoringConfiguration(generatedGroups); testMonitorInitializationPolicy(generatedGroups, ImmutableList.of("Chat")); assertEquals(generatedGroups.get("operation_Chat"), expectedGroups.get("operation_Chat")); assertEquals(generatedGroups.get("operation_MessageDatabase"), expectedGroups.get("operation_MessageDatabase")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_c1_medium_us_west_2"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_c1_medium_us_west_2")); assertEquals(generatedGroups.get("add_brooklyn_location_Amazon_EC2_c1_medium_sa_east_1"), expectedGroups.get("add_brooklyn_location_Amazon_EC2_c1_medium_sa_east_1")); }