src/test/java/nl/uva/qcdis/sdia/commons/utils/ToscaHelperTest.java
/**
     * Test of setCredentialsInVMTopology method, of class ToscaHelper.
     *
     * @throws java.lang.Exception
     */
Test of setCredentialsInVMTopology method, of class ToscaHelper.
Test of setCredentialsInVMTopology method of class ToscaHelper .
@Test
    public void testSetCredentialsAndInterface() throws Exception {
        if (serviceUp) {
            toscaTemplateWithCredentials = null;
            System.out.println("setCredentialsInVMTopology");
            instance.uploadToscaTemplate(toscaTemplatea2TVMopologies);
            List<NodeTemplateMap> vmTopologies = instance.getVMTopologyTemplates();
            for (NodeTemplateMap vmTopologyMap : vmTopologies) {
                String provider = instance.getTopologyProvider(vmTopologyMap);
                Credential credential = new Credential();
                credential.setCloudProviderName(provider);
                credential.setProtocol("protocol");
                Map<String, String> keys = new HashMap<>();
                keys.put("key1", "eeeeeeavovfouirveiuvbepuyb8rwqovd8boacbdbvwy8oqry7f08r3euadinanzxcjc078yn0183xoqedw");
                credential.setKeys(keys);
                credential.setToken("ijwbfciweubfriw");
                credential.setTokenType("passwrd");
                credential.setUser("user");
                vmTopologyMap = instance.setCredentialsInVMTopology(vmTopologyMap, credential);
                toscaTemplateWithCredentials = instance.setNodeInToscaTemplate(toscaTemplatea2TVMopologies, vmTopologyMap);
            }
            instance.uploadToscaTemplate(toscaTemplateWithCredentials);
            NodeTemplate topology_1 = toscaTemplateWithCredentials.getTopologyTemplate().getNodeTemplates().get("topology_1");
            Map<String, Object> attributes = topology_1.getAttributes();
            assertNotNull(attributes);
            assertNotNull(attributes.get("credentials"));
            NodeTemplate topology = toscaTemplateWithCredentials.getTopologyTemplate().getNodeTemplates().get("topology");
            attributes = topology.getAttributes();
            assertNotNull(attributes);
            assertNotNull(attributes.get("credentials"));
            List<NodeTemplateMap> vmTopologiesMaps = instance.getVMTopologyTemplates();
            for (NodeTemplateMap vmTopologyMap : vmTopologiesMaps) {
                List<Credential> toscaCredentials = instance.getCredentialsFromVMTopology(vmTopologyMap);
                assertNotNull(toscaCredentials);
            }
            vmTopologies = instance.getVMTopologyTemplates();
            ToscaTemplate toscaTemplateWithInterface = null;
            Provisioner provisioner = new Provisioner();
            provisioner.setName("CloudsStorm");
            provisioner.setDescription("Interface for VM topology management with "
                    + "CloudsStorm. More at https:cloudsstorm.github.io/");
            provisioner.setToscaInterfaceType(CLOUD_STORM_INTERFACE);
            String operation = "provision";
            topology = toscaTemplateWithCredentials.getTopologyTemplate().getNodeTemplates().get("topology");
            instance.uploadToscaTemplate(toscaTemplatea2TVMopologies);
        }
    }
@ Test public void testSetCredentialsAndInterface ( ) throws Exception { if ( serviceUp ) { toscaTemplateWithCredentials = null ; System . out . println ( "setCredentialsInVMTopology" ) ; instance . uploadToscaTemplate ( toscaTemplatea2TVMopologies ) ; List < NodeTemplateMap > vmTopologies = instance . getVMTopologyTemplates ( ) ; for ( NodeTemplateMap vmTopologyMap : vmTopologies ) { String provider = instance . getTopologyProvider ( vmTopologyMap ) ; Credential credential = new Credential ( ) ; credential . setCloudProviderName ( provider ) ; credential . setProtocol ( "protocol" ) ; Map < String , String > keys = new HashMap < > ( ) ; keys . put ( "key1" , "eeeeeeavovfouirveiuvbepuyb8rwqovd8boacbdbvwy8oqry7f08r3euadinanzxcjc078yn0183xoqedw" ) ; credential . setKeys ( keys ) ; credential . setToken ( "ijwbfciweubfriw" ) ; credential . setTokenType ( "passwrd" ) ; credential . setUser ( "user" ) ; vmTopologyMap = instance . setCredentialsInVMTopology ( vmTopologyMap , credential ) ; toscaTemplateWithCredentials = instance . setNodeInToscaTemplate ( toscaTemplatea2TVMopologies , vmTopologyMap ) ; } instance . uploadToscaTemplate ( toscaTemplateWithCredentials ) ; NodeTemplate topology_1 = toscaTemplateWithCredentials . getTopologyTemplate ( ) . getNodeTemplates ( ) . get ( "topology_1" ) ; Map < String , Object > attributes = topology_1 . getAttributes ( ) ; assertNotNull ( attributes ) ; assertNotNull ( attributes . get ( "credentials" ) ) ; NodeTemplate topology = toscaTemplateWithCredentials . getTopologyTemplate ( ) . getNodeTemplates ( ) . get ( "topology" ) ; attributes = topology . getAttributes ( ) ; assertNotNull ( attributes ) ; assertNotNull ( attributes . get ( "credentials" ) ) ; List < NodeTemplateMap > vmTopologiesMaps = instance . getVMTopologyTemplates ( ) ; for ( NodeTemplateMap vmTopologyMap : vmTopologiesMaps ) { List < Credential > toscaCredentials = instance . getCredentialsFromVMTopology ( vmTopologyMap ) ; assertNotNull ( toscaCredentials ) ; } vmTopologies = instance . getVMTopologyTemplates ( ) ; ToscaTemplate toscaTemplateWithInterface = null ; Provisioner provisioner = new Provisioner ( ) ; provisioner . setName ( "CloudsStorm" ) ; provisioner . setDescription ( "Interface for VM topology management with " + "CloudsStorm. More at https://cloudsstorm.github.io/" ) ; provisioner . setToscaInterfaceType ( CLOUD_STORM_INTERFACE ) ; String operation = "provision" ; instance . uploadToscaTemplate ( toscaTemplatea2TVMopologies ) ; } }
Test of setCredentialsInVMTopology method, of class ToscaHelper.
Test of setCredentialsInVMTopology method of class ToscaHelper .
//            for (NodeTemplateMap vmTopologyMap : vmTopologies) { //                Map<String, Object> provisionInterface = instance.getProvisionInterface(provisioner, operation); //                List<String> objects = new ArrayList<>(); //                objects.add("subtopology"); //                String key = provisionInterface.keySet().iterator().next(); //                Map<String, Object> provisionOperation = (Map<String, Object>) provisionInterface.get(key); //                Map<String, Object> operationMap = (Map<String, Object>) provisionOperation.get(operation); //                List<Map<String, Object>> inputs = (List<Map<String, Object>>) operationMap.get("inputs"); //                for (Map<String, Object> input : inputs) { //                    if (input.containsKey("objects")) { //                        input.put("objects", objects); //                        break; //                    } //                } //                vmTopologyMap = instance.setProvisionerInterfaceInVMTopology(vmTopologyMap, provisionInterface); //                toscaTemplateWithInterface = instance.setNodeInToscaTemplate(toscaTemplatea2TVMopologies, vmTopologyMap); ////            } //            instance.uploadToscaTemplate(toscaTemplateWithInterface); //            topology_1 = toscaTemplateWithCredentials.getTopologyTemplate().getNodeTemplates().get("topology_1"); // //            topology = toscaTemplateWithCredentials.getTopologyTemplate().getNodeTemplates().get("topology");