package org.opennaas.itests.roadm.helpers; /* * #%L * OpenNaaS :: iTests :: ROADM * %% * Copyright (C) 2007 - 2014 FundaciĆ³ Privada i2CAT, Internet i InnovaciĆ³ a Catalunya * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #L% */ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.opennaas.core.resources.ResourceIdentifier; import org.opennaas.core.resources.descriptor.CapabilityDescriptor; import org.opennaas.core.resources.descriptor.CapabilityProperty; import org.opennaas.core.resources.descriptor.Information; import org.opennaas.core.resources.descriptor.ResourceDescriptor; import org.opennaas.core.resources.descriptor.ResourceDescriptorConstants; //FIXME: We need to know how a resource has to be filled. public class CapabilityHelper { static Log log = LogFactory .getLog(CapabilityHelper.class); public static ResourceDescriptor newResourceDescriptor(String type) { ResourceDescriptor resourceDescriptor = new ResourceDescriptor(); Map<String, String> properties = new HashMap<String, String>(); List<CapabilityDescriptor> capabilityDescriptors = new ArrayList<CapabilityDescriptor>(); capabilityDescriptors.add(newCapabilityDescriptorProteus("connections")); capabilityDescriptors.add(newCapabilityDescriptorProteus("queue")); resourceDescriptor.setCapabilityDescriptors(capabilityDescriptors); /* FIXME PUT PROTOCOL_URI IN RESOURCE DESCRIPTOR CONSTANTS */ properties.put(ResourceDescriptorConstants.PROTOCOL_URI, "user:pass@host.net:2212"); resourceDescriptor.setProperties(properties); ResourceIdentifier identifier = new ResourceIdentifier(type); resourceDescriptor.setId(identifier.getId()); /* information. It is only necessary to add type */ Information information = new Information(); information.setType(type); information.setName("Junos Test"); resourceDescriptor.setInformation(information); return resourceDescriptor; } public static CapabilityDescriptor newCapabilityDescriptorProteus(String type) { CapabilityDescriptor capabilityDescriptor = new CapabilityDescriptor(); CapabilityProperty property = new CapabilityProperty( ResourceDescriptorConstants.ACTION_NAME, "proteus"); capabilityDescriptor.getCapabilityProperties().add(property); property = new CapabilityProperty( ResourceDescriptorConstants.ACTION_VERSION, "1.0"); capabilityDescriptor.getCapabilityProperties().add(property); Information capabilityInformation = new Information(); capabilityInformation.setType(type); capabilityDescriptor.setCapabilityInformation(capabilityInformation); return capabilityDescriptor; } public static CapabilityDescriptor newCapabilityDescriptorJunos(String type) { CapabilityDescriptor capabilityDescriptor = new CapabilityDescriptor(); CapabilityProperty property = new CapabilityProperty( ResourceDescriptorConstants.ACTION_NAME, "junos"); capabilityDescriptor.getCapabilityProperties().add(property); property = new CapabilityProperty( ResourceDescriptorConstants.ACTION_VERSION, "1.0"); capabilityDescriptor.getCapabilityProperties().add(property); Information capabilityInformation = new Information(); capabilityInformation.setType(type); capabilityDescriptor.setCapabilityInformation(capabilityInformation); return capabilityDescriptor; } }