diff options
author | ChrisC <cc697w@intl.att.com> | 2017-01-31 11:40:03 +0100 |
---|---|---|
committer | ChrisC <cc697w@intl.att.com> | 2017-01-31 12:59:33 +0100 |
commit | 025301d08b061482c1f046d562bf017c8cbcfe8d (patch) | |
tree | 68a2a549736c9bf0f7cd4e71c76e40ef7e2606f2 /adapters | |
parent | 2754ad52f833278a5c925bd788a16d1dce16a598 (diff) |
Initial OpenECOMP MSO commit
Change-Id: Ia6a7574859480717402cc2f22534d9973a78fa6d
Signed-off-by: ChrisC <cc697w@intl.att.com>
Diffstat (limited to 'adapters')
438 files changed, 53155 insertions, 0 deletions
diff --git a/adapters/mso-adapter-utils/README b/adapters/mso-adapter-utils/README new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/adapters/mso-adapter-utils/README diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml new file mode 100644 index 0000000000..24641756ec --- /dev/null +++ b/adapters/mso-adapter-utils/pom.xml @@ -0,0 +1,137 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp.mso</groupId> + <artifactId>adapters</artifactId> + <version>0.0.4-SNAPSHOT</version> + </parent> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <name>mso-adapter-utils</name> + <description>Common MSO utilities, including Openstack client wrappers.</description> + + <build> + <finalName>${project.artifactId}</finalName> + <sourceDirectory>src/main/java</sourceDirectory> + <plugins> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <version>2.6</version> + <executions> + <execution> + <id>copy-resources</id> + <phase>validate</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <resources> + <resource> + <directory>./src/main/resources/META-INF</directory> + <filtering>false</filtering> + </resource> + </resources> + <outputDirectory>${project.build.directory}/${project.build.finalName}/META-INF/</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>2.3</version> + <configuration> + <warSourceDirectory>WebContent</warSourceDirectory> + <failOnMissingWebXml>false</failOnMissingWebXml> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.openecomp.mso.libs.openstack-java-sdk</groupId> + <artifactId>keystone-client</artifactId> + <version>3.2.4</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso.libs.openstack-java-sdk</groupId> + <artifactId>heat-client</artifactId> + <version>3.2.4</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso.libs.openstack-java-sdk</groupId> + <artifactId>quantum-client</artifactId> + <version>3.2.4</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso.libs.openstack-java-sdk.client-connectors</groupId> + <artifactId>http-connector</artifactId> + <version>3.2.4</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>common</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>mso-catalog-db</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.resteasy</groupId> + <artifactId>resteasy-jaxrs</artifactId> + <version>3.0.19.Final</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </exclusion> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <version>1.10.19</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.jboss.spec.javax.ejb</groupId> + <artifactId>jboss-ejb-api_3.2_spec</artifactId> + <version>1.0.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.ejb3</groupId> + <artifactId>jboss-ejb3-ext-api</artifactId> + <version>2.2.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.yaml</groupId> + <artifactId>snakeyaml</artifactId> + <version>1.15</version> + </dependency> + + </dependencies> +</project> diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java new file mode 100644 index 0000000000..abcea2d494 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java @@ -0,0 +1,262 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.cloud; + +import java.io.FileReader; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.annotate.JsonRootName; + +import org.openecomp.mso.logger.MsoLogger; + +/** + * JavaBean JSON class for a CloudConfig. This bean maps a JSON-format cloud + * configuration file to Java. The CloudConfig contains information about + * Openstack cloud configurations (in particular for the NVP/AIC cloud). + * It includes: + * - CloudIdentity objects, representing DCP nodes (Openstack Identity Service) + * - CloudSite objects, representing LCP nodes (Openstack Compute & other services) + * + * Note that this is only used to access Cloud Configurations loaded from a + * JSON config file, so there are no explicit property setters. + * + * This class also contains methods to query cloud sites and/or identity + * services by ID. + * + */ + +@JsonRootName("cloud_config") +public class CloudConfig { + + @JsonProperty("identity_services") + private Map <String, CloudIdentity> identityServices = new HashMap <String, CloudIdentity> (); + @JsonProperty("cloud_sites") + private Map <String, CloudSite> cloudSites = new HashMap <String, CloudSite> (); + + private static ObjectMapper mapper = new ObjectMapper (); + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + + protected String configFilePath; + + protected int refreshTimerInMinutes; + + public CloudConfig () { + mapper.enable (DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + mapper.enable (DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + } + + /** + * Get a Map of all IdentityServices that have been loaded. + * @return the Map + */ + public synchronized Map <String, CloudIdentity> getIdentityServices () { + return identityServices; + } + + /** + * Get a Map of all CloudSites that have been loaded. + * @return the Map + */ + public synchronized Map <String, CloudSite> getCloudSites () { + return cloudSites; + } + + /** + * Get a specific CloudSites, based on an ID. The ID is first checked against + * the regions, and if no match is found there, then against individual entries + * to try and find one with a CLLI that matches the ID and an AIC version of 2.5. + * @param id the ID to match + * @return a CloudSite, or null of no match found + */ + public synchronized CloudSite getCloudSite (String id) { + if (id != null) { + if (cloudSites.containsKey (id)) { + return cloudSites.get (id); + } + // check for id == CLLI now as well + return getCloudSiteWithClli(id, "2.5"); + } + return null; + } + + /** + * Get a specific CloudSites, based on a CLLI and (optional) version, which will be matched + * against the aic_version field of the CloudSite. + * @param clli the CLLI to match + * @param version the version to match; may be null in which case any version matches + * @return a CloudSite, or null of no match found + */ + public synchronized CloudSite getCloudSiteWithClli(String clli, String version) { + if (clli != null) { + // New with 1610 - find cloud site called "DEFAULT" - return that object, + // with the name modified to match what they asked for. We're looping thru + // the cloud sites anyway - so save off the default one in case we need it. + CloudSite defaultCloudSite = null; + for (CloudSite cs : cloudSites.values()) { + if (cs.getClli() != null && clli.equals(cs.getClli())) { + if (version == null || version.equals(cs.getAic_version())) { + return cs; + } + } else if (cs.getId().equalsIgnoreCase("default")) { + // save it off in case we need it + defaultCloudSite = cs.clone(); + } + } + // If we get here - we didn't find a match - so return the default cloud site + if (defaultCloudSite != null) { + defaultCloudSite.setRegionId(clli); + defaultCloudSite.setId(clli); + } + return defaultCloudSite; + } + return null; + } + + /** + * Get a specific CloudIdentity, based on an ID. + * @param id the ID to match + * @return a CloudIdentity, or null of no match found + */ + public synchronized CloudIdentity getIdentityService (String id) { + if (identityServices.containsKey (id)) { + return identityServices.get (id); + } + return null; + } + + protected synchronized void reloadPropertiesFile() throws JsonParseException, JsonMappingException, IOException { + this.loadCloudConfig(this.configFilePath, this.refreshTimerInMinutes); + } + + protected synchronized void loadCloudConfig (String configFile, int refreshTimer) throws JsonParseException, JsonMappingException, IOException { + + FileReader reader=null; + configFilePath=configFile; + this.refreshTimerInMinutes = refreshTimer; + + CloudConfig cloudConfig = null; + + try { + reader = new FileReader (configFile); + // Parse the JSON input into a CloudConfig + + cloudConfig = mapper.readValue (reader, CloudConfig.class); + + this.cloudSites = cloudConfig.cloudSites; + this.identityServices = cloudConfig.identityServices; + + // Copy Cloud Identity IDs to CloudIdentity objects + for (Entry <String, CloudIdentity> entry : cloudConfig.getIdentityServices ().entrySet ()) { + entry.getValue ().setId (entry.getKey ()); + } + + // Copy Cloud Site IDs to CloudSite objects, and set up internal + // pointers to their corresponding identity service. + for (Entry <String, CloudSite> entry : cloudConfig.getCloudSites ().entrySet ()) { + CloudSite s = entry.getValue (); + s.setId (entry.getKey ()); + s.setIdentityService (cloudConfig.getIdentityService (s.getIdentityServiceId ())); + } + } finally { + try { + if (reader != null) { + reader.close(); + } + } catch (IOException e) { + LOGGER.debug("Exception while closing reader for file:" + configFilePath, e); + } + } + } + + public String getConfigFilePath() { + return configFilePath; + } + + @Override + public synchronized CloudConfig clone() { + CloudConfig ccCopy = new CloudConfig(); + for (Entry<String,CloudIdentity> e:identityServices.entrySet()) { + + ccCopy.identityServices.put(e.getKey(), e.getValue().clone()); + } + + for (Entry<String,CloudSite> e:cloudSites.entrySet()) { + + ccCopy.cloudSites.put(e.getKey(), e.getValue().clone()); + } + + ccCopy.configFilePath = this.configFilePath; + + ccCopy.refreshTimerInMinutes = this.refreshTimerInMinutes; + + return ccCopy; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((cloudSites == null) ? 0 : cloudSites.hashCode()); + result = prime * result + ((configFilePath == null) ? 0 : configFilePath.hashCode()); + result = prime * result + ((identityServices == null) ? 0 : identityServices.hashCode()); + result = prime * result + refreshTimerInMinutes; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CloudConfig other = (CloudConfig) obj; + if (cloudSites == null) { + if (other.cloudSites != null) + return false; + } else if (!cloudSites.equals(other.cloudSites)) + return false; + if (configFilePath == null) { + if (other.configFilePath != null) + return false; + } else if (!configFilePath.equals(other.configFilePath)) + return false; + if (identityServices == null) { + if (other.identityServices != null) + return false; + } else if (!identityServices.equals(other.identityServices)) + return false; + if (refreshTimerInMinutes != other.refreshTimerInMinutes) + return false; + return true; + } +} + diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java new file mode 100644 index 0000000000..6ee6721083 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java @@ -0,0 +1,226 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.cloud; + + +import java.io.IOException; +import java.io.Serializable; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +import javax.ejb.ConcurrencyManagement; +import javax.ejb.ConcurrencyManagementType; +import javax.ejb.LocalBean; +import javax.ejb.Schedule; +import javax.ejb.Singleton; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Response; + +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.map.JsonMappingException; + +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.utils.MsoHeatUtils; +import org.openecomp.mso.openstack.utils.MsoKeystoneUtils; +import org.openecomp.mso.openstack.utils.MsoNeutronUtils; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.logger.MessageEnum; + +/** + * This class returns a cloud Config instances + * + * + */ + +@Singleton(name = "CloudConfigFactory") +@ConcurrencyManagement(ConcurrencyManagementType.BEAN) +@LocalBean +@Path("/cloud") +public class CloudConfigFactory implements Serializable { + + private static final long serialVersionUID = 2956662716453261085L; + + private static CloudConfig cloudConfigCache = new CloudConfig (); + + protected static String prefixMsoPropertiesPath = System.getProperty ("mso.config.path"); + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + + private static int refreshTimer; + + private static final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock (); + + static { + if (prefixMsoPropertiesPath == null) { + prefixMsoPropertiesPath = ""; + } + } + + public void initializeCloudConfig (String filePath, int refreshTimer) { + + rwl.writeLock ().lock (); + try { + cloudConfigCache.loadCloudConfig (prefixMsoPropertiesPath + filePath, refreshTimer); + LOGGER.info (MessageEnum.RA_CONFIG_LOAD, prefixMsoPropertiesPath + filePath, "", ""); + } catch (JsonParseException e) { + LOGGER.error (MessageEnum.RA_CONFIG_EXC, "Error parsing cloud config file " + filePath, "", "", MsoLogger.ErrorCode.DataError, "Exception - JsonParseException", e); + } catch (JsonMappingException e) { + LOGGER.error (MessageEnum.RA_CONFIG_EXC, "Error parsing cloud config file " + filePath, "", "", MsoLogger.ErrorCode.DataError, "Exception - JsonMappingException", e); + } catch (IOException e) { + LOGGER.error (MessageEnum.RA_CONFIG_NOT_FOUND, filePath, "", "", MsoLogger.ErrorCode.DataError, "Exception - config not found", e); + } finally { + rwl.writeLock ().unlock (); + } + } + + public void changeMsoPropertiesFilePath (String newMsoPropPath) throws MsoPropertiesException { + rwl.writeLock ().lock (); + try { + CloudConfigFactory.cloudConfigCache.configFilePath = prefixMsoPropertiesPath + newMsoPropPath; + } finally { + rwl.writeLock ().unlock (); + } + } + + public CloudConfigFactory () { + } + + public CloudConfig getCloudConfig () { + rwl.readLock ().lock (); + try { + return cloudConfigCache.clone (); + } finally { + rwl.readLock ().unlock (); + } + } + + /** + * This method is not intended to be called, it's used to refresh the config + * automatically + * + * @return true if Properties have been reloaded, false otherwise + */ + @Schedule(minute = "*/1", hour = "*", persistent = false) + public void reloadCloudConfig () { + + try { + if (!rwl.writeLock ().tryLock () && !rwl.writeLock ().tryLock (30L, TimeUnit.SECONDS)) { + LOGGER.debug ("Busy write lock on mso cloud config factory, skipping the reloading"); + return; + } + } catch (InterruptedException e1) { + LOGGER.debug ("Interrupted while trying to acquire write lock on cloud config factory, skipping the reloading"); + Thread.currentThread ().interrupt (); + return; + } + try { + //LOGGER.debug ("Processing a reload of the mso properties file entries"); + try { + + if (refreshTimer <= 1) { + CloudConfig oldCloudConfig = cloudConfigCache.clone(); + cloudConfigCache.reloadPropertiesFile (); + refreshTimer = cloudConfigCache.refreshTimerInMinutes; + if (!cloudConfigCache.equals(oldCloudConfig)) { + LOGGER.info (MessageEnum.RA_CONFIG_LOAD, prefixMsoPropertiesPath + cloudConfigCache.configFilePath, "", ""); + } + + } else { + --refreshTimer; + } + + } catch (JsonParseException e) { + LOGGER.error (MessageEnum.RA_CONFIG_EXC, + "Error parsing cloud config file " + cloudConfigCache.configFilePath, "", "", MsoLogger.ErrorCode.DataError, "Exception - JsonParseException", + e); + } catch (JsonMappingException e) { + LOGGER.error (MessageEnum.RA_CONFIG_EXC, + "Error parsing cloud config file " + cloudConfigCache.configFilePath, "", "", MsoLogger.ErrorCode.DataError, "Exception - JsonMappingException", + e); + } catch (IOException e) { + LOGGER.error (MessageEnum.RA_CONFIG_NOT_FOUND, cloudConfigCache.configFilePath, "", "", MsoLogger.ErrorCode.DataError, "Exception - config not found", e); + } + } catch (Exception e) { + LOGGER.error (MessageEnum.LOAD_PROPERTIES_FAIL, "Unknown. Global issue while reloading", "", "", MsoLogger.ErrorCode.DataError, "Exception - Global issue while reloading\"", e); + } finally { + rwl.writeLock ().unlock (); + } + } + + @GET + @Path("/showConfig") + @Produces("text/plain") + public Response showCloudConfig () { + CloudConfig cloudConfig = this.getCloudConfig (); + + StringBuffer response = new StringBuffer (); + response.append ("Cloud Sites:\n"); + for (CloudSite site : cloudConfig.getCloudSites ().values ()) { + response.append (site.toString () + "\n"); + } + + response.append ("\n\nCloud Identity Services:\n"); + for (CloudIdentity identity : cloudConfig.getIdentityServices ().values ()) { + response.append (identity.toString () + "\n"); + } + + return Response.status (200).entity (response).build (); + } + + @GET + @Path("/resetClientCaches") + @Produces("text/plain") + public Response resetClientCaches () { + // Reset all cached clients/credentials + MsoKeystoneUtils.adminCacheReset (); + MsoHeatUtils.heatCacheReset (); + MsoNeutronUtils.neutronCacheReset (); + + String response = "Client caches reset. All entries removed."; + return Response.status (200).entity (response).build (); + } + + @GET + @Path("/cleanupClientCaches") + @Produces("text/plain") + public Response cleanupClientCaches () { + // Reset all cached clients/credentials + MsoKeystoneUtils.adminCacheCleanup (); + MsoHeatUtils.heatCacheCleanup (); + MsoNeutronUtils.neutronCacheCleanup (); + + String response = "Client caches cleaned up. All expired entries removed"; + return Response.status (200).entity (response).build (); + } + + @GET + @Path("/encryptPassword/{pwd}") + @Produces("text/plain") + public Response encryptPassword (@PathParam("pwd") String pwd) { + String encryptedPassword = CloudIdentity.encryptPassword (pwd); + + String response = "Encrypted Password = " + encryptedPassword; + return Response.status (200).entity (response).build (); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java new file mode 100644 index 0000000000..a777e4133c --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java @@ -0,0 +1,316 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.cloud; + +import java.security.GeneralSecurityException; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import com.woorea.openstack.keystone.model.authentication.RackspaceAuthentication; +import com.woorea.openstack.keystone.model.authentication.UsernamePassword; +import org.openecomp.mso.utils.CryptoUtils; +import com.woorea.openstack.keystone.model.Authentication; + +/** + * JavaBean JSON class for a CloudIdentity. This bean represents a cloud identity + * service instance (i.e. a DCP node) in the NVP/AIC cloud. It will be loaded via + * CloudConfig object, of which it is a component (a CloudConfig JSON configuration + * file may contain multiple CloudIdentity definitions). + * + * Note that this is only used to access Cloud Configurations loaded from a + * JSON config file, so there are no explicit setters. + * + */ +public class CloudIdentity { + + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + + public enum IdentityServerType {KEYSTONE}; + + public enum IdentityAuthenticationType { USERNAME_PASSWORD, RACKSPACE_APIKEY }; + + @JsonProperty + private String id; + @JsonProperty("identity_url") + private String identityUrl; + @JsonProperty("mso_id") + private String msoId; + @JsonProperty("mso_pass") + private String msoPass; + @JsonProperty("admin_tenant") + private String adminTenant; + @JsonProperty("member_role") + private String memberRole; + @JsonProperty("tenant_metadata") + private Boolean tenantMetadata; + @JsonProperty("identity_server_type") + private IdentityServerType identityServerType; + @JsonProperty("identity_authentication_type") + private IdentityAuthenticationType identityAuthenticationType; + + private static String cloudKey = "aa3871669d893c7fb8abbcda31b88b4f"; + + public CloudIdentity () { + } + + public String getId () { + return id; + } + + public void setId (String id) { + this.id = id; + } + + //DEPRECATED + public String getKeystoneUrl () throws MsoException { + if (this.identityServerType.equals(IdentityServerType.KEYSTONE)) + return this.identityUrl; + else + return null; + } + + public String getKeystoneUrl (String regionId, String msoPropID) throws MsoException { + if (IdentityServerType.KEYSTONE.equals(this.identityServerType)) { + return this.identityUrl; + } + else { + return null; + } + } + + public Authentication getAuthentication () throws MsoException { + if (IdentityAuthenticationType.RACKSPACE_APIKEY.equals(this.identityAuthenticationType)) { + return new RackspaceAuthentication (this.getMsoId (),this.getMsoPass ()); + } + else { + // Use default case + return new UsernamePassword (this.getMsoId (),this.getMsoPass ()); + } + + } + + public void setKeystoneUrl (String url) { + if (IdentityServerType.KEYSTONE.equals(this.identityServerType)) { + this.identityUrl = url; + } + } + + public String getIdentityUrl() { + return this.identityUrl; + } + public void setIdentityUrl(String url) { + this.identityUrl = url; + } + + public String getMsoId () { + return msoId; + } + + public void setMsoId (String id) { + this.msoId = id; + } + + public String getMsoPass () { + try { + return CryptoUtils.decrypt (msoPass, cloudKey); + } catch (GeneralSecurityException e) { + LOGGER.error (MessageEnum.RA_GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in getMsoPass", e); + return null; + } + } + + public void setMsoPass (String pwd) { + this.msoPass = pwd; + } + + public String getAdminTenant () { + return adminTenant; + } + + public void setAdminTenant (String tenant) { + this.adminTenant = tenant; + } + + public String getMemberRole () { + return memberRole; + } + + public void setMemberRole (String role) { + this.memberRole = role; + } + + public boolean hasTenantMetadata () { + return tenantMetadata; + } + + public void setTenantMetadata (boolean meta) { + this.tenantMetadata = meta; + } + + public IdentityServerType getIdentityServerType() { + return this.identityServerType; + } + public void setIdentityServerType(IdentityServerType ist) { + this.identityServerType = ist; + } + public String getIdentityServerTypeAsString() { + return this.identityServerType.toString(); + } + /** + * @return the identityAuthenticationType + */ + public IdentityAuthenticationType getIdentityAuthenticationType() { + return identityAuthenticationType; + } + + /** + * @param identityAuthenticationType the identityAuthenticationType to set + */ + public void setIdentityAuthenticationType(IdentityAuthenticationType identityAuthenticationType) { + this.identityAuthenticationType = identityAuthenticationType; + } + + @Override + public String toString () { + StringBuilder stringBuilder = new StringBuilder (); + stringBuilder.append ("Cloud Identity Service: id=") + .append (id) + .append (", identityUrl=") + .append (this.identityUrl) + .append (", msoId=") + .append (msoId) + .append (", adminTenant=") + .append (adminTenant) + .append (", memberRole=") + .append (memberRole) + .append (", tenantMetadata=") + .append (tenantMetadata) + .append (", identityServerType=") + .append (identityServerType.toString()) + .append (", identityAuthenticationType=") + .append (identityAuthenticationType.toString()); + + return stringBuilder.toString (); + } + + public static String encryptPassword (String msoPass) { + try { + return CryptoUtils.encrypt (msoPass, cloudKey); + } catch (GeneralSecurityException e) { + LOGGER.error (MessageEnum.RA_GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in encryptPassword", e); + return null; + } + } + + + @Override + public CloudIdentity clone() { + CloudIdentity cloudIdentityCopy = new CloudIdentity(); + + cloudIdentityCopy.id = this.id; + cloudIdentityCopy.identityUrl = this.identityUrl; + cloudIdentityCopy.msoId = this.msoId; + cloudIdentityCopy.msoPass = this.msoPass; + cloudIdentityCopy.adminTenant = this.adminTenant; + cloudIdentityCopy.memberRole = this.memberRole; + cloudIdentityCopy.tenantMetadata = this.tenantMetadata; + cloudIdentityCopy.identityServerType = this.identityServerType; + cloudIdentityCopy.identityAuthenticationType = this.identityAuthenticationType; + + return cloudIdentityCopy; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((adminTenant == null) ? 0 : adminTenant.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((identityUrl == null) ? 0 : identityUrl.hashCode()); + result = prime * result + ((memberRole == null) ? 0 : memberRole.hashCode()); + result = prime * result + ((msoId == null) ? 0 : msoId.hashCode()); + result = prime * result + ((msoPass == null) ? 0 : msoPass.hashCode()); + result = prime * result + ((tenantMetadata == null) ? 0 : tenantMetadata.hashCode()); + result = prime * result + ((identityServerType == null) ? 0 : identityServerType.hashCode()); + result = prime * result + ((identityAuthenticationType == null) ? 0 : identityAuthenticationType.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CloudIdentity other = (CloudIdentity) obj; + if (adminTenant == null) { + if (other.adminTenant != null) + return false; + } else if (!adminTenant.equals(other.adminTenant)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (identityUrl == null) { + if (other.identityUrl != null) + return false; + } else if (!identityUrl.equals(other.identityUrl)) + return false; + if (memberRole == null) { + if (other.memberRole != null) + return false; + } else if (!memberRole.equals(other.memberRole)) + return false; + if (msoId == null) { + if (other.msoId != null) + return false; + } else if (!msoId.equals(other.msoId)) + return false; + if (msoPass == null) { + if (other.msoPass != null) + return false; + } else if (!msoPass.equals(other.msoPass)) + return false; + if (tenantMetadata == null) { + if (other.tenantMetadata != null) + return false; + } else if (!tenantMetadata.equals(other.tenantMetadata)) + return false; + if (identityServerType == null) { + if (other.getIdentityServerType() != null) + return false; + } else if (!identityServerType.equals(other.getIdentityServerType())) + return false; + if (identityAuthenticationType == null) { + if (other.getIdentityAuthenticationType() != null) + return false; + } else if (!identityAuthenticationType.equals(other.getIdentityAuthenticationType())) + return false; + + return true; + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudSite.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudSite.java new file mode 100644 index 0000000000..16963deb20 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudSite.java @@ -0,0 +1,160 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.cloud; + + +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * JavaBean JSON class for a CloudSite. This bean represents a cloud location + * (i.e. and LCP node) in the NVP/AIC cloud. It will be loaded via CloudConfig + * object, of which it is a component (a CloudConfig JSON configuration file + * will contain multiple CloudSite definitions). + * + * Note that this is only used to access Cloud Configurations loaded from a + * JSON config file, so there are no explicit setters. + * + */ +public class CloudSite { + @JsonProperty + private String id; + @JsonProperty("region_id") + private String regionId; + @JsonProperty("identity_service_id") + private String identityServiceId; + @JsonProperty("aic_version") + private String aic_version; + @JsonProperty("clli") + private String clli; + + // Derived property (set by CloudConfig loader based on identityServiceId) + private CloudIdentity identityService; + + public CloudSite() {} + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + public String getRegionId() { + return regionId; + } + + public void setRegionId(String regionId) { + this.regionId = regionId; + } + + public String getIdentityServiceId() { + return identityServiceId; + } + + public CloudIdentity getIdentityService () { + return identityService; + } + + public void setIdentityService (CloudIdentity identity) { + this.identityService = identity; + } + + public String getAic_version() { + return aic_version; + } + + public void setAic_version(String aic_version) { + this.aic_version = aic_version; + } + + public String getClli() { + return clli; + } + + public void setClli(String clli) { + this.clli = clli; + } + + @Override + public String toString() { + return "CloudSite: id=" + id + + ", regionId=" + regionId + + ", identityServiceId=" + identityServiceId + + ", aic_version=" + aic_version + + ", clli=" + clli; + } + + @Override + public CloudSite clone() { + CloudSite cloudSiteCopy = new CloudSite(); + cloudSiteCopy.id = this.id; + cloudSiteCopy.regionId = this.regionId; + cloudSiteCopy.identityServiceId = this.identityServiceId; + cloudSiteCopy.aic_version = this.aic_version; + cloudSiteCopy.clli = this.clli; + cloudSiteCopy.identityService = this.identityService.clone(); + return cloudSiteCopy; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((identityService == null) ? 0 : identityService.hashCode()); + result = prime * result + ((identityServiceId == null) ? 0 : identityServiceId.hashCode()); + result = prime * result + ((regionId == null) ? 0 : regionId.hashCode()); + result = prime * result + ((aic_version == null) ? 0 : aic_version.hashCode()); + result = prime * result + ((clli == null) ? 0 : clli.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CloudSite other = (CloudSite) obj; + if (!cmp(id, other.id)) + return false; + if (!cmp(regionId, other.regionId)) + return false; + if (!cmp(identityServiceId, other.identityServiceId)) + return false; + if (!cmp(aic_version, other.aic_version)) + return false; + if (!cmp(clli, other.clli)) + return false; + if (!cmp(identityService, other.identityService)) + return false; + return true; + } + private boolean cmp(Object a, Object b) { + if (a == null) { + return (b == null); + } else { + return a.equals(b); + } + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/HeatStatus.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/HeatStatus.java new file mode 100644 index 0000000000..8c51c746ef --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/HeatStatus.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.beans; + + +/* + * Enum status values to mirror the Openstack Heat stack status values + */ +public enum HeatStatus { + INIT, CREATED, NOTFOUND, FAILED, BUILDING, DELETING, UNKNOWN, UPDATING, UPDATED +} + diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/MsoTenant.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/MsoTenant.java new file mode 100644 index 0000000000..95a58f35dd --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/MsoTenant.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.beans; + + + +import java.util.Map; + +/** + * This bean class represents the Openstack tenant properties that are + * needed by MSO. + * + * + */ +public class MsoTenant { + private String tenantId; + private String tenantName; + private Map<String,String> metadata; + + public MsoTenant() {} + + public MsoTenant (String id, String name, Map<String,String> metadata) { + this.tenantId = id; + this.tenantName = name; + this.metadata = metadata; + } + + public String getTenantId() { + return tenantId; + } + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getTenantName() { + return tenantName; + } + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + + public Map<String, String> getMetadata() { + return metadata; + } + public void setMetadata(Map<String, String> metadata) { + this.metadata = metadata; + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java new file mode 100644 index 0000000000..11bf63b5c1 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java @@ -0,0 +1,177 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.beans; + + + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.HashMap; + +import com.woorea.openstack.quantum.model.Network; +import com.woorea.openstack.quantum.model.Segment; + +/* + * This Java bean class relays Network details (including status) to ActiveVOS processes. + * + * This bean is returned by all Network-specific adapter operations (create, query, delete) + */ + +public class NetworkInfo { + // Set defaults for everything + private String name = ""; + private String id = ""; + private NetworkStatus status = NetworkStatus.UNKNOWN; + private String provider = ""; + private List<Integer> vlans = new ArrayList<Integer>(); + private List<String> subnets = new ArrayList<String>(); + private String shared = ""; + + static Map<String,NetworkStatus> NetworkStatusMap; + static { + NetworkStatusMap = new HashMap<String,NetworkStatus>(); + NetworkStatusMap.put("ACTIVE", NetworkStatus.ACTIVE); + NetworkStatusMap.put("DOWN", NetworkStatus.DOWN); + NetworkStatusMap.put("BUILD", NetworkStatus.BUILD); + NetworkStatusMap.put("ERROR", NetworkStatus.ERROR); + } + + public NetworkInfo () { + } + + public NetworkInfo (String name, NetworkStatus status) { + this.name = name; + this.id = name; // Don't have an ID, so just use name + this.status = status; + } + + /** + * Capture the data from a Neutron Network object. + * + * For MSO, there are assumptions regarding all networks. + * - Everything will be a provider network + * - All provider networks are VLANs + * - Multiple VLANs are supported, and indicated by multi-provider segments. + * Each will have the same physical network & network type "vlan". + * + * @param network + */ + public NetworkInfo (Network network) + { + if (network == null) { + this.status = NetworkStatus.NOTFOUND; + return; + } + + this.name = network.getName(); + this.id = network.getId(); + + if (network.getStatus() == null) { + // Can this happen on a newly created network? + this.status = NetworkStatus.UNKNOWN; + } else if (NetworkStatusMap.containsKey(network.getStatus())) { + this.status = NetworkStatusMap.get(network.getStatus()); + } else { + this.status = NetworkStatus.UNKNOWN; + } + + if (network.getProviderPhysicalNetwork() != null) { + this.provider = network.getProviderPhysicalNetwork(); + if (network.getProviderNetworkType().equals("vlan")) { + this.vlans.add(network.getProviderSegmentationId()); + } + } + else if (network.getSegments() != null && network.getSegments().size() > 0) { + Segment s = network.getSegments().get(0); + this.provider = s.getProviderPhysicalNetwork(); + if (s.getProviderNetworkType().equals("vlan")) { + for (Segment s1 : network.getSegments()) { + this.vlans.add(s1.getProviderSegmentationId()); + } + } + } + this.subnets = network.getSubnets(); + } + + public String getName() { + return name; + } + + public void setName (String name) { + this.name = name; + } + + public String getId() { + return id; + } + + public void setId (String id) { + this.id = id; + } + + public NetworkStatus getStatus() { + return status; + } + + public void setStatus (NetworkStatus status) { + this.status = status; + } + + public String getProvider() { + return provider; + } + + public void setProvider (String provider) { + this.provider = provider; + } + + public List<Integer> getVlans () { + return vlans; + } + + public void setVlans (List<Integer> vlans) { + this.vlans = vlans; + } + + public List<String> getSubnets () { + return subnets; + } + + public void setSubnets (List<String> subnets) { + this.subnets = subnets; + } + + public String getShared() { + return shared; + } + + public void setShared(String shared) { + this.shared = shared; + } + + @Override + public String toString () { + return "Network: name=" + name + ",id=" + id + ",status=" + status + + ",provider=" + provider + ",vlans=" + vlans + ",subnets=" + subnets + ",shared=" + shared; + } +} + diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkRollback.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkRollback.java new file mode 100644 index 0000000000..11a74d4494 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkRollback.java @@ -0,0 +1,139 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.beans; + + +import java.util.List; + +import org.openecomp.mso.entity.MsoRequest; + +/** + * Javabean representing the rollback criteria following a "Create Network" + * or "Update Network" operation. This structure can be passed back to the + * "Rollback Network" operation to undo the effects of the create/update. + * + * Once a network is created, the only possible update through MSO is to + * the set of VLANs supported by the network. The vlans attribute of the + * rollback object contains the previous VLANs before update. + * + * + */ +public class NetworkRollback { + private String networkId; + private String neutronNetworkId; + private String networkStackId; + private String tenantId; + private String cloudId; + private String networkType; + private boolean networkCreated = false; + // Previous values for updates + private String networkName = null; + private String physicalNetwork = null; + private List<Integer> vlans = null; + private MsoRequest msoRequest; + + public String getNetworkId() { + return networkId; + } + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + public String getNeutronNetworkId() { + return neutronNetworkId; + } + public void setNeutronNetworkId(String neutronNetworkId) { + this.neutronNetworkId = neutronNetworkId; + } + + public String getNetworkStackId() { + return networkStackId; + } + public void setNetworkStackId(String networkStackId) { + this.networkStackId = networkStackId; + } + public String getTenantId() { + return tenantId; + } + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getCloudId() { + return cloudId; + } + public void setCloudId(String cloudId) { + this.cloudId = cloudId; + } + + public String getNetworkType() { + return networkType; + } + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + + public boolean getNetworkCreated() { + return networkCreated; + } + public void setNetworkCreated(boolean networkCreated) { + this.networkCreated = networkCreated; + } + + public String getNetworkName() { + return networkName; + } + public void setNetworkName(String networkName) { + this.networkName = networkName; + } + + public String getPhysicalNetwork() { + return physicalNetwork; + } + public void setPhysicalNetwork(String physicalNetwork) { + this.physicalNetwork = physicalNetwork; + } + + public List<Integer> getVlans () { + return vlans; + } + public void setVlans (List<Integer> vlans) { + this.vlans = vlans; + } + + public MsoRequest getMsoRequest() { + return msoRequest; + } + public void setMsoRequest (MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } + + @Override + public String toString() { + return "NetworkRollback [networkId=" + networkId + + ", neutronNetworkId=" + neutronNetworkId + ", networkStackId=" + + networkStackId + ", tenantId=" + tenantId + ", cloudId=" + + cloudId + ", networkType=" + networkType + + ", networkCreated=" + networkCreated + ", networkName=" + networkName + + ", physicalNetwork=" + physicalNetwork + "]"; + } + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkStatus.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkStatus.java new file mode 100644 index 0000000000..f1a5dad615 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkStatus.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.beans; + + +/** + * Enum status values to mirror the Openstack Neutron + * network status values + */ +public enum NetworkStatus { + NOTFOUND, ACTIVE, DOWN, BUILD, ERROR, UNKNOWN +} + diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/Pool.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/Pool.java new file mode 100644 index 0000000000..ae179c4354 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/Pool.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.beans; + + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "start", + "end" +}) +public class Pool { + + private String start; + private String end; + + /** + * @return the start + */ + public String getStart() { + return start; + } + /** + * @param start the start to set + */ + public void setStart(String start) { + this.start = start; + } + /** + * @return the end + */ + public String getEnd() { + return end; + } + /** + * @param end the end to set + */ + public void setEnd(String end) { + this.end = end; + } + + @Override + public String toString() { + return "Allocation_pool [start=" + start + ", end=" + end + "]"; + } + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/StackInfo.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/StackInfo.java new file mode 100644 index 0000000000..cdf4b2c34b --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/StackInfo.java @@ -0,0 +1,155 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.beans; + + +import java.util.Map; +import java.util.HashMap; + +import com.woorea.openstack.heat.model.Stack; + +/* + * This Java bean class relays Heat stack status information to ActiveVOS processes. + * + * This bean is returned by all Heat-specific adapter operations (create, query, delete) + */ + +public class StackInfo { + // Set defaults for everything + private String name = ""; + private String canonicalName = ""; + private HeatStatus status = HeatStatus.UNKNOWN; + private String statusMessage = ""; + private Map<String,Object> outputs = new HashMap<String,Object>(); + private Map<String,Object> parameters = new HashMap<String,Object>(); + + static Map<String,HeatStatus> HeatStatusMap; + static { + HeatStatusMap = new HashMap<String,HeatStatus>(); + HeatStatusMap.put("CREATE_IN_PROGRESS", HeatStatus.BUILDING); + HeatStatusMap.put("CREATE_COMPLETE", HeatStatus.CREATED); + HeatStatusMap.put("CREATE_FAILED", HeatStatus.FAILED); + HeatStatusMap.put("DELETE_IN_PROGRESS", HeatStatus.DELETING); + HeatStatusMap.put("DELETE_COMPLETE", HeatStatus.NOTFOUND); + HeatStatusMap.put("DELETE_FAILED", HeatStatus.FAILED); + HeatStatusMap.put("UPDATE_IN_PROGRESS", HeatStatus.UPDATING); + HeatStatusMap.put("UPDATE_FAILED", HeatStatus.FAILED); + HeatStatusMap.put("UPDATE_COMPLETE", HeatStatus.UPDATED); + } + + public StackInfo () { + } + + public StackInfo (String name, HeatStatus status, String statusMessage, Map<String,Object> outputs) { + this.name = name; + this.canonicalName = name; // Don't have an ID, so just use name + + this.status = status; + if (statusMessage != null) this.statusMessage = statusMessage; + if (outputs != null) this.outputs = outputs; + } + + public StackInfo (String name, HeatStatus status) { + this.name = name; + this.canonicalName = name; // Don't have an ID, so just use name + this.status = status; + } + + public StackInfo (Stack stack) + { + if (stack == null) { + this.status = HeatStatus.NOTFOUND; + return; + } + + this.name = stack.getStackName(); + this.canonicalName = stack.getStackName() + "/" + stack.getId(); + + if (stack.getStackStatus() == null) { + this.status = HeatStatus.INIT; + } else if (HeatStatusMap.containsKey(stack.getStackStatus())) { + this.status = HeatStatusMap.get(stack.getStackStatus()); + } else { + this.status = HeatStatus.UNKNOWN; + } + + this.statusMessage = stack.getStackStatusReason(); + + if (stack.getOutputs() != null) { + this.outputs = new HashMap<String,Object>(); + for (Stack.Output output : stack.getOutputs()) { + this.outputs.put(output.getOutputKey(), output.getOutputValue()); + } + } + + this.parameters = stack.getParameters(); + } + + public String getName() { + return name; + } + + public void setName (String name) { + this.name = name; + } + + public String getCanonicalName() { + return canonicalName; + } + + public void setCanonicalName (String name) { + this.canonicalName = name; + } + + public HeatStatus getStatus() { + return status; + } + + public void setStatus (HeatStatus status) { + this.status = status; + } + + public String getStatusMessage() { + return statusMessage; + } + + public void setStatusMessage (String statusMessage) { + this.statusMessage = statusMessage; + } + + public Map<String,Object> getOutputs () { + return outputs; + } + + public void setOutputs (Map<String,Object> outputs) { + this.outputs = outputs; + } + + public Map<String,Object> getParameters () { + return parameters; + } + + public void setParameters (Map<String,Object> parameters) { + this.parameters = parameters; + } + +} + diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/Subnet.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/Subnet.java new file mode 100644 index 0000000000..eb514cd565 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/Subnet.java @@ -0,0 +1,200 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.beans; + + + +import java.util.List; + +import javax.xml.bind.annotation.XmlTransient; + +public class Subnet { + + private String subnetName; + + private String neutronId; + + private String subnetId; // value from aai + + private String cidr; //Only field required + + private String gatewayIp=""; + + private String ipVersion="4"; + + private Boolean enableDHCP=false; + + private List<String> hostRoutes; + + private List<Pool> allocationPools; + + private List<String> dnsNameServers; + + public Subnet () { + } + + public String getSubnetName() { + return subnetName; + } + + public void setSubnetName(String subnetName) { + this.subnetName = subnetName; + } + + public List<Pool> getAllocationPools() { + return allocationPools; + } + + /** + * @return the cidr + */ + public String getCidr() { + return cidr; + } + + /** + * @return the dnsNames + */ + public List<String> getDnsNameServers() { + return dnsNameServers; + } + + + public Boolean getEnableDHCP() { + return enableDHCP; + } + + /** + * @return the gw + */ + public String getGatewayIp() { + return gatewayIp; + } + + /** + * @return the hostRoutes + */ + public List<String> getHostRoutes() { + return hostRoutes; + } + + /** + * @return the NeutronId + */ + @XmlTransient + public String getNeutronId() { + return neutronId; + } + + /** + * @return the ipversion + */ + public String getIpVersion() { + return ipVersion; + } + + /** + * @return the name + */ + public String getSubnetId() { + return subnetId; + } + + public void setAllocationPools(List<Pool> allocationPools) { + this.allocationPools = allocationPools; + } + + /** + * @param cidr + * the cidr to set + */ + public void setCidr(String cidr) { + this.cidr = cidr; + } + + /** + * @param dnsNames + * the dnsNames to set + */ + public void setDnsNameServers(List<String> dnsNameServers) { + this.dnsNameServers = dnsNameServers; + } + + /** + * @param enableDHCP + * the enableDHCP to set + */ + public void setEnableDHCP(Boolean enableDHCP) { + this.enableDHCP = enableDHCP; + } + + /** + * @param gw + * the gw to set + */ + public void setGatewayIp(String gatewayIp) { + this.gatewayIp = gatewayIp; + } + + /** + * @param hostRoutes + * the hostRoutes to set + */ + public void setHostRoutes(List<String> hostRoutes) { + this.hostRoutes = hostRoutes; + } + + /** + * @param neutronId + * the id to set + */ + public void setNeutronId(String neutronId) { + this.neutronId = neutronId; + } + + /** + * @param ipversion + * the ipversion to set + */ + public void setIpVersion(String ipVersion) { + this.ipVersion = ipVersion; + } + + /** + * @param name + * the name to set + */ + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + + @Override + public String toString() { + return "Subnet [subnetName=" + subnetName + ", neutronId=" + neutronId + + ", subnetId=" + subnetId + ", cidr=" + cidr + ", gatewayIp=" + + gatewayIp + ", ipVersion=" + ipVersion + ", enableDHCP=" + + enableDHCP + ", hostRoutes=" + hostRoutes + + ", allocationPools=" + allocationPools + ", dnsNameServers=" + + dnsNameServers + "]"; + } + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/VnfRollback.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/VnfRollback.java new file mode 100644 index 0000000000..b6e4a6e855 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/VnfRollback.java @@ -0,0 +1,152 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.beans; + +import org.openecomp.mso.entity.MsoRequest; +/** + * Javabean representing the rollback criteria following a "Create VNF" + * operation. This structure can be passed back to the "Rollback VNF" + * operation to undo the effects of the create. + * + * + */ +public class VnfRollback { + private String vnfId; + private String tenantId; + private String cloudSiteId; + private boolean tenantCreated = false; + private boolean vnfCreated = false; + private MsoRequest msoRequest; + private String volumeGroupName; + private String volumeGroupId; + private String requestType; + private String volumeGroupHeatStackId; + private String baseGroupHeatStackId; + private boolean isBase = false; + private String vfModuleStackId; + + public VnfRollback() {} + + public VnfRollback(String vnfId, String tenantId, String cloudSiteId, + boolean tenantCreated, boolean vnfCreated, + MsoRequest msoRequest, + String volumeGroupName, String volumeGroupId, String requestType) { + super(); + this.vnfId = vnfId; + this.tenantId = tenantId; + this.cloudSiteId = cloudSiteId; + this.tenantCreated = tenantCreated; + this.vnfCreated = vnfCreated; + this.msoRequest = msoRequest; + this.volumeGroupName = volumeGroupName; + this.volumeGroupId = volumeGroupId; + this.requestType = requestType; + } + + public String getVnfId() { + return vnfId; + } + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + public String getCloudSiteId() { + return cloudSiteId; + } + public void setCloudSiteId(String cloudId) { + this.cloudSiteId = cloudId; + } + public boolean getTenantCreated() { + return tenantCreated; + } + public void setTenantCreated(boolean tenantCreated) { + this.tenantCreated = tenantCreated; + } + public boolean getVnfCreated() { + return vnfCreated; + } + public void setVnfCreated(boolean vnfCreated) { + this.vnfCreated = vnfCreated; + } + public MsoRequest getMsoRequest() { + return msoRequest; + } + public void setMsoRequest (MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } + public String getVolumeGroupName() { + return this.volumeGroupName; + } + public void setVolumeGroupName(String volumeGroupName) { + this.volumeGroupName = volumeGroupName; + } + public String getVolumeGroupId() { + return this.volumeGroupId; + } + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + public String getRequestType() { + return this.requestType; + } + public void setRequestType(String requestType) { + this.requestType = requestType; + } + public String getVolumeGroupHeatStackId() { + return this.volumeGroupHeatStackId; + } + public void setVolumeGroupHeatStackId(String volumeGroupHeatStackId) { + this.volumeGroupHeatStackId = volumeGroupHeatStackId; + } + + public String getBaseGroupHeatStackId() { + return this.baseGroupHeatStackId; + } + public void setBaseGroupHeatStackId(String baseGroupHeatStackId) { + this.baseGroupHeatStackId = baseGroupHeatStackId; + } + + public boolean isBase() { + return this.isBase; + } + public void setIsBase(boolean isBase) { + this.isBase = isBase; + } + public String getVfModuleStackId() { + return this.vfModuleStackId; + } + public void setVfModuleStackId(String vfModuleStackId) { + this.vfModuleStackId = vfModuleStackId; + } + + @Override + public String toString() { + return "VnfRollback: cloud=" + cloudSiteId + ", tenant=" + tenantId + + ", vnf=" + vnfId + ", tenantCreated=" + tenantCreated + + ", vnfCreated=" + vnfCreated + ", requestType = " + requestType; + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/VnfStatus.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/VnfStatus.java new file mode 100644 index 0000000000..40f46716fd --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/VnfStatus.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.beans; + + +/* + * Enum status values to mirror the Openstack Heat stack status values + */ +public enum VnfStatus { + ACTIVE, FAILED, NOTFOUND, UNKNOWN +} + diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoAdapterException.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoAdapterException.java new file mode 100644 index 0000000000..d7198aed5a --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoAdapterException.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.exceptions; + + + +/** + * General MSO Exception class for any non-specific errors. + * + * + */ +public class MsoAdapterException extends MsoException +{ + private static final long serialVersionUID = 1L; + + // Constructor to create a new MsoException instance + public MsoAdapterException (String message) { + super(message); + super.category = MsoExceptionCategory.INTERNAL; + } + + // Constructor to wrap a nested exception + public MsoAdapterException (String message, Throwable t) { + super(message, t); + super.category = MsoExceptionCategory.INTERNAL; + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFound.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFound.java new file mode 100644 index 0000000000..4392ee039f --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFound.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.exceptions; + + +/** + * Cloud site not found exception. + */ +public class MsoCloudSiteNotFound extends MsoException { + + /** + * Serialization id. + */ + private static final long serialVersionUID = 2583769056266415664L; + + /** + * Default constructor (needed for BPEL/JAXB) + */ + public MsoCloudSiteNotFound () { + super("Cloud site not found"); + super.category=MsoExceptionCategory.USERDATA; + } + + /** + * Constructor to create a new MsoOpenstackException instance + * @param cloudSite the cloud site + */ + public MsoCloudSiteNotFound (String cloudSite) { + // Set the detailed error as the Exception 'message' + super("Cloud Site [" + cloudSite + "] not found"); + super.category=MsoExceptionCategory.USERDATA; + } + + @Override + public String toString () { + return getMessage(); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java new file mode 100644 index 0000000000..538a60d499 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.exceptions; + + + +public abstract class MsoException extends Exception +{ + private static final long serialVersionUID = 1L; + + protected MsoExceptionCategory category = MsoExceptionCategory.INTERNAL; + protected String context = null; + + protected MsoException (String message) { + super(message); + } + + protected MsoException (String message, Throwable t) { + super(message,t); + } + + public MsoExceptionCategory getCategory() { + return category; + } + public void setCategory (MsoExceptionCategory category) { + this.category = category; + } + + public String getContext () { + return context; + } + public void setContext (String context) { + this.context = context; + } + public void addContext (String ctx) { + if (this.context != null) + this.context = ctx + ":" + this.context; + else + this.context = ctx; + } + + public String getContextMessage () { + if (this.context == null) + return getMessage(); + else + return ("[" + context + "] " + getMessage()); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoExceptionCategory.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoExceptionCategory.java new file mode 100644 index 0000000000..4cc6b410e5 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoExceptionCategory.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.exceptions; + + + +public enum MsoExceptionCategory { + OPENSTACK, IO, INTERNAL, USERDATA +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoIOException.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoIOException.java new file mode 100644 index 0000000000..eafb033e4b --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoIOException.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.exceptions; + + +/** + * I/O exception + */ +public class MsoIOException extends MsoException +{ + + /** + * Serialization id. + */ + private static final long serialVersionUID = 6752445132721635760L; + + /** + * Basic constructor with message + * @param message the error message + */ + public MsoIOException (String message) { + super(message); + super.category = MsoExceptionCategory.IO; + } + + /** + * Constructor to wrap a nested exception + * @param message the error message + * @param t the cause + */ + public MsoIOException (String message, Throwable t) { + super (message, t); + super.category = MsoExceptionCategory.IO; + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoNetworkAlreadyExists.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoNetworkAlreadyExists.java new file mode 100644 index 0000000000..d234bbf73a --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoNetworkAlreadyExists.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.exceptions; + + + +public class MsoNetworkAlreadyExists extends MsoOpenstackException { + + private static final long serialVersionUID = 1L; + + // Constructor to create a new MsoOpenstackException instance + public MsoNetworkAlreadyExists (String stack, String tenant, String cloud) { + // Set the detailed error as the Exception 'message' + super(409, "Conflict", "Stack " + stack + " already exists in Tenant + " + tenant + " in Cloud " + cloud); + } + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoNetworkNotFound.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoNetworkNotFound.java new file mode 100644 index 0000000000..8aa7115629 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoNetworkNotFound.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.exceptions; + + + +public class MsoNetworkNotFound extends MsoOpenstackException { + + private static final long serialVersionUID = 1L; + + // Constructor to create a new MsoOpenstackException instance + public MsoNetworkNotFound (String networkId, String tenant, String cloud) { + // Set the detailed error as the Exception 'message' + super(404, "Not Found", "Network " + networkId + " does not exist in Cloud/Tenant " + cloud + "/" + tenant); + } + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java new file mode 100644 index 0000000000..2ad0f5b26f --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.exceptions; + + +/** + * OpenStack exception. + */ +public class MsoOpenstackException extends MsoException +{ + + /** + * Serialization id. + */ + private static final long serialVersionUID = 3313636124141766495L; + + private int statusCode; + private String statusMessage; + private String errorDetail; + + /** + * Constructor to create a new MsoOpenstackException instance + * @param code the error code + * @param message the error message + * @param detail error details + */ + public MsoOpenstackException (int code, String message, String detail) { + // Set the detailed error as the Exception 'message' + super(detail); + super.category = MsoExceptionCategory.OPENSTACK; + + this.statusCode = code; + this.statusMessage = message; + this.errorDetail = detail; + } + + /** + * Constructor to propagate the caught exception (mostly for stack trace) + * @param code the error code + * @param message the error message + * @param detail error details + * @param e the cause + */ + public MsoOpenstackException (int code, String message, String detail, Exception e) { + // Set the detailed error as the Exception 'message' + super(detail, e); + super.category = MsoExceptionCategory.OPENSTACK; + + this.statusCode = code; + this.statusMessage = message; + this.errorDetail = detail; + } + + @Override + public String toString () { + String error = "" + statusCode + " " + statusMessage + ": " + errorDetail; + return error; + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoStackAlreadyExists.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoStackAlreadyExists.java new file mode 100644 index 0000000000..2aba5b9d03 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoStackAlreadyExists.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.exceptions; + + + +public class MsoStackAlreadyExists extends MsoOpenstackException { + + private static final long serialVersionUID = 1L; + + // Constructor to create a new MsoOpenstackException instance + public MsoStackAlreadyExists (String stack, String tenant, String cloud) { + // Set the detailed error as the Exception 'message' + super(409, "Conflict", "Stack " + stack + " already exists in Tenant + " + tenant + " in Cloud " + cloud); + } + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoStackNotFound.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoStackNotFound.java new file mode 100644 index 0000000000..583d97616d --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoStackNotFound.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.exceptions; + + +/** + * Thrown when HEAT stack is not found or deleted. + */ +public class MsoStackNotFound extends MsoOpenstackException { + + /** + * Serialization id. + */ + private static final long serialVersionUID = 7354069716354359246L; + + /** + * Constructor to create a new MsoOpenstackException instance. + * @param stack the stack name + * @param tenant the tenant name + * @param cloud the cloud name + */ + public MsoStackNotFound (String stack, String tenant, String cloud) { + // Set the detailed error as the Exception 'message' + super(404, "Not Found", "Stack " + stack + " does not exist in Cloud/Tenant " + cloud + "/" + tenant); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExists.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExists.java new file mode 100644 index 0000000000..9edfdea591 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExists.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.exceptions; + + + +public class MsoTenantAlreadyExists extends MsoOpenstackException { + + private static final long serialVersionUID = 1L; + + // Constructor to create a new MsoOpenstackException instance + public MsoTenantAlreadyExists (String tenant, String cloud) { + // Set the detailed error as the Exception 'message' + super(409, "Conflict", "Tenant " + tenant + " already exists in Cloud " + cloud); + } + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoTenantNotFound.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoTenantNotFound.java new file mode 100644 index 0000000000..bd099388ee --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoTenantNotFound.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.exceptions; + + +/** + * Tenant not found exception. + */ +public class MsoTenantNotFound extends MsoOpenstackException { + + /** + * Serialization id. + */ + private static final long serialVersionUID = 5640069939645577063L; + + /** + * Constructor to create the exception + * @param tenant the tenant id + * @param cloud the cloud id + */ + public MsoTenantNotFound (String tenant, String cloud) { + // Set the detailed error as the Exception 'message' + super(404, "Not Found", "Tenant " + tenant + " does not exist in Cloud " + cloud); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/CloudConfigInitializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/CloudConfigInitializer.java new file mode 100644 index 0000000000..3d9c23cc32 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/CloudConfigInitializer.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.utils; + + +import javax.ejb.EJB; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.annotation.WebListener; + +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; + +/** + * This class will attempt to initialize Cloud Config when part of a web application. + * + * + * + */ +@WebListener +public class CloudConfigInitializer implements ServletContextListener +{ + + private CloudConfigFactory cloudConfigFactory=new CloudConfigFactory(); + + public CloudConfigInitializer () { + } + + @Override + public void contextDestroyed(ServletContextEvent event) { + // Nothing to do... + } + + + @Override + public void contextInitialized(ServletContextEvent event) + { + + // Note - this logger may be before or after MSO Logging configuration applied + MsoLogger initLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); + try { + // Look first in the init-parameters + String msoPropConfigParam = event.getServletContext().getInitParameter("mso.cloud_config.configuration"); + + String[] configFileSplit = msoPropConfigParam.split(","); + for (String msoPropConfig:configFileSplit) { + String[] msoPropDecoded = msoPropConfig.split("="); + + try { + cloudConfigFactory.initializeCloudConfig(msoPropDecoded[0], Integer.valueOf(msoPropDecoded[1])); + initLogger.info(MessageEnum.RA_CONFIG_LOAD, msoPropDecoded[0], "", ""); + initLogger.debug("Mso properties successfully loaded:"+msoPropDecoded[0]+"(Timer(mins):"+Integer.valueOf(msoPropDecoded[1])); + } catch (NumberFormatException ne) { + initLogger.error(MessageEnum.RA_CONFIG_EXC, msoPropDecoded[0] + ". MSO Properties failed due to conversion error (in web.xml file)", "", "", MsoLogger.ErrorCode.DataError, "MSO Properties failed due to conversion error (in web.xml file)", ne); + } + } + } + catch (Exception e) { + initLogger.error(MessageEnum.RA_CONFIG_EXC, "Unknown. MSO Properties failed to initialize completely", "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception - MSO Properties failed to initialize completely", e); + } + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java new file mode 100644 index 0000000000..6787e72df6 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java @@ -0,0 +1,315 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.utils; + + +import java.lang.StackTraceElement; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.openstack.exceptions.MsoAdapterException; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.openecomp.mso.openstack.exceptions.MsoIOException; +import org.openecomp.mso.openstack.exceptions.MsoOpenstackException; +import org.openecomp.mso.properties.MsoJavaProperties; +import com.woorea.openstack.base.client.OpenStackBaseException; +import com.woorea.openstack.base.client.OpenStackConnectException; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.base.client.OpenStackResponseException; +import com.woorea.openstack.heat.model.Explanation; +import com.woorea.openstack.keystone.model.Error; +import com.woorea.openstack.quantum.model.NeutronError; + +public class MsoCommonUtils { + + private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + protected static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); + + protected static String retryDelayProp = "ecomp.mso.adapters.po.retryDelay"; + protected static String retryCountProp = "ecomp.mso.adapters.po.retryCount"; + protected static String retryCodesProp = "ecomp.mso.adapters.po.retryCodes"; + + protected static int retryDelayDefault = 5; + protected static int retryCountDefault = 3; + protected static String retryCodesDefault = "504"; + + /* + * Method to execute an Openstack command and track its execution time. + * For the metrics log, a category of "Openstack" is used along with a + * sub-category that identifies the specific call (using the real + * openstack-java-sdk classname of the OpenStackRequest<T> parameter). + */ + + protected static <T> T executeAndRecordOpenstackRequest (OpenStackRequest <T> request) + { + return executeAndRecordOpenstackRequest (request, null); + } + protected static <T> T executeAndRecordOpenstackRequest (OpenStackRequest <T> request, MsoJavaProperties msoProps) { + + int limit; + // Get the name and method name of the parent class, which triggered this method + StackTraceElement[] classArr = new Exception ().getStackTrace (); + if (classArr.length >=2) { + limit = 3; + } else { + limit = classArr.length; + } + String parentServiceMethodName = classArr[0].getClassName () + "." + classArr[0].getMethodName (); + for (int i = 1; i < limit; i++) { + String className = classArr[i].getClassName (); + if (!className.equals (MsoCommonUtils.class.getName ())) { + parentServiceMethodName = className + "." + classArr[i].getMethodName (); + break; + } + } + + long start = System.currentTimeMillis (); + String requestType; + if (request.getClass ().getEnclosingClass () != null) { + requestType = request.getClass ().getEnclosingClass ().getSimpleName () + "." + + request.getClass ().getSimpleName (); + } else { + requestType = request.getClass ().getSimpleName (); + } + + int retryDelay = retryDelayDefault; + int retryCount = retryCountDefault; + String retryCodes = retryCodesDefault; + if (msoProps != null) //extra check to avoid NPE + { + retryDelay = msoProps.getIntProperty (retryDelayProp, retryDelayDefault); + retryCount = msoProps.getIntProperty (retryCountProp, retryCountDefault); + retryCodes = msoProps.getProperty (retryCodesProp, retryCodesDefault); + } + + // Run the actual command. All exceptions will be propagated + while (true) + { + try { + return request.execute (); + } + catch (OpenStackResponseException e) { + boolean retry = false; + if (retryCodes != null ) { + int code = e.getStatus(); + LOGGER.debug ("Config values RetryDelay:" + retryDelay + " RetryCount:" + retryCount + " RetryCodes:" + retryCodes + " ResponseCode:" + code); + for (String rCode : retryCodes.split (",")) { + try { + if (retryCount > 0 && code == Integer.parseInt (rCode)) + { + retryCount--; + retry = true; + LOGGER.debug ("OpenStackResponseException ResponseCode:" + code + " at:" + parentServiceMethodName + " request:" + requestType + " Retry indicated. Attempts remaining:" + retryCount); + break; + } + } catch (NumberFormatException e1) { + LOGGER.error (MessageEnum.RA_CONFIG_EXC, "No retries. Exception in parsing retry code in config:" + rCode, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in parsing retry code in config"); + throw e; + } + } + } + if (retry) + { + try { + Thread.sleep (retryDelay * 1000L); + } catch (InterruptedException e1) { + LOGGER.debug ("Thread interrupted while sleeping", e1); + } + } + else + throw e; // exceeded retryCount or code is not retryable + } + catch (OpenStackConnectException e) { + // Connection to Openstack failed + if (retryCount > 0) + { + retryCount--; + LOGGER.debug ("OpenstackConnectException at:" + parentServiceMethodName + " request:" + requestType + " Retry indicated. Attempts remaining:" + retryCount); + try { + Thread.sleep (retryDelay * 1000L); + } catch (InterruptedException e1) { + LOGGER.debug ("Thread interrupted while sleeping", e1); + } + } + else + throw e; + + } + } + } + + /* + * Convert an Openstack Exception on a Keystone call to an MsoException. + * This method supports both OpenstackResponseException and OpenStackConnectException. + */ + protected static MsoException keystoneErrorToMsoException (OpenStackBaseException e, String context) { + MsoException me = null; + + if (e instanceof OpenStackResponseException) { + OpenStackResponseException re = (OpenStackResponseException) e; + + try { + // Failed Keystone calls return an Error entity body. + Error error = re.getResponse ().getErrorEntity (Error.class); + LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "Openstack Keystone Error on " + context + ": " + error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Keystone Error on " + context); + me = new MsoOpenstackException (error.getCode (), error.getTitle (), error.getMessage ()); + } catch (Exception e2) { + // Can't parse the body as an "Error". Report the HTTP error + LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "HTTP Error on " + context + ": " + re.getStatus() + "," + re.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "HTTP Error on " + context, e2); + me = new MsoOpenstackException (re.getStatus (), re.getMessage (), ""); + } + + // Add the context of the error + me.addContext (context); + + // Generate an alarm for 5XX and higher errors. + if (re.getStatus () >= 500) { + alarmLogger.sendAlarm ("KeystoneError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + } + } else if (e instanceof OpenStackConnectException) { + OpenStackConnectException ce = (OpenStackConnectException) e; + + me = new MsoIOException (ce.getMessage ()); + me.addContext (context); + + // Generate an alarm for all connection errors. + LOGGER.error(MessageEnum.RA_GENERAL_EXCEPTION_ARG, "Openstack Keystone connection error on " + context + ": " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Keystone connection error on " + context); + alarmLogger.sendAlarm ("KeystoneIOError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + } + + return me; + } + + /* + * Convert an Openstack Exception on a Heat call to an MsoOpenstackException. + * This method supports both OpenstackResponseException and OpenStackConnectException. + */ + protected MsoException heatExceptionToMsoException (OpenStackBaseException e, String context) { + MsoException me = null; + + if (e instanceof OpenStackResponseException) { + OpenStackResponseException re = (OpenStackResponseException) e; + + try { + // Failed Heat calls return an Explanation entity body. + Explanation explanation = re.getResponse ().getErrorEntity (Explanation.class); + LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Error on " + context + ": " + explanation.toString(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - Openstack Error on " + context); + String fullError = explanation.getExplanation() + ", error.type=" + explanation.getError().getType() + ", error.message=" + explanation.getError().getMessage(); + LOGGER.debug(fullError); + me = new MsoOpenstackException (explanation.getCode (), + explanation.getTitle (), + //explanation.getExplanation ()); + fullError); + } catch (Exception e2) { + // Couldn't parse the body as an "Explanation". Report the original HTTP error. + LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "HTTP Error on " + context + ": " + re.getStatus() + "," + e.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - HTTP Error on " + context, e2); + me = new MsoOpenstackException (re.getStatus (), re.getMessage (), ""); + } + + // Add the context of the error + me.addContext (context); + + // Generate an alarm for 5XX and higher errors. + if (re.getStatus () >= 500) { + alarmLogger.sendAlarm ("HeatError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + } + } else if (e instanceof OpenStackConnectException) { + OpenStackConnectException ce = (OpenStackConnectException) e; + + me = new MsoIOException (ce.getMessage ()); + me.addContext (context); + + // Generate an alarm for all connection errors. + alarmLogger.sendAlarm ("HeatIOError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + LOGGER.error(MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Heat connection error on " + context + ": " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Heat connection error on " + context); + } + + return me; + } + + /* + * Convert an Openstack Exception on a Neutron call to an MsoOpenstackException. + * This method supports both OpenstackResponseException and OpenStackConnectException. + */ + protected MsoException neutronExceptionToMsoException (OpenStackBaseException e, String context) { + MsoException me = null; + + if (e instanceof OpenStackResponseException) { + OpenStackResponseException re = (OpenStackResponseException) e; + + try { + // Failed Neutron calls return an NeutronError entity body + NeutronError error = re.getResponse ().getErrorEntity (NeutronError.class); + LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Neutron Error on " + context + ": " + error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Neutron Error on " + context); + me = new MsoOpenstackException (re.getStatus (), error.getType (), error.getMessage ()); + } catch (Exception e2) { + // Couldn't parse body as a NeutronError. Report the HTTP error. + LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "HTTP Error on " + context + ": " + re.getStatus() + "," + e.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack HTTP Error on " + context, e2); + me = new MsoOpenstackException (re.getStatus (), re.getMessage (), null); + } + + // Add the context of the error + me.addContext (context); + + // Generate an alarm for 5XX and higher errors. + if (re.getStatus () >= 500) { + alarmLogger.sendAlarm ("NeutronError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + } + } else if (e instanceof OpenStackConnectException) { + OpenStackConnectException ce = (OpenStackConnectException) e; + + me = new MsoIOException (ce.getMessage ()); + me.addContext (context); + + // Generate an alarm for all connection errors. + alarmLogger.sendAlarm ("NeutronIOError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + LOGGER.error(MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Neutron Connection error on "+ context + ": " + e, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Openstack Neutron Connection error on "+ context); + } + + return me; + } + + /* + * Convert a Java Runtime Exception to an MsoException. + * All Runtime exceptions will be translated into an MsoAdapterException, + * which captures internal errors. + * Alarms will be generated on all such exceptions. + */ + protected MsoException runtimeExceptionToMsoException (RuntimeException e, String context) { + MsoAdapterException me = new MsoAdapterException (e.getMessage (), e); + me.addContext (context); + me.setCategory (MsoExceptionCategory.INTERNAL); + + // Always generate an alarm for internal exceptions + LOGGER.error(MessageEnum.RA_GENERAL_EXCEPTION_ARG, "An exception occured on "+ context + ": " + e, "OpenStack", "", MsoLogger.ErrorCode.DataError, "An exception occured on "+ context); + alarmLogger.sendAlarm ("AdapterInternalError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + + return me; + } + + public static boolean isNullOrEmpty (String s) { + return s == null || s.isEmpty(); + } + + + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java new file mode 100644 index 0000000000..13ea4331e8 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java @@ -0,0 +1,227 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.utils; + + + +import java.util.HashSet; +import java.util.ArrayList; +import java.util.Set; +import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; + +public class MsoHeatEnvironmentEntry { + + private Set<MsoHeatEnvironmentParameter> parameters = null; + private Set<MsoHeatEnvironmentResource> resources = null; + private StringBuilder rawEntry = null; + private boolean valid = true; + private String errorString = null; + private StringBuilder resourceRegistryEntryRaw = null; + + public MsoHeatEnvironmentEntry() { + super(); + } + + public MsoHeatEnvironmentEntry(StringBuilder sb) { + this(); + this.rawEntry = sb; + this.processRawEntry(); + } + + private void processRawEntry() { + try { + if (this.rawEntry == null || this.rawEntry.equals("")) + return; + byte[] b = this.rawEntry.toString().getBytes(); + MsoYamlEditorWithEnvt yaml = new MsoYamlEditorWithEnvt(b); + this.parameters = yaml.getParameterListFromEnvt(); + //this.resources = yaml.getResourceListFromEnvt(); + StringBuilder sb = this.getResourceRegistryRawEntry(); + if (sb == null) { + this.resourceRegistryEntryRaw = new StringBuilder(""); + } else { + this.resourceRegistryEntryRaw = sb; + } + } catch (Exception e) { + this.valid = false; + this.errorString = e.getMessage(); + //e.printStackTrace(); + } + } + + public boolean isValid() { + return this.valid; + } + public String getErrorString() { + return this.errorString; + } + + public Set<MsoHeatEnvironmentParameter> getParameters() { + return this.parameters; + } + public Set<MsoHeatEnvironmentResource> getResources() { + return this.resources; + } + public void setParameters(Set<MsoHeatEnvironmentParameter> paramSet) { + if (paramSet == null) { + this.parameters = null; + } else { + this.parameters = paramSet; + } + } + public void setResources(Set<MsoHeatEnvironmentResource> resourceSet) { + if (resourceSet == null) { + this.resources = null; + } else { + this.resources = resourceSet; + } + } + + public void addParameter(MsoHeatEnvironmentParameter hep) { + if (this.parameters == null) { + this.parameters = new HashSet<MsoHeatEnvironmentParameter>(); + } + this.parameters.add(hep); + } + public void addResource(MsoHeatEnvironmentResource her) { + if (this.resources == null) { + this.resources = new HashSet<MsoHeatEnvironmentResource>(); + } + this.resources.add(her); + } + + public int getNumberOfParameters() { + return this.parameters.size(); + } + public int getNumberOfResources() { + return this.resources.size(); + } + + public boolean hasResources() { + if (this.resources != null && this.resources.size() > 0) { + return true; + } + return false; + } + public boolean hasParameters() { + if (this.parameters != null && this.parameters.size() > 0) { + return true; + } + return false; + } + + public boolean containsParameter(String paramName) { + boolean contains = false; + if (this.parameters == null || this.parameters.size() < 1) { + return false; + } + if (this.parameters.contains(new MsoHeatEnvironmentParameter(paramName))) { + contains = true; + } + return contains; + } + + public boolean containsParameter(String paramName, String paramAlias) { + if (this.containsParameter(paramName)) { + return true; + } + if (this.containsParameter(paramAlias)) { + return true; + } + return false; + } + + public StringBuilder toFullStringExcludeNonParams(Set<HeatTemplateParam> params) { + // Basically give back the envt - but exclude the params that aren't in the HeatTemplate + + StringBuilder sb = new StringBuilder(); + ArrayList<String> paramNameList = new ArrayList<String>(params.size()); + for (HeatTemplateParam htp : params) { + paramNameList.add(htp.getParamName()); + } + + if (this.hasParameters()) { + sb.append("parameters:\n"); + for (MsoHeatEnvironmentParameter hep : this.parameters) { + String paramName = hep.getName(); + if (paramNameList.contains(paramName)) { + // This parameter *is* in the Heat Template - so include it: + sb.append(" " + hep.getName() + ": " + hep.getValue() + "\n"); + // New - 1607 - if any of the params mapped badly - JUST RETURN THE ORIGINAL ENVT! + if (hep.getValue().startsWith("_BAD")) { + return this.rawEntry; + } + } + } + sb.append("\n"); + } +// if (this.hasResources()) { +// sb.append("resource_registry:\n"); +// for (MsoHeatEnvironmentResource her : this.resources) { +// sb.append(" \"" + her.getName() + "\": " + her.getValue() + "\n"); +// } +// } + sb.append("\n"); + sb.append(this.resourceRegistryEntryRaw); + return sb; + } + + public StringBuilder toFullString() { + StringBuilder sb = new StringBuilder(); + + if (this.hasParameters()) { + sb.append("parameters:\n"); + for (MsoHeatEnvironmentParameter hep : this.parameters) { + sb.append(" " + hep.getName() + ": " + hep.getValue() + "\n"); + } + sb.append("\n"); + } +// if (this.hasResources()) { +// sb.append("resource_registry:\n"); +// for (MsoHeatEnvironmentResource her : this.resources) { +// sb.append(" \"" + her.getName() + "\": " + her.getValue() + "\n"); +// } +// } + sb.append("\n"); + sb.append(this.resourceRegistryEntryRaw); + return sb; + } + + public StringBuilder getRawEntry() { + return this.rawEntry; + } + + private StringBuilder getResourceRegistryRawEntry() { + + if (this.rawEntry == null) { + return null; + } + + StringBuilder sb = new StringBuilder(); + int indexOf = this.rawEntry.indexOf("resource_registry:"); + if (indexOf < 0) { // no resource_registry: + return null; + } + sb.append(this.rawEntry.substring(indexOf)); + return sb; + } + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentParameter.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentParameter.java new file mode 100644 index 0000000000..4cf9023b7c --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentParameter.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.utils; + + + +public class MsoHeatEnvironmentParameter { + + private String name; + private String value; + + public MsoHeatEnvironmentParameter(String name, String value) { + super(); + this.name = name; + this.value = value; + } + public MsoHeatEnvironmentParameter(String name) { + // Allow to initialize with a null value + this(name, null); + } + public MsoHeatEnvironmentParameter() { + this(null, null); + } + + public String getName() { + return this.name; + } + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return this.value; + } + public void setValue(String value) { + this.value = value; + } + public String toString() { + return this.name + ": " + this.value; + } + + public boolean equals(Object o) { + if (!(o instanceof MsoHeatEnvironmentParameter)) { + return false; + } + if (this == o) { + return true; + } + MsoHeatEnvironmentParameter hep = (MsoHeatEnvironmentParameter) o; + // If the name of the parameter is the same, then they're equal + if (hep.getName().equals(this.getName())) { + return true; + } + return false; + } + + public int hashCode() { + int result = 0; + try { + result = this.name.hashCode(); + } catch (Exception e) { + // in case it's null - return zero + } + return result; + } + + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java new file mode 100644 index 0000000000..202a084f45 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.utils; + + + +public class MsoHeatEnvironmentResource { + + private String name; + private String value; + + public MsoHeatEnvironmentResource(String name, String value) { + super(); + this.name = name; + this.value = value; + } + public MsoHeatEnvironmentResource(String name) { + // Allow to initialize with a null value + this(name, null); + } + public MsoHeatEnvironmentResource() { + this(null, null); + } + + public String getName() { + return this.name; + } + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return this.value; + } + public void setValue(String value) { + this.value = value; + } + public String toString() { + return "\"" + this.name + "\": " + this.value; + } + + public boolean equals(Object o) { + if (!(o instanceof MsoHeatEnvironmentResource)) { + return false; + } + if (this == o) { + return true; + } + MsoHeatEnvironmentResource her = (MsoHeatEnvironmentResource) o; + // If the name of the parameter is the same, then they're equal + if (her.getName().equals(this.getName())) { + return true; + } + return false; + } + + public int hashCode() { + int result = 0; + try { + result = this.name.hashCode(); + } catch (Exception e) { + // in case it's null - return zero + } + return result; + } + + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java new file mode 100644 index 0000000000..8d66505c6a --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java @@ -0,0 +1,1229 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.utils; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.JsonNode; +import org.codehaus.jackson.JsonParseException; + +import org.openecomp.mso.cloud.CloudConfig; +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.cloud.CloudIdentity; +import org.openecomp.mso.cloud.CloudSite; +import org.openecomp.mso.db.catalog.beans.HeatTemplate; +import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.beans.HeatStatus; +import org.openecomp.mso.openstack.beans.StackInfo; +import org.openecomp.mso.openstack.exceptions.MsoAdapterException; +import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoIOException; +import org.openecomp.mso.openstack.exceptions.MsoOpenstackException; +import org.openecomp.mso.openstack.exceptions.MsoStackAlreadyExists; +import org.openecomp.mso.openstack.exceptions.MsoTenantNotFound; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; +import com.woorea.openstack.base.client.OpenStackConnectException; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.base.client.OpenStackResponseException; +import com.woorea.openstack.heat.Heat; +import com.woorea.openstack.heat.model.CreateStackParam; +import com.woorea.openstack.heat.model.Stack; +import com.woorea.openstack.heat.model.Stacks; +import com.woorea.openstack.keystone.Keystone; +import com.woorea.openstack.keystone.model.Access; +import com.woorea.openstack.keystone.model.Authentication; +import com.woorea.openstack.keystone.utils.KeystoneUtils; + +public class MsoHeatUtils extends MsoCommonUtils { + + private MsoPropertiesFactory msoPropertiesFactory; + + private CloudConfigFactory cloudConfigFactory; + + private static final String TOKEN_AUTH = "TokenAuth"; + + private static final String QUERY_ALL_STACKS = "QueryAllStacks"; + + private static final String DELETE_STACK = "DeleteStack"; + + private static final String HEAT_ERROR = "HeatError"; + + private static final String CREATE_STACK = "CreateStack"; + + // Cache Heat Clients statically. Since there is just one MSO user, there is no + // benefit to re-authentication on every request (or across different flows). The + // token will be used until it expires. + // + // The cache key is "tenantId:cloudId" + private static Map <String, HeatCacheEntry> heatClientCache = new HashMap <String, HeatCacheEntry> (); + + // Fetch cloud configuration each time (may be cached in CloudConfig class) + protected CloudConfig cloudConfig; + + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + + protected MsoJavaProperties msoProps = null; + + // Properties names and variables (with default values) + protected String createPollIntervalProp = "ecomp.mso.adapters.heat.create.pollInterval"; + private String deletePollIntervalProp = "ecomp.mso.adapters.heat.delete.pollInterval"; + private String deletePollTimeoutProp = "ecomp.mso.adapters.heat.delete.pollTimeout"; + + protected int createPollIntervalDefault = 15; + private int deletePollIntervalDefault = 15; + private int deletePollTimeoutDefault = 300; + private String msoPropID; + + private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); + + /** + * This constructor MUST be used ONLY in the JUNIT tests, not for real code. + * The MsoPropertiesFactory will be added by EJB injection. + * + * @param msoPropID ID of the mso pro config as defined in web.xml + * @param msoPropFactory The mso properties factory instanciated by EJB injection + * @param cloudConfFactory the Cloud Config instantiated by EJB injection + */ + public MsoHeatUtils (String msoPropID, MsoPropertiesFactory msoPropFactory, CloudConfigFactory cloudConfFactory) { + msoPropertiesFactory = msoPropFactory; + cloudConfigFactory = cloudConfFactory; + this.msoPropID = msoPropID; + // Dynamically get properties each time (in case reloaded). + + try { + msoProps = msoPropertiesFactory.getMsoJavaProperties (msoPropID); + } catch (MsoPropertiesException e) { + LOGGER.error (MessageEnum.LOAD_PROPERTIES_FAIL, "Unknown. Mso Properties ID not found in cache: " + msoPropID, "", "", MsoLogger.ErrorCode.DataError, "Exception - Mso Properties ID not found in cache", e); + } + cloudConfig = cloudConfigFactory.getCloudConfig (); + LOGGER.debug("MsoHeatUtils:" + msoPropID); + + } + + + /** + * keep this old method signature here to maintain backwards compatibility. keep others as well. + * this method does not include environment, files, or heatFiles + */ + public StackInfo createStack (String cloudSiteId, + String tenantId, + String stackName, + String heatTemplate, + Map <String, ? extends Object> stackInputs, + boolean pollForCompletion, + int timeoutMinutes) throws MsoException { + // Just call the new method with the environment & files variable set to null + return this.createStack (cloudSiteId, + tenantId, + stackName, + heatTemplate, + stackInputs, + pollForCompletion, + timeoutMinutes, + null, + null, + null, + true); + } + + // This method has environment, but not files or heatFiles + public StackInfo createStack (String cloudSiteId, + String tenantId, + String stackName, + String heatTemplate, + Map <String, ? extends Object> stackInputs, + boolean pollForCompletion, + int timeoutMinutes, + String environment) throws MsoException { + // Just call the new method with the files/heatFiles variables set to null + return this.createStack (cloudSiteId, + tenantId, + stackName, + heatTemplate, + stackInputs, + pollForCompletion, + timeoutMinutes, + environment, + null, + null, + true); + } + + // This method has environment and files, but not heatFiles. + public StackInfo createStack (String cloudSiteId, + String tenantId, + String stackName, + String heatTemplate, + Map <String, ? extends Object> stackInputs, + boolean pollForCompletion, + int timeoutMinutes, + String environment, + Map <String, Object> files) throws MsoException { + return this.createStack (cloudSiteId, + tenantId, + stackName, + heatTemplate, + stackInputs, + pollForCompletion, + timeoutMinutes, + environment, + files, + null, + true); + } + + // This method has environment, files, heatfiles + public StackInfo createStack (String cloudSiteId, + String tenantId, + String stackName, + String heatTemplate, + Map <String, ? extends Object> stackInputs, + boolean pollForCompletion, + int timeoutMinutes, + String environment, + Map <String, Object> files, + Map <String, Object> heatFiles) throws MsoException { + return this.createStack (cloudSiteId, + tenantId, + stackName, + heatTemplate, + stackInputs, + pollForCompletion, + timeoutMinutes, + environment, + files, + heatFiles, + true); + } + + /** + * Create a new Stack in the specified cloud location and tenant. The Heat template + * and parameter map are passed in as arguments, along with the cloud access credentials. + * It is expected that parameters have been validated and contain at minimum the required + * parameters for the given template with no extra (undefined) parameters.. + * + * The Stack name supplied by the caller must be unique in the scope of this tenant. + * However, it should also be globally unique, as it will be the identifier for the + * resource going forward in Inventory. This latter is managed by the higher levels + * invoking this function. + * + * The caller may choose to let this function poll Openstack for completion of the + * stack creation, or may handle polling itself via separate calls to query the status. + * In either case, a StackInfo object will be returned containing the current status. + * When polling is enabled, a status of CREATED is expected. When not polling, a + * status of BUILDING is expected. + * + * An error will be thrown if the requested Stack already exists in the specified + * Tenant and Cloud. + * + * For 1510 - add "environment", "files" (nested templates), and "heatFiles" (get_files) as + * parameters for createStack. If environment is non-null, it will be added to the stack. + * The nested templates and get_file entries both end up being added to the "files" on the + * stack. We must combine them before we add them to the stack if they're both non-null. + * + * @param cloudSiteId The cloud (may be a region) in which to create the stack. + * @param tenantId The Openstack ID of the tenant in which to create the Stack + * @param stackName The name of the stack to create + * @param stackTemplate The Heat template + * @param stackInputs A map of key/value inputs + * @param pollForCompletion Indicator that polling should be handled in Java vs. in the client + * @param environment An optional yaml-format string to specify environmental parameters + * @param files a Map<String, Object> that lists the child template IDs (file is the string, object is an int of + * Template id) + * @param heatFiles a Map<String, Object> that lists the get_file entries (fileName, fileBody) + * @param backout Donot delete stack on create Failure - defaulted to True + * @return A StackInfo object + * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception. + */ + + @SuppressWarnings("unchecked") + public StackInfo createStack (String cloudSiteId, + String tenantId, + String stackName, + String heatTemplate, + Map <String, ? extends Object> stackInputs, + boolean pollForCompletion, + int timeoutMinutes, + String environment, + Map <String, Object> files, + Map <String, Object> heatFiles, + boolean backout) throws MsoException { + // Create local variables checking to see if we have an environment, nested, get_files + // Could later add some checks to see if it's valid. + boolean haveEnvtVariable = true; + if (environment == null || "".equalsIgnoreCase (environment.trim ())) { + haveEnvtVariable = false; + LOGGER.debug ("createStack called with no environment variable"); + } else { + LOGGER.debug ("createStack called with an environment variable: " + environment); + } + + boolean haveFiles = true; + if (files == null || files.isEmpty ()) { + haveFiles = false; + LOGGER.debug ("createStack called with no files / child template ids"); + } else { + LOGGER.debug ("createStack called with " + files.size () + " files / child template ids"); + } + + boolean haveHeatFiles = true; + if (heatFiles == null || heatFiles.isEmpty ()) { + haveHeatFiles = false; + LOGGER.debug ("createStack called with no heatFiles"); + } else { + LOGGER.debug ("createStack called with " + heatFiles.size () + " heatFiles"); + } + + // Obtain the cloud site information where we will create the stack + CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + if (cloudSite == null) { + throw new MsoCloudSiteNotFound (cloudSiteId); + } + // Get a Heat client. They are cached between calls (keyed by tenantId:cloudId) + // This could throw MsoTenantNotFound or MsoOpenstackException (both propagated) + Heat heatClient = getHeatClient (cloudSite, tenantId); + + LOGGER.debug ("Ready to Create Stack (" + heatTemplate + ") with input params: " + stackInputs); + + // Build up the stack to create + // Disable auto-rollback, because error reason is lost. Always rollback in the code. + CreateStackParam stack = new CreateStackParam (); + stack.setStackName (stackName); + stack.setTimeoutMinutes (timeoutMinutes); + stack.setParameters ((Map <String, Object>) stackInputs); + stack.setTemplate (heatTemplate); + stack.setDisableRollback (true); + // TJM New for PO Adapter - add envt variable + if (haveEnvtVariable) { + LOGGER.debug ("Found an environment variable - value: " + environment); + stack.setEnvironment (environment); + } + // Now handle nested templates or get_files - have to combine if we have both + // as they're both treated as "files:" on the stack. + if (haveFiles && haveHeatFiles) { + // Let's do this here - not in the bean + LOGGER.debug ("Found files AND heatFiles - combine and add!"); + Map <String, Object> combinedFiles = new HashMap <String, Object> (); + for (String keyString : files.keySet ()) { + combinedFiles.put (keyString, files.get (keyString)); + } + for (String keyString : heatFiles.keySet ()) { + combinedFiles.put (keyString, heatFiles.get (keyString)); + } + stack.setFiles (combinedFiles); + } else { + // Handle if we only have one or neither: + if (haveFiles) { + LOGGER.debug ("Found files - adding to stack"); + stack.setFiles (files); + } + if (haveHeatFiles) { + LOGGER.debug ("Found heatFiles - adding to stack"); + // the setFiles was modified to handle adding the entries + stack.setFiles (heatFiles); + } + } + + Stack heatStack = null; + try { + // Execute the actual Openstack command to create the Heat stack + OpenStackRequest <Stack> request = heatClient.getStacks ().create (stack); + // Begin X-Auth-User + // Obtain an MSO token for the tenant + CloudIdentity cloudIdentity = cloudSite.getIdentityService (); + // cloudIdentity.getMsoId(), cloudIdentity.getMsoPass() + //req + request.header ("X-Auth-User", cloudIdentity.getMsoId ()); + request.header ("X-Auth-Key", cloudIdentity.getMsoPass ()); + LOGGER.debug ("headers added, about to executeAndRecordOpenstackRequest"); + LOGGER.debug(this.requestToStringBuilder(stack).toString()); + // END - try to fix X-Auth-User + heatStack = executeAndRecordOpenstackRequest (request, msoProps); + } catch (OpenStackResponseException e) { + // Since this came on the 'Create Stack' command, nothing was changed + // in the cloud. Return the error as an exception. + if (e.getStatus () == 409) { + // Stack already exists. Return a specific error for this case + MsoStackAlreadyExists me = new MsoStackAlreadyExists (stackName, tenantId, cloudSiteId); + me.addContext (CREATE_STACK); + throw me; + } else { + // Convert the OpenStackResponseException to an MsoOpenstackException + LOGGER.debug("ERROR STATUS = " + e.getStatus() + ",\n" + e.getMessage() + "\n" + e.getLocalizedMessage()); + throw heatExceptionToMsoException (e, CREATE_STACK); + } + } catch (OpenStackConnectException e) { + // Error connecting to Openstack instance. Convert to an MsoException + throw heatExceptionToMsoException (e, CREATE_STACK); + } catch (RuntimeException e) { + // Catch-all + throw runtimeExceptionToMsoException (e, CREATE_STACK); + } + + // Subsequent access by the canonical name "<stack name>/<stack-id>". + // Otherwise, simple query by name returns a 302 redirect. + // NOTE: This is specific to the v1 Orchestration API. + String canonicalName = stackName + "/" + heatStack.getId (); + + // If client has requested a final response, poll for stack completion + if (pollForCompletion) { + // Set a time limit on overall polling. + // Use the resource (template) timeout for Openstack (expressed in minutes) + // and add one poll interval to give Openstack a chance to fail on its own. + int createPollInterval = msoProps.getIntProperty (createPollIntervalProp, createPollIntervalDefault); + int pollTimeout = (timeoutMinutes * 60) + createPollInterval; + // New 1610 - poll on delete if we rollback - use same values for now + int deletePollInterval = createPollInterval; + int deletePollTimeout = pollTimeout; + boolean createTimedOut = false; + StringBuilder stackErrorStatusReason = new StringBuilder(""); + LOGGER.debug("createPollInterval=" + createPollInterval + ", pollTimeout=" + pollTimeout); + + while (true) { + try { + heatStack = queryHeatStack (heatClient, canonicalName); + LOGGER.debug (heatStack.getStackStatus () + " (" + canonicalName + ")"); + + if ("CREATE_IN_PROGRESS".equals (heatStack.getStackStatus ())) { + // Stack creation is still running. + // Sleep and try again unless timeout has been reached + if (pollTimeout <= 0) { + // Note that this should not occur, since there is a timeout specified + // in the Openstack call. + LOGGER.error (MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, heatStack.getStackStatus (), "", "", MsoLogger.ErrorCode.AvailabilityError, "Create stack timeout"); + createTimedOut = true; + break; + } + try { + Thread.sleep (createPollInterval * 1000L); + } catch (InterruptedException e) { + LOGGER.debug ("Thread interrupted while sleeping", e); + } + + pollTimeout -= createPollInterval; + LOGGER.debug("pollTimeout remaining: " + pollTimeout); + } else { + //save off the status & reason msg before we attempt delete + stackErrorStatusReason.append("Stack error (" + heatStack.getStackStatus() + "): " + heatStack.getStackStatusReason()); + break; + } + } catch (MsoException me) { + // Cannot query the stack status. Something is wrong. + // Try to roll back the stack + if (!backout) + { + LOGGER.warn(MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack, stack deletion suppressed"); + } + else + { + try { + LOGGER.debug("Create Stack error - unable to query for stack status - attempting to delete stack: " + canonicalName + " - This will likely fail and/or we won't be able to query to see if delete worked"); + OpenStackRequest <Void> request = heatClient.getStacks ().deleteByName (canonicalName); + executeAndRecordOpenstackRequest (request, msoProps); + // this may be a waste of time - if we just got an exception trying to query the stack - we'll just + // get another one, n'est-ce pas? + boolean deleted = false; + while (!deleted) { + try { + heatStack = queryHeatStack(heatClient, canonicalName); + if (heatStack != null) { + LOGGER.debug(heatStack.getStackStatus()); + if ("DELETE_IN_PROGRESS".equals(heatStack.getStackStatus())) { + if (deletePollTimeout <= 0) { + LOGGER.error (MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, + heatStack.getStackStatus (), "", "", MsoLogger.ErrorCode.AvailabilityError, + "Rollback: DELETE stack timeout"); + break; + } else { + try { + Thread.sleep(deletePollInterval * 1000L); + } catch (InterruptedException ie) { + LOGGER.debug("Thread interrupted while sleeping", ie); + } + deletePollTimeout -= deletePollInterval; + } + } else if ("DELETE_COMPLETE".equals(heatStack.getStackStatus())){ + LOGGER.debug("DELETE_COMPLETE for " + canonicalName); + deleted = true; + continue; + } else { + //got a status other than DELETE_IN_PROGRESS or DELETE_COMPLETE - so break and evaluate + break; + } + } else { + // assume if we can't find it - it's deleted + LOGGER.debug("heatStack returned null - assume the stack " + canonicalName + " has been deleted"); + deleted = true; + continue; + } + + } catch (Exception e3) { + // Just log this one. We will report the original exception. + LOGGER.error (MessageEnum.RA_CREATE_STACK_ERR, "Create Stack: Nested exception rolling back stack: " + e3, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack: Nested exception rolling back stack on error on query"); + + } + } + } catch (Exception e2) { + // Just log this one. We will report the original exception. + LOGGER.error (MessageEnum.RA_CREATE_STACK_ERR, "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack: Nested exception rolling back stack"); + } + } + + // Propagate the original exception from Stack Query. + me.addContext (CREATE_STACK); + throw me; + } + } + + if (!"CREATE_COMPLETE".equals (heatStack.getStackStatus ())) { + LOGGER.error (MessageEnum.RA_CREATE_STACK_ERR, "Create Stack error: Polling complete with non-success status: " + + heatStack.getStackStatus () + ", " + heatStack.getStackStatusReason (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error"); + + // Rollback the stack creation, since it is in an indeterminate state. + if (!backout) + { + LOGGER.warn(MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error, stack deletion suppressed"); + } + else + { + try { + LOGGER.debug("Create Stack errored - attempting to DELETE stack: " + canonicalName); + LOGGER.debug("deletePollInterval=" + deletePollInterval + ", deletePollTimeout=" + deletePollTimeout); + OpenStackRequest <Void> request = heatClient.getStacks ().deleteByName (canonicalName); + executeAndRecordOpenstackRequest (request, msoProps); + boolean deleted = false; + while (!deleted) { + try { + heatStack = queryHeatStack(heatClient, canonicalName); + if (heatStack != null) { + LOGGER.debug(heatStack.getStackStatus() + " (" + canonicalName + ")"); + if ("DELETE_IN_PROGRESS".equals(heatStack.getStackStatus())) { + if (deletePollTimeout <= 0) { + LOGGER.error (MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, + heatStack.getStackStatus (), "", "", MsoLogger.ErrorCode.AvailabilityError, + "Rollback: DELETE stack timeout"); + break; + } else { + try { + Thread.sleep(deletePollInterval * 1000L); + } catch (InterruptedException ie) { + LOGGER.debug("Thread interrupted while sleeping", ie); + } + deletePollTimeout -= deletePollInterval; + LOGGER.debug("deletePollTimeout remaining: " + deletePollTimeout); + } + } else if ("DELETE_COMPLETE".equals(heatStack.getStackStatus())){ + LOGGER.debug("DELETE_COMPLETE for " + canonicalName); + deleted = true; + continue; + } else if ("DELETE_FAILED".equals(heatStack.getStackStatus())) { + // Warn about this (?) - but still throw the original exception + LOGGER.warn(MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, stack deletion FAILED", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error, stack deletion FAILED"); + LOGGER.debug("Stack deletion FAILED on a rollback of a create - " + canonicalName + ", status=" + heatStack.getStackStatus() + ", reason=" + heatStack.getStackStatusReason()); + break; + } else { + //got a status other than DELETE_IN_PROGRESS or DELETE_COMPLETE - so break and evaluate + break; + } + } else { + // assume if we can't find it - it's deleted + LOGGER.debug("heatStack returned null - assume the stack " + canonicalName + " has been deleted"); + deleted = true; + continue; + } + + } catch (MsoException me2) { + // We got an exception on the delete - don't throw this exception - throw the original - just log. + LOGGER.debug("Exception thrown trying to delete " + canonicalName + " on a create->rollback: " + me2.getContextMessage()); + LOGGER.warn(MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, then stack deletion FAILED - exception thrown", "", "", MsoLogger.ErrorCode.BusinessProcesssError, me2.getContextMessage()); + } + + } // end while !deleted + StringBuilder errorContextMessage = null; + if (createTimedOut) { + errorContextMessage = new StringBuilder("Stack Creation Timeout"); + } else { + errorContextMessage = stackErrorStatusReason; + } + if (deleted) { + errorContextMessage.append(" - stack successfully deleted"); + } else { + errorContextMessage.append(" - encountered an error trying to delete the stack"); + } +// MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString()); + // me.addContext(CREATE_STACK); + // alarmLogger.sendAlarm(HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage()); + // throw me; + } catch (Exception e2) { + // shouldn't happen - but handle + LOGGER.error (MessageEnum.RA_CREATE_STACK_ERR, "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack: rolling back stack"); + } + } + MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString()); + me.addContext(CREATE_STACK); + alarmLogger.sendAlarm(HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage()); + throw me; + } + + } else { + // Get initial status, since it will have been null after the create. + heatStack = queryHeatStack (heatClient, canonicalName); + LOGGER.debug (heatStack.getStackStatus ()); + } + + return new StackInfo (heatStack); + } + + /** + * Query for a single stack (by Name) in a tenant. This call will always return a + * StackInfo object. If the stack does not exist, an "empty" StackInfo will be + * returned - containing only the stack name and a status of NOTFOUND. + * + * @param tenantId The Openstack ID of the tenant in which to query + * @param cloudSiteId The cloud identifier (may be a region) in which to query + * @param stackName The name of the stack to query (may be simple or canonical) + * @return A StackInfo object + * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception. + */ + public StackInfo queryStack (String cloudSiteId, String tenantId, String stackName) throws MsoException { + LOGGER.debug ("Query HEAT stack: " + stackName + " in tenant " + tenantId); + + // Obtain the cloud site information where we will create the stack + CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + if (cloudSite == null) { + throw new MsoCloudSiteNotFound (cloudSiteId); + } + + // Get a Heat client. They are cached between calls (keyed by tenantId:cloudId) + Heat heatClient = null; + try { + heatClient = getHeatClient (cloudSite, tenantId); + } catch (MsoTenantNotFound e) { + // Tenant doesn't exist, so stack doesn't either + LOGGER.debug ("Tenant with id " + tenantId + "not found.", e); + return new StackInfo (stackName, HeatStatus.NOTFOUND, null, null); + } catch (MsoException me) { + // Got an Openstack error. Propagate it + LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Exception on Token request: " + me, "Openstack", "", MsoLogger.ErrorCode.AvailabilityError, "Connection Exception"); + me.addContext ("QueryStack"); + throw me; + } + + // Query the Stack. + // An MsoException will propagate transparently to the caller. + Stack heatStack = queryHeatStack (heatClient, stackName); + + if (heatStack == null) { + // Stack does not exist. Return a StackInfo with status NOTFOUND + StackInfo stackInfo = new StackInfo (stackName, HeatStatus.NOTFOUND, null, null); + return stackInfo; + } + + return new StackInfo (heatStack); + } + + /** + * Delete a stack (by Name/ID) in a tenant. If the stack is not found, it will be + * considered a successful deletion. The return value is a StackInfo object which + * contains the current stack status. + * + * The client may choose to let the adapter poll Openstack for completion of the + * stack deletion, or may handle polling itself via separate query calls. In either + * case, a StackInfo object will be returned. When polling is enabled, a final + * status of NOTFOUND is expected. When not polling, a status of DELETING is expected. + * + * There is no rollback from a successful stack deletion. A deletion failure will + * also result in an undefined stack state - the components may or may not have been + * all or partially deleted, so the resulting stack must be considered invalid. + * + * @param tenantId The Openstack ID of the tenant in which to perform the delete + * @param cloudSiteId The cloud identifier (may be a region) from which to delete the stack. + * @param stackName The name/id of the stack to delete. May be simple or canonical + * @param pollForCompletion Indicator that polling should be handled in Java vs. in the client + * @return A StackInfo object + * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception. + * @throws MsoCloudSiteNotFound + */ + public StackInfo deleteStack (String tenantId, + String cloudSiteId, + String stackName, + boolean pollForCompletion) throws MsoException { + // Obtain the cloud site information where we will create the stack + CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + if (cloudSite == null) { + throw new MsoCloudSiteNotFound (cloudSiteId); + } + + // Get a Heat client. They are cached between calls (keyed by tenantId:cloudId) + Heat heatClient = null; + try { + heatClient = getHeatClient (cloudSite, tenantId); + } catch (MsoTenantNotFound e) { + // Tenant doesn't exist, so stack doesn't either + LOGGER.debug ("Tenant with id " + tenantId + "not found.", e); + return new StackInfo (stackName, HeatStatus.NOTFOUND, null, null); + } catch (MsoException me) { + // Got an Openstack error. Propagate it + LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "Openstack", "Openstack Exception on Token request: " + me, "Openstack", "", MsoLogger.ErrorCode.AvailabilityError, "Connection Exception"); + me.addContext (DELETE_STACK); + throw me; + } + + // OK if stack not found, perform a query first + Stack heatStack = queryHeatStack (heatClient, stackName); + if (heatStack == null || "DELETE_COMPLETE".equals (heatStack.getStackStatus ())) { + // Not found. Return a StackInfo with status NOTFOUND + return new StackInfo (stackName, HeatStatus.NOTFOUND, null, null); + } + + // Delete the stack. + + // Use canonical name "<stack name>/<stack-id>" to delete. + // Otherwise, deletion by name returns a 302 redirect. + // NOTE: This is specific to the v1 Orchestration API. + String canonicalName = heatStack.getStackName () + "/" + heatStack.getId (); + + try { + OpenStackRequest <Void> request = heatClient.getStacks ().deleteByName (canonicalName); + executeAndRecordOpenstackRequest (request, msoProps); + } catch (OpenStackResponseException e) { + if (e.getStatus () == 404) { + // Not found. We are OK with this. Return a StackInfo with status NOTFOUND + return new StackInfo (stackName, HeatStatus.NOTFOUND, null, null); + } else { + // Convert the OpenStackResponseException to an MsoOpenstackException + throw heatExceptionToMsoException (e, DELETE_STACK); + } + } catch (OpenStackConnectException e) { + // Error connecting to Openstack instance. Convert to an MsoException + throw heatExceptionToMsoException (e, DELETE_STACK); + } catch (RuntimeException e) { + // Catch-all + throw runtimeExceptionToMsoException (e, DELETE_STACK); + } + + // Requery the stack for current status. + // It will probably still exist with "DELETE_IN_PROGRESS" status. + heatStack = queryHeatStack (heatClient, canonicalName); + + if (pollForCompletion) { + // Set a timeout on polling + int pollInterval = msoProps.getIntProperty (deletePollIntervalProp, deletePollIntervalDefault); + int pollTimeout = msoProps.getIntProperty (deletePollTimeoutProp, deletePollTimeoutDefault); + + // When querying by canonical name, Openstack returns DELETE_COMPLETE status + // instead of "404" (which would result from query by stack name). + while (heatStack != null && !"DELETE_COMPLETE".equals (heatStack.getStackStatus ())) { + LOGGER.debug ("Stack status: " + heatStack.getStackStatus ()); + + if ("DELETE_FAILED".equals (heatStack.getStackStatus ())) { + // Throw a 'special case' of MsoOpenstackException to report the Heat status + String error = "Stack delete error (" + heatStack.getStackStatus () + + "): " + + heatStack.getStackStatusReason (); + MsoOpenstackException me = new MsoOpenstackException (0, "", error); + me.addContext (DELETE_STACK); + + // Alarm this condition, stack deletion failed + alarmLogger.sendAlarm (HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + + throw me; + } + + if (pollTimeout <= 0) { + LOGGER.error (MessageEnum.RA_DELETE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, heatStack.getStackStatus (), "", "", MsoLogger.ErrorCode.AvailabilityError, "Delete Stack Timeout"); + + // Throw a 'special case' of MsoOpenstackException to report the Heat status + MsoOpenstackException me = new MsoOpenstackException (0, "", "Stack Deletion Timeout"); + me.addContext (DELETE_STACK); + + // Alarm this condition, stack deletion failed + alarmLogger.sendAlarm (HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + + throw me; + } + + try { + Thread.sleep (pollInterval * 1000L); + } catch (InterruptedException e) { + LOGGER.debug ("Thread interrupted while sleeping", e); + } + + pollTimeout -= pollInterval; + + heatStack = queryHeatStack (heatClient, canonicalName); + } + + // The stack is gone when this point is reached + return new StackInfo (stackName, HeatStatus.NOTFOUND, null, null); + } + + // Return the current status (if not polling, the delete may still be in progress) + StackInfo stackInfo = new StackInfo (heatStack); + stackInfo.setName (stackName); + + return stackInfo; + } + + /** + * Query for all stacks in a tenant site. This call will return a List of StackInfo + * objects, one for each deployed stack. + * + * Note that this is limited to a single site. To ensure that a tenant is truly + * empty would require looping across all tenant endpoints. + * + * @param tenantId The Openstack ID of the tenant to query + * @param cloudSiteId The cloud identifier (may be a region) in which to query. + * @return A List of StackInfo objects + * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception. + * @throws MsoCloudSiteNotFound + */ + public List <StackInfo> queryAllStacks (String tenantId, String cloudSiteId) throws MsoException { + // Obtain the cloud site information where we will create the stack + CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + if (cloudSite == null) { + throw new MsoCloudSiteNotFound (cloudSiteId); + } + + // Get a Heat client. They are cached between calls (keyed by tenantId:cloudId) + Heat heatClient = getHeatClient (cloudSite, tenantId); + + try { + OpenStackRequest <Stacks> request = heatClient.getStacks ().list (); + Stacks stacks = executeAndRecordOpenstackRequest (request, msoProps); + + List <StackInfo> stackList = new ArrayList <StackInfo> (); + + // Not sure if returns an empty list or null if no stacks exist + if (stacks != null) { + for (Stack stack : stacks) { + stackList.add (new StackInfo (stack)); + } + } + + return stackList; + } catch (OpenStackResponseException e) { + if (e.getStatus () == 404) { + // Not sure if this can happen, but return an empty list + LOGGER.debug ("queryAllStacks - stack not found: "); + return new ArrayList <StackInfo> (); + } else { + // Convert the OpenStackResponseException to an MsoOpenstackException + throw heatExceptionToMsoException (e, QUERY_ALL_STACKS); + } + } catch (OpenStackConnectException e) { + // Error connecting to Openstack instance. Convert to an MsoException + throw heatExceptionToMsoException (e, QUERY_ALL_STACKS); + } catch (RuntimeException e) { + // Catch-all + throw runtimeExceptionToMsoException (e, QUERY_ALL_STACKS); + } + } + + /** + * Validate parameters to be passed to Heat template. This method performs + * three functions: + * 1. Apply default values to parameters which have them defined + * 2. Report any required parameters that are missing. This will generate an + * exception in the caller, since stack create/update operations would fail. + * 3. Report and remove any extraneous parameters. This will allow clients to + * pass supersets of parameters and not get errors. + * + * These functions depend on the HeatTemplate definition from the MSO Catalog DB, + * along with the input parameter Map. The output is an updated parameter map. + * If the parameters are invalid for the template, an IllegalArgumentException + * is thrown. + */ + public Map <String, Object> validateStackParams (Map <String, Object> inputParams, + HeatTemplate heatTemplate) throws IllegalArgumentException { + // Check that required parameters have been supplied for this template type + String missingParams = null; + List <String> paramList = new ArrayList <String> (); + + // TODO: Enhance DB to support defaults for Heat Template parameters + + for (HeatTemplateParam parm : heatTemplate.getParameters ()) { + if (parm.isRequired () && !inputParams.containsKey (parm.getParamName ())) { + if (missingParams == null) { + missingParams = parm.getParamName (); + } else { + missingParams += "," + parm.getParamName (); + } + } + paramList.add (parm.getParamName ()); + } + if (missingParams != null) { + // Problem - missing one or more required parameters + String error = "Missing Required inputs for HEAT Template: " + missingParams; + LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams + " for HEAT Template", "", "", MsoLogger.ErrorCode.SchemaError, "Missing Required inputs for HEAT Template: " + missingParams); + throw new IllegalArgumentException (error); + } + + // Remove any extraneous parameters (don't throw an error) + Map <String, Object> updatedParams = new HashMap <String, Object> (); + List <String> extraParams = new ArrayList <String> (); + for (String key : inputParams.keySet ()) { + if (!paramList.contains (key)) { + // This is not a valid parameter for this template + extraParams.add (key); + } else { + updatedParams.put (key, inputParams.get (key)); + } + } + if (!extraParams.isEmpty ()) { + LOGGER.warn (MessageEnum.RA_GENERAL_WARNING, "Heat Stack (" + heatTemplate.getTemplateName () + + ") extra input params received: " + + extraParams, "", "", MsoLogger.ErrorCode.DataError, "Heat Stack (" + heatTemplate.getTemplateName () + ") extra input params received: "+ extraParams); + } + + return updatedParams; + } + + // --------------------------------------------------------------- + // PRIVATE FUNCTIONS FOR USE WITHIN THIS CLASS + + /** + * Get a Heat client for the Openstack Identity service. + * This requires a 'member'-level userId + password, which will be retrieved from + * properties based on the specified cloud Id. The tenant in which to operate + * must also be provided. + * <p> + * On successful authentication, the Heat object will be cached for the + * tenantID + cloudId so that it can be reused without reauthenticating with + * Openstack every time. + * + * @param tenantName + * @param cloudId + * @return an authenticated Heat object + */ + public Heat getHeatClient (CloudSite cloudSite, String tenantId) throws MsoException { + String cloudId = cloudSite.getId (); + + // Check first in the cache of previously authorized clients + String cacheKey = cloudId + ":" + tenantId; + if (heatClientCache.containsKey (cacheKey)) { + if (!heatClientCache.get (cacheKey).isExpired ()) { + LOGGER.debug ("Using Cached HEAT Client for " + cacheKey); + return heatClientCache.get (cacheKey).getHeatClient (); + } else { + // Token is expired. Remove it from cache. + heatClientCache.remove (cacheKey); + LOGGER.debug ("Expired Cached HEAT Client for " + cacheKey); + } + } + + // Obtain an MSO token for the tenant + CloudIdentity cloudIdentity = cloudSite.getIdentityService (); + String keystoneUrl = cloudIdentity.getKeystoneUrl (cloudId, msoPropID); + Keystone keystoneTenantClient = new Keystone (keystoneUrl); + Access access = null; + try { + Authentication credentials = cloudIdentity.getAuthentication (); + + OpenStackRequest <Access> request = keystoneTenantClient.tokens () + .authenticate (credentials).withTenantId (tenantId); + + access = executeAndRecordOpenstackRequest (request, msoProps); + } catch (OpenStackResponseException e) { + if (e.getStatus () == 401) { + // Authentication error. + String error = "Authentication Failure: tenant=" + tenantId + ",cloud=" + cloudIdentity.getId (); + alarmLogger.sendAlarm ("MsoAuthenticationError", MsoAlarmLogger.CRITICAL, error); + throw new MsoAdapterException (error); + } else { + throw keystoneErrorToMsoException (e, TOKEN_AUTH); + } + } catch (OpenStackConnectException e) { + // Connection to Openstack failed + MsoIOException me = new MsoIOException (e.getMessage (), e); + me.addContext (TOKEN_AUTH); + throw me; + } catch (RuntimeException e) { + // Catch-all + throw runtimeExceptionToMsoException (e, TOKEN_AUTH); + } + + // For DCP/LCP, the region should be the cloudId. + String region = cloudSite.getRegionId (); + String heatUrl = null; + try { + heatUrl = KeystoneUtils.findEndpointURL (access.getServiceCatalog (), "orchestration", region, "public"); + } catch (RuntimeException e) { + // This comes back for not found (probably an incorrect region ID) + String error = "Orchestration service not found: region=" + region + ",cloud=" + cloudIdentity.getId (); + alarmLogger.sendAlarm ("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error); + throw new MsoAdapterException (error, e); + } + // This is needed for testing in the MT cloud + if ("MT".equals (cloudId)) { + heatUrl = heatUrl.replace ("controller", "mtdnj02bh01wt.bvoip.labs.att.com"); + } + + Heat heatClient = new Heat (heatUrl); + heatClient.token (access.getToken ().getId ()); + + heatClientCache.put (cacheKey, + new HeatCacheEntry (heatUrl, + access.getToken ().getId (), + access.getToken ().getExpires ())); + LOGGER.debug ("Caching HEAT Client for " + cacheKey); + + return heatClient; + } + + /** + * Forcibly expire a HEAT client from the cache. This call is for use by + * the KeystoneClient in case where a tenant is deleted. In that case, + * all cached credentials must be purged so that fresh authentication is + * done if a similarly named tenant is re-created. + * <p> + * Note: This is probably only applicable to dev/test environments where + * the same Tenant Name is repeatedly used for creation/deletion. + * <p> + * + * @param tenantName + * @param cloudId + */ + public static void expireHeatClient (String tenantId, String cloudId) { + String cacheKey = cloudId + ":" + tenantId; + if (heatClientCache.containsKey (cacheKey)) { + heatClientCache.remove (cacheKey); + LOGGER.debug ("Deleted Cached HEAT Client for " + cacheKey); + } + } + + /* + * Query for a Heat Stack. This function is needed in several places, so + * a common method is useful. This method takes an authenticated Heat Client + * (which internally identifies the cloud & tenant to search), and returns + * a Stack object if found, Null if not found, or an MsoOpenstackException + * if the Openstack API call fails. + * + * The stack name may be a simple name or a canonical name ("{name}/{id}"). + * When simple name is used, Openstack always returns a 302 redirect which + * results in a 2nd request (to the canonical name). Note that query by + * canonical name for a deleted stack returns a Stack object with status + * "DELETE_COMPLETE" while query by simple name for a deleted stack returns + * HTTP 404. + * + * @param heatClient an authenticated Heat client + * + * @param stackName the stack name to query + * + * @return a Stack object that describes the current stack or null if the + * requested stack doesn't exist. + * + * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception + */ + protected Stack queryHeatStack (Heat heatClient, String stackName) throws MsoException { + if (stackName == null) { + return null; + } + try { + OpenStackRequest <Stack> request = heatClient.getStacks ().byName (stackName); + return executeAndRecordOpenstackRequest (request, msoProps); + } catch (OpenStackResponseException e) { + if (e.getStatus () == 404) { + LOGGER.debug ("queryHeatStack - stack not found: " + stackName); + return null; + } else { + // Convert the OpenStackResponseException to an MsoOpenstackException + throw heatExceptionToMsoException (e, "QueryStack"); + } + } catch (OpenStackConnectException e) { + // Connection to Openstack failed + throw heatExceptionToMsoException (e, "QueryAllStack"); + } + } + + /* + * An entry in the Heat Client Cache. It saves the Heat client object + * along with the token expiration. After this interval, this cache + * item will no longer be used. + */ + private static class HeatCacheEntry implements Serializable { + + private static final long serialVersionUID = 1L; + + private String heatUrl; + private String token; + private Calendar expires; + + public HeatCacheEntry (String heatUrl, String token, Calendar expires) { + this.heatUrl = heatUrl; + this.token = token; + this.expires = expires; + } + + public Heat getHeatClient () { + Heat heatClient = new Heat (heatUrl); + heatClient.token (token); + return heatClient; + } + + public boolean isExpired () { + if (expires == null) { + return true; + } + + Calendar now = Calendar.getInstance (); + if (now.after (expires)) { + return true; + } + + return false; + } + } + + /** + * Clean up the Heat client cache to remove expired entries. + */ + public static void heatCacheCleanup () { + for (String cacheKey : heatClientCache.keySet ()) { + if (heatClientCache.get (cacheKey).isExpired ()) { + heatClientCache.remove (cacheKey); + LOGGER.debug ("Cleaned Up Cached Heat Client for " + cacheKey); + } + } + } + + /** + * Reset the Heat client cache. + * This may be useful if cached credentials get out of sync. + */ + public static void heatCacheReset () { + heatClientCache = new HashMap <String, HeatCacheEntry> (); + } + + public Map<String, Object> queryStackForOutputs(String cloudSiteId, + String tenantId, String stackName) throws MsoException { + LOGGER.debug("MsoHeatUtils.queryStackForOutputs)"); + StackInfo heatStack = this.queryStack(cloudSiteId, tenantId, stackName); + if (heatStack == null || heatStack.getStatus() == HeatStatus.NOTFOUND) { + return null; + } + Map<String, Object> outputs = heatStack.getOutputs(); + return outputs; + } + + public void queryAndCopyOutputsToInputs(String cloudSiteId, + String tenantId, String stackName, Map<String, String> inputs, + boolean overWrite) throws MsoException { + LOGGER.debug("MsoHeatUtils.queryAndCopyOutputsToInputs"); + Map<String, Object> outputs = this.queryStackForOutputs(cloudSiteId, + tenantId, stackName); + this.copyStringOutputsToInputs(inputs, outputs, overWrite); + return; + } + + public void copyStringOutputsToInputs(Map<String, String> inputs, + Map<String, Object> otherStackOutputs, boolean overWrite) { + if (inputs == null || otherStackOutputs == null) + return; + for (String key : otherStackOutputs.keySet()) { + if (!inputs.containsKey(key)) { + Object obj = otherStackOutputs.get(key); + if (obj instanceof String) { + inputs.put(key, (String) otherStackOutputs.get(key)); + } else if (obj instanceof JsonNode ){ + // This is a bit of mess - but I think it's the least impacting + // let's convert it BACK to a string - then it will get converted back later + try { + String str = this.convertNode((JsonNode) obj); + inputs.put(key, str); + } catch (Exception e) { + LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for "+ key); + //effect here is this value will not have been copied to the inputs - and therefore will error out downstream + } + } else if (obj instanceof java.util.LinkedHashMap) { + LOGGER.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode"); + try { + String str = JSON_MAPPER.writeValueAsString(obj); + inputs.put(key, str); + } catch (Exception e) { + LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for "+ key); + } + } else { + // just try to cast it - could be an integer or some such + try { + String str = (String) obj; + inputs.put(key, str); + } catch (Exception e) { + LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for "+ key); + //effect here is this value will not have been copied to the inputs - and therefore will error out downstream + } + } + } + } + return; + } + public StringBuilder requestToStringBuilder(CreateStackParam stack) { + StringBuilder sb = new StringBuilder(); + sb.append("Stack:\n"); + sb.append("\tStackName: " + stack.getStackName()); + sb.append("\tTemplateUrl: " + stack.getTemplateUrl()); + sb.append("\tTemplate: " + stack.getTemplate()); + sb.append("\tEnvironment: " + stack.getEnvironment()); + sb.append("\tTimeout: " + stack.getTimeoutMinutes()); + sb.append("\tParameters:\n"); + Map<String, Object> params = stack.getParameters(); + if (params == null || params.size() < 1) { + sb.append("\tNONE"); + } else { + for (String key : params.keySet()) { + if (params.get(key) instanceof String) { + sb.append("\t" + key + "=" + (String) params.get(key)); + } else if (params.get(key) instanceof JsonNode) { + String jsonStringOut = this.convertNode((JsonNode)params.get(key)); + sb.append("\t" + key + "=" + jsonStringOut); + } else { + sb.append("\t" + key + "= [some non-string/non-json]"); + } + } + } + return sb; + } + + private String convertNode(final JsonNode node) { + try { + final Object obj = JSON_MAPPER.treeToValue(node, Object.class); + final String json = JSON_MAPPER.writeValueAsString(obj); + return json; + } catch (JsonParseException jpe) { + LOGGER.debug("Error converting json to string " + jpe.getMessage()); + } catch (Exception e) { + LOGGER.debug("Error converting json to string " + e.getMessage()); + } + return "[Error converting json to string]"; + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java new file mode 100644 index 0000000000..04dfa12796 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java @@ -0,0 +1,333 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.utils; + + +import java.util.HashMap; +import java.util.Map; + +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.cloud.CloudSite; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.beans.StackInfo; +import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoOpenstackException; +import org.openecomp.mso.openstack.exceptions.MsoStackNotFound; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; +import com.woorea.openstack.base.client.OpenStackBaseException; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.heat.Heat; +import com.woorea.openstack.heat.model.Stack; +import com.woorea.openstack.heat.model.UpdateStackParam; + +public class MsoHeatUtilsWithUpdate extends MsoHeatUtils { + + private static final String UPDATE_STACK = "UpdateStack"; + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + + protected MsoJavaProperties msoProps = null; + + public MsoHeatUtilsWithUpdate (String msoPropID, MsoPropertiesFactory msoPropertiesFactory, CloudConfigFactory cloudConfFactory) { + super (msoPropID,msoPropertiesFactory,cloudConfFactory); + + try { + msoProps = msoPropertiesFactory.getMsoJavaProperties (msoPropID); + } catch (MsoPropertiesException e) { + LOGGER.error (MessageEnum.LOAD_PROPERTIES_FAIL, "Unknown. Mso Properties ID not found in cache: " + msoPropID, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception Mso Properties ID not found in cache: " + msoPropID, e); + } + } + + /* + * Keep these methods around for backward compatibility + */ + + public StackInfo updateStack (String cloudSiteId, + String tenantId, + String stackName, + String heatTemplate, + Map <String, Object> stackInputs, + boolean pollForCompletion, + int timeoutMinutes) throws MsoException { + // Keeping this method to allow compatibility with no environment or files variable sent. In this case, + // simply return the new method with the environment variable set to null. + return this.updateStack (cloudSiteId, + tenantId, + stackName, + heatTemplate, + stackInputs, + pollForCompletion, + timeoutMinutes, + null, + null, + null); + } + + public StackInfo updateStack (String cloudSiteId, + String tenantId, + String stackName, + String heatTemplate, + Map <String, Object> stackInputs, + boolean pollForCompletion, + int timeoutMinutes, + String environment) throws MsoException { + // Keeping this method to allow compatibility with no environment variable sent. In this case, + // simply return the new method with the files variable set to null. + return this.updateStack (cloudSiteId, + tenantId, + stackName, + heatTemplate, + stackInputs, + pollForCompletion, + timeoutMinutes, + environment, + null, + null); + } + + public StackInfo updateStack (String cloudSiteId, + String tenantId, + String stackName, + String heatTemplate, + Map <String, Object> stackInputs, + boolean pollForCompletion, + int timeoutMinutes, + String environment, + Map <String, Object> files) throws MsoException { + return this.updateStack (cloudSiteId, + tenantId, + stackName, + heatTemplate, + stackInputs, + pollForCompletion, + timeoutMinutes, + environment, + files, + null); + } + + /** + * Update a Stack in the specified cloud location and tenant. The Heat template + * and parameter map are passed in as arguments, along with the cloud access credentials. + * It is expected that parameters have been validated and contain at minimum the required + * parameters for the given template with no extra (undefined) parameters.. + * + * The Stack name supplied by the caller must be unique in the scope of this tenant. + * However, it should also be globally unique, as it will be the identifier for the + * resource going forward in Inventory. This latter is managed by the higher levels + * invoking this function. + * + * The caller may choose to let this function poll Openstack for completion of the + * stack creation, or may handle polling itself via separate calls to query the status. + * In either case, a StackInfo object will be returned containing the current status. + * When polling is enabled, a status of CREATED is expected. When not polling, a + * status of BUILDING is expected. + * + * An error will be thrown if the requested Stack already exists in the specified + * Tenant and Cloud. + * + * @param tenantId The Openstack ID of the tenant in which to create the Stack + * @param cloudSiteId The cloud identifier (may be a region) in which to create the tenant. + * @param stackName The name of the stack to update + * @param stackTemplate The Heat template + * @param stackInputs A map of key/value inputs + * @param pollForCompletion Indicator that polling should be handled in Java vs. in the client + * @param environment An optional yaml-format string to specify environmental parameters + * @param files a Map<String, Object> for listing child template IDs + * @param heatFiles a Map<String, Object> for listing get_file entries (fileName, fileBody) + * @return A StackInfo object + * @throws MsoException Thrown if the Openstack API call returns an exception. + */ + + public StackInfo updateStack (String cloudSiteId, + String tenantId, + String stackName, + String heatTemplate, + Map <String, Object> stackInputs, + boolean pollForCompletion, + int timeoutMinutes, + String environment, + Map <String, Object> files, + Map <String, Object> heatFiles) throws MsoException { + boolean heatEnvtVariable = true; + if (environment == null || "".equalsIgnoreCase (environment.trim ())) { + heatEnvtVariable = false; + } + boolean haveFiles = true; + if (files == null || files.isEmpty ()) { + haveFiles = false; + } + boolean haveHeatFiles = true; + if (heatFiles == null || heatFiles.isEmpty ()) { + haveHeatFiles = false; + } + + // Obtain the cloud site information where we will create the stack + CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + if (cloudSite == null) { + throw new MsoCloudSiteNotFound (cloudSiteId); + } + // Get a Heat client. They are cached between calls (keyed by tenantId:cloudId) + // This could throw MsoTenantNotFound or MsoOpenstackException (both propagated) + Heat heatClient = getHeatClient (cloudSite, tenantId); + + // Perform a query first to get the current status + Stack heatStack = queryHeatStack (heatClient, stackName); + if (heatStack == null || "DELETE_COMPLETE".equals (heatStack.getStackStatus ())) { + // Not found. Return a StackInfo with status NOTFOUND + throw new MsoStackNotFound (stackName, tenantId, cloudSiteId); + } + + // Use canonical name "<stack name>/<stack-id>" to update the stack. + // Otherwise, update by name returns a 302 redirect. + // NOTE: This is specific to the v1 Orchestration API. + String canonicalName = heatStack.getStackName () + "/" + heatStack.getId (); + + LOGGER.debug ("Ready to Update Stack (" + canonicalName + ") with input params: " + stackInputs); + + // Build up the stack update parameters + // Disable auto-rollback, because error reason is lost. Always rollback in the code. + UpdateStackParam stack = new UpdateStackParam (); + stack.setTimeoutMinutes (timeoutMinutes); + stack.setParameters (stackInputs); + stack.setTemplate (heatTemplate); + stack.setDisableRollback (true); + // TJM add envt to stack + if (heatEnvtVariable) { + stack.setEnvironment (environment); + } + + // Handle nested templates & get_files here. if we have both - must combine + // and then add to stack (both are part of "files:" being added to stack) + if (haveFiles && haveHeatFiles) { + // Let's do this here - not in the bean + LOGGER.debug ("Found files AND heatFiles - combine and add!"); + Map <String, Object> combinedFiles = new HashMap <String, Object> (); + for (String keyString : files.keySet ()) { + combinedFiles.put (keyString, files.get (keyString)); + } + for (String keyString : heatFiles.keySet ()) { + combinedFiles.put (keyString, heatFiles.get (keyString)); + } + stack.setFiles (combinedFiles); + } else { + // Handle case where we have one or neither + if (haveFiles) { + stack.setFiles (files); + } + if (haveHeatFiles) { + // setFiles method modified to handle adding a map. + stack.setFiles (heatFiles); + } + } + + try { + // Execute the actual Openstack command to update the Heat stack + OpenStackRequest <Void> request = heatClient.getStacks ().update (canonicalName, stack); + executeAndRecordOpenstackRequest (request, msoProps); + } catch (OpenStackBaseException e) { + // Since this came on the 'Update Stack' command, nothing was changed + // in the cloud. Rethrow the error as an MSO exception. + throw heatExceptionToMsoException (e, UPDATE_STACK); + } catch (RuntimeException e) { + // Catch-all + throw runtimeExceptionToMsoException (e, UPDATE_STACK); + } + + // If client has requested a final response, poll for stack completion + Stack updateStack = null; + if (pollForCompletion) { + // Set a time limit on overall polling. + // Use the resource (template) timeout for Openstack (expressed in minutes) + // and add one poll interval to give Openstack a chance to fail on its own. + int createPollInterval = msoProps.getIntProperty (createPollIntervalProp, createPollIntervalDefault); + int pollTimeout = (timeoutMinutes * 60) + createPollInterval; + + boolean loopAgain = true; + while (loopAgain) { + try { + updateStack = queryHeatStack (heatClient, canonicalName); + LOGGER.debug (updateStack.getStackStatus ()); + + if ("UPDATE_IN_PROGRESS".equals (updateStack.getStackStatus ())) { + // Stack update is still running. + // Sleep and try again unless timeout has been reached + if (pollTimeout <= 0) { + // Note that this should not occur, since there is a timeout specified + // in the Openstack call. + LOGGER.error (MessageEnum.RA_UPDATE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, updateStack.getStackStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError, "Update stack timeout"); + loopAgain = false; + } else { + try { + Thread.sleep (createPollInterval * 1000L); + } catch (InterruptedException e) { + // If we are interrupted, we should stop ASAP. + loopAgain = false; + // Set again the interrupted flag + Thread.currentThread().interrupt(); + } + } + pollTimeout -= createPollInterval; + } else { + loopAgain = false; + } + } catch (MsoException e) { + // Cannot query the stack. Something is wrong. + + // TODO: No way to roll back the stack at this point. What to do? + e.addContext (UPDATE_STACK); + throw e; + } + } + + if (!"UPDATE_COMPLETE".equals (updateStack.getStackStatus ())) { + LOGGER.error (MessageEnum.RA_UPDATE_STACK_ERR, updateStack.getStackStatus(), updateStack.getStackStatusReason(), "", "", MsoLogger.ErrorCode.DataError, "Update Stack error"); + + // TODO: No way to roll back the stack at this point. What to do? + // Throw a 'special case' of MsoOpenstackException to report the Heat status + MsoOpenstackException me = null; + if ("UPDATE_IN_PROGRESS".equals (updateStack.getStackStatus ())) { + me = new MsoOpenstackException (0, "", "Stack Update Timeout"); + } else { + String error = "Stack error (" + updateStack.getStackStatus () + + "): " + + updateStack.getStackStatusReason (); + me = new MsoOpenstackException (0, "", error); + } + me.addContext (UPDATE_STACK); + throw me; + } + + } else { + // Return the current status. + updateStack = queryHeatStack (heatClient, canonicalName); + if (updateStack != null) { + LOGGER.debug ("UpdateStack, status = " + updateStack.getStackStatus ()); + } else { + LOGGER.debug ("UpdateStack, stack not found"); + } + } + return new StackInfo (updateStack); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java new file mode 100644 index 0000000000..82203d044c --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java @@ -0,0 +1,684 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.utils; + + +import java.io.Serializable; +import java.util.Calendar; +import java.util.HashMap; +import java.util.Map; + +import org.openecomp.mso.cloud.CloudConfig; +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.cloud.CloudIdentity; +import org.openecomp.mso.cloud.CloudSite; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.openstack.beans.MsoTenant; +import org.openecomp.mso.openstack.exceptions.MsoAdapterException; +import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoOpenstackException; +import org.openecomp.mso.openstack.exceptions.MsoTenantAlreadyExists; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; +import com.woorea.openstack.base.client.OpenStackBaseException; +import com.woorea.openstack.base.client.OpenStackConnectException; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.base.client.OpenStackResponseException; +import com.woorea.openstack.keystone.Keystone; +import com.woorea.openstack.keystone.model.Access; +import com.woorea.openstack.keystone.model.Metadata; +import com.woorea.openstack.keystone.model.Role; +import com.woorea.openstack.keystone.model.Roles; +import com.woorea.openstack.keystone.model.Tenant; +import com.woorea.openstack.keystone.model.User; +import com.woorea.openstack.keystone.utils.KeystoneUtils; +import com.woorea.openstack.keystone.model.Authentication; + +public class MsoKeystoneUtils extends MsoTenantUtils { + + // Cache the Keystone Clients statically. Since there is just one MSO user, there is no + // benefit to re-authentication on every request (or across different flows). The + // token will be used until it expires. + // + // The cache key is "cloudId" + private static Map <String, KeystoneCacheEntry> adminClientCache = new HashMap <String, KeystoneCacheEntry> (); + + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + String msoPropID; + + public MsoKeystoneUtils (String msoPropID) { + super(msoPropID); + this.msoPropID = msoPropID; + LOGGER.debug("MsoKeyStoneUtils:" + msoPropID); + } + + /** + * Create a tenant with the specified name in the given cloud. If the tenant already exists, + * an Exception will be thrown. The MSO User will also be added to the "member" list of + * the new tenant to perform subsequent Nova/Heat commands in the tenant. If the MSO User + * association fails, the entire transaction will be rolled back. + * <p> + * For the AIC Cloud (DCP/LCP): it is not clear that cloudId is needed, as all admin + * requests go to the centralized identity service in DCP. However, if some artifact + * must exist in each local LCP instance as well, then it will be needed to access the + * correct region. + * <p> + * + * @param tenantName The tenant name to create + * @param cloudId The cloud identifier (may be a region) in which to create the tenant. + * @return the tenant ID of the newly created tenant + * @throws MsoTenantAlreadyExists Thrown if the requested tenant already exists + * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception + */ + public String createTenant (String tenantName, + String cloudSiteId, + Map <String, String> metadata, + boolean backout) throws MsoException { + // Obtain the cloud site information where we will create the tenant + CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + if (cloudSite == null) { + LOGGER.error(MessageEnum.RA_CREATE_TENANT_ERR, "MSOCloudSite not found", "", "", MsoLogger.ErrorCode.DataError, "MSOCloudSite not found"); + throw new MsoCloudSiteNotFound (cloudSiteId); + } + Keystone keystoneAdminClient = getKeystoneAdminClient (cloudSite); + + Tenant tenant = null; + try { + // Check if the tenant already exists + tenant = findTenantByName (keystoneAdminClient, tenantName); + + if (tenant != null) { + // Tenant already exists. Throw an exception + LOGGER.error(MessageEnum.RA_TENANT_ALREADY_EXIST, tenantName, cloudSiteId, "", "", MsoLogger.ErrorCode.DataError, "Tenant already exists"); + throw new MsoTenantAlreadyExists (tenantName, cloudSiteId); + } + + // Does not exist, create a new one + tenant = new Tenant (); + tenant.setName (tenantName); + tenant.setDescription ("SDN Tenant (via MSO)"); + tenant.setEnabled (true); + + OpenStackRequest <Tenant> request = keystoneAdminClient.tenants ().create (tenant); + tenant = executeAndRecordOpenstackRequest (request, msoProps); + } catch (OpenStackBaseException e) { + // Convert Keystone OpenStackResponseException to MsoOpenstackException + throw keystoneErrorToMsoException (e, "CreateTenant"); + } catch (RuntimeException e) { + // Catch-all + throw runtimeExceptionToMsoException (e, "CreateTenant"); + } + + // Add MSO User to the tenant as a member and + // apply tenant metadata if supported by the cloud site + try { + CloudIdentity cloudIdentity = cloudSite.getIdentityService (); + + User msoUser = findUserByNameOrId (keystoneAdminClient, cloudIdentity.getMsoId ()); + Role memberRole = findRoleByNameOrId (keystoneAdminClient, cloudIdentity.getMemberRole ()); + + OpenStackRequest <Void> request = keystoneAdminClient.tenants ().addUser (tenant.getId (), + msoUser.getId (), + memberRole.getId ()); + executeAndRecordOpenstackRequest (request, msoProps); + + if (cloudIdentity.hasTenantMetadata () && metadata != null && !metadata.isEmpty ()) { + Metadata tenantMetadata = new Metadata (); + tenantMetadata.setMetadata (metadata); + + OpenStackRequest <Metadata> metaRequest = keystoneAdminClient.tenants () + .createOrUpdateMetadata (tenant.getId (), + tenantMetadata); + executeAndRecordOpenstackRequest (metaRequest, msoProps); + } + } catch (Exception e) { + // Failed to attach MSO User to the new tenant. Can't operate without access, + // so roll back the tenant. + if (!backout) + { + LOGGER.warn(MessageEnum.RA_CREATE_TENANT_ERR, "Create Tenant errored, Tenant deletion suppressed", "Openstack", "", MsoLogger.ErrorCode.DataError, "Create Tenant error, Tenant deletion suppressed"); + } + else + { + try { + OpenStackRequest <Void> request = keystoneAdminClient.tenants ().delete (tenant.getId ()); + executeAndRecordOpenstackRequest (request, msoProps); + } catch (Exception e2) { + // Just log this one. We will report the original exception. + LOGGER.error (MessageEnum.RA_CREATE_TENANT_ERR, "Nested exception rolling back tenant", "Openstack", "", MsoLogger.ErrorCode.DataError, "Create Tenant error, Nested exception rolling back tenant", e2); + } + } + + + // Propagate the original exception on user/role/tenant mapping + if (e instanceof OpenStackBaseException) { + // Convert Keystone Exception to MsoOpenstackException + throw keystoneErrorToMsoException ((OpenStackBaseException) e, "CreateTenantUser"); + } else { + MsoAdapterException me = new MsoAdapterException (e.getMessage (), e); + me.addContext ("CreateTenantUser"); + throw me; + } + } + return tenant.getId (); + } + + /** + * Query for a tenant by ID in the given cloud. If the tenant exists, + * return an MsoTenant object. If not, return null. + * <p> + * For the AIC Cloud (DCP/LCP): it is not clear that cloudId is needed, as all admin + * requests go to the centralized identity service in DCP. However, if some artifact + * must exist in each local LCP instance as well, then it will be needed to access the + * correct region. + * <p> + * + * @param tenantId The Openstack ID of the tenant to query + * @param cloudSiteId The cloud identifier (may be a region) in which to query the tenant. + * @return the tenant properties of the queried tenant, or null if not found + * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception + */ + public MsoTenant queryTenant (String tenantId, String cloudSiteId) throws MsoException, MsoCloudSiteNotFound { + // Obtain the cloud site information where we will query the tenant + CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + if (cloudSite == null) { + throw new MsoCloudSiteNotFound (cloudSiteId); + } + + Keystone keystoneAdminClient = getKeystoneAdminClient (cloudSite); + + // Check if the tenant exists and return its Tenant Id + try { + Tenant tenant = findTenantById (keystoneAdminClient, tenantId); + if (tenant == null) { + return null; + } + + Map <String, String> metadata = new HashMap <String, String> (); + if (cloudSite.getIdentityService ().hasTenantMetadata ()) { + OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ()); + Metadata tenantMetadata = executeAndRecordOpenstackRequest (request, msoProps); + if (tenantMetadata != null) { + metadata = tenantMetadata.getMetadata (); + } + } + return new MsoTenant (tenant.getId (), tenant.getName (), metadata); + } catch (OpenStackBaseException e) { + // Convert Keystone OpenStackResponseException to MsoOpenstackException + throw keystoneErrorToMsoException (e, "QueryTenant"); + } catch (RuntimeException e) { + // Catch-all + throw runtimeExceptionToMsoException (e, "QueryTenant"); + } + } + + /** + * Query for a tenant with the specified name in the given cloud. If the tenant exists, + * return an MsoTenant object. If not, return null. This query is useful if the client + * knows it has the tenant name, skipping an initial lookup by ID that would always fail. + * <p> + * For the AIC Cloud (DCP/LCP): it is not clear that cloudId is needed, as all admin + * requests go to the centralized identity service in DCP. However, if some artifact + * must exist in each local LCP instance as well, then it will be needed to access the + * correct region. + * <p> + * + * @param tenantName The name of the tenant to query + * @param cloudSiteId The cloud identifier (may be a region) in which to query the tenant. + * @return the tenant properties of the queried tenant, or null if not found + * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception + */ + public MsoTenant queryTenantByName (String tenantName, String cloudSiteId) throws MsoException { + // Obtain the cloud site information where we will query the tenant + CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + if (cloudSite == null) { + throw new MsoCloudSiteNotFound (cloudSiteId); + } + Keystone keystoneAdminClient = getKeystoneAdminClient (cloudSite); + + try { + Tenant tenant = findTenantByName (keystoneAdminClient, tenantName); + if (tenant == null) { + return null; + } + + Map <String, String> metadata = new HashMap <String, String> (); + if (cloudSite.getIdentityService ().hasTenantMetadata ()) { + OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ()); + Metadata tenantMetadata = executeAndRecordOpenstackRequest (request, msoProps); + if (tenantMetadata != null) { + metadata = tenantMetadata.getMetadata (); + } + } + return new MsoTenant (tenant.getId (), tenant.getName (), metadata); + } catch (OpenStackBaseException e) { + // Convert Keystone OpenStackResponseException to MsoOpenstackException + throw keystoneErrorToMsoException (e, "QueryTenantName"); + } catch (RuntimeException e) { + // Catch-all + throw runtimeExceptionToMsoException (e, "QueryTenantName"); + } + } + + /** + * Delete the specified Tenant (by ID) in the given cloud. This method returns true or + * false, depending on whether the tenant existed and was successfully deleted, or if + * the tenant already did not exist. Both cases are treated as success (no Exceptions). + * <p> + * Note for the AIC Cloud (DCP/LCP): all admin requests go to the centralized identity + * service in DCP. So deleting a tenant from one cloudSiteId will remove it from all + * sites managed by that identity service. + * <p> + * + * @param tenantId The Openstack ID of the tenant to delete + * @param cloudSiteId The cloud identifier from which to delete the tenant. + * @return true if the tenant was deleted, false if the tenant did not exist. + * @throws MsoOpenstackException If the Openstack API call returns an exception. + */ + public boolean deleteTenant (String tenantId, String cloudSiteId) throws MsoException { + // Obtain the cloud site information where we will query the tenant + CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + if (cloudSite == null) { + throw new MsoCloudSiteNotFound (cloudSiteId); + } + Keystone keystoneAdminClient = getKeystoneAdminClient (cloudSite); + + try { + // Check that the tenant exists. Also, need the ID to delete + Tenant tenant = findTenantById (keystoneAdminClient, tenantId); + if (tenant == null) { + LOGGER.error(MessageEnum.RA_TENANT_NOT_FOUND, tenantId, cloudSiteId, "", "", MsoLogger.ErrorCode.DataError, "Tenant not found"); + return false; + } + + OpenStackRequest <Void> request = keystoneAdminClient.tenants ().delete (tenant.getId ()); + executeAndRecordOpenstackRequest (request, msoProps); + LOGGER.debug ("Deleted Tenant " + tenant.getId () + " (" + tenant.getName () + ")"); + + // Clear any cached clients. Not really needed, ID will not be reused. + MsoHeatUtils.expireHeatClient (tenant.getId (), cloudSiteId); + MsoNeutronUtils.expireNeutronClient (tenant.getId (), cloudSiteId); + } catch (OpenStackBaseException e) { + // Convert Keystone OpenStackResponseException to MsoOpenstackException + throw keystoneErrorToMsoException (e, "Delete Tenant"); + } catch (RuntimeException e) { + // Catch-all + throw runtimeExceptionToMsoException (e, "DeleteTenant"); + } + + return true; + } + + /** + * Delete the specified Tenant (by Name) in the given cloud. This method returns true or + * false, depending on whether the tenant existed and was successfully deleted, or if + * the tenant already did not exist. Both cases are treated as success (no Exceptions). + * <p> + * Note for the AIC Cloud (DCP/LCP): all admin requests go to the centralized identity + * service in DCP. So deleting a tenant from one cloudSiteId will remove it from all + * sites managed by that identity service. + * <p> + * + * @param tenantName The name of the tenant to delete + * @param cloudSiteId The cloud identifier from which to delete the tenant. + * @return true if the tenant was deleted, false if the tenant did not exist. + * @throws MsoOpenstackException If the Openstack API call returns an exception. + */ + public boolean deleteTenantByName (String tenantName, String cloudSiteId) throws MsoException { + // Obtain the cloud site information where we will query the tenant + CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + if (cloudSite == null) { + throw new MsoCloudSiteNotFound (cloudSiteId); + } + Keystone keystoneAdminClient = getKeystoneAdminClient (cloudSite); + + try { + // Need the Tenant ID to delete (can't directly delete by name) + Tenant tenant = findTenantByName (keystoneAdminClient, tenantName); + if (tenant == null) { + // OK if tenant already doesn't exist. + LOGGER.error(MessageEnum.RA_TENANT_NOT_FOUND, tenantName, cloudSiteId, "", "", MsoLogger.ErrorCode.DataError, "Tenant not found"); + return false; + } + + // Execute the Delete. It has no return value. + OpenStackRequest <Void> request = keystoneAdminClient.tenants ().delete (tenant.getId ()); + executeAndRecordOpenstackRequest (request, msoProps); + + LOGGER.debug ("Deleted Tenant " + tenant.getId () + " (" + tenant.getName () + ")"); + + // Clear any cached clients. Not really needed, ID will not be reused. + MsoHeatUtils.expireHeatClient (tenant.getId (), cloudSiteId); + MsoNeutronUtils.expireNeutronClient (tenant.getId (), cloudSiteId); + } catch (OpenStackBaseException e) { + // Note: It doesn't seem to matter if tenant doesn't exist, no exception is thrown. + // Convert Keystone OpenStackResponseException to MsoOpenstackException + throw keystoneErrorToMsoException (e, "DeleteTenant"); + } catch (RuntimeException e) { + // Catch-all + throw runtimeExceptionToMsoException (e, "DeleteTenant"); + } + + return true; + } + + // ------------------------------------------------------------------- + // PRIVATE UTILITY FUNCTIONS FOR USE WITHIN THIS CLASS + + /* + * Get a Keystone Admin client for the Openstack Identity service. + * This requires an 'admin'-level userId + password along with an 'admin' tenant + * in the target cloud. These values will be retrieved from properties based + * on the specified cloud ID. + * <p> + * On successful authentication, the Keystone object will be cached for the cloudId + * so that it can be reused without going back to Openstack every time. + * + * @param cloudId + * + * @return an authenticated Keystone object + */ + public Keystone getKeystoneAdminClient (CloudSite cloudSite) throws MsoException { + CloudIdentity cloudIdentity = cloudSite.getIdentityService (); + + String cloudId = cloudIdentity.getId (); + String adminTenantName = cloudIdentity.getAdminTenant (); + String region = cloudSite.getRegionId (); + + // Check first in the cache of previously authorized clients + KeystoneCacheEntry entry = adminClientCache.get (cloudId); + if (entry != null) { + if (!entry.isExpired ()) { + return entry.getKeystoneClient (); + } else { + // Token is expired. Remove it from cache. + adminClientCache.remove (cloudId); + } + } + + Keystone keystone = new Keystone (cloudIdentity.getKeystoneUrl (region, msoPropID)); + + // Must authenticate against the 'admin' tenant to get the services endpoints + Access access = null; + String token = null; + try { + Authentication credentials = cloudIdentity.getAuthentication (); + OpenStackRequest <Access> request = keystone.tokens () + .authenticate (credentials) + .withTenantName (adminTenantName); + access = executeAndRecordOpenstackRequest (request, msoProps); + token = access.getToken ().getId (); + } catch (OpenStackResponseException e) { + if (e.getStatus () == 401) { + // Authentication error. Can't access admin tenant - something is mis-configured + String error = "MSO Authentication Failed for " + cloudIdentity.getId (); + alarmLogger.sendAlarm ("MsoAuthenticationError", MsoAlarmLogger.CRITICAL, error); + throw new MsoAdapterException (error); + } else { + throw keystoneErrorToMsoException (e, "TokenAuth"); + } + } catch (OpenStackConnectException e) { + // Connection to Openstack failed + throw keystoneErrorToMsoException (e, "TokenAuth"); + } + + // Get the Identity service URL. Throws runtime exception if not found per region. + String adminUrl = null; + try { + adminUrl = KeystoneUtils.findEndpointURL (access.getServiceCatalog (), "identity", region, "admin"); + } catch (RuntimeException e) { + String error = "Identity service not found: region=" + region + ",cloud=" + cloudIdentity.getId (); + alarmLogger.sendAlarm ("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error); + LOGGER.error(MessageEnum.IDENTITY_SERVICE_NOT_FOUND, region, cloudIdentity.getId(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception in findEndpointURL"); + throw new MsoAdapterException (error, e); + } + // The following is needed for the MT lab. + if ("MT".equals (cloudSite.getId ())) { + adminUrl = adminUrl.replace ("controller", "mtdnj02bh01wt.bvoip.labs.att.com"); + } + + // A new Keystone object is required for the new URL. Use the auth token from above. + // Note: this doesn't go back to Openstack, it's just a local object. + keystone = new Keystone (adminUrl); + keystone.token (token); + + // Cache to avoid re-authentication for every call. + KeystoneCacheEntry cacheEntry = new KeystoneCacheEntry (adminUrl, token, access.getToken ().getExpires ()); + adminClientCache.put (cloudId, cacheEntry); + + return keystone; + } + + /* + * Find a tenant (or query its existance) by its Name or Id. Check first against the + * ID. If that fails, then try by name. + * + * @param adminClient an authenticated Keystone object + * + * @param tenantName the tenant name or ID to query + * + * @return a Tenant object or null if not found + */ + public Tenant findTenantByNameOrId (Keystone adminClient, String tenantNameOrId) { + if (tenantNameOrId == null) { + return null; + } + + Tenant tenant = findTenantById (adminClient, tenantNameOrId); + if (tenant == null) { + tenant = findTenantByName (adminClient, tenantNameOrId); + } + + return tenant; + } + + /* + * Find a tenant (or query its existance) by its Id. + * + * @param adminClient an authenticated Keystone object + * + * @param tenantName the tenant ID to query + * + * @return a Tenant object or null if not found + */ + private Tenant findTenantById (Keystone adminClient, String tenantId) { + if (tenantId == null) { + return null; + } + + try { + OpenStackRequest <Tenant> request = adminClient.tenants ().show (tenantId); + return executeAndRecordOpenstackRequest (request, msoProps); + } catch (OpenStackResponseException e) { + if (e.getStatus () == 404) { + return null; + } else { + LOGGER.error(MessageEnum.RA_CONNECTION_EXCEPTION, "Openstack Error, GET Tenant by Id (" + tenantId + "): " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception in Openstack GET tenant by Id"); + throw e; + } + } + } + + /* + * Find a tenant (or query its existance) by its Name. This method avoids an + * initial lookup by ID when it's known that we have the tenant Name. + * + * @param adminClient an authenticated Keystone object + * + * @param tenantName the tenant name to query + * + * @return a Tenant object or null if not found + */ + public Tenant findTenantByName (Keystone adminClient, String tenantName) { + if (tenantName == null) { + return null; + } + + try { + OpenStackRequest <Tenant> request = adminClient.tenants ().show ("").queryParam ("name", tenantName); + return executeAndRecordOpenstackRequest (request, msoProps); + } catch (OpenStackResponseException e) { + if (e.getStatus () == 404) { + return null; + } else { + LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "Openstack Error, GET Tenant By Name (" + tenantName + "): " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception in Openstack GET Tenant By Name"); + throw e; + } + } + } + + /* + * Look up an Openstack User by Name or Openstack ID. Check the ID first, and if that + * fails, try the Name. + * + * @param adminClient an authenticated Keystone object + * + * @param userName the user name or ID to query + * + * @return a User object or null if not found + */ + private User findUserByNameOrId (Keystone adminClient, String userNameOrId) { + if (userNameOrId == null) { + return null; + } + + try { + OpenStackRequest <User> request = adminClient.users ().show (userNameOrId); + return executeAndRecordOpenstackRequest (request, msoProps); + } catch (OpenStackResponseException e) { + if (e.getStatus () == 404) { + // Not found by ID. Search for name + return findUserByName (adminClient, userNameOrId); + } else { + LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "Openstack Error, GET User (" + userNameOrId + "): " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception in Openstack GET User"); + throw e; + } + } + } + + /* + * Look up an Openstack User by Name. This avoids initial Openstack query by ID + * if we know we have the User Name. + * + * @param adminClient an authenticated Keystone object + * + * @param userName the user name to query + * + * @return a User object or null if not found + */ + public User findUserByName (Keystone adminClient, String userName) { + if (userName == null) { + return null; + } + + try { + OpenStackRequest <User> request = adminClient.users ().show ("").queryParam ("name", userName); + return executeAndRecordOpenstackRequest (request, msoProps); + } catch (OpenStackResponseException e) { + if (e.getStatus () == 404) { + return null; + } else { + LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "Openstack Error, GET User By Name (" + userName + "): " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception in Openstack GET User By Name"); + throw e; + } + } + } + + /* + * Look up an Openstack Role by Name or Id. There is no direct query for Roles, so + * need to retrieve a full list from Openstack and look for a match. By default, + * Openstack should have a "_member_" role for normal VM-level privileges and an + * "admin" role for expanded privileges (e.g. administer tenants, users, and roles). + * <p> + * + * @param adminClient an authenticated Keystone object + * + * @param roleNameOrId the Role name or ID to look up + * + * @return a Role object + */ + private Role findRoleByNameOrId (Keystone adminClient, String roleNameOrId) { + if (roleNameOrId == null) { + return null; + } + + // Search by name or ID. Must search in list + OpenStackRequest <Roles> request = adminClient.roles ().list (); + Roles roles = executeAndRecordOpenstackRequest (request, msoProps); + + for (Role role : roles) { + if (roleNameOrId.equals (role.getName ()) || roleNameOrId.equals (role.getId ())) { + return role; + } + } + + return null; + } + + private static class KeystoneCacheEntry implements Serializable { + + private static final long serialVersionUID = 1L; + + private String keystoneUrl; + private String token; + private Calendar expires; + + public KeystoneCacheEntry (String url, String token, Calendar expires) { + this.keystoneUrl = url; + this.token = token; + this.expires = expires; + } + + public Keystone getKeystoneClient () { + Keystone keystone = new Keystone (keystoneUrl); + keystone.token (token); + return keystone; + } + + public boolean isExpired () { + return Calendar.getInstance ().after (expires); + } + } + + /** + * Clean up the Admin client cache to remove expired entries. + */ + public static void adminCacheCleanup () { + for (String cacheKey : adminClientCache.keySet ()) { + if (adminClientCache.get (cacheKey).isExpired ()) { + adminClientCache.remove (cacheKey); + LOGGER.debug ("Cleaned Up Cached Admin Client for " + cacheKey); + } + } + } + + /** + * Reset the Admin client cache. + * This may be useful if cached credentials get out of sync. + */ + public static void adminCacheReset () { + adminClientCache = new HashMap <String, KeystoneCacheEntry> (); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java new file mode 100644 index 0000000000..7e388a5ef8 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java @@ -0,0 +1,616 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.utils; + + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.openecomp.mso.cloud.CloudConfig; +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.cloud.CloudIdentity; +import org.openecomp.mso.cloud.CloudSite; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.beans.NetworkInfo; +import org.openecomp.mso.openstack.exceptions.MsoAdapterException; +import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoIOException; +import org.openecomp.mso.openstack.exceptions.MsoNetworkAlreadyExists; +import org.openecomp.mso.openstack.exceptions.MsoNetworkNotFound; +import org.openecomp.mso.openstack.exceptions.MsoOpenstackException; +import org.openecomp.mso.openstack.exceptions.MsoTenantNotFound; +import com.woorea.openstack.base.client.OpenStackBaseException; +import com.woorea.openstack.base.client.OpenStackConnectException; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.base.client.OpenStackResponseException; +import com.woorea.openstack.keystone.Keystone; +import com.woorea.openstack.keystone.model.Access; +import com.woorea.openstack.keystone.utils.KeystoneUtils; +import com.woorea.openstack.quantum.Quantum; +import com.woorea.openstack.quantum.model.Network; +import com.woorea.openstack.quantum.model.Networks; +import com.woorea.openstack.quantum.model.Segment; +import com.woorea.openstack.keystone.model.Authentication; + +public class MsoNeutronUtils extends MsoCommonUtils +{ + // Cache Neutron Clients statically. Since there is just one MSO user, there is no + // benefit to re-authentication on every request (or across different flows). The + // token will be used until it expires. + // + // The cache key is "tenantId:cloudId" + private static Map<String,NeutronCacheEntry> neutronClientCache = new HashMap<String,NeutronCacheEntry>(); + + // Fetch cloud configuration each time (may be cached in CloudConfig class) + private CloudConfig cloudConfig; + + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private String msoPropID; + + public enum NetworkType { + BASIC, PROVIDER, MULTI_PROVIDER + }; + + public MsoNeutronUtils(String msoPropID, CloudConfigFactory cloudConfigFactory) { + cloudConfig = cloudConfigFactory.getCloudConfig(); + this.msoPropID = msoPropID; + } + + /** + * Create a network with the specified parameters in the given cloud/tenant. + * + * If a network already exists with the same name, an exception will be thrown. Note that + * this is an MSO-imposed restriction. Openstack does not require uniqueness on network names. + * <p> + * @param cloudSiteId The cloud identifier (may be a region) in which to create the network. + * @param tenantId The tenant in which to create the network + * @param type The type of network to create (Basic, Provider, Multi-Provider) + * @param networkName The network name to create + * @param provider The provider network name (for Provider or Multi-Provider networks) + * @param vlans A list of VLAN segments for the network (for Provider or Multi-Provider networks) + * @return a NetworkInfo object which describes the newly created network + * @throws MsoNetworkAlreadyExists Thrown if a network with the same name already exists + * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception + * @throws MsoCloudSiteNotFound Thrown if the cloudSite is invalid or unknown + */ + public NetworkInfo createNetwork (String cloudSiteId, String tenantId, NetworkType type, String networkName, String provider, List<Integer> vlans) + throws MsoException, MsoNetworkAlreadyExists, MsoCloudSiteNotFound + { + // Obtain the cloud site information where we will create the stack + CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId); + if (cloudSite == null) { + throw new MsoCloudSiteNotFound(cloudSiteId); + } + + Quantum neutronClient = getNeutronClient (cloudSite, tenantId); + + // Check if a network already exists with this name + // Openstack will allow duplicate name, so require explicit check + Network network = findNetworkByName (neutronClient, networkName); + + if (network != null) { + // Network already exists. Throw an exception + LOGGER.error(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Network already exists"); + throw new MsoNetworkAlreadyExists (networkName, tenantId, cloudSiteId); + } + + // Does not exist, create a new one + network = new Network(); + network.setName(networkName); + network.setAdminStateUp(true); + + if (type == NetworkType.PROVIDER) { + if (provider != null && vlans != null && vlans.size() > 0) { + network.setProviderPhysicalNetwork (provider); + network.setProviderNetworkType("vlan"); + network.setProviderSegmentationId (vlans.get(0)); + } + } else if (type == NetworkType.MULTI_PROVIDER) { + if (provider != null && vlans != null && vlans.size() > 0) { + List<Segment> segments = new ArrayList<Segment>(vlans.size()); + for (int vlan : vlans) { + Segment segment = new Segment(); + segment.setProviderPhysicalNetwork (provider); + segment.setProviderNetworkType("vlan"); + segment.setProviderSegmentationId (vlan); + + segments.add(segment); + } + network.setSegments(segments); + } + } + + try { + OpenStackRequest<Network> request = neutronClient.networks().create(network); + Network newNetwork = executeAndRecordOpenstackRequest(request); + return new NetworkInfo(newNetwork); + } + catch (OpenStackBaseException e) { + // Convert Neutron exception to an MsoOpenstackException + MsoException me = neutronExceptionToMsoException (e, "CreateNetwork"); + throw me; + } + catch (RuntimeException e) { + // Catch-all + MsoException me = runtimeExceptionToMsoException(e, "CreateNetwork"); + throw me; + } + } + + + /** + * Query for a network with the specified name or ID in the given cloud. If the network exists, + * return an NetworkInfo object. If not, return null. + * <p> + * Whenever possible, the network ID should be used as it is much more efficient. Query by + * name requires retrieval of all networks for the tenant and search for matching name. + * <p> + * @param networkNameOrId The network to query + * @param tenantId The Openstack tenant to look in for the network + * @param cloudSiteId The cloud identifier (may be a region) in which to query the network. + * @return a NetworkInfo object describing the queried network, or null if not found + * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception + * @throws MsoCloudSiteNotFound + */ + public NetworkInfo queryNetwork (String networkNameOrId, String tenantId, String cloudSiteId) + throws MsoException, MsoCloudSiteNotFound + { + LOGGER.debug("In queryNetwork"); + + // Obtain the cloud site information + CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId); + if (cloudSite == null) { + throw new MsoCloudSiteNotFound(cloudSiteId); + } + + Quantum neutronClient = getNeutronClient (cloudSite, tenantId); + + // Check if the network exists and return its info + try { + Network network = findNetworkByNameOrId (neutronClient, networkNameOrId); + if (network == null) { + LOGGER.debug ("Query Network: " + networkNameOrId + " not found in tenant " + tenantId); + return null; + } + return new NetworkInfo(network); + } + catch (OpenStackBaseException e) { + // Convert Neutron exception to an MsoOpenstackException + MsoException me = neutronExceptionToMsoException (e, "QueryNetwork"); + throw me; + } + catch (RuntimeException e) { + // Catch-all + MsoException me = runtimeExceptionToMsoException(e, "QueryNetwork"); + throw me; + } + } + + /** + * Delete the specified Network (by ID) in the given cloud. + * If the network does not exist, success is returned. + * <p> + * @param networkNameOrId The name or Openstack ID of the network to delete + * @param cloudId The cloud identifier (may be a region) from which to delete the network. + * @return true if the network was deleted, false if the network did not exist + * @throws MsoOpenstackException If the Openstack API call returns an exception, this local + * exception will be thrown. + * @throws MsoCloudSiteNotFound + */ + public boolean deleteNetwork (String networkId, String tenantId, String cloudSiteId) + throws MsoException, MsoCloudSiteNotFound + { + // Obtain the cloud site information where we will create the stack + CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId); + if (cloudSite == null) { + throw new MsoCloudSiteNotFound(cloudSiteId); + } + + Quantum neutronClient = getNeutronClient (cloudSite, tenantId); + + try { + // Check that the network exists. + Network network = findNetworkById (neutronClient, networkId); + if (network == null) { + LOGGER.info(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", ""); + return false; + } + + OpenStackRequest<Void> request = neutronClient.networks().delete(network.getId()); + executeAndRecordOpenstackRequest(request); + + LOGGER.debug ("Deleted Network " + network.getId() + " (" + network.getName() + ")"); + } + catch (OpenStackBaseException e) { + // Convert Neutron exception to an MsoOpenstackException + MsoException me = neutronExceptionToMsoException (e, "Delete Network"); + throw me; + } + catch (RuntimeException e) { + // Catch-all + MsoException me = runtimeExceptionToMsoException(e, "DeleteNetwork"); + throw me; + } + + return true; + } + + + /** + * Update a network with the specified parameters in the given cloud/tenant. + * + * Specifically, this call is intended to update the VLAN segments on a + * multi-provider network. The provider segments will be replaced with the + * supplied list of VLANs. + * <p> + * Note that updating the 'segments' array is not normally supported by Neutron. + * This method relies on a Platform Orchestration extension (using SDN controller + * to manage the virtual networking). + * + * @param cloudSiteId The cloud site ID (may be a region) in which to update the network. + * @param the Openstack ID of the tenant in which to update the network + * @param networkId The unique Openstack ID of the network to be updated + * @param type The network type (Basic, Provider, Multi-Provider) + * @param provider The provider network name. This should not change. + * @param vlans The list of VLAN segments to replace + * @return a NetworkInfo object which describes the updated network + * @throws MsoNetworkNotFound Thrown if the requested network does not exist + * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception + * @throws MsoCloudSiteNotFound + */ + public NetworkInfo updateNetwork (String cloudSiteId, String tenantId, String networkId, NetworkType type, String provider, List<Integer> vlans) + throws MsoException, MsoNetworkNotFound, MsoCloudSiteNotFound + { + // Obtain the cloud site information where we will create the stack + CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId); + if (cloudSite == null) { + throw new MsoCloudSiteNotFound(cloudSiteId); + } + Quantum neutronClient = getNeutronClient (cloudSite, tenantId); + + // Check that the network exists + Network network = findNetworkById (neutronClient, networkId); + + if (network == null) { + // Network not found. Throw an exception + LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Network not found"); + throw new MsoNetworkNotFound (networkId, tenantId, cloudSiteId); + } + + // Overwrite the properties to be updated + if (type == NetworkType.PROVIDER) { + if (provider != null && vlans != null && vlans.size() > 0) { + network.setProviderPhysicalNetwork (provider); + network.setProviderNetworkType("vlan"); + network.setProviderSegmentationId (vlans.get(0)); + } + } else if (type == NetworkType.MULTI_PROVIDER) { + if (provider != null && vlans != null && vlans.size() > 0) { + List<Segment> segments = new ArrayList<Segment>(vlans.size()); + for (int vlan : vlans) { + Segment segment = new Segment(); + segment.setProviderPhysicalNetwork (provider); + segment.setProviderNetworkType("vlan"); + segment.setProviderSegmentationId (vlan); + + segments.add(segment); + } + network.setSegments(segments); + } + } + + try { + OpenStackRequest<Network> request = neutronClient.networks().update(network); + Network newNetwork = executeAndRecordOpenstackRequest(request); + return new NetworkInfo(newNetwork); + } + catch (OpenStackBaseException e) { + // Convert Neutron exception to an MsoOpenstackException + MsoException me = neutronExceptionToMsoException (e, "UpdateNetwork"); + throw me; + } + catch (RuntimeException e) { + // Catch-all + MsoException me = runtimeExceptionToMsoException(e, "UpdateNetwork"); + throw me; + } + } + + + // ------------------------------------------------------------------- + // PRIVATE UTILITY FUNCTIONS FOR USE WITHIN THIS CLASS + + /** + * Get a Neutron (Quantum) client for the Openstack Network service. + * This requires a 'member'-level userId + password, which will be retrieved from + * properties based on the specified cloud Id. The tenant in which to operate + * must also be provided. + * <p> + * On successful authentication, the Quantum object will be cached for the + * tenantID + cloudId so that it can be reused without reauthenticating with + * Openstack every time. + * + * @param cloudSite - a cloud site definition + * @param tenantId - Openstack tenant ID + * @return an authenticated Quantum object + */ + private Quantum getNeutronClient (CloudSite cloudSite, String tenantId) + throws MsoTenantNotFound, MsoException + { + String cloudId = cloudSite.getId(); + + // Check first in the cache of previously authorized clients + String cacheKey = cloudId + ":" + tenantId; + if (neutronClientCache.containsKey(cacheKey)) { + if (! neutronClientCache.get(cacheKey).isExpired()) { + LOGGER.debug ("Using Cached HEAT Client for " + cacheKey); + Quantum neutronClient = neutronClientCache.get(cacheKey).getNeutronClient(); + return neutronClient; + } + else { + // Token is expired. Remove it from cache. + neutronClientCache.remove(cacheKey); + LOGGER.debug ("Expired Cached Neutron Client for " + cacheKey); + } + } + + // Obtain an MSO token for the tenant from the identity service + CloudIdentity cloudIdentity = cloudSite.getIdentityService(); + Keystone keystoneTenantClient = new Keystone (cloudIdentity.getKeystoneUrl(cloudId, msoPropID)); + Access access = null; + try { + Authentication credentials = cloudIdentity.getAuthentication (); + OpenStackRequest<Access> request = keystoneTenantClient.tokens().authenticate(credentials).withTenantId(tenantId); + access = executeAndRecordOpenstackRequest(request); + } + catch (OpenStackResponseException e) { + if (e.getStatus() == 401) { + // Authentication error. + String error = "Authentication Failure: tenant=" + tenantId + ",cloud=" + cloudIdentity.getId(); + alarmLogger .sendAlarm("MsoAuthenticationError", MsoAlarmLogger.CRITICAL, error); + throw new MsoAdapterException(error); + } + else { + MsoException me = keystoneErrorToMsoException(e, "TokenAuth"); + throw me; + } + } + catch (OpenStackConnectException e) { + // Connection to Openstack failed + MsoIOException me = new MsoIOException (e.getMessage(), e); + me.addContext("TokenAuth"); + throw me; + } + catch (RuntimeException e) { + // Catch-all + MsoException me = runtimeExceptionToMsoException(e, "TokenAuth"); + throw me; + } + + String region = cloudSite.getRegionId(); + String neutronUrl = null; + try { + neutronUrl = KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "network", region, "public"); + if (! neutronUrl.endsWith("/")) { + neutronUrl += "/v2.0/"; + } + } catch (RuntimeException e) { + // This comes back for not found (probably an incorrect region ID) + String error = "Network service not found: region=" + region + ",cloud=" + cloudIdentity.getId(); + alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error); + throw new MsoAdapterException (error, e); + } + // This is needed for testing in the MT cloud + if (cloudId.equals("MT")) { + neutronUrl = neutronUrl.replace("controller", "mtdnj02bh01wt.bvoip.labs.att.com"); + } + + Quantum neutronClient = new Quantum(neutronUrl); + neutronClient.token(access.getToken().getId()); + + neutronClientCache.put(cacheKey, new NeutronCacheEntry(neutronUrl, access.getToken().getId(), access.getToken().getExpires())); + LOGGER.debug ("Caching Neutron Client for " + cacheKey); + + return neutronClient; + } + + /** + * Forcibly expire a Neutron client from the cache. This call is for use by + * the KeystoneClient in case where a tenant is deleted. In that case, + * all cached credentials must be purged so that fresh authentication is + * done on subsequent calls. + * <p> + * @param tenantName + * @param cloudId + */ + public static void expireNeutronClient (String tenantId, String cloudId) { + String cacheKey = cloudId + ":" + tenantId; + if (neutronClientCache.containsKey(cacheKey)) { + neutronClientCache.remove(cacheKey); + LOGGER.debug ("Deleted Cached Neutron Client for " + cacheKey); + } + } + + + /* + * Find a tenant (or query its existence) by its Name or Id. Check first against the + * ID. If that fails, then try by name. + * + * @param adminClient an authenticated Keystone object + * @param tenantName the tenant name or ID to query + * @return a Tenant object or null if not found + */ + public Network findNetworkByNameOrId (Quantum neutronClient, String networkNameOrId) + { + if (networkNameOrId == null) { + return null; + } + + Network network = findNetworkById(neutronClient, networkNameOrId); + + if (network == null) { + network = findNetworkByName(neutronClient, networkNameOrId); + } + + return network; + } + + /* + * Find a network (or query its existence) by its Id. + * + * @param neutronClient an authenticated Quantum object + * @param networkId the network ID to query + * @return a Network object or null if not found + */ + private static Network findNetworkById (Quantum neutronClient, String networkId) + { + if (networkId == null) { + return null; + } + + try { + OpenStackRequest<Network> request = neutronClient.networks().show(networkId); + Network network = executeAndRecordOpenstackRequest(request); + return network; + } + catch (OpenStackResponseException e) { + if (e.getStatus() == 404) { + return null; + } else { + LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Error, GET Network By ID (" + networkId + "): " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception in Openstack"); + throw e; + } + } + } + + /* + * Find a network (or query its existence) by its Name. This method avoids an + * initial lookup by ID when it's known that we have the network Name. + * + * Neutron does not support 'name=*' query parameter for Network query (show). + * The only way to query by name is to retrieve all networks and look for the + * match. While inefficient, this capability will be provided as it is needed + * by MSO, but should be avoided in favor of ID whenever possible. + * + * TODO: + * Network names are not required to be unique, though MSO will attempt to enforce + * uniqueness. This call probably needs to return an error (instead of returning + * the first match). + * + * @param neutronClient an authenticated Quantum object + * @param networkName the network name to query + * @return a Network object or null if not found + */ + public Network findNetworkByName (Quantum neutronClient, String networkName) + { + if (networkName == null) { + return null; + } + + try { + OpenStackRequest<Networks> request = neutronClient.networks().list(); + Networks networks = executeAndRecordOpenstackRequest(request); + for (Network network : networks.getList()) { + if (network.getName().equals(networkName)) { + LOGGER.debug ("Found match on network name: " + networkName); + return network; + } + } + LOGGER.debug ("findNetworkByName - no match found for " + networkName); + return null; + } + catch (OpenStackResponseException e) { + if (e.getStatus() == 404) { + return null; + } else { + LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Error, GET Network By Name (" + networkName + "): " + e, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception in OpenStack"); + throw e; + } + } + } + + + /* + * An entry in the Neutron Client Cache. It saves the Neutron client object + * along with the token expiration. After this interval, this cache + * item will no longer be used. + */ + private static class NeutronCacheEntry implements Serializable + { + private static final long serialVersionUID = 1L; + + private String neutronUrl; + private String token; + private Calendar expires; + + public NeutronCacheEntry (String neutronUrl, String token, Calendar expires) { + this.neutronUrl = neutronUrl; + this.token = token; + this.expires = expires; + } + + public Quantum getNeutronClient () { + Quantum neutronClient = new Quantum(neutronUrl); + neutronClient.token(token); + return neutronClient; + } + + public boolean isExpired() { + if (expires == null) { + return true; + } + + Calendar now = Calendar.getInstance(); + if (now.after(expires)) { + return true; + } + + return false; + } + } + + /** + * Clean up the Neutron client cache to remove expired entries. + */ + public static void neutronCacheCleanup () { + for (String cacheKey : neutronClientCache.keySet()) { + if (neutronClientCache.get(cacheKey).isExpired()) { + neutronClientCache.remove(cacheKey); + LOGGER.debug ("Cleaned Up Cached Neutron Client for " + cacheKey); + } + } + } + + /** + * Reset the Neutron client cache. + * This may be useful if cached credentials get out of sync. + */ + public static void neutronCacheReset () { + neutronClientCache = new HashMap<String,NeutronCacheEntry>(); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtils.java new file mode 100644 index 0000000000..41104707cb --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtils.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.utils; + + +import java.io.Serializable; +import java.util.Calendar; +import java.util.HashMap; +import java.util.Map; + +import org.openecomp.mso.cloud.CloudConfig; +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.openstack.beans.MsoTenant; +import org.openecomp.mso.openstack.exceptions.MsoAdapterException; +import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoOpenstackException; +import org.openecomp.mso.openstack.exceptions.MsoTenantAlreadyExists; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; +import com.woorea.openstack.keystone.Keystone; + +public abstract class MsoTenantUtils extends MsoCommonUtils { + + protected CloudConfigFactory cloudConfigFactory; + protected MsoPropertiesFactory msoPropFactory; + protected static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + protected MsoJavaProperties msoProps; + protected CloudConfig cloudConfig; + + public MsoTenantUtils (String msoPropID) { + cloudConfigFactory = new CloudConfigFactory(); + msoPropFactory = new MsoPropertiesFactory(); + cloudConfig = cloudConfigFactory.getCloudConfig (); + + LOGGER.debug("msoTenantUtils:" + msoPropID); + + try { + msoProps = msoPropFactory.getMsoJavaProperties (msoPropID); + } catch (MsoPropertiesException e) { + LOGGER.error (MessageEnum.LOAD_PROPERTIES_FAIL, "Unknown. Mso Properties ID not found in cache: " + msoPropID, "", "", MsoLogger.ErrorCode.DataError, "Exception - Mso Properties ID not found in cache", e); + } + } + + public abstract String createTenant (String tenantName, String cloudSiteId, Map <String, String> metadata, boolean backout) + throws MsoException; + + public abstract MsoTenant queryTenant (String tenantId, String cloudSiteId) + throws MsoException, MsoCloudSiteNotFound; + + public abstract MsoTenant queryTenantByName (String tenantName, String cloudSiteId) + throws MsoException, MsoCloudSiteNotFound; + + public abstract boolean deleteTenant (String tenantId, String cloudSiteId) + throws MsoException; + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java new file mode 100644 index 0000000000..6fd7a6364a --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.utils; + +import org.openecomp.mso.cloud.CloudConfig; +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.cloud.CloudIdentity; +import org.openecomp.mso.cloud.CloudSite; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.openstack.utils.MsoKeystoneUtils; + + +public class MsoTenantUtilsFactory { + + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private CloudConfigFactory cloudConfigFactory= new CloudConfigFactory(); + protected CloudConfig cloudConfig; + protected MsoJavaProperties msoProps = null; + private String msoPropID; + + public MsoTenantUtilsFactory (String msoPropID) { + this.msoPropID = msoPropID; + } + + //based on Cloud IdentityServerType returns ORM or KEYSTONE Utils + public MsoTenantUtils getTenantUtils(String cloudSiteId) { + + // Obtain the cloud site information + cloudConfig = cloudConfigFactory.getCloudConfig(); + CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + + MsoTenantUtils tenantU = null; + if (cloudSite.getIdentityService().getIdentityServerType() == CloudIdentity.IdentityServerType.KEYSTONE) + { + tenantU = new MsoKeystoneUtils (msoPropID); + } + return tenantU; + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java new file mode 100644 index 0000000000..d1246580b2 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java @@ -0,0 +1,163 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openstack.utils; + + + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; +import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; +import org.codehaus.jackson.map.ObjectMapper; +import java.util.LinkedHashMap; + +import org.yaml.snakeyaml.Yaml; + + +public class MsoYamlEditorWithEnvt { + + private Map <String, Object> yml; + private Yaml yaml = new Yaml (); + private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); + + public MsoYamlEditorWithEnvt() { + super(); + } + public MsoYamlEditorWithEnvt(byte[] b) { + init(b); + } + + @SuppressWarnings("unchecked") + private synchronized void init (byte[] body) { + InputStream input = new ByteArrayInputStream (body); + yml = (Map <String, Object>) yaml.load (input); + } + + @SuppressWarnings("unchecked") + public synchronized Set <MsoHeatEnvironmentParameter> getParameterListFromEnvt() { + // In an environment entry, the parameters section can only contain the name:value - + // not other attributes. + Set <MsoHeatEnvironmentParameter> paramSet = new HashSet<MsoHeatEnvironmentParameter>(); + Map<String, Object> resourceMap = null; + try { + resourceMap = (Map<String,Object>) yml.get("parameters"); + } catch (Exception e) { + return paramSet; + } + if (resourceMap == null) { + return paramSet; + } + Iterator <Entry <String, Object>> it = resourceMap.entrySet().iterator(); + + while (it.hasNext()) { + MsoHeatEnvironmentParameter hep = new MsoHeatEnvironmentParameter(); + Map.Entry <String, Object> pair = it.next(); + //Map<String, String> resourceEntry = (Map <String, String>) pair.getValue(); + //String value = null; + String value = null; + Object obj = pair.getValue(); + if (obj instanceof java.lang.String) { + //value = (String) pair.getValue(); + // handle block scalar - literals and folded: + value = yaml.dump(obj); + // but this adds an extra '\n' at the end - which won't hurt - but we don't need it + value = value.substring(0, value.length() - 1); + } else if (obj instanceof java.util.LinkedHashMap) { + //Handle that it's json + try { + value = JSON_MAPPER.writeValueAsString(obj); + } catch (Exception e) { + value = "_BAD_JSON_MAPPING"; + } + } else { + //this handles integers/longs/floats/etc. + value = String.valueOf(obj); + } + hep.setName((String) pair.getKey()); + hep.setValue(value); + paramSet.add(hep); + } + return paramSet; + } + public synchronized Set <MsoHeatEnvironmentResource> getResourceListFromEnvt() { + try { + Set<MsoHeatEnvironmentResource> resourceList = new HashSet<MsoHeatEnvironmentResource>(); + @SuppressWarnings("unchecked") + Map<String, Object> resourceMap = (Map<String,Object>) yml.get("resource_registry"); + Iterator<Entry <String,Object>> it = resourceMap.entrySet().iterator(); + + while (it.hasNext()) { + MsoHeatEnvironmentResource her = new MsoHeatEnvironmentResource(); + Map.Entry<String, Object> pair = it.next(); + her.setName((String) pair.getKey()); + her.setValue((String) pair.getValue()); + resourceList.add(her); + } + return resourceList; + } catch (Exception e) { + + } + return null; + } + public synchronized Set <HeatTemplateParam> getParameterList () { + Set <HeatTemplateParam> paramSet = new HashSet <HeatTemplateParam> (); + @SuppressWarnings("unchecked") + Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("parameters"); + Iterator <Entry <String, Object>> it = resourceMap.entrySet ().iterator (); + + while (it.hasNext ()) { + HeatTemplateParam param = new HeatTemplateParam (); + Map.Entry <String, Object> pair = it.next (); + @SuppressWarnings("unchecked") + Map <String, String> resourceEntry = (Map <String, String>) pair.getValue (); + String value = null; + try { + value = resourceEntry.get ("default"); + } catch (java.lang.ClassCastException cce) { + // This exception only - the value is an integer. For what we're doing + // here - we don't care - so set value to something - and it will + // get marked as not being required - which is correct. + //System.out.println("cce exception!"); + value = "300"; + // okay + } + param.setParamName ((String) pair.getKey ()); + if (value != null) { + param.setRequired (false); + } else { + param.setRequired (true); + } + value = resourceEntry.get ("type"); + param.setParamType (value); + + paramSet.add (param); + + } + return paramSet; + + } + + +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java new file mode 100644 index 0000000000..8632d02164 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java @@ -0,0 +1,173 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapter_utils.tests; + + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import org.junit.BeforeClass; +import org.junit.Test; +import java.util.Map; +import org.openecomp.mso.cloud.CloudConfig; +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.cloud.CloudIdentity; +import org.openecomp.mso.cloud.CloudSite; + + +/** + * This class implements test methods of the CloudConfig features. + * + * + */ +public class CloudConfigTest { + + private static CloudConfig con; + private static CloudConfigFactory cloudConfigFactory= new CloudConfigFactory(); + + public CloudConfigTest () { + + } + + /** + * This method is called before any test occurs. + * It creates a fake tree from scratch + */ + @BeforeClass + public static final void prepare () { + ClassLoader classLoader = CloudConfigTest.class.getClassLoader(); + String config = classLoader.getResource("cloud_config.json").toString().substring(5); + + cloudConfigFactory.initializeCloudConfig(config,1); + con = cloudConfigFactory.getCloudConfig(); + } + + /** + * This method implements a test for the getCloudConfig method. + */ + @Test + public final void testGetCloudConfig () { + assertNotNull(con); + } + + /** + * This method implements a test for the getCloudSites method. + */ + @Test + public final void testGetCloudSites () { + Map<String,CloudSite> siteMap = con.getCloudSites(); + assertNotNull(siteMap); + + CloudSite site1 = siteMap.get("MT"); + CloudSite site2 = siteMap.get("DAN"); + CloudSite site3 = siteMap.get("MTINJVCC101"); + + assertEquals (site1.getRegionId(), "regionOne"); + assertEquals (site1.getIdentityServiceId(), "MT_KEYSTONE"); + assertEquals (site2.getRegionId(), "RegionOne"); + assertEquals (site2.getIdentityServiceId(), "DAN_KEYSTONE"); + assertEquals (site3.getRegionId(), "regionTwo"); + assertEquals (site3.getIdentityServiceId(), "MTINJVCC101_DCP"); + + } + + + /** + * This method implements a test for the getIdentityServices method. + */ + @Test + public final void testGetIdentityServices () { + Map<String,CloudIdentity> identityMap = con.getIdentityServices (); + assertNotNull(identityMap); + + CloudIdentity identity1 = identityMap.get("MT_KEYSTONE"); + CloudIdentity identity2 = identityMap.get("DAN_KEYSTONE"); + CloudIdentity identity3 = identityMap.get("MTINJVCC101_DCP"); + CloudIdentity identity4 = identityMap.get("MTSNJA3DCP1"); + +// assertEquals (identity1.getKeystoneUrl(), "http://localhost:5000/v2.0"); +// assertEquals (identity1.getIdentityUrl(), "http://localhost:5000/v2.0"); + assertEquals (identity1.getMsoId(), "john"); + assertEquals (identity1.getMsoPass(), "changeme"); + assertEquals (identity1.getAdminTenant(), "admin"); + assertEquals (identity1.getMemberRole(), "_member_"); + assertEquals (identity1.hasTenantMetadata(), false); + +// assertEquals (identity2.getKeystoneUrl(), "http://localhost:5000/v2.0"); +// assertEquals (identity2.getIdentityUrl(), "http://localhost:5000/v2.0"); + assertEquals (identity2.getMsoId(), "mockId"); + assertEquals (identity2.getMsoPass(), "stack123"); + assertEquals (identity2.getAdminTenant(), "service"); + assertEquals (identity2.getMemberRole(), "_member_"); + assertEquals (identity2.hasTenantMetadata(), false); + +// assertEquals (identity3.getKeystoneUrl(), "http://localhost:5000/v2.0"); +// assertEquals (identity3.getIdentityUrl(), "http://localhost:5000/v2.0"); + assertEquals (identity3.getMsoId(), "mockIdToo"); + assertEquals (identity3.getMsoPass(), "AICG@mm@@2015"); + assertEquals (identity3.getAdminTenant(), "service"); + assertEquals (identity3.getMemberRole(), "admin"); + assertEquals (identity3.hasTenantMetadata(), true); + +// assertEquals (identity4.getKeystoneUrl(), "https://localhost:5000/v2.0"); +// assertEquals (identity4.getIdentityUrl(), "https://localhost:5000/v2.0"); + assertEquals (identity4.getMsoId(), "mockIdToo"); + assertEquals (identity4.getMsoPass(), "2315QRS2015srq"); + assertEquals (identity4.getAdminTenant(), "service"); + assertEquals (identity4.getMemberRole(), "admin"); + assertEquals (identity4.hasTenantMetadata(), true); + + } + + /** + * This method implements a test for the getCloudSite method. + */ + @Test + public final void testGetCloudSite () { + CloudSite site1 = con.getCloudSite("MT"); + assertNotNull(site1); + assertEquals (site1.getRegionId(), "regionOne"); + assertEquals (site1.getIdentityServiceId(), "MT_KEYSTONE"); + + + + } + + /** + * This method implements a test for the getIdentityService method. + */ + @Test + public final void testGetIdentityService () { + CloudIdentity identity1 = con.getIdentityService("MT_KEYSTONE"); + assertNotNull(identity1); +// assertEquals (identity1.getKeystoneUrl(), "http://localhost:5000/v2.0"); +// assertEquals (identity1.getIdentityUrl(), "http://localhost:5000/v2.0"); + assertEquals (identity1.getMsoId(), "john"); + assertEquals (identity1.getMsoPass(), "changeme"); + assertEquals (identity1.getAdminTenant(), "admin"); + assertEquals (identity1.getMemberRole(), "_member_"); + assertEquals (identity1.hasTenantMetadata(), false); + + CloudIdentity identity2 = con.getIdentityService("Test"); + assertNull(identity2); + } + +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoCommonUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoCommonUtilsTest.java new file mode 100644 index 0000000000..9f17283786 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoCommonUtilsTest.java @@ -0,0 +1,130 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapter_utils.tests; + + +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.Mockito; + +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.openstack.exceptions.MsoAdapterException; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.openecomp.mso.openstack.exceptions.MsoIOException; +import org.openecomp.mso.openstack.exceptions.MsoOpenstackException; +import org.openecomp.mso.openstack.utils.MsoCommonUtils; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; +import com.woorea.openstack.base.client.OpenStackBaseException; +import com.woorea.openstack.base.client.OpenStackConnectException; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.base.client.OpenStackResponseException; + + +/** + * This class implements test methods of the MsoCommonUtils + * + * + */ +public class MsoCommonUtilsTest extends MsoCommonUtils { + + public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + + @Test + public final void testExecuteAndRecordOpenstackRequest () { + OpenStackRequest openstackRequest = Mockito.mock(OpenStackRequest.class); + Mockito.when(openstackRequest.endpoint()).thenReturn("localhost"); + Mockito.when(openstackRequest.path()).thenReturn("/test"); + //TODO:Must try a real connection + assertNull(super.executeAndRecordOpenstackRequest (openstackRequest)); + + } + + @Test + public final void testKeystoneErrorToMsoException () { + OpenStackBaseException openStackConnectException = new OpenStackConnectException("connect"); + + OpenStackBaseException openStackResponseException = new OpenStackResponseException("response",1); + + MsoException me = super.keystoneErrorToMsoException (openStackConnectException,"ContextError"); + + assertTrue(me instanceof MsoIOException); + assertTrue("connect".equals(me.getMessage())); + + + MsoException me2 = super.keystoneErrorToMsoException (openStackResponseException,"ContextError"); + assertTrue(me2 instanceof MsoOpenstackException); + assertTrue("ContextError".equals(me2.getContext())); + assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory())); + + } + + @Test + public final void testHeatExceptionToMsoException () { + OpenStackBaseException openStackConnectException = new OpenStackConnectException("connect"); + + OpenStackBaseException openStackResponseException = new OpenStackResponseException("response",1); + + MsoException me = super.heatExceptionToMsoException (openStackConnectException,"ContextError"); + + assertTrue(me instanceof MsoIOException); + assertTrue("connect".equals(me.getMessage())); + + + MsoException me2 = super.heatExceptionToMsoException (openStackResponseException,"ContextError"); + assertTrue(me2 instanceof MsoOpenstackException); + assertTrue("ContextError".equals(me2.getContext())); + assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory())); + } + + @Test + public final void testNeutronExceptionToMsoException () { + OpenStackBaseException openStackConnectException = new OpenStackConnectException("connect"); + + OpenStackBaseException openStackResponseException = new OpenStackResponseException("response",1); + + MsoException me = super.neutronExceptionToMsoException (openStackConnectException,"ContextError"); + + assertTrue(me instanceof MsoIOException); + assertTrue("connect".equals(me.getMessage())); + + MsoException me2 = super.neutronExceptionToMsoException (openStackResponseException,"ContextError"); + assertTrue(me2 instanceof MsoOpenstackException); + assertTrue("ContextError".equals(me2.getContext())); + assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory())); + } + + @Test + public final void testRuntimeExceptionToMsoException () { + RuntimeException re = new RuntimeException ("runtime"); + MsoException me = super.runtimeExceptionToMsoException (re, "ContextError"); + + assertTrue (me instanceof MsoAdapterException); + assertTrue("ContextError".equals(me.getContext())); + assertTrue(MsoExceptionCategory.INTERNAL.equals(me.getCategory())); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java new file mode 100644 index 0000000000..6f8a6e93d8 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapter_utils.tests; + +import java.util.HashMap; + +import org.junit.BeforeClass; +import org.junit.Test; + +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.openstack.exceptions.MsoAdapterException; +import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoIOException; +import org.openecomp.mso.openstack.exceptions.MsoStackAlreadyExists; +import org.openecomp.mso.openstack.exceptions.MsoTenantNotFound; +import org.openecomp.mso.openstack.utils.MsoCommonUtils; +import org.openecomp.mso.openstack.utils.MsoHeatUtils; +import org.openecomp.mso.properties.MsoPropertiesFactory; + + + +/** + * This class implements test methods of the MsoHeatUtils + * + * + */ +public class MsoHeatUtilsTest extends MsoCommonUtils { + public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + public static CloudConfigFactory cloudConfigFactory = new CloudConfigFactory(); + public static MsoHeatUtils msoHeatUtils; + + @BeforeClass + public static final void loadClasses() { + ClassLoader classLoader = CloudConfigTest.class.getClassLoader(); + String config = classLoader.getResource("cloud_config.json").toString().substring(5); + cloudConfigFactory.initializeCloudConfig(config, 1); + msoHeatUtils = new MsoHeatUtils("NO_PROP",msoPropertiesFactory,cloudConfigFactory); + } + + @Test + public final void testCreateStackBadCloudConfig () { + try { + msoHeatUtils.createStack ("DOESNOTEXIST", "test", "stackName", "test", new HashMap<String,Object> (), Boolean.TRUE, 10); + } catch (MsoException e) { + + } + + } + + @Test + public final void testCreateStackFailedConnectionHeatClient () throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound { + try { + msoHeatUtils.createStack ("MT", "test", "stackName", "test", new HashMap<String,Object> (), Boolean.TRUE, 10); + } catch (MsoIOException e) { + + } + + } + + @Test + public final void testCreateStackFailedConnection () throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound { + try { + msoHeatUtils.createStack ("MT", "test", "stackName", "test", new HashMap<String,Object> (), Boolean.TRUE, 10); + } catch (MsoIOException e) { + + } + + } + + + +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java new file mode 100644 index 0000000000..a5d46da614 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java @@ -0,0 +1,132 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapter_utils.tests; + +import static org.junit.Assert.fail; +import static org.mockito.Mockito.when; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; + +import org.openecomp.mso.cloud.CloudConfig; +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.cloud.CloudIdentity; +import org.openecomp.mso.cloud.CloudSite; +import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoIOException; +import org.openecomp.mso.openstack.utils.MsoHeatUtilsWithUpdate; +import org.openecomp.mso.properties.MsoPropertiesFactory; +import com.woorea.openstack.base.client.OpenStackConnectException; + +@RunWith(MockitoJUnitRunner.class) +public class MsoHeatUtilsWithUpdateTest { + + public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + public static CloudConfigFactory cloudConfigFactory = new CloudConfigFactory(); + + @Mock + CloudConfig cloudConfig; + @InjectMocks + MsoHeatUtilsWithUpdate util=new MsoHeatUtilsWithUpdate("NO_PROP",msoPropertiesFactory,cloudConfigFactory); + + private CloudSite cloudSite; + + @Before + public void init () { + cloudSite = new CloudSite (); + cloudSite.setId ("cloud"); + CloudIdentity cloudIdentity = new CloudIdentity (); + cloudSite.setIdentityService (cloudIdentity); + cloudIdentity.setKeystoneUrl ("toto"); + cloudIdentity.setMsoPass (CloudIdentity.encryptPassword ("mockId")); + + when (cloudConfig.getCloudSite ("cloud")).thenReturn (cloudSite); + when (cloudConfig.getCloudSite ("none")).thenReturn (null); + } + + @Test + public void testUpdateStack () { + // Heat heat = Mockito.mock (Heat.class); + Map <String, Object> stackInputs = new HashMap <> (); + try { + util.updateStack ("none", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1); + } catch (MsoException e) { + if (e instanceof MsoCloudSiteNotFound) { + // Ok + } else { + e.printStackTrace (); + fail ("Exception caught"); + } + } + try { + util.updateStack ("cloud", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1); + } catch (MsoException e) { + if (e instanceof MsoIOException && e.getCause () != null + && e.getCause () instanceof OpenStackConnectException) { + // Ok, we were able to go up to the connection to OpenStack + } else { + e.printStackTrace (); + fail ("Exception caught"); + } + } + try { + util.updateStack ("cloud", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1, "environment"); + } catch (MsoException e) { + if (e instanceof MsoIOException && e.getCause () != null + && e.getCause () instanceof OpenStackConnectException) { + // Ok, we were able to go up to the connection to OpenStack + } else { + e.printStackTrace (); + fail ("Exception caught"); + } + } + try { + util.updateStack ("cloud", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1, "environment", null); + } catch (MsoException e) { + if (e instanceof MsoIOException && e.getCause () != null + && e.getCause () instanceof OpenStackConnectException) { + // Ok, we were able to go up to the connection to OpenStack + } else { + e.printStackTrace (); + fail ("Exception caught"); + } + } + try { + util.updateStack ("cloud", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1, "environment", null, null); + } catch (MsoException e) { + if (e instanceof MsoIOException && e.getCause () != null + && e.getCause () instanceof OpenStackConnectException) { + // Ok, we were able to go up to the connection to OpenStack + } else { + e.printStackTrace (); + fail ("Exception caught"); + } + } + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudIdentityESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudIdentityESTest.java new file mode 100644 index 0000000000..69fbb2625d --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudIdentityESTest.java @@ -0,0 +1,400 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:37:20 GMT 2016 + */ + +package org.openecomp.mso.cloud; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.PrivateAccess; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class CloudIdentityESTest { + + @Test(timeout = 4000) + public void test00() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setMsoId("ga-cj*/"); + cloudIdentity0.hashCode(); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setTenantMetadata(true); + boolean boolean0 = cloudIdentity0.hasTenantMetadata(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setMsoPass(""); + String string0 = cloudIdentity0.getMsoPass(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setMsoId("hz4IjQ&in.t^IC|"); + String string0 = cloudIdentity0.getMsoId(); + assertEquals("hz4IjQ&in.t^IC|", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setMemberRole("Exception in encryptPassword"); + String string0 = cloudIdentity0.getMemberRole(); + assertEquals("Exception in encryptPassword", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setIdentityUrl("ASDC_ARTIFACT_ALREADY_DEPLOYED"); + String string0 = cloudIdentity0.getIdentityUrl(); + assertEquals("ASDC_ARTIFACT_ALREADY_DEPLOYED", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + CloudIdentity.IdentityServerType cloudIdentity_IdentityServerType0 = CloudIdentity.IdentityServerType.KEYSTONE; + PrivateAccess.setVariable((Class<CloudIdentity>) CloudIdentity.class, cloudIdentity0, "identityServerType", (Object) cloudIdentity_IdentityServerType0); + String string0 = cloudIdentity0.getIdentityServerTypeAsString(); + assertEquals("KEYSTONE", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setId(""); + String string0 = cloudIdentity0.getId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setAdminTenant("0hh5nz?kd3N,FTKBX"); + String string0 = cloudIdentity0.getAdminTenant(); + assertEquals("0hh5nz?kd3N,FTKBX", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setTenantMetadata(true); + CloudIdentity cloudIdentity1 = cloudIdentity0.clone(); + assertTrue(cloudIdentity1.equals((Object)cloudIdentity0)); + assertTrue(cloudIdentity1.hasTenantMetadata()); + assertNotSame(cloudIdentity1, cloudIdentity0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setTenantMetadata(false); + CloudIdentity cloudIdentity1 = cloudIdentity0.clone(); + assertFalse(cloudIdentity1.hasTenantMetadata()); + assertTrue(cloudIdentity1.equals((Object)cloudIdentity0)); + assertNotSame(cloudIdentity1, cloudIdentity0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setMsoPass("0LAxuQ0#K,Ma"); + // Undeclared exception! + try { + cloudIdentity0.getMsoPass(); + fail("Expecting exception: NumberFormatException"); + + } catch(NumberFormatException e) { + // + // For input string: \"0L\" + // + verifyException("java.lang.NumberFormatException", e); + } + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + // Undeclared exception! + try { + cloudIdentity0.getKeystoneUrl(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.cloud.CloudIdentity", e); + } + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + // Undeclared exception! + try { + CloudIdentity.encryptPassword((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.utils.CryptoUtils", e); + } + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + CloudIdentity cloudIdentity1 = cloudIdentity0.clone(); + assertTrue(cloudIdentity1.equals((Object)cloudIdentity0)); + + PrivateAccess.setVariable((Class<CloudIdentity>) CloudIdentity.class, cloudIdentity1, "msoPass", (Object) "0~=?Wm,~42b4:K"); + boolean boolean0 = cloudIdentity0.equals(cloudIdentity1); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setMemberRole("r"); + CloudIdentity cloudIdentity1 = new CloudIdentity(); + boolean boolean0 = cloudIdentity0.equals(cloudIdentity1); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + CloudIdentity cloudIdentity1 = cloudIdentity0.clone(); + assertTrue(cloudIdentity1.equals((Object)cloudIdentity0)); + + cloudIdentity1.setMemberRole("RA_SET_CALLBACK_AUTH_EXC"); + boolean boolean0 = cloudIdentity0.equals(cloudIdentity1); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setMemberRole("r"); + CloudIdentity cloudIdentity1 = cloudIdentity0.clone(); + boolean boolean0 = cloudIdentity0.equals(cloudIdentity1); + assertNotSame(cloudIdentity1, cloudIdentity0); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + Object object0 = new Object(); + boolean boolean0 = cloudIdentity0.equals(object0); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + boolean boolean0 = cloudIdentity0.equals((Object) null); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + boolean boolean0 = cloudIdentity0.equals(cloudIdentity0); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setMsoPass("9Y#4-v1Fu27keLW"); + cloudIdentity0.hashCode(); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setMemberRole("ASDC_GENERAL_METRICS"); + cloudIdentity0.hashCode(); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setIdentityUrl("g9+j0@{H}S|"); + cloudIdentity0.hashCode(); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setId("FSmZDF:2*!OtMq!i"); + cloudIdentity0.hashCode(); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setKeystoneUrl("VdON&(o*x/W!"); + assertNull(cloudIdentity0.getMemberRole()); + } + + @Test(timeout = 4000) + public void test27() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + String string0 = cloudIdentity0.getKeystoneUrl("A9Z Ol `I1^y]F[EC0", ""); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test28() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + String string0 = cloudIdentity0.getMemberRole(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test29() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + // Undeclared exception! + try { + cloudIdentity0.getIdentityServerTypeAsString(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.cloud.CloudIdentity", e); + } + } + + @Test(timeout = 4000) + public void test30() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setIdentityUrl("com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES"); + CloudIdentity cloudIdentity1 = new CloudIdentity(); + boolean boolean0 = cloudIdentity0.equals(cloudIdentity1); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test31() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + String string0 = cloudIdentity0.getId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test32() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setTenantMetadata(false); + cloudIdentity0.hashCode(); + assertFalse(cloudIdentity0.hasTenantMetadata()); + } + + @Test(timeout = 4000) + public void test34() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.setAdminTenant("0hh5nz?kd3N,FTKBX"); + cloudIdentity0.hashCode(); + } + + @Test(timeout = 4000) + public void test35() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + String string0 = cloudIdentity0.getAdminTenant(); + assertNull(string0); + + } + + @Test(timeout = 4000) + public void test37() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + String string0 = cloudIdentity0.getMsoId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test38() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudIdentity0.getIdentityServerType(); + } + + @Test(timeout = 4000) + public void test39() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + // Undeclared exception! + try { + cloudIdentity0.getMsoPass(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.utils.CryptoUtils", e); + } + } + + @Test(timeout = 4000) + public void test40() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + // Undeclared exception! + try { + cloudIdentity0.toString(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.cloud.CloudIdentity", e); + } + } + + @Test(timeout = 4000) + public void test41() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + // Undeclared exception! + try { + cloudIdentity0.hasTenantMetadata(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.cloud.CloudIdentity", e); + } + } + + @Test(timeout = 4000) + public void test42() throws Throwable { + CloudIdentity cloudIdentity0 = new CloudIdentity(); + String string0 = cloudIdentity0.getIdentityUrl(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test43() throws Throwable { + String string0 = CloudIdentity.encryptPassword("jaR\"aJmqpa>(&"); + assertEquals("718A16EDF9EA61E9350A07703082D5B5", string0); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudIdentityTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudIdentityTest.java new file mode 100644 index 0000000000..377a7243ca --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudIdentityTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.cloud; + + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + + +public class CloudIdentityTest { + + @Test + public final void testCloudIdentity () { + CloudIdentity id = new CloudIdentity (); + id.setAdminTenant ("AdminTenant"); + id.setId ("id"); +// id.setKeystoneUrl ("keystone"); + id.setIdentityUrl ("keystone"); + id.setMemberRole ("member"); + id.setMsoId ("msoId"); + id.setMsoPass (CloudIdentity.encryptPassword ("password")); + id.setTenantMetadata (true); + + assertTrue (id.getAdminTenant ().equals ("AdminTenant")); + assertTrue (id.getId ().equals ("id")); +// assertTrue (id.getKeystoneUrl ().equals ("keystone")); + assertTrue (id.getMemberRole ().equals ("member")); + assertTrue (id.getMsoId ().equals ("msoId")); + assertTrue (id.getMsoPass ().equals ("password")); + assertTrue (id.hasTenantMetadata ()); +// assertTrue (id.toString ().contains ("keystone")); + } + + @Test + public final void testEncryption () { + String encrypted = CloudIdentity.encryptPassword ("password"); + assertTrue (encrypted != null); + assertTrue (!encrypted.equals ("password")); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudSiteESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudSiteESTest.java new file mode 100644 index 0000000000..68bccfcc1b --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudSiteESTest.java @@ -0,0 +1,315 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:42:36 GMT 2016 + */ + +package org.openecomp.mso.cloud; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.PrivateAccess; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class CloudSiteESTest extends CloudSiteESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + cloudSite0.setAic_version("-t"); + cloudSite0.hashCode(); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + cloudSite0.setRegionId("CloudSite: id="); + String string0 = cloudSite0.getRegionId(); + assertEquals("CloudSite: id=", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + cloudSite0.setRegionId(""); + String string0 = cloudSite0.getRegionId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + PrivateAccess.setVariable((Class<CloudSite>) CloudSite.class, cloudSite0, "identityServiceId", (Object) "PUBLIC"); + String string0 = cloudSite0.getIdentityServiceId(); + assertEquals("PUBLIC", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudSite0.setIdentityService(cloudIdentity0); + cloudIdentity0.setTenantMetadata(false); + CloudIdentity cloudIdentity1 = cloudSite0.getIdentityService(); + assertNull(cloudIdentity1.getAdminTenant()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + cloudSite0.setId(""); + String string0 = cloudSite0.getId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + cloudSite0.setClli("N;w7*-)9\"t|T/jCa"); + String string0 = cloudSite0.getClli(); + assertEquals("N;w7*-)9\"t|T/jCa", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + cloudSite0.setClli(""); + String string0 = cloudSite0.getClli(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + cloudSite0.setAic_version("v&K[by0"); + String string0 = cloudSite0.getAic_version(); + assertEquals("v&K[by0", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + cloudSite0.setAic_version(""); + String string0 = cloudSite0.getAic_version(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + CloudIdentity cloudIdentity0 = mock(CloudIdentity.class, new ViolatedAssumptionAnswer()); + doReturn((CloudIdentity) null).when(cloudIdentity0).clone(); + cloudSite0.setIdentityService(cloudIdentity0); + CloudSite cloudSite1 = cloudSite0.clone(); + boolean boolean0 = cloudSite0.equals(cloudSite1); + assertFalse(boolean0); + assertFalse(cloudSite1.equals((Object)cloudSite0)); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + CloudSite cloudSite1 = new CloudSite(); + assertTrue(cloudSite1.equals((Object)cloudSite0)); + + cloudSite1.setClli("CloudSite: id=null, regionId=null, identityServiceId=null, aic_version=null, clli=null"); + boolean boolean0 = cloudSite0.equals(cloudSite1); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudSite0.setIdentityService(cloudIdentity0); + CloudSite cloudSite1 = cloudSite0.clone(); + assertTrue(cloudSite1.equals((Object)cloudSite0)); + + cloudSite1.setAic_version(""); + boolean boolean0 = cloudSite0.equals(cloudSite1); + assertFalse(cloudSite1.equals((Object)cloudSite0)); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudSite0.setIdentityService(cloudIdentity0); + CloudSite cloudSite1 = cloudSite0.clone(); + boolean boolean0 = cloudSite0.equals(cloudSite1); + assertNotSame(cloudSite1, cloudSite0); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + cloudSite0.setRegionId("CloudSite: id=null, regionId=null, identityServiceId=null, aic_version=null, clli=null"); + CloudSite cloudSite1 = new CloudSite(); + boolean boolean0 = cloudSite0.equals(cloudSite1); + assertFalse(cloudSite1.equals((Object)cloudSite0)); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudSite0.setIdentityService(cloudIdentity0); + CloudSite cloudSite1 = cloudSite0.clone(); + assertTrue(cloudSite1.equals((Object)cloudSite0)); + + cloudSite1.setId("Tx;$hjj"); + boolean boolean0 = cloudSite1.equals(cloudSite0); + assertFalse(boolean0); + assertFalse(cloudSite1.equals((Object)cloudSite0)); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + Object object0 = new Object(); + boolean boolean0 = cloudSite0.equals(object0); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + boolean boolean0 = cloudSite0.equals((Object) null); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + boolean boolean0 = cloudSite0.equals(cloudSite0); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + PrivateAccess.setVariable((Class<CloudSite>) CloudSite.class, cloudSite0, "identityServiceId", (Object) ""); + CloudSite cloudSite1 = new CloudSite(); + boolean boolean0 = cloudSite0.equals(cloudSite1); + assertFalse(boolean0); + assertFalse(cloudSite1.equals((Object)cloudSite0)); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + PrivateAccess.setVariable((Class<CloudSite>) CloudSite.class, cloudSite0, "clli", (Object) "AgBkO0S\"V'R'"); + cloudSite0.hashCode(); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + PrivateAccess.setVariable((Class<CloudSite>) CloudSite.class, cloudSite0, "regionId", (Object) "`V+.b PU'3:EbS"); + cloudSite0.hashCode(); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + PrivateAccess.setVariable((Class<CloudSite>) CloudSite.class, cloudSite0, "identityServiceId", (Object) "PUBLIC"); + cloudSite0.hashCode(); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + PrivateAccess.setVariable((Class<CloudSite>) CloudSite.class, cloudSite0, "id", (Object) "PUBLIC"); + cloudSite0.hashCode(); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + String string0 = cloudSite0.getIdentityServiceId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + String string0 = cloudSite0.toString(); + assertEquals("CloudSite: id=null, regionId=null, identityServiceId=null, aic_version=null, clli=null", string0); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + String string0 = cloudSite0.getAic_version(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test27() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + CloudIdentity cloudIdentity0 = new CloudIdentity(); + cloudSite0.setIdentityService(cloudIdentity0); + cloudSite0.hashCode(); + } + + @Test(timeout = 4000) + public void test28() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + String string0 = cloudSite0.getClli(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test29() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + String string0 = cloudSite0.getId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test30() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + String string0 = cloudSite0.getRegionId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test31() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + cloudSite0.setId("Tx;$hjj"); + String string0 = cloudSite0.getId(); + assertEquals("Tx;$hjj", string0); + } + + @Test(timeout = 4000) + public void test32() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + CloudIdentity cloudIdentity0 = cloudSite0.getIdentityService(); + assertNull(cloudIdentity0); + } + + @Test(timeout = 4000) + public void test33() throws Throwable { + CloudSite cloudSite0 = new CloudSite(); + // Undeclared exception! + try { + cloudSite0.clone(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.cloud.CloudSite", e); + } + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudSiteESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudSiteESTestscaffolding.java new file mode 100644 index 0000000000..48e800ff5b --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudSiteESTestscaffolding.java @@ -0,0 +1,150 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:42:36 GMT 2016 + */ + +package org.openecomp.mso.cloud; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class CloudSiteESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.cloud.CloudSite"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(CloudSiteESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.logger.MsoLogger", + "org.openecomp.mso.logger.MessageEnum", + "com.att.eelf.i18n.EELFResolvableErrorEnum", + "org.openecomp.mso.logger.MsoLogger$ResponseCode", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.cloud.CloudSite", + "org.openecomp.mso.logger.MsoLogger$StatusCode", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "com.att.eelf.configuration.EELFManager", + "org.openecomp.mso.cloud.CloudIdentity$IdentityServerType", + "org.openecomp.mso.logger.MsoLogger$ErrorCode", + "com.att.eelf.configuration.EELFLogger", + "com.att.eelf.i18n.EELFMsgs", + "org.openecomp.mso.openstack.exceptions.MsoException", + "com.att.eelf.configuration.EELFLogger$Level", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "com.att.eelf.configuration.SLF4jWrapper", + "com.att.eelf.i18n.EELFResourceManager", + "org.openecomp.mso.cloud.CloudIdentity" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(CloudSiteESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.openecomp.mso.logger.MsoLogger", + "com.att.eelf.i18n.EELFResourceManager", + "com.att.eelf.i18n.EELFMsgs", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "org.apache.xerces.jaxp.SAXParserFactoryImpl", + "org.apache.xerces.jaxp.SAXParserImpl", + "org.apache.xerces.parsers.XMLParser", + "org.apache.xerces.parsers.AbstractSAXParser", + "org.apache.xerces.parsers.SAXParser", + "org.apache.xerces.parsers.ObjectFactory", + "org.apache.xerces.util.ParserConfigurationSettings", + "org.apache.xerces.parsers.XML11Configuration", + "org.apache.xerces.parsers.XIncludeAwareParserConfiguration", + "org.apache.xerces.util.SymbolTable", + "org.apache.xerces.impl.XMLEntityManager", + "org.apache.xerces.util.AugmentationsImpl$SmallContainer", + "org.apache.xerces.impl.XMLEntityManager$ByteBufferPool", + "org.apache.xerces.impl.XMLEntityManager$CharacterBufferPool", + "org.apache.xerces.impl.XMLEntityScanner$1", + "org.apache.xerces.impl.XMLEntityScanner", + "org.apache.xerces.impl.XMLErrorReporter", + "org.apache.xerces.impl.XMLScanner", + "org.apache.xerces.impl.XMLDocumentFragmentScannerImpl", + "org.apache.xerces.impl.XMLDocumentScannerImpl", + "org.apache.xerces.util.XMLStringBuffer", + "org.apache.xerces.util.XMLAttributesImpl", + "org.apache.xerces.impl.XMLDTDScannerImpl", + "org.apache.xerces.impl.dtd.XMLDTDProcessor", + "org.apache.xerces.impl.dtd.XMLDTDValidator", + "org.apache.xerces.impl.validation.ValidationState", + "org.apache.xerces.impl.dtd.XMLElementDecl", + "org.apache.xerces.impl.dtd.XMLSimpleType", + "org.apache.xerces.impl.dv.DTDDVFactory", + "org.apache.xerces.impl.dv.ObjectFactory", + "org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl", + "org.apache.xerces.impl.XMLVersionDetector", + "org.apache.xerces.impl.msg.XMLMessageFormatter", + "org.apache.xerces.impl.io.UTF8Reader", + "org.apache.xerces.util.XMLSymbols", + "org.apache.xerces.xni.NamespaceContext", + "org.apache.xerces.util.XMLChar", + "org.apache.xerces.impl.Constants", + "com.att.eelf.configuration.EELFLogger$Level", + "com.att.eelf.configuration.EELFManager", + "org.openecomp.mso.logger.MessageEnum", + "org.openecomp.mso.cloud.CloudIdentity", + "org.openecomp.mso.utils.CryptoUtils", + "org.openecomp.mso.logger.MsoAlarmLogger", + "org.openecomp.mso.openstack.utils.MsoCommonUtils" + ); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/MsoTenantESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/MsoTenantESTest.java new file mode 100644 index 0000000000..241ca88a1d --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/MsoTenantESTest.java @@ -0,0 +1,83 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:56:50 GMT 2016 + */ + +package org.openecomp.mso.openstack.beans; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoTenantESTest extends MsoTenantESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoTenant msoTenant0 = new MsoTenant("P<5j-:=G4zf", "P<5j-:=G4zf", (Map<String, String>) null); + String string0 = msoTenant0.getTenantName(); + assertEquals("P<5j-:=G4zf", string0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + MsoTenant msoTenant0 = new MsoTenant("", "", (Map<String, String>) null); + String string0 = msoTenant0.getTenantName(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + MsoTenant msoTenant0 = new MsoTenant(); + String string0 = msoTenant0.getTenantName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + MsoTenant msoTenant0 = new MsoTenant(); + Map<String, String> map0 = msoTenant0.getMetadata(); + assertNull(map0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + MsoTenant msoTenant0 = new MsoTenant("", "SsK{%:", (Map<String, String>) null); + String string0 = msoTenant0.getTenantId(); + assertEquals("", string0); + assertEquals("SsK{%:", msoTenant0.getTenantName()); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + MsoTenant msoTenant0 = new MsoTenant(); + msoTenant0.setTenantId("9A"); + String string0 = msoTenant0.getTenantId(); + assertEquals("9A", string0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + MsoTenant msoTenant0 = new MsoTenant(); + msoTenant0.setMetadata((Map<String, String>) null); + assertNull(msoTenant0.getTenantName()); + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + MsoTenant msoTenant0 = new MsoTenant(); + msoTenant0.setTenantName("9A"); + assertNull(msoTenant0.getTenantId()); + } + + @Test(timeout = 4000) + public void test8() throws Throwable { + MsoTenant msoTenant0 = new MsoTenant(); + String string0 = msoTenant0.getTenantId(); + assertNull(string0); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/MsoTenantESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/MsoTenantESTestscaffolding.java new file mode 100644 index 0000000000..0ac4893ee8 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/MsoTenantESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:56:50 GMT 2016 + */ + +package org.openecomp.mso.openstack.beans; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoTenantESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.beans.MsoTenant"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoTenantESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.beans.MsoTenant" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkInfoESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkInfoESTest.java new file mode 100644 index 0000000000..9c157252ed --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkInfoESTest.java @@ -0,0 +1,247 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:44:14 GMT 2016 + */ + +package org.openecomp.mso.openstack.beans; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.MockitoExtension.*; + +import com.woorea.openstack.quantum.model.Network; +import com.woorea.openstack.quantum.model.Segment; +import java.util.List; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class NetworkInfoESTest extends NetworkInfoESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + networkInfo0.setVlans((List<Integer>) null); + List<Integer> list0 = networkInfo0.getVlans(); + assertNull(list0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + Network network0 = mock(Network.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(network0).getId(); + doReturn((String) null).when(network0).getName(); + doReturn((String) null).when(network0).getProviderPhysicalNetwork(); + doReturn((List) null).when(network0).getSegments(); + doReturn((String) null).when(network0).getStatus(); + doReturn((List) null).when(network0).getSubnets(); + NetworkInfo networkInfo0 = new NetworkInfo(network0); + List<String> list0 = networkInfo0.getSubnets(); + assertNull(list0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + networkInfo0.setShared("Network [id="); + String string0 = networkInfo0.getShared(); + assertEquals("Network [id=", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + networkInfo0.setProvider((String) null); + String string0 = networkInfo0.getProvider(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + networkInfo0.setProvider("ERROR"); + String string0 = networkInfo0.getProvider(); + assertEquals("ERROR", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + networkInfo0.setId((String) null); + String string0 = networkInfo0.getId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + NetworkStatus networkStatus0 = NetworkStatus.DOWN; + NetworkInfo networkInfo0 = new NetworkInfo("IghhGdNW B*}", networkStatus0); + String string0 = networkInfo0.getId(); + assertEquals("IghhGdNW B*}", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + Network network0 = mock(Network.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(network0).getId(); + doReturn((String) null).when(network0).getName(); + doReturn((String) null).when(network0).getProviderPhysicalNetwork(); + doReturn((List) null).when(network0).getSegments(); + doReturn((String) null).when(network0).getStatus(); + doReturn((List) null).when(network0).getSubnets(); + NetworkInfo networkInfo0 = new NetworkInfo(network0); + List<String> list0 = networkInfo0.getSubnets(); + Network network1 = mock(Network.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(network1).getId(); + doReturn((String) null).when(network1).getName(); + doReturn((String) null).when(network1).getProviderPhysicalNetwork(); + doReturn((List<Segment>) null).when(network1).getSegments(); + doReturn("uxR^({\"", (String) null).when(network1).getStatus(); + doReturn(list0).when(network1).getSubnets(); + NetworkInfo networkInfo1 = new NetworkInfo(network1); + assertNull(networkInfo1.getName()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + Network network0 = mock(Network.class, new ViolatedAssumptionAnswer()); + doReturn(", segments: ").when(network0).getId(); + doReturn("ACTIVE").when(network0).getName(); + doReturn("l1~gC_#a'H,#*").when(network0).getProviderNetworkType(); + doReturn("ACTIVE", "").when(network0).getProviderPhysicalNetwork(); + doReturn("ERROR", "ERROR", "%<3T-").when(network0).getStatus(); + doReturn((List) null).when(network0).getSubnets(); + NetworkInfo networkInfo0 = new NetworkInfo(network0); + networkInfo0.getStatus(); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + Network network0 = mock(Network.class, new ViolatedAssumptionAnswer()); + doReturn(", segments: ").when(network0).getId(); + doReturn("ACTIVE").when(network0).getName(); + doReturn((String) null).when(network0).getProviderNetworkType(); + doReturn("ACTIVE", (String) null).when(network0).getProviderPhysicalNetwork(); + doReturn("ERROR", (String) null).when(network0).getStatus(); + NetworkInfo networkInfo0 = null; + try { + networkInfo0 = new NetworkInfo(network0); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + } + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo((Network) null); + assertEquals("", networkInfo0.getId()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + String string0 = networkInfo0.toString(); + assertEquals("Network: name=,id=,status=UNKNOWN,provider=,vlans=[],subnets=[],shared=", string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + NetworkStatus networkStatus0 = NetworkStatus.NOTFOUND; + networkInfo0.setStatus(networkStatus0); + assertEquals("", networkInfo0.getShared()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + NetworkStatus networkStatus0 = NetworkStatus.UNKNOWN; + NetworkInfo networkInfo0 = new NetworkInfo((String) null, networkStatus0); + String string0 = networkInfo0.getName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + networkInfo0.setShared((String) null); + String string0 = networkInfo0.getShared(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + String string0 = networkInfo0.getShared(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + List<String> list0 = networkInfo0.getSubnets(); + Network network0 = mock(Network.class, new ViolatedAssumptionAnswer()); + doReturn("R65k@>rbu`lzb#").when(network0).getId(); + doReturn("ERROR").when(network0).getName(); + doReturn("DOWN").when(network0).getProviderNetworkType(); + doReturn("u1Z(%z~k-ao5#y", "R65k@>rbu`lzb#").when(network0).getProviderPhysicalNetwork(); + doReturn("R65k@>rbu`lzb#", "R65k@>rbu`lzb#").when(network0).getStatus(); + doReturn(list0).when(network0).getSubnets(); + NetworkInfo networkInfo1 = new NetworkInfo(network0); + networkInfo1.getName(); + assertEquals("R65k@>rbu`lzb#", networkInfo1.getProvider()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + List<Integer> list0 = networkInfo0.getVlans(); + networkInfo0.setVlans(list0); + assertEquals("", networkInfo0.getProvider()); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + networkInfo0.setName(""); + assertEquals(NetworkStatus.UNKNOWN, networkInfo0.getStatus()); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + networkInfo0.setSubnets((List<String>) null); + assertEquals("", networkInfo0.getShared()); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + NetworkStatus networkStatus0 = networkInfo0.getStatus(); + assertEquals(NetworkStatus.UNKNOWN, networkStatus0); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + String string0 = networkInfo0.getProvider(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + String string0 = networkInfo0.getId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + NetworkInfo networkInfo0 = new NetworkInfo(); + String string0 = networkInfo0.getName(); + assertEquals("", string0); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkInfoESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkInfoESTestscaffolding.java new file mode 100644 index 0000000000..0c87ca9016 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkInfoESTestscaffolding.java @@ -0,0 +1,92 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:44:14 GMT 2016 + */ + +package org.openecomp.mso.openstack.beans; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class NetworkInfoESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.beans.NetworkInfo"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(NetworkInfoESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "com.woorea.openstack.quantum.model.Network", + "org.codehaus.jackson.annotate.JsonIgnoreProperties", + "com.woorea.openstack.quantum.model.Segment", + "org.openecomp.mso.openstack.beans.NetworkInfo", + "org.openecomp.mso.openstack.beans.NetworkStatus", + "com.woorea.openstack.quantum.model.Network$NetworkType", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(NetworkInfoESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.openstack.beans.NetworkStatus", + "org.openecomp.mso.openstack.beans.NetworkInfo", + "com.woorea.openstack.quantum.model.Network" + ); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkRollbackESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkRollbackESTest.java new file mode 100644 index 0000000000..bad2bde0af --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkRollbackESTest.java @@ -0,0 +1,303 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:55:12 GMT 2016 + */ + +package org.openecomp.mso.openstack.beans; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.MockitoExtension.*; +import org.openecomp.mso.entity.MsoRequest; + +import java.util.List; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class NetworkRollbackESTest extends NetworkRollbackESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNetworkStackId("H/r!m+_NT$?ed$IPcLD"); + networkRollback0.setNeutronNetworkId("H/r!m+_NT$?ed$IPcLD"); + MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); + doReturn((String) null, (String) null, (String) null).when(msoRequest0).toString(); + networkRollback0.setNetworkStackId(""); + networkRollback0.setMsoRequest((MsoRequest) null); + networkRollback0.setMsoRequest(msoRequest0); + networkRollback0.toString(); + networkRollback0.setNeutronNetworkId("NetworkRollback [networkId=null, neutronNetworkId=H/r!m+_NT$?ed$IPcLD, networkStackId=, tenantId=null, cloudId=null, networkType=null, networkCreated=false, networkName=null, physicalNetwork=null]"); + networkRollback0.getVlans(); + networkRollback0.setCloudId("NetworkRollback [networkId=null, neutronNetworkId=H/r!m+_NT$?ed$IPcLD, networkStackId=, tenantId=null, cloudId=null, networkType=null, networkCreated=false, networkName=null, physicalNetwork=null]"); + networkRollback0.setNetworkType("NetworkRollback [networkId=null, neutronNetworkId=H/r!m+_NT$?ed$IPcLD, networkStackId=, tenantId=null, cloudId=null, networkType=null, networkCreated=false, networkName=null, physicalNetwork=null]"); + networkRollback0.toString(); + networkRollback0.setCloudId("NetworkRollback [networkId=null, neutronNetworkId=H/r!m+_NT$?ed$IPcLD, networkStackId=, tenantId=null, cloudId=null, networkType=null, networkCreated=false, networkName=null, physicalNetwork=null]"); + networkRollback0.setTenantId("80\u0002<]~y|x(#fl"); + networkRollback0.setCloudId("=:U\"]"); + networkRollback0.toString(); + networkRollback0.getVlans(); + networkRollback0.toString(); + networkRollback0.getVlans(); + networkRollback0.getVlans(); + networkRollback0.getVlans(); + networkRollback0.setVlans((List<Integer>) null); + networkRollback0.toString(); + networkRollback0.getMsoRequest(); + networkRollback0.getVlans(); + networkRollback0.toString(); + networkRollback0.getMsoRequest(); + networkRollback0.getVlans(); + networkRollback0.getMsoRequest(); + networkRollback0.getVlans(); + List<Integer> list0 = networkRollback0.getVlans(); + assertNull(list0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNetworkType((String) null); + networkRollback0.getMsoRequest(); + networkRollback0.setMsoRequest((MsoRequest) null); + networkRollback0.setNetworkId(""); + networkRollback0.setTenantId(""); + networkRollback0.getNetworkId(); + networkRollback0.setNeutronNetworkId(""); + networkRollback0.setCloudId("O;On"); + assertFalse(networkRollback0.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setCloudId("C5FS|V@CMBag"); + networkRollback0.getVlans(); + networkRollback0.setVlans((List<Integer>) null); + networkRollback0.getPhysicalNetwork(); + networkRollback0.setVlans((List<Integer>) null); + networkRollback0.getNeutronNetworkId(); + networkRollback0.setNetworkType("C5FS|V@CMBag"); + networkRollback0.getNetworkType(); + assertFalse(networkRollback0.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNetworkId(", networkName="); + networkRollback0.setNetworkStackId("u)"); + networkRollback0.setNetworkId("u)"); + networkRollback0.setNetworkId(", networkName="); + networkRollback0.getNetworkStackId(); + assertFalse(networkRollback0.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNetworkType("V3$f~dKduUu0"); + networkRollback0.setNetworkType(""); + networkRollback0.setTenantId(""); + networkRollback0.getPhysicalNetwork(); + networkRollback0.getVlans(); + networkRollback0.getNetworkType(); + assertFalse(networkRollback0.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setTenantId("Lu#)!pt2p=<#T."); + networkRollback0.getTenantId(); + networkRollback0.setNetworkStackId("Lu#)!pt2p=<#T."); + networkRollback0.getNeutronNetworkId(); + networkRollback0.setTenantId("Lu#)!pt2p=<#T."); + networkRollback0.setNetworkStackId((String) null); + String string0 = networkRollback0.toString(); + assertEquals("NetworkRollback [networkId=null, neutronNetworkId=null, networkStackId=null, tenantId=Lu#)!pt2p=<#T., cloudId=null, networkType=null, networkCreated=false, networkName=null, physicalNetwork=null]", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.getMsoRequest(); + networkRollback0.setMsoRequest((MsoRequest) null); + String string0 = networkRollback0.toString(); + assertEquals("NetworkRollback [networkId=null, neutronNetworkId=null, networkStackId=null, tenantId=null, cloudId=null, networkType=null, networkCreated=false, networkName=null, physicalNetwork=null]", string0); + + networkRollback0.setNetworkName(""); + networkRollback0.getNetworkName(); + networkRollback0.setNetworkCreated(true); + networkRollback0.setNetworkName(""); + networkRollback0.getPhysicalNetwork(); + networkRollback0.setTenantId(""); + networkRollback0.setNetworkId(""); + assertTrue(networkRollback0.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.getTenantId(); + networkRollback0.setNetworkStackId((String) null); + networkRollback0.getVlans(); + networkRollback0.setTenantId(""); + networkRollback0.getTenantId(); + networkRollback0.setVlans((List<Integer>) null); + String string0 = networkRollback0.toString(); + assertEquals("NetworkRollback [networkId=null, neutronNetworkId=null, networkStackId=null, tenantId=, cloudId=null, networkType=null, networkCreated=false, networkName=null, physicalNetwork=null]", string0); + + NetworkRollback networkRollback1 = new NetworkRollback(); + assertFalse(networkRollback1.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNeutronNetworkId(""); + networkRollback0.setCloudId(""); + networkRollback0.getTenantId(); + networkRollback0.setTenantId(""); + networkRollback0.setNetworkType("Y=x>wx'"); + networkRollback0.getNeutronNetworkId(); + networkRollback0.getVlans(); + networkRollback0.setVlans((List<Integer>) null); + networkRollback0.setNetworkStackId("6P7@4aGo &Kd>V"); + networkRollback0.getCloudId(); + NetworkRollback networkRollback1 = new NetworkRollback(); + assertFalse(networkRollback1.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + assertFalse(networkRollback0.getNetworkCreated()); + + networkRollback0.setNetworkCreated(true); + networkRollback0.toString(); + networkRollback0.setNeutronNetworkId("NetworkRollback [networkId=null, neutronNetworkId=null, networkStackId=null, tenantId=null, cloudId=null, networkType=null, networkCreated=true, networkName=null, physicalNetwork=null]"); + networkRollback0.getPhysicalNetwork(); + boolean boolean0 = networkRollback0.getNetworkCreated(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNetworkId(", tenantId="); + networkRollback0.setNetworkId(""); + networkRollback0.setTenantId(", tenantId="); + networkRollback0.setNetworkName("+*"); + networkRollback0.getNetworkName(); + networkRollback0.setNetworkStackId(", tenantId="); + networkRollback0.setCloudId("+*"); + networkRollback0.getCloudId(); + NetworkRollback networkRollback1 = new NetworkRollback(); + assertFalse(networkRollback1.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setPhysicalNetwork("!(>41heY7e"); + networkRollback0.setTenantId("j"); + networkRollback0.setNeutronNetworkId("j"); + networkRollback0.getPhysicalNetwork(); + networkRollback0.getVlans(); + NetworkRollback networkRollback1 = new NetworkRollback(); + networkRollback1.getMsoRequest(); + networkRollback0.setMsoRequest((MsoRequest) null); + networkRollback0.setNetworkCreated(false); + networkRollback0.setNeutronNetworkId("j"); + assertFalse(networkRollback0.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setPhysicalNetwork(""); + networkRollback0.setNetworkStackId(""); + networkRollback0.setNeutronNetworkId(""); + networkRollback0.getNetworkStackId(); + networkRollback0.getMsoRequest(); + assertFalse(networkRollback0.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setCloudId("7u@lc[l##+g`2V"); + networkRollback0.getVlans(); + networkRollback0.setVlans((List<Integer>) null); + networkRollback0.setNetworkType(""); + networkRollback0.setCloudId(", physicalNetwork="); + networkRollback0.setPhysicalNetwork(""); + networkRollback0.setNeutronNetworkId(", physicalNetwork="); + networkRollback0.getPhysicalNetwork(); + networkRollback0.getNeutronNetworkId(); + assertFalse(networkRollback0.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.getNetworkId(); + assertFalse(networkRollback0.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.getMsoRequest(); + networkRollback0.setMsoRequest((MsoRequest) null); + networkRollback0.getNetworkCreated(); + networkRollback0.setNetworkId(", networkName="); + networkRollback0.getNeutronNetworkId(); + networkRollback0.setPhysicalNetwork((String) null); + networkRollback0.getNetworkId(); + NetworkRollback networkRollback1 = new NetworkRollback(); + String string0 = networkRollback1.toString(); + assertEquals("NetworkRollback [networkId=null, neutronNetworkId=null, networkStackId=null, tenantId=null, cloudId=null, networkType=null, networkCreated=false, networkName=null, physicalNetwork=null]", string0); + + networkRollback1.getVlans(); + networkRollback0.setVlans((List<Integer>) null); + networkRollback0.getNetworkId(); + networkRollback1.getPhysicalNetwork(); + networkRollback1.setNetworkCreated(false); + assertFalse(networkRollback1.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.getNetworkType(); + networkRollback0.setTenantId((String) null); + networkRollback0.setNetworkName(" networkStacId="); + networkRollback0.getCloudId(); + networkRollback0.getTenantId(); + networkRollback0.setNetworkStackId(" networkStacId="); + networkRollback0.setNeutronNetworkId((String) null); + assertFalse(networkRollback0.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.getNetworkName(); + assertFalse(networkRollback0.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNetworkType("uK+JCvyg\"J(C d.w["); + networkRollback0.setCloudId("uK+JCvyg\"J(C d.w["); + networkRollback0.getNetworkStackId(); + assertFalse(networkRollback0.getNetworkCreated()); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkRollbackESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkRollbackESTestscaffolding.java new file mode 100644 index 0000000000..1665732f62 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkRollbackESTestscaffolding.java @@ -0,0 +1,79 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:55:12 GMT 2016 + */ + +package org.openecomp.mso.openstack.beans; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class NetworkRollbackESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.beans.NetworkRollback"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(NetworkRollbackESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.openstack.beans.NetworkRollback" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/PoolESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/PoolESTest.java new file mode 100644 index 0000000000..0ec588ded9 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/PoolESTest.java @@ -0,0 +1,70 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:49:52 GMT 2016 + */ + +package org.openecomp.mso.openstack.beans; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class PoolESTest extends PoolESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + Pool pool0 = new Pool(); + pool0.setStart("Allocation_pool [start=null, end=null]"); + String string0 = pool0.getStart(); + assertEquals("Allocation_pool [start=null, end=null]", string0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + Pool pool0 = new Pool(); + pool0.setEnd("Allocation_pool [start=null, end=null]"); + String string0 = pool0.getEnd(); + assertEquals("Allocation_pool [start=null, end=null]", string0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + Pool pool0 = new Pool(); + String string0 = pool0.getEnd(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + Pool pool0 = new Pool(); + pool0.setStart(""); + String string0 = pool0.getStart(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + Pool pool0 = new Pool(); + String string0 = pool0.toString(); + assertEquals("Allocation_pool [start=null, end=null]", string0); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + Pool pool0 = new Pool(); + pool0.setEnd(""); + String string0 = pool0.getEnd(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + Pool pool0 = new Pool(); + String string0 = pool0.getStart(); + assertNull(string0); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/PoolESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/PoolESTestscaffolding.java new file mode 100644 index 0000000000..8ce9cb88b7 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/PoolESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:49:52 GMT 2016 + */ + +package org.openecomp.mso.openstack.beans; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class PoolESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.beans.Pool"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(PoolESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.beans.Pool" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/SubnetESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/SubnetESTest.java new file mode 100644 index 0000000000..7be8339439 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/SubnetESTest.java @@ -0,0 +1,221 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:52:14 GMT 2016 + */ + +package org.openecomp.mso.openstack.beans; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.List; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class SubnetESTest extends SubnetESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setSubnetName("lu[c8x"); + subnet0.getSubnetName(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setSubnetName(""); + subnet0.getSubnetName(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setSubnetId("nL"); + subnet0.getSubnetId(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setSubnetId(""); + subnet0.getSubnetId(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setNeutronId("`jC)vXXeOG"); + subnet0.getNeutronId(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setIpVersion(""); + String string0 = subnet0.getIpVersion(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setGatewayIp((String) null); + subnet0.getGatewayIp(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setGatewayIp("Subnet [subnetName=null, neutronId=null, subnetId=null, cidr=null, gatewayIp=, ipVersion=4, enableDHCP=false, hostRoutes=null, allocationPools=null, dnsNameServers=null]"); + subnet0.getGatewayIp(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setCidr("H3%q_*bOC2"); + subnet0.getCidr(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setIpVersion((String) null); + String string0 = subnet0.getIpVersion(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setAllocationPools((List<Pool>) null); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.getNeutronId(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.getHostRoutes(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + Subnet subnet0 = new Subnet(); + String string0 = subnet0.toString(); + assertEquals("Subnet [subnetName=null, neutronId=null, subnetId=null, cidr=null, gatewayIp=, ipVersion=4, enableDHCP=false, hostRoutes=null, allocationPools=null, dnsNameServers=null]", string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.getSubnetName(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setNeutronId(""); + subnet0.getNeutronId(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setCidr(""); + subnet0.getCidr(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.getDnsNameServers(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setHostRoutes((List<String>) null); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + Subnet subnet0 = new Subnet(); + String string0 = subnet0.getIpVersion(); + assertEquals("4", string0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.getSubnetId(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setEnableDHCP((Boolean) null); + subnet0.getEnableDHCP(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.getAllocationPools(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.getCidr(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.getGatewayIp(); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + Subnet subnet0 = new Subnet(); + subnet0.setDnsNameServers((List<String>) null); + assertEquals("4", subnet0.getIpVersion()); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + Subnet subnet0 = new Subnet(); + Boolean boolean0 = subnet0.getEnableDHCP(); + assertFalse(boolean0); + assertEquals("4", subnet0.getIpVersion()); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/SubnetESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/SubnetESTestscaffolding.java new file mode 100644 index 0000000000..a9bf598355 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/SubnetESTestscaffolding.java @@ -0,0 +1,79 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:52:14 GMT 2016 + */ + +package org.openecomp.mso.openstack.beans; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class SubnetESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.beans.Subnet"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(SubnetESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.beans.Pool", + "org.openecomp.mso.openstack.beans.Subnet" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/VnfRollbackESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/VnfRollbackESTest.java new file mode 100644 index 0000000000..e76ce410d4 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/VnfRollbackESTest.java @@ -0,0 +1,403 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:51:17 GMT 2016 + */ + +package org.openecomp.mso.openstack.beans; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; + +import org.openecomp.mso.entity.MsoRequest; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class VnfRollbackESTest extends VnfRollbackESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVolumeGroupName(", vnfCreated="); + vnfRollback0.getVolumeGroupName(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVolumeGroupId("}mvn2f6!r5FG1/_M~M"); + vnfRollback0.getVolumeGroupId(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVolumeGroupId(""); + vnfRollback0.getVolumeGroupId(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVolumeGroupHeatStackId("Z^t$4-eOKP9"); + vnfRollback0.getVolumeGroupHeatStackId(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getVnfId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVnfId(""); + vnfRollback0.getVnfId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVfModuleStackId("8y*`!>A$@*l8#a>"); + vnfRollback0.getVfModuleStackId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVfModuleStackId(""); + vnfRollback0.getVfModuleStackId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(", tenant=", ", tenant=", ", tenant=", false, false, (MsoRequest) null, ", tenant=", "f5`2h^e^.-x", ", tenant="); + String string0 = vnfRollback0.getTenantId(); + assertFalse(vnfRollback0.getVnfCreated()); + assertEquals(", tenant=", vnfRollback0.getCloudSiteId()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.isBase()); + assertEquals(", tenant=", vnfRollback0.getRequestType()); + assertEquals("f5`2h^e^.-x", vnfRollback0.getVolumeGroupId()); + assertEquals(", tenant=", vnfRollback0.getVolumeGroupName()); + assertEquals(", tenant=", vnfRollback0.getVnfId()); + assertEquals(", tenant=", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setTenantId(""); + vnfRollback0.getTenantId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + assertFalse(vnfRollback0.getTenantCreated()); + + vnfRollback0.setTenantCreated(true); + boolean boolean0 = vnfRollback0.getTenantCreated(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); + VnfRollback vnfRollback0 = new VnfRollback("", ", vnf=", "Jvr", false, false, msoRequest0, "", "f'D", "VnfRollback: cloud="); + String string0 = vnfRollback0.getRequestType(); + assertFalse(vnfRollback0.isBase()); + assertEquals("Jvr", vnfRollback0.getCloudSiteId()); + assertEquals("", vnfRollback0.getVnfId()); + assertFalse(vnfRollback0.getTenantCreated()); + assertEquals("f'D", vnfRollback0.getVolumeGroupId()); + assertEquals(", vnf=", vnfRollback0.getTenantId()); + assertEquals("VnfRollback: cloud=", string0); + assertFalse(vnfRollback0.getVnfCreated()); + assertEquals("", vnfRollback0.getVolumeGroupName()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setRequestType(""); + vnfRollback0.getRequestType(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); + doReturn("Jvr").when(msoRequest0).toString(); + VnfRollback vnfRollback0 = new VnfRollback("", ", vnf=", "Jvr", false, false, msoRequest0, "", "f'D", "VnfRollback: cloud="); + vnfRollback0.getMsoRequest(); + assertEquals("Jvr", vnfRollback0.getCloudSiteId()); + assertEquals("", vnfRollback0.getVnfId()); + assertFalse(vnfRollback0.isBase()); + assertEquals(", vnf=", vnfRollback0.getTenantId()); + assertEquals("", vnfRollback0.getVolumeGroupName()); + assertEquals("f'D", vnfRollback0.getVolumeGroupId()); + assertEquals("VnfRollback: cloud=", vnfRollback0.getRequestType()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(", tenant=", ", tenant=", ", tenant=", false, false, (MsoRequest) null, ", tenant=", "f5`2h^e^.-x", ", tenant="); + String string0 = vnfRollback0.getCloudSiteId(); + assertFalse(vnfRollback0.isBase()); + assertEquals(", tenant=", string0); + assertEquals("f5`2h^e^.-x", vnfRollback0.getVolumeGroupId()); + assertFalse(vnfRollback0.getVnfCreated()); + assertEquals(", tenant=", vnfRollback0.getVnfId()); + assertFalse(vnfRollback0.getTenantCreated()); + assertEquals(", tenant=", vnfRollback0.getVolumeGroupName()); + assertEquals(", tenant=", vnfRollback0.getRequestType()); + assertEquals(", tenant=", vnfRollback0.getTenantId()); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setCloudSiteId(""); + vnfRollback0.getCloudSiteId(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setBaseGroupHeatStackId("3(6Q^)Ic kf:zj"); + vnfRollback0.getBaseGroupHeatStackId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setBaseGroupHeatStackId(""); + vnfRollback0.getBaseGroupHeatStackId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + assertFalse(vnfRollback0.isBase()); + + vnfRollback0.setIsBase(true); + boolean boolean0 = vnfRollback0.isBase(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getVfModuleStackId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getVolumeGroupName(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVolumeGroupName(""); + vnfRollback0.getVolumeGroupName(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + boolean boolean0 = vnfRollback0.getTenantCreated(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(boolean0); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + boolean boolean0 = vnfRollback0.isBase(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + String string0 = vnfRollback0.toString(); + assertFalse(vnfRollback0.isBase()); + assertEquals("VnfRollback: cloud=null, tenant=null, vnf=null, tenantCreated=false, vnfCreated=false, requestType = null", string0); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + boolean boolean0 = vnfRollback0.getVnfCreated(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(boolean0); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getVolumeGroupHeatStackId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test27() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getBaseGroupHeatStackId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test28() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getCloudSiteId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test29() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getTenantId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test30() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); + vnfRollback0.setMsoRequest(msoRequest0); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test31() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getMsoRequest(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test32() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + assertFalse(vnfRollback0.getVnfCreated()); + + vnfRollback0.setVnfCreated(true); + boolean boolean0 = vnfRollback0.getVnfCreated(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test33() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getVolumeGroupId(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test34() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getRequestType(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test35() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVolumeGroupHeatStackId(""); + vnfRollback0.getVolumeGroupHeatStackId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test36() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(", tenant=", ", tenant=", ", tenant=", false, false, (MsoRequest) null, ", tenant=", "f5`2h^e^.-x", ", tenant="); + String string0 = vnfRollback0.getVnfId(); + assertEquals(", tenant=", string0); + assertEquals(", tenant=", vnfRollback0.getTenantId()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertEquals(", tenant=", vnfRollback0.getCloudSiteId()); + assertEquals(", tenant=", vnfRollback0.getVolumeGroupName()); + assertEquals(", tenant=", vnfRollback0.getRequestType()); + assertEquals("f5`2h^e^.-x", vnfRollback0.getVolumeGroupId()); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/VnfRollbackESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/VnfRollbackESTestscaffolding.java new file mode 100644 index 0000000000..e07b2cfee3 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/VnfRollbackESTestscaffolding.java @@ -0,0 +1,79 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:51:17 GMT 2016 + */ + +package org.openecomp.mso.openstack.beans; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class VnfRollbackESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.beans.VnfRollback"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(VnfRollbackESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.beans.VnfRollback", + "org.openecomp.mso.entity.MsoRequest" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoAdapterExceptionESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoAdapterExceptionESTest.java new file mode 100644 index 0000000000..ccc5a949b7 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoAdapterExceptionESTest.java @@ -0,0 +1,24 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:51:02 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoAdapterExceptionESTest extends MsoAdapterExceptionESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoAdapterException msoAdapterException0 = new MsoAdapterException(""); + MsoAdapterException msoAdapterException1 = new MsoAdapterException("", (Throwable) msoAdapterException0); + assertFalse(msoAdapterException1.equals((Object)msoAdapterException0)); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoAdapterExceptionESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoAdapterExceptionESTestscaffolding.java new file mode 100644 index 0000000000..657b8b28c4 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoAdapterExceptionESTestscaffolding.java @@ -0,0 +1,87 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:51:02 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoAdapterExceptionESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.exceptions.MsoAdapterException"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoAdapterExceptionESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoAdapterException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(MsoAdapterExceptionESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoAdapterException" + ); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFoundESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFoundESTest.java new file mode 100644 index 0000000000..f840c12025 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFoundESTest.java @@ -0,0 +1,30 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:56:48 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoCloudSiteNotFoundESTest extends MsoCloudSiteNotFoundESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoCloudSiteNotFound msoCloudSiteNotFound0 = new MsoCloudSiteNotFound(); + assertEquals(MsoExceptionCategory.USERDATA, msoCloudSiteNotFound0.getCategory()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + MsoCloudSiteNotFound msoCloudSiteNotFound0 = new MsoCloudSiteNotFound("NQz5T^"); + String string0 = msoCloudSiteNotFound0.toString(); + assertEquals("Cloud Site [NQz5T^] not found", string0); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFoundESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFoundESTestscaffolding.java new file mode 100644 index 0000000000..ba287051dd --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFoundESTestscaffolding.java @@ -0,0 +1,87 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:56:48 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoCloudSiteNotFoundESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoCloudSiteNotFoundESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound", + "org.openecomp.mso.openstack.exceptions.MsoException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(MsoCloudSiteNotFoundESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound" + ); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoExceptionESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoExceptionESTest.java new file mode 100644 index 0000000000..2bd71fb525 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoExceptionESTest.java @@ -0,0 +1,77 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:48:01 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoExceptionESTest extends MsoExceptionESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoTenantNotFound msoTenantNotFound0 = new MsoTenantNotFound("T&~q", "Cloud Site ["); + MsoIOException msoIOException0 = new MsoIOException("", (Throwable) msoTenantNotFound0); + String string0 = msoIOException0.getContextMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + MsoNetworkNotFound msoNetworkNotFound0 = new MsoNetworkNotFound("", "", ""); + msoNetworkNotFound0.addContext(""); + String string0 = msoNetworkNotFound0.getContext(); + assertEquals("", string0); + assertNotNull(string0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + MsoAdapterException msoAdapterException0 = new MsoAdapterException(" "); + msoAdapterException0.setContext(" "); + String string0 = msoAdapterException0.getContextMessage(); + assertEquals("[ ] ", string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + MsoCloudSiteNotFound msoCloudSiteNotFound0 = new MsoCloudSiteNotFound(); + MsoAdapterException msoAdapterException0 = new MsoAdapterException("", (Throwable) msoCloudSiteNotFound0); + msoAdapterException0.addContext(""); + msoAdapterException0.addContext(""); + String string0 = msoAdapterException0.getContext(); + assertEquals(":", msoAdapterException0.getContext()); + assertNotNull(string0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + MsoCloudSiteNotFound msoCloudSiteNotFound0 = new MsoCloudSiteNotFound((String) null); + MsoExceptionCategory msoExceptionCategory0 = msoCloudSiteNotFound0.getCategory(); + MsoAdapterException msoAdapterException0 = new MsoAdapterException((String) null, (Throwable) msoCloudSiteNotFound0); + msoAdapterException0.setCategory(msoExceptionCategory0); + assertNull(msoAdapterException0.getContext()); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + MsoNetworkNotFound msoNetworkNotFound0 = new MsoNetworkNotFound("", "", ""); + String string0 = msoNetworkNotFound0.getContext(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + MsoCloudSiteNotFound msoCloudSiteNotFound0 = new MsoCloudSiteNotFound((String) null); + MsoAdapterException msoAdapterException0 = new MsoAdapterException((String) null, (Throwable) msoCloudSiteNotFound0); + String string0 = msoAdapterException0.getContextMessage(); + assertNull(string0); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoExceptionESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoExceptionESTestscaffolding.java new file mode 100644 index 0000000000..8ce85b76bf --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoExceptionESTestscaffolding.java @@ -0,0 +1,101 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:48:01 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoExceptionESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.exceptions.MsoException"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoExceptionESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoTenantNotFound", + "org.openecomp.mso.openstack.exceptions.MsoIOException", + "org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound", + "org.openecomp.mso.openstack.exceptions.MsoNetworkNotFound", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoAdapterException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(MsoExceptionESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound", + "org.openecomp.mso.openstack.exceptions.MsoIOException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException", + "org.openecomp.mso.openstack.exceptions.MsoNetworkAlreadyExists", + "org.openecomp.mso.openstack.exceptions.MsoNetworkNotFound", + "org.openecomp.mso.openstack.exceptions.MsoStackAlreadyExists", + "org.openecomp.mso.openstack.exceptions.MsoStackNotFound", + "org.openecomp.mso.openstack.exceptions.MsoTenantNotFound", + "org.openecomp.mso.openstack.exceptions.MsoAdapterException", + "org.openecomp.mso.openstack.exceptions.MsoTenantAlreadyExists", + "org.openecomp.mso.openstack.exceptions.MsoException" + ); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoIOExceptionESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoIOExceptionESTest.java new file mode 100644 index 0000000000..ec2699c3f3 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoIOExceptionESTest.java @@ -0,0 +1,24 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:50:20 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoIOExceptionESTest extends MsoIOExceptionESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoIOException msoIOException0 = new MsoIOException(""); + MsoIOException msoIOException1 = new MsoIOException("", (Throwable) msoIOException0); + assertNull(msoIOException1.getContext()); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoIOExceptionESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoIOExceptionESTestscaffolding.java new file mode 100644 index 0000000000..e657718fc4 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoIOExceptionESTestscaffolding.java @@ -0,0 +1,87 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:50:20 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoIOExceptionESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.exceptions.MsoIOException"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoIOExceptionESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.exceptions.MsoIOException", + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(MsoIOExceptionESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoIOException" + ); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoNetworkAlreadyExistsESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoNetworkAlreadyExistsESTest.java new file mode 100644 index 0000000000..2c423b7405 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoNetworkAlreadyExistsESTest.java @@ -0,0 +1,23 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:52:37 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoNetworkAlreadyExistsESTest extends MsoNetworkAlreadyExistsESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoNetworkAlreadyExists msoNetworkAlreadyExists0 = new MsoNetworkAlreadyExists((String) null, (String) null, (String) null); + assertNull(msoNetworkAlreadyExists0.getContext()); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoNetworkAlreadyExistsESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoNetworkAlreadyExistsESTestscaffolding.java new file mode 100644 index 0000000000..1c00ba9d8d --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoNetworkAlreadyExistsESTestscaffolding.java @@ -0,0 +1,89 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:52:37 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoNetworkAlreadyExistsESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.exceptions.MsoNetworkAlreadyExists"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoNetworkAlreadyExistsESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoNetworkAlreadyExists", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(MsoNetworkAlreadyExistsESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException", + "org.openecomp.mso.openstack.exceptions.MsoNetworkAlreadyExists" + ); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoNetworkNotFoundESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoNetworkNotFoundESTest.java new file mode 100644 index 0000000000..418545056c --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoNetworkNotFoundESTest.java @@ -0,0 +1,23 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:54:45 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoNetworkNotFoundESTest extends MsoNetworkNotFoundESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoNetworkNotFound msoNetworkNotFound0 = new MsoNetworkNotFound("6", "6", "yX9(}I;;7<c%.4HYX"); + assertNull(msoNetworkNotFound0.getContext()); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoNetworkNotFoundESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoNetworkNotFoundESTestscaffolding.java new file mode 100644 index 0000000000..1506836f1e --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoNetworkNotFoundESTestscaffolding.java @@ -0,0 +1,89 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:54:45 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoNetworkNotFoundESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.exceptions.MsoNetworkNotFound"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoNetworkNotFoundESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoNetworkNotFound", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(MsoNetworkNotFoundESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException", + "org.openecomp.mso.openstack.exceptions.MsoNetworkNotFound" + ); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackExceptionESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackExceptionESTest.java new file mode 100644 index 0000000000..00d7035c93 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackExceptionESTest.java @@ -0,0 +1,32 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:51:53 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoOpenstackExceptionESTest extends MsoOpenstackExceptionESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoOpenstackException msoOpenstackException0 = new MsoOpenstackException((-20), "zOT*@]B@O~zuv2", "zOT*@]B@O~zuv2"); + MsoOpenstackException msoOpenstackException1 = new MsoOpenstackException((-20), "zOT*@]B@O~zuv2", "zOT*@]B@O~zuv2", (Exception) msoOpenstackException0); + assertEquals(MsoExceptionCategory.OPENSTACK, msoOpenstackException1.getCategory()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + MsoOpenstackException msoOpenstackException0 = new MsoOpenstackException((-20), "zOT*@]B@O~zuv2", "zOT*@]B@O~zuv2"); + String string0 = msoOpenstackException0.toString(); + assertNotNull(string0); + assertEquals("-20 zOT*@]B@O~zuv2: zOT*@]B@O~zuv2", string0); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackExceptionESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackExceptionESTestscaffolding.java new file mode 100644 index 0000000000..78a71cce45 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackExceptionESTestscaffolding.java @@ -0,0 +1,87 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:51:53 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoOpenstackExceptionESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.exceptions.MsoOpenstackException"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoOpenstackExceptionESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(MsoOpenstackExceptionESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException" + ); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoStackAlreadyExistsESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoStackAlreadyExistsESTest.java new file mode 100644 index 0000000000..289b2a6aa2 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoStackAlreadyExistsESTest.java @@ -0,0 +1,23 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:55:08 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoStackAlreadyExistsESTest extends MsoStackAlreadyExistsESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoStackAlreadyExists msoStackAlreadyExists0 = new MsoStackAlreadyExists("", "", ""); + assertEquals(MsoExceptionCategory.OPENSTACK, msoStackAlreadyExists0.getCategory()); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoStackAlreadyExistsESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoStackAlreadyExistsESTestscaffolding.java new file mode 100644 index 0000000000..c7b8c85f67 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoStackAlreadyExistsESTestscaffolding.java @@ -0,0 +1,89 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:55:08 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoStackAlreadyExistsESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.exceptions.MsoStackAlreadyExists"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoStackAlreadyExistsESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.exceptions.MsoStackAlreadyExists", + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(MsoStackAlreadyExistsESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException", + "org.openecomp.mso.openstack.exceptions.MsoStackAlreadyExists" + ); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoStackNotFoundESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoStackNotFoundESTest.java new file mode 100644 index 0000000000..e8b6e85e74 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoStackNotFoundESTest.java @@ -0,0 +1,23 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:55:36 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoStackNotFoundESTest extends MsoStackNotFoundESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoStackNotFound msoStackNotFound0 = new MsoStackNotFound("", (String) null, (String) null); + assertEquals(MsoExceptionCategory.OPENSTACK, msoStackNotFound0.getCategory()); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoStackNotFoundESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoStackNotFoundESTestscaffolding.java new file mode 100644 index 0000000000..3ce09164d8 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoStackNotFoundESTestscaffolding.java @@ -0,0 +1,89 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:55:36 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoStackNotFoundESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.exceptions.MsoStackNotFound"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoStackNotFoundESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoStackNotFound", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(MsoStackNotFoundESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException", + "org.openecomp.mso.openstack.exceptions.MsoStackNotFound" + ); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExistsESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExistsESTest.java new file mode 100644 index 0000000000..a47f778cc0 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExistsESTest.java @@ -0,0 +1,23 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:56:00 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoTenantAlreadyExistsESTest extends MsoTenantAlreadyExistsESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoTenantAlreadyExists msoTenantAlreadyExists0 = new MsoTenantAlreadyExists("Q]>\u00018.eW8", "Q]>\u00018.eW8"); + assertEquals(MsoExceptionCategory.OPENSTACK, msoTenantAlreadyExists0.getCategory()); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExistsESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExistsESTestscaffolding.java new file mode 100644 index 0000000000..11700e6e75 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExistsESTestscaffolding.java @@ -0,0 +1,89 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:56:00 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoTenantAlreadyExistsESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.exceptions.MsoTenantAlreadyExists"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoTenantAlreadyExistsESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoTenantAlreadyExists", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(MsoTenantAlreadyExistsESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException", + "org.openecomp.mso.openstack.exceptions.MsoTenantAlreadyExists" + ); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoTenantNotFoundESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoTenantNotFoundESTest.java new file mode 100644 index 0000000000..b65bd1f5e4 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoTenantNotFoundESTest.java @@ -0,0 +1,23 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:52:17 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoTenantNotFoundESTest extends MsoTenantNotFoundESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoTenantNotFound msoTenantNotFound0 = new MsoTenantNotFound("", ""); + assertEquals(MsoExceptionCategory.OPENSTACK, msoTenantNotFound0.getCategory()); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoTenantNotFoundESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoTenantNotFoundESTestscaffolding.java new file mode 100644 index 0000000000..bd45ba62ad --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/exceptions/MsoTenantNotFoundESTestscaffolding.java @@ -0,0 +1,89 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:52:17 GMT 2016 + */ + +package org.openecomp.mso.openstack.exceptions; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoTenantNotFoundESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.exceptions.MsoTenantNotFound"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoTenantNotFoundESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.exceptions.MsoTenantNotFound", + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(MsoTenantNotFoundESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.openstack.exceptions.MsoException", + "org.openecomp.mso.openstack.exceptions.MsoOpenstackException", + "org.openecomp.mso.openstack.exceptions.MsoTenantNotFound" + ); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntryESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntryESTest.java new file mode 100644 index 0000000000..6eaac45a43 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntryESTest.java @@ -0,0 +1,562 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:40:12 GMT 2016 + */ + +package org.openecomp.mso.openstack.utils; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.EvoAssertions.*; +import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; + +import java.util.LinkedHashSet; +import java.util.Set; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.PrivateAccess; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoHeatEnvironmentEntryESTest { + + @Test(timeout = 4000) + public void test00() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + Set<MsoHeatEnvironmentResource> set0 = (Set<MsoHeatEnvironmentResource>) mock(Set.class, new ViolatedAssumptionAnswer()); + doReturn((-237540137)).when(set0).size(); + msoHeatEnvironmentEntry0.setResources(set0); + boolean boolean0 = msoHeatEnvironmentEntry0.hasResources(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + PrivateAccess.setVariable((Class<MsoHeatEnvironmentEntry>) MsoHeatEnvironmentEntry.class, msoHeatEnvironmentEntry0, "valid", (Object) false); + boolean boolean0 = msoHeatEnvironmentEntry0.isValid(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + LinkedHashSet<MsoHeatEnvironmentResource> linkedHashSet0 = new LinkedHashSet<MsoHeatEnvironmentResource>(); + msoHeatEnvironmentEntry0.setResources(linkedHashSet0); + msoHeatEnvironmentEntry0.getResources(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource("9>KEckx", "8&T!e[SABZ"); + msoHeatEnvironmentEntry0.addResource(msoHeatEnvironmentResource0); + msoHeatEnvironmentEntry0.getResources(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + StringBuilder stringBuilder0 = msoHeatEnvironmentEntry0.toFullString(); + PrivateAccess.setVariable((Class<MsoHeatEnvironmentEntry>) MsoHeatEnvironmentEntry.class, msoHeatEnvironmentEntry0, "rawEntry", (Object) stringBuilder0); + StringBuilder stringBuilder1 = msoHeatEnvironmentEntry0.getRawEntry(); + assertEquals("\nnull", stringBuilder1.toString()); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + LinkedHashSet<MsoHeatEnvironmentParameter> linkedHashSet0 = new LinkedHashSet<MsoHeatEnvironmentParameter>(); + msoHeatEnvironmentEntry0.setParameters(linkedHashSet0); + msoHeatEnvironmentEntry0.getParameters(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(); + msoHeatEnvironmentEntry0.addParameter(msoHeatEnvironmentParameter0); + msoHeatEnvironmentEntry0.getParameters(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + LinkedHashSet<MsoHeatEnvironmentResource> linkedHashSet0 = new LinkedHashSet<MsoHeatEnvironmentResource>(); + msoHeatEnvironmentEntry0.setResources(linkedHashSet0); + msoHeatEnvironmentEntry0.getNumberOfResources(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource(); + msoHeatEnvironmentEntry0.addResource(msoHeatEnvironmentResource0); + msoHeatEnvironmentEntry0.getNumberOfResources(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + Set<MsoHeatEnvironmentResource> set0 = (Set<MsoHeatEnvironmentResource>) mock(Set.class, new ViolatedAssumptionAnswer()); + doReturn(0).when(set0).size(); + msoHeatEnvironmentEntry0.setResources(set0); + msoHeatEnvironmentEntry0.getNumberOfResources(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + LinkedHashSet<MsoHeatEnvironmentParameter> linkedHashSet0 = new LinkedHashSet<MsoHeatEnvironmentParameter>(); + msoHeatEnvironmentEntry0.setParameters(linkedHashSet0); + msoHeatEnvironmentEntry0.getNumberOfParameters(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(); + msoHeatEnvironmentEntry0.addParameter(msoHeatEnvironmentParameter0); + msoHeatEnvironmentEntry0.getNumberOfParameters(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + PrivateAccess.setVariable((Class<MsoHeatEnvironmentEntry>) MsoHeatEnvironmentEntry.class, msoHeatEnvironmentEntry0, "errorString", (Object) "Param="); + msoHeatEnvironmentEntry0.getErrorString(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + Set<HeatTemplateParam> set0 = (Set<HeatTemplateParam>) mock(Set.class, new ViolatedAssumptionAnswer()); + doReturn((-2945)).when(set0).size(); + // Undeclared exception! + try { + msoHeatEnvironmentEntry0.toFullStringExcludeNonParams(set0); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Illegal Capacity: -2945 + // + verifyException("java.util.ArrayList", e); + } + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + LinkedHashSet<MsoHeatEnvironmentParameter> linkedHashSet0 = new LinkedHashSet<MsoHeatEnvironmentParameter>(); + linkedHashSet0.add((MsoHeatEnvironmentParameter) null); + msoHeatEnvironmentEntry0.setParameters(linkedHashSet0); + // Undeclared exception! + try { + msoHeatEnvironmentEntry0.toFullString(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.openstack.utils.MsoHeatEnvironmentEntry", e); + } + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(); + msoHeatEnvironmentEntry0.addParameter(msoHeatEnvironmentParameter0); + // Undeclared exception! + try { + msoHeatEnvironmentEntry0.containsParameter((String) null, ""); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.openstack.utils.MsoHeatEnvironmentParameter", e); + } + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + LinkedHashSet<MsoHeatEnvironmentParameter> linkedHashSet0 = new LinkedHashSet<MsoHeatEnvironmentParameter>(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(); + linkedHashSet0.add(msoHeatEnvironmentParameter0); + msoHeatEnvironmentEntry0.setParameters(linkedHashSet0); + // Undeclared exception! + try { + msoHeatEnvironmentEntry0.containsParameter((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.openstack.utils.MsoHeatEnvironmentParameter", e); + } + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource(); + msoHeatEnvironmentEntry0.addResource(msoHeatEnvironmentResource0); + MsoHeatEnvironmentResource msoHeatEnvironmentResource1 = new MsoHeatEnvironmentResource(); + // Undeclared exception! + try { + msoHeatEnvironmentEntry0.addResource(msoHeatEnvironmentResource1); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.openstack.utils.MsoHeatEnvironmentResource", e); + } + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(); + msoHeatEnvironmentEntry0.addParameter(msoHeatEnvironmentParameter0); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter1 = new MsoHeatEnvironmentParameter(); + // Undeclared exception! + try { + msoHeatEnvironmentEntry0.addParameter(msoHeatEnvironmentParameter1); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.openstack.utils.MsoHeatEnvironmentParameter", e); + } + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter("", ""); + msoHeatEnvironmentEntry0.addParameter(msoHeatEnvironmentParameter0); + boolean boolean0 = msoHeatEnvironmentEntry0.containsParameter(""); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(); + msoHeatEnvironmentEntry0.addParameter(msoHeatEnvironmentParameter0); + boolean boolean0 = msoHeatEnvironmentEntry0.hasParameters(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + msoHeatEnvironmentEntry0.hasParameters(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + LinkedHashSet<MsoHeatEnvironmentParameter> linkedHashSet0 = new LinkedHashSet<MsoHeatEnvironmentParameter>(); + msoHeatEnvironmentEntry0.setParameters(linkedHashSet0); + boolean boolean0 = msoHeatEnvironmentEntry0.hasParameters(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + PrivateAccess.callMethod((Class<MsoHeatEnvironmentEntry>) MsoHeatEnvironmentEntry.class, msoHeatEnvironmentEntry0, "getResourceRegistryRawEntry"); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + LinkedHashSet<HeatTemplateParam> linkedHashSet0 = new LinkedHashSet<HeatTemplateParam>(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(); + msoHeatEnvironmentParameter0.setValue("_BAD"); + HeatTemplateParam heatTemplateParam0 = new HeatTemplateParam(); + linkedHashSet0.add(heatTemplateParam0); + msoHeatEnvironmentEntry0.addParameter(msoHeatEnvironmentParameter0); + msoHeatEnvironmentEntry0.toFullStringExcludeNonParams(linkedHashSet0); + assertTrue(msoHeatEnvironmentEntry0.hasParameters()); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + LinkedHashSet<HeatTemplateParam> linkedHashSet0 = new LinkedHashSet<HeatTemplateParam>(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(); + msoHeatEnvironmentParameter0.setValue("t'N`.KI:L9"); + HeatTemplateParam heatTemplateParam0 = new HeatTemplateParam(); + linkedHashSet0.add(heatTemplateParam0); + msoHeatEnvironmentEntry0.addParameter(msoHeatEnvironmentParameter0); + msoHeatEnvironmentEntry0.toFullStringExcludeNonParams(linkedHashSet0); + assertTrue(msoHeatEnvironmentEntry0.hasParameters()); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + LinkedHashSet<HeatTemplateParam> linkedHashSet0 = new LinkedHashSet<HeatTemplateParam>(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(); + HeatTemplateParam heatTemplateParam0 = new HeatTemplateParam(); + linkedHashSet0.add(heatTemplateParam0); + msoHeatEnvironmentEntry0.addParameter(msoHeatEnvironmentParameter0); + // Undeclared exception! + try { + msoHeatEnvironmentEntry0.toFullStringExcludeNonParams(linkedHashSet0); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + } + } + + @Test(timeout = 4000) + public void test27() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(""); + msoHeatEnvironmentEntry0.addParameter(msoHeatEnvironmentParameter0); + LinkedHashSet<HeatTemplateParam> linkedHashSet0 = new LinkedHashSet<HeatTemplateParam>(); + msoHeatEnvironmentEntry0.toFullStringExcludeNonParams(linkedHashSet0); + assertTrue(msoHeatEnvironmentEntry0.hasParameters()); + } + + @Test(timeout = 4000) + public void test28() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + LinkedHashSet<HeatTemplateParam> linkedHashSet0 = new LinkedHashSet<HeatTemplateParam>(); + HeatTemplateParam heatTemplateParam0 = new HeatTemplateParam(); + linkedHashSet0.add(heatTemplateParam0); + msoHeatEnvironmentEntry0.toFullStringExcludeNonParams(linkedHashSet0); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test29() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + assertFalse(msoHeatEnvironmentEntry0.hasParameters()); + + LinkedHashSet<HeatTemplateParam> linkedHashSet0 = new LinkedHashSet<HeatTemplateParam>(); + StringBuilder stringBuilder0 = msoHeatEnvironmentEntry0.toFullStringExcludeNonParams(linkedHashSet0); + PrivateAccess.setVariable((Class<MsoHeatEnvironmentEntry>) MsoHeatEnvironmentEntry.class, msoHeatEnvironmentEntry0, "rawEntry", (Object) stringBuilder0); + StringBuilder stringBuilder1 = (StringBuilder)PrivateAccess.callMethod((Class<MsoHeatEnvironmentEntry>) MsoHeatEnvironmentEntry.class, msoHeatEnvironmentEntry0, "getResourceRegistryRawEntry"); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + assertNull(stringBuilder1); + } + + @Test(timeout = 4000) + public void test30() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(""); + msoHeatEnvironmentEntry0.addParameter(msoHeatEnvironmentParameter0); + boolean boolean0 = msoHeatEnvironmentEntry0.containsParameter("9MTP2Qt0FH.^", ""); + assertTrue(boolean0); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test31() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + boolean boolean0 = msoHeatEnvironmentEntry0.containsParameter("dP:* hj", "dP:* hj"); + assertFalse(boolean0); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test32() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(""); + msoHeatEnvironmentEntry0.addParameter(msoHeatEnvironmentParameter0); + boolean boolean0 = msoHeatEnvironmentEntry0.containsParameter("", ""); + assertTrue(boolean0); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test33() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + LinkedHashSet<MsoHeatEnvironmentParameter> linkedHashSet0 = new LinkedHashSet<MsoHeatEnvironmentParameter>(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = mock(MsoHeatEnvironmentParameter.class, new ViolatedAssumptionAnswer()); + linkedHashSet0.add(msoHeatEnvironmentParameter0); + msoHeatEnvironmentEntry0.setParameters(linkedHashSet0); + boolean boolean0 = msoHeatEnvironmentEntry0.containsParameter("kz`LZx"); + assertTrue(msoHeatEnvironmentEntry0.hasParameters()); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test34() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + LinkedHashSet<MsoHeatEnvironmentParameter> linkedHashSet0 = new LinkedHashSet<MsoHeatEnvironmentParameter>(); + msoHeatEnvironmentEntry0.setParameters(linkedHashSet0); + boolean boolean0 = msoHeatEnvironmentEntry0.containsParameter("kz`LZx"); + assertFalse(boolean0); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test35() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + boolean boolean0 = msoHeatEnvironmentEntry0.containsParameter(",=?%4z"); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test36() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + LinkedHashSet<MsoHeatEnvironmentParameter> linkedHashSet0 = new LinkedHashSet<MsoHeatEnvironmentParameter>(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = mock(MsoHeatEnvironmentParameter.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(msoHeatEnvironmentParameter0).getName(); + doReturn((String) null).when(msoHeatEnvironmentParameter0).getValue(); + linkedHashSet0.add(msoHeatEnvironmentParameter0); + msoHeatEnvironmentEntry0.setParameters(linkedHashSet0); + msoHeatEnvironmentEntry0.toFullString(); + assertTrue(msoHeatEnvironmentEntry0.hasParameters()); + } + + @Test(timeout = 4000) + public void test37() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource(""); + msoHeatEnvironmentEntry0.addResource(msoHeatEnvironmentResource0); + boolean boolean0 = msoHeatEnvironmentEntry0.hasResources(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test38() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + Set<MsoHeatEnvironmentResource> set0 = (Set<MsoHeatEnvironmentResource>) mock(Set.class, new ViolatedAssumptionAnswer()); + doReturn(0).when(set0).size(); + msoHeatEnvironmentEntry0.setResources(set0); + boolean boolean0 = msoHeatEnvironmentEntry0.hasResources(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test39() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + boolean boolean0 = msoHeatEnvironmentEntry0.hasResources(); + assertFalse(boolean0); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test40() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + msoHeatEnvironmentEntry0.setResources((Set<MsoHeatEnvironmentResource>) null); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test41() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + msoHeatEnvironmentEntry0.setParameters((Set<MsoHeatEnvironmentParameter>) null); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + + @Test(timeout = 4000) + public void test43() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + // Undeclared exception! + try { + msoHeatEnvironmentEntry0.getNumberOfResources(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.openstack.utils.MsoHeatEnvironmentEntry", e); + } + } + + @Test(timeout = 4000) + public void test44() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + boolean boolean0 = msoHeatEnvironmentEntry0.isValid(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test45() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry((StringBuilder) null); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test46() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + // Undeclared exception! + try { + msoHeatEnvironmentEntry0.getNumberOfParameters(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.openstack.utils.MsoHeatEnvironmentEntry", e); + } + } + + @Test(timeout = 4000) + public void test47() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + msoHeatEnvironmentEntry0.getRawEntry(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test48() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + msoHeatEnvironmentEntry0.getParameters(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test49() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + msoHeatEnvironmentEntry0.getResources(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } + + @Test(timeout = 4000) + public void test50() throws Throwable { + MsoHeatEnvironmentEntry msoHeatEnvironmentEntry0 = new MsoHeatEnvironmentEntry(); + msoHeatEnvironmentEntry0.getErrorString(); + assertTrue(msoHeatEnvironmentEntry0.isValid()); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentParameterESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentParameterESTest.java new file mode 100644 index 0000000000..6ec389b809 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentParameterESTest.java @@ -0,0 +1,129 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:45:40 GMT 2016 + */ + +package org.openecomp.mso.openstack.utils; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoHeatEnvironmentParameterESTest extends MsoHeatEnvironmentParameterESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(); + msoHeatEnvironmentParameter0.hashCode(); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(""); + boolean boolean0 = msoHeatEnvironmentParameter0.equals(msoHeatEnvironmentParameter0); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(""); + msoHeatEnvironmentParameter0.setValue(""); + String string0 = msoHeatEnvironmentParameter0.getValue(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(); + String string0 = msoHeatEnvironmentParameter0.getName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter("<*+ogA@v;MO4'8{1"); + String string0 = msoHeatEnvironmentParameter0.getName(); + assertEquals("<*+ogA@v;MO4'8{1", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(""); + String string0 = msoHeatEnvironmentParameter0.getName(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter("", "-3Y=_MqzpVL7|^$8"); + String string0 = msoHeatEnvironmentParameter0.getValue(); + assertEquals("-3Y=_MqzpVL7|^$8", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(""); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter1 = new MsoHeatEnvironmentParameter("{Ox?zu\"*"); + boolean boolean0 = msoHeatEnvironmentParameter1.equals(msoHeatEnvironmentParameter0); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter("?.@!au:}y7xGSg|}8"); + boolean boolean0 = msoHeatEnvironmentParameter0.equals("?.@!au:}y7xGSg|}8"); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(""); + msoHeatEnvironmentParameter0.setName(""); + assertEquals("", msoHeatEnvironmentParameter0.getName()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(""); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter1 = new MsoHeatEnvironmentParameter(""); + boolean boolean0 = msoHeatEnvironmentParameter0.equals(msoHeatEnvironmentParameter1); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(""); + String string0 = msoHeatEnvironmentParameter0.getValue(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(""); + msoHeatEnvironmentParameter0.hashCode(); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(); + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter1 = new MsoHeatEnvironmentParameter(); + // Undeclared exception! + try { + msoHeatEnvironmentParameter0.equals(msoHeatEnvironmentParameter1); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + } + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + MsoHeatEnvironmentParameter msoHeatEnvironmentParameter0 = new MsoHeatEnvironmentParameter(""); + String string0 = msoHeatEnvironmentParameter0.toString(); + assertEquals(": null", string0); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentParameterESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentParameterESTestscaffolding.java new file mode 100644 index 0000000000..f7e33bb8ce --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentParameterESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:45:40 GMT 2016 + */ + +package org.openecomp.mso.openstack.utils; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoHeatEnvironmentParameterESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.utils.MsoHeatEnvironmentParameter"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoHeatEnvironmentParameterESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.utils.MsoHeatEnvironmentParameter" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResourceESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResourceESTest.java new file mode 100644 index 0000000000..d3e7d29717 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResourceESTest.java @@ -0,0 +1,129 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 08:45:54 GMT 2016 + */ + +package org.openecomp.mso.openstack.utils; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoHeatEnvironmentResourceESTest extends MsoHeatEnvironmentResourceESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource("", ""); + msoHeatEnvironmentResource0.hashCode(); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource("8{,8]8v", "8{,8]8v"); + String string0 = msoHeatEnvironmentResource0.getValue(); + assertEquals("8{,8]8v", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource("", ""); + String string0 = msoHeatEnvironmentResource0.getValue(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource("\"(_{*)._$D2+w8wk"); + String string0 = msoHeatEnvironmentResource0.getName(); + assertEquals("\"(_{*)._$D2+w8wk", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource(); + MsoHeatEnvironmentResource msoHeatEnvironmentResource1 = new MsoHeatEnvironmentResource(); + // Undeclared exception! + try { + msoHeatEnvironmentResource0.equals(msoHeatEnvironmentResource1); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + } + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource("", ""); + MsoHeatEnvironmentResource msoHeatEnvironmentResource1 = new MsoHeatEnvironmentResource("", ""); + boolean boolean0 = msoHeatEnvironmentResource0.equals(msoHeatEnvironmentResource1); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource("m"); + MsoHeatEnvironmentResource msoHeatEnvironmentResource1 = new MsoHeatEnvironmentResource("l", "l"); + boolean boolean0 = msoHeatEnvironmentResource0.equals(msoHeatEnvironmentResource1); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource(); + boolean boolean0 = msoHeatEnvironmentResource0.equals("1Z^#74OJV(OBf<=#r"); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource(); + boolean boolean0 = msoHeatEnvironmentResource0.equals(msoHeatEnvironmentResource0); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource(); + String string0 = msoHeatEnvironmentResource0.getName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource(); + msoHeatEnvironmentResource0.setName(""); + String string0 = msoHeatEnvironmentResource0.getName(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource(""); + String string0 = msoHeatEnvironmentResource0.getValue(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource(); + msoHeatEnvironmentResource0.hashCode(); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource(); + String string0 = msoHeatEnvironmentResource0.toString(); + assertEquals("\"null\": null", string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + MsoHeatEnvironmentResource msoHeatEnvironmentResource0 = new MsoHeatEnvironmentResource(); + msoHeatEnvironmentResource0.setValue(""); + assertNull(msoHeatEnvironmentResource0.getName()); + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResourceESTestscaffolding.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResourceESTestscaffolding.java new file mode 100644 index 0000000000..3917b8904c --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResourceESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 08:45:54 GMT 2016 + */ + +package org.openecomp.mso.openstack.utils; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoHeatEnvironmentResourceESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.openstack.utils.MsoHeatEnvironmentResource"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoHeatEnvironmentResourceESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.utils.MsoHeatEnvironmentResource" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-adapter-utils/src/test/resources/cloud_config.json b/adapters/mso-adapter-utils/src/test/resources/cloud_config.json new file mode 100644 index 0000000000..0230a7d4bf --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/resources/cloud_config.json @@ -0,0 +1,80 @@ +{ "cloud_config": { + "identity_services": + { + "MT_KEYSTONE": + { + "identity_url": "http://localhost:5000/v2.0", + "mso_id": "john", + "mso_pass": "FD205490A48D48475607C36B9AD902BF", + "admin_tenant": "admin", + "member_role": "_member_", + "tenant_metadata": false, + "identity_server_type": "KEYSTONE", + "identity_authentication_type": "RACKSPACE_APIKEY" + }, + "DAN_KEYSTONE": + { + "identity_url": "http://localhost:5000/v2.0", + "mso_id": "mockId", + "mso_pass": "BC59F80E38208A42ABB81ECCDD4FB3E4", + "admin_tenant": "service", + "member_role": "_member_", + "tenant_metadata": false, + "identity_server_type": "KEYSTONE", + "identity_authentication_type": "USERNAME_PASSWORD" + }, + "MTINJVCC101_DCP": + { + "identity_url": "http://localhost:5000/v2.0", + "mso_id": "mockIdToo", + "mso_pass": "95604B9EAAC4D77D74786FAE54177206", + "admin_tenant": "service", + "member_role": "admin", + "tenant_metadata": true, + "identity_server_type": "KEYSTONE", + "identity_authentication_type": "USERNAME_PASSWORD" + }, + "MTSNJA3DCP1": + { + "identity_url": "https://localhost:5000/v2.0", + "mso_id": "mockIdToo", + "mso_pass": "1491DE07AC9D716A7966BB8C2848F031", + "admin_tenant": "service", + "member_role": "admin", + "tenant_metadata": true, + "identity_server_type": "KEYSTONE", + "identity_authentication_type": "USERNAME_PASSWORD" + } + + }, + "cloud_sites": + { + "MT": + { + "region_id": "regionOne", + "clli": "MT", + "aic_version": "2.5", + "identity_service_id": "MT_KEYSTONE" + }, + "DAN": + { + "region_id": "RegionOne", + "clli": "DAN", + "aic_version": "2.5", + "identity_service_id": "DAN_KEYSTONE" + }, + "MTINJVCC101": + { + "region_id": "regionTwo", + "clli": "MTINJVCC101", + "aic_version": "2.5", + "identity_service_id": "MTINJVCC101_DCP" + } + + } +} +} + + + + diff --git a/adapters/mso-adapter-utils/src/test/resources/logback-test.xml b/adapters/mso-adapter-utils/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..d2c17192ea --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/resources/logback-test.xml @@ -0,0 +1,48 @@ +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + 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. + ============LICENSE_END========================================================= + --> + +<configuration > + + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern> + </encoder> + </appender> + + + <logger name="com.att.eelf.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="trace" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <root level="info"> + <appender-ref ref="STDOUT" /> + </root> + + +</configuration> diff --git a/adapters/mso-adapter-utils/src/test/resources/mso.properties b/adapters/mso-adapter-utils/src/test/resources/mso.properties new file mode 100644 index 0000000000..d58521f1db --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/resources/mso.properties @@ -0,0 +1,27 @@ +### +# ============LICENSE_START======================================================= +# ECOMP MSO +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# 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. +# ============LICENSE_END========================================================= +### + +ecomp.mso.cloud.1.cloudId=MT +ecomp.mso.cloud.1.keystoneUrl=http://localhost:5000/v2.0 +ecomp.mso.cloud.1.msoId=John +ecomp.mso.cloud.1.publicNetId=FD205490A48D48475607C36B9AD902BF +ecomp.mso.cloud.1.test=1234 +ecomp.mso.cloud.1.boolean=true +ecomp.mso.cloud.1.enum=enum1 diff --git a/adapters/mso-adapter-utils/src/test/resources/mso2.properties b/adapters/mso-adapter-utils/src/test/resources/mso2.properties new file mode 100644 index 0000000000..a47ce77146 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/resources/mso2.properties @@ -0,0 +1,21 @@ +### +# ============LICENSE_START======================================================= +# ECOMP MSO +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# 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. +# ============LICENSE_END========================================================= +### + +ecomp.mso.cloud.1.cloudId=MT2 diff --git a/adapters/mso-adapters-rest-interface/pom.xml b/adapters/mso-adapters-rest-interface/pom.xml new file mode 100644 index 0000000000..f48514123f --- /dev/null +++ b/adapters/mso-adapters-rest-interface/pom.xml @@ -0,0 +1,52 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp.mso</groupId> + <artifactId>adapters</artifactId> + <version>0.0.4-SNAPSHOT</version> + </parent> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapters-rest-interface</artifactId> + <packaging>jar</packaging> + <name>mso-adapters-rest-interface</name> + <description> + Java Beans (Requests and Responses) for Network/Tenant/VNF REST Operations + </description> + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <version>2.6</version> + <configuration> + <classesDirectory>target/classes</classesDirectory> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>org.jboss.resteasy</groupId> + <artifactId>resteasy-jaxrs</artifactId> + <version>3.0.19.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.resteasy</groupId> + <artifactId>resteasy-jackson-provider</artifactId> + <version>3.0.19.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.resteasy</groupId> + <artifactId>resteasy-jettison-provider</artifactId> + <version>3.0.19.Final</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project> diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/ContrailNetwork.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/ContrailNetwork.java new file mode 100644 index 0000000000..af44ce42b6 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/ContrailNetwork.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + +import java.util.List; + +public class ContrailNetwork { + private String shared = "false"; + private String external = "false"; + private List<String> routeTargets; + private List<String> policyFqdns; + private List<String> routeTableFqdns; + + public ContrailNetwork() { + super(); + } + + public ContrailNetwork(String shared, String external, List<String> routeTargets, List<String> policyFqdns, List<String> routeTableFqdns) { + super(); + this.shared = shared; + this.external = external; + this.routeTargets = routeTargets; + this.policyFqdns = policyFqdns; + this.routeTableFqdns = routeTableFqdns; + } + + public String getShared() { + return shared; + } + + public void setShared(String shared) { + this.shared = shared; + } + + public String getExternal() { + return external; + } + + public void setExternal(String external) { + this.external = external; + } + + public List<String> getRouteTargets() { + return routeTargets; + } + + public void setRouteTargets(List<String> routeTargets) { + this.routeTargets = routeTargets; + } + + public List<String> getPolicyFqdns() { + return policyFqdns; + } + + public void setPolicyFqdns(List<String> policyFqdns) { + this.policyFqdns = policyFqdns; + } + + public List<String> getRouteTableFqdns() { + return routeTableFqdns; + } + + public void setRouteTableFqdns(List<String> routeTableFqdns) { + this.routeTableFqdns = routeTableFqdns; + } + +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/CreateNetworkError.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/CreateNetworkError.java new file mode 100644 index 0000000000..e756261afb --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/CreateNetworkError.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jboss.resteasy.annotations.providers.NoJackson; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +@XmlRootElement(name = "createNetworkError") +@NoJackson +public class CreateNetworkError extends NetworkExceptionResponse implements Serializable { + private static final long serialVersionUID = -4283402447149144456L; + + public CreateNetworkError() { + super(""); + } + + public CreateNetworkError(String message) { + super(message); + } + + public CreateNetworkError(String message, MsoExceptionCategory category, boolean rolledBack, String messageid) { + super(message, category, rolledBack, messageid); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/CreateNetworkRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/CreateNetworkRequest.java new file mode 100644 index 0000000000..b8c70dd193 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/CreateNetworkRequest.java @@ -0,0 +1,191 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + + +import org.openecomp.mso.openstack.beans.Subnet; +import org.openecomp.mso.entity.MsoRequest; + +import java.util.List; +import java.util.Map; +import java.util.HashMap; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jboss.resteasy.annotations.providers.NoJackson; + +import org.codehaus.jackson.map.annotate.JsonRootName; + +/* README +* 1) Used JAXB/Jettison - see @NoJackson annotation on class to get RootElements REad by RestEasy +* 2) due to 1) Maps need to use this format + +"networkParams": {"entry": [ + {"key": "network_id", + "value": "59ed7b41-2983-413f-ba93-e7d437433916"}, + {"key": "subnet_id", + "value": "086c9298-5c57-49b7-bb2b-6fd5730c5d92"}, + {"key": "server_name_0", + "value": "RaaNetwork1"} + ]}, + * 3) to output json see toJSonString method below which required the @JsonRootName annotation and the WRAP_ROOT feature enabled + * 4) Tryong to work with RESTEASY JACKSON and JAXB/JETTISON to conform to Json input/output specs +*/ +@JsonRootName("createNetworkRequest") +@XmlRootElement(name = "createNetworkRequest") +@NoJackson +public class CreateNetworkRequest extends NetworkRequestCommon { + private String cloudSiteId; + private String tenantId; + private String networkId; + private String networkName; + private String networkType; + private String networkTypeVersion; + private NetworkTechnology networkTechnology = NetworkTechnology.NEUTRON; + private List<Subnet> subnets; + private ProviderVlanNetwork providerVlanNetwork; + private ContrailNetwork contrailNetwork; + private Boolean failIfExists = false; + private Boolean backout = true; + private Map<String,String> networkParams = new HashMap<String, String>(); + private MsoRequest msoRequest = new MsoRequest(); + + public CreateNetworkRequest() { + super(); + } + + public String getCloudSiteId() { + return cloudSiteId; + } + + public void setCloudSiteId(String cloudSiteId) { + this.cloudSiteId = cloudSiteId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + public String getNetworkName() { + return networkName; + } + + public void setNetworkName(String networkName) { + this.networkName = networkName; + } + + public String getNetworkType() { + return networkType; + } + + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + + public String getNetworkTypeVersion() { + return networkTypeVersion; + } + + public void setNetworkTypeVersion(String networkTypeVersion) { + this.networkTypeVersion = networkTypeVersion; + } + + public String getNetworkTechnology() { + return networkTechnology.toString(); + } + + public void setNetworkTechnology(String networkTechnology) { + this.networkTechnology = NetworkTechnology.valueOf(networkTechnology); + } + + public List<Subnet> getSubnets() { + return subnets; + } + + public void setSubnets(List<Subnet> subnets) { + this.subnets = subnets; + } + + public ProviderVlanNetwork getProviderVlanNetwork() { + return providerVlanNetwork; + } + + public void setProviderVlanNetwork(ProviderVlanNetwork providerVlanNetwork) { + this.providerVlanNetwork = providerVlanNetwork; + } + + public ContrailNetwork getContrailNetwork() { + return contrailNetwork; + } + + public void setContrailNetwork(ContrailNetwork contrailNetwork) { + this.contrailNetwork = contrailNetwork; + } + + public Boolean getFailIfExists() { + return failIfExists; + } + + public void setFailIfExists(Boolean failIfExists) { + this.failIfExists = failIfExists; + } + + public Boolean getBackout() { + return backout; + } + + public void setBackout(Boolean backout) { + this.backout = backout; + } + + public Map<String, String> getNetworkParams() { + return networkParams; + } + + public void setNetworkParams(Map<String, String> networkParams) { + this.networkParams = networkParams; + } + + public MsoRequest getMsoRequest() { + return msoRequest; + } + + public void setMsoRequest(MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } + + public boolean isContrailRequest() { + return (networkTechnology == NetworkTechnology.CONTRAIL) && (contrailNetwork != null); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/CreateNetworkResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/CreateNetworkResponse.java new file mode 100644 index 0000000000..f47272f5db --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/CreateNetworkResponse.java @@ -0,0 +1,122 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + + +import org.openecomp.mso.openstack.beans.NetworkRollback; +import java.util.Map; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("createNetworkResponse") +@XmlRootElement(name = "createNetworkResponse") +@NoJackson +public class CreateNetworkResponse extends NetworkResponseCommon { + private String networkId; + private String neutronNetworkId; + private String networkStackId; + private String networkFqdn; + private Boolean networkCreated; + private Map<String, String> subnetMap; + private NetworkRollback rollback = new NetworkRollback(); + + public CreateNetworkResponse() { + super(); + } + + public CreateNetworkResponse(String networkId, + String neutronNetworkId, + String networkStackId, + String networkFqdn, + Boolean networkCreated, + Map<String, String> subnetIdMap, + NetworkRollback rollback, + String messageId) { + super(messageId); + this.networkId = networkId; + this.neutronNetworkId = neutronNetworkId; + this.networkStackId = networkStackId; + this.networkFqdn = networkFqdn; + this.networkCreated = networkCreated; + this.subnetMap = subnetIdMap; + this.rollback = rollback; + } + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + public String getNeutronNetworkId() { + return neutronNetworkId; + } + + public void setNeutronNetworkId(String neutronNetworkId) { + this.neutronNetworkId = neutronNetworkId; + } + + public String getNetworkStackId() { + return networkStackId; + } + + public void setNetworkStackId(String networkStackId) { + this.networkStackId = networkStackId; + } + + public String getNetworkFqdn() { + return networkFqdn; + } + + public void setNetworkFqdn(String networkFqdn) { + this.networkFqdn = networkFqdn; + } + + public Boolean getNetworkCreated() { + return networkCreated; + } + + public void setNetworkCreated(Boolean networkCreated) { + this.networkCreated = networkCreated; + } + + public Map<String, String> getSubnetMap() { + return subnetMap; + } + + public void setSubnetMap(Map<String, String> subnetMap) { + this.subnetMap = subnetMap; + } + + public NetworkRollback getRollback() { + return rollback; + } + + public void setRollback(NetworkRollback rollback) { + this.rollback = rollback; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkError.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkError.java new file mode 100644 index 0000000000..22af7fe21b --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkError.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jboss.resteasy.annotations.providers.NoJackson; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +@XmlRootElement(name = "deleteNetworkError") +@NoJackson +public class DeleteNetworkError extends NetworkExceptionResponse implements Serializable { + private static final long serialVersionUID = 2735474165790444180L; + + public DeleteNetworkError() { + super(""); + } + + public DeleteNetworkError(String message) { + super(message); + } + + public DeleteNetworkError(String message, MsoExceptionCategory category, boolean unused, String messageid) { + super(message, category, unused, messageid); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkRequest.java new file mode 100644 index 0000000000..62c308d142 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkRequest.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + + +import org.openecomp.mso.entity.MsoRequest; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("deleteNetworkRequest") +@XmlRootElement(name = "deleteNetworkRequest") +@NoJackson +public class DeleteNetworkRequest extends NetworkRequestCommon { + + private String cloudSiteId; + private String tenantId; + private String networkId; + private String networkStackId; + private String networkType; + private MsoRequest msoRequest = new MsoRequest(); + + public DeleteNetworkRequest() {} + + public String getCloudSiteId() { + return cloudSiteId; + } + + public void setCloudSiteId(String cloudSiteId) { + this.cloudSiteId = cloudSiteId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + public String getNetworkStackId() { + return networkStackId; + } + + public void setNetworkStackId(String networkStackId) { + this.networkStackId = networkStackId; + } + + public String getNetworkType() { + return networkType; + } + + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + + public MsoRequest getMsoRequest() { + return msoRequest; + } + + public void setMsoRequest(MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkResponse.java new file mode 100644 index 0000000000..d6d295a53a --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkResponse.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + + +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("deleteNetworkResponse") +@XmlRootElement(name = "deleteNetworkResponse") +@NoJackson +public class DeleteNetworkResponse extends NetworkResponseCommon { + + private String networkId; + private Boolean networkDeleted; + + public DeleteNetworkResponse() { + super(); + } + + public DeleteNetworkResponse(String networkId, Boolean networkDeleted, String messageId) { + super(messageId); + this.networkId = networkId; + this.networkDeleted = networkDeleted; + } + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + public Boolean getNetworkDeleted() { + return networkDeleted; + } + + public void setNetworkDeleted(Boolean networkDeleted) { + this.networkDeleted = networkDeleted; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkExceptionResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkExceptionResponse.java new file mode 100644 index 0000000000..de37c3d8fd --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkExceptionResponse.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +public class NetworkExceptionResponse extends NetworkResponseCommon { + private String message; + private MsoExceptionCategory category; + private Boolean rolledBack; + + public NetworkExceptionResponse () {} + + public NetworkExceptionResponse (String message) { + super(); + this.message = message; + } + + public NetworkExceptionResponse (String message, MsoExceptionCategory category, boolean rolledBack, String messageid) { + super(messageid); + this.message = message; + this.category = category; + this.rolledBack = rolledBack; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public MsoExceptionCategory getCategory () { + return category; + } + + public void setCategory (MsoExceptionCategory category) { + this.category = category; + } + + public Boolean getRolledBack() { + return rolledBack; + } + + public void setRolledBack(Boolean rolledBack) { + this.rolledBack = rolledBack; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkRequestCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkRequestCommon.java new file mode 100644 index 0000000000..d04e960b00 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkRequestCommon.java @@ -0,0 +1,95 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + + +import java.io.ByteArrayOutputStream; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; + +/** + * Everything that is common between all Network Requests. + */ +public abstract class NetworkRequestCommon { + private Boolean skipAAI = false; + private String messageId; + private String notificationUrl; + + public Boolean getSkipAAI() { + return skipAAI; + } + + public void setSkipAAI(Boolean skipAAI) { + this.skipAAI = skipAAI; + } + + public String getMessageId() { + return messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getNotificationUrl() { + return notificationUrl; + } + + public void setNotificationUrl(String notificationUrl) { + this.notificationUrl = notificationUrl; + } + + public boolean isSynchronous() { + return notificationUrl == null || (notificationUrl != null && notificationUrl.isEmpty()); + } + + public String toJsonString() { + String jsonString = null; + try { + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + jsonString = mapper.writeValueAsString(this); + } catch (Exception e) { + // ignore + } + return jsonString; + } + + public String toXmlString() { + try { + ByteArrayOutputStream bs = new ByteArrayOutputStream(); + JAXBContext context = JAXBContext.newInstance(this.getClass()); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //pretty print XML + marshaller.marshal(this, bs); + return bs.toString(); + } catch (Exception e) { + // Shouldn't happen... + e.printStackTrace(); + return ""; + } + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkResponseCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkResponseCommon.java new file mode 100644 index 0000000000..e7cc9b9ceb --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkResponseCommon.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + + +import java.io.ByteArrayOutputStream; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; + +/** + * Everything that is common between all Volume Group Responses, except for QueryVolumeGroupResponse. + */ +public abstract class NetworkResponseCommon { + private String messageId; + + public NetworkResponseCommon() { + messageId = null; + } + + public NetworkResponseCommon(String messageId) { + this.messageId = messageId; + } + + public String getMessageId() { + return messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String toJsonString() { + String jsonString = null; + try { + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + jsonString = mapper.writeValueAsString(this); + } catch (Exception e) { + // ignore + } + return jsonString; + } + + public String toXmlString() { + try { + ByteArrayOutputStream bs = new ByteArrayOutputStream(); + JAXBContext context = JAXBContext.newInstance(this.getClass()); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //pretty print XML + marshaller.marshal(this, bs); + return bs.toString(); + } catch (Exception e) { + // Shouldn't happen... + e.printStackTrace(); + return ""; + } + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkTechnology.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkTechnology.java new file mode 100644 index 0000000000..62a821d658 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkTechnology.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + +public enum NetworkTechnology { + NEUTRON, VMWARE, CONTRAIL +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/ProviderVlanNetwork.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/ProviderVlanNetwork.java new file mode 100644 index 0000000000..3956d3e785 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/ProviderVlanNetwork.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + + +import java.util.List; + +public class ProviderVlanNetwork { + private String physicalNetworkName; + private List<Integer> vlans; + + public ProviderVlanNetwork() { + super(); + } + + public ProviderVlanNetwork(String physicalNetworkName, List<Integer> vlans) { + super(); + this.physicalNetworkName = physicalNetworkName; + this.vlans = vlans; + } + + public String getPhysicalNetworkName() { + return physicalNetworkName; + } + + public void setPhysicalNetworkName(String physicalNetworkName) { + this.physicalNetworkName = physicalNetworkName; + } + + public List<Integer> getVlans() { + return vlans; + } + + public void setVlans(List<Integer> vlans) { + this.vlans = vlans; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkError.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkError.java new file mode 100644 index 0000000000..2b602f6882 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkError.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jboss.resteasy.annotations.providers.NoJackson; + +@XmlRootElement(name = "queryNetworkError") +@NoJackson +public class QueryNetworkError extends NetworkExceptionResponse implements Serializable { + private static final long serialVersionUID = -6125469596399867146L; +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponse.java new file mode 100644 index 0000000000..e79b463f93 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponse.java @@ -0,0 +1,144 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + + +import org.openecomp.mso.openstack.beans.NetworkStatus; + +import java.util.List; +import java.util.Map; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.ObjectMapper; +import org.jboss.resteasy.annotations.providers.NoJackson; + +@XmlRootElement(name = "queryNetworkResponse") +@NoJackson +public class QueryNetworkResponse { + private String networkId; + private String neutronNetworkId; + private String networkStackId; + private Boolean networkExists; + private NetworkStatus networkStatus; + private List<Integer> vlans; + private List<String> routeTargets; + private Map<String, String> subnetIdMap; + private Map<String, String> networkOutputs; + + public QueryNetworkResponse() { + super(); + } + + public QueryNetworkResponse(String networkId, String neutronNetworkId, + String networkStackId, NetworkStatus networkStatus, + Map<String, String> networkOutputs) { + super(); + this.networkId = networkId; + this.neutronNetworkId = neutronNetworkId; + this.networkStackId = networkStackId; + this.networkStatus = networkStatus; + this.networkOutputs = networkOutputs; + } + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + public String getNeutronNetworkId() { + return neutronNetworkId; + } + + public void setNeutronNetworkId(String neutronNetworkId) { + this.neutronNetworkId = neutronNetworkId; + } + + public String getNetworkStackId() { + return networkStackId; + } + + public void setNetworkStackId(String networkStackId) { + this.networkStackId = networkStackId; + } + + public NetworkStatus getNetworkStatus() { + return networkStatus; + } + + public void setNetworkStatus(NetworkStatus networkStatus) { + this.networkStatus = networkStatus; + } + + public Boolean getNetworkExists() { + return networkExists; + } + + public void setNetworkExists(Boolean networkExists) { + this.networkExists = networkExists; + } + + public List<Integer> getVlans() { + return vlans; + } + + public void setVlans(List<Integer> vlans) { + this.vlans = vlans; + } + + public List<String> getRouteTargets() { + return routeTargets; + } + + public void setRouteTargets(List<String> routeTargets) { + this.routeTargets = routeTargets; + } + + public Map<String, String> getSubnetIdMap() { + return subnetIdMap; + } + + public void setSubnetIdMap(Map<String, String> subnetIdMap) { + this.subnetIdMap = subnetIdMap; + } + + public Map<String, String> getNetworkOutputs() { + return networkOutputs; + } + + public void setNetworkOutputs(Map<String, String> networkOutputs) { + this.networkOutputs = networkOutputs; + } + + public String toJsonString() { + String jsonString = null; + try { + ObjectMapper mapper = new ObjectMapper(); + jsonString = mapper.writeValueAsString(this); + } + catch (Exception e) {} + return jsonString; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkError.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkError.java new file mode 100644 index 0000000000..9e6a328998 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkError.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jboss.resteasy.annotations.providers.NoJackson; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +@XmlRootElement(name = "rollbackNetworkError") +@NoJackson +public class RollbackNetworkError extends NetworkExceptionResponse implements Serializable { + private static final long serialVersionUID = -3954464103037391980L; + + public RollbackNetworkError() { + super(""); + } + + public RollbackNetworkError(String message) { + super(message); + } + + public RollbackNetworkError(String message, MsoExceptionCategory category, boolean unused, String messageid) { + super(message, category, unused, messageid); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkRequest.java new file mode 100644 index 0000000000..37751149b9 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkRequest.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + + +import org.openecomp.mso.openstack.beans.NetworkRollback; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("rollbackNetworkRequest") +@XmlRootElement(name = "rollbackNetworkRequest") +@NoJackson +public class RollbackNetworkRequest extends NetworkRequestCommon { + private NetworkRollback networkRollback; + + public RollbackNetworkRequest() { + super(); + } + + public NetworkRollback getNetworkRollback() { + return networkRollback; + } + + public void setNetworkRollback(NetworkRollback networkRollback) { + this.networkRollback = networkRollback; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkResponse.java new file mode 100644 index 0000000000..a7b3c16efa --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkResponse.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("rollbackNetworkResponse") +@XmlRootElement(name = "rollbackNetworkResponse") +@NoJackson +public class RollbackNetworkResponse extends NetworkResponseCommon { + + private Boolean networkRolledBack; + + public RollbackNetworkResponse() { + super(); + } + + public RollbackNetworkResponse(Boolean networkRolledBack, String messageId) { + super(messageId); + this.networkRolledBack = networkRolledBack; + } + + public Boolean getNetworkRolledBack() { + return networkRolledBack; + } + + public void setNetworkRolledBack(Boolean networkRolledBack) { + this.networkRolledBack = networkRolledBack; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkError.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkError.java new file mode 100644 index 0000000000..f7066daa83 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkError.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jboss.resteasy.annotations.providers.NoJackson; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +@XmlRootElement(name = "updateNetworkError") +@NoJackson +public class UpdateNetworkError extends NetworkExceptionResponse implements Serializable { + private static final long serialVersionUID = 46820809807914392L; + + public UpdateNetworkError() { + super(""); + } + + public UpdateNetworkError(String message) { + super(message); + } + + public UpdateNetworkError(String message, MsoExceptionCategory category, boolean unused, String messageid) { + super(message, category, unused, messageid); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java new file mode 100644 index 0000000000..5ddc050131 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java @@ -0,0 +1,178 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + + +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.Subnet; + +import java.util.Map; +import java.util.HashMap; +import java.util.List; + +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("updateNetworkRequest") +@XmlRootElement(name = "updateNetworkRequest") +@NoJackson +public class UpdateNetworkRequest extends NetworkRequestCommon { + private String cloudSiteId; + private String tenantId; + private String networkId; + private String networkStackId; + private String networkName; + private String networkType; + private String networkTypeVersion; + private NetworkTechnology networkTechnology = NetworkTechnology.NEUTRON; + private List<Subnet> subnets; + private ProviderVlanNetwork providerVlanNetwork; + private ContrailNetwork contrailNetwork; + private Boolean backout = true; + private Map<String,String> networkParams = new HashMap<String, String>(); + private MsoRequest msoRequest = new MsoRequest(); + + public UpdateNetworkRequest() { + super(); + } + + public String getCloudSiteId() { + return cloudSiteId; + } + + public void setCloudSiteId(String cloudSiteId) { + this.cloudSiteId = cloudSiteId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + public String getNetworkStackId() { + return networkStackId; + } + + public void setNetworkStackId(String networkStackId) { + this.networkStackId = networkStackId; + } + + public String getNetworkName() { + return networkName; + } + + public void setNetworkName(String networkName) { + this.networkName = networkName; + } + + public String getNetworkType() { + return networkType; + } + + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + + public String getNetworkTypeVersion() { + return networkTypeVersion; + } + + public void setNetworkTypeVersion(String networkTypeVersion) { + this.networkTypeVersion = networkTypeVersion; + } + + public String getNetworkTechnology() { + return networkTechnology.toString(); + } + + public void setNetworkTechnology(String networkTechnology) { + try { + this.networkTechnology = NetworkTechnology.valueOf(networkTechnology.toUpperCase()); + } catch (IllegalArgumentException e) { + // ignore + } + } + + public List<Subnet> getSubnets() { + return subnets; + } + + public void setSubnets(List<Subnet> subnets) { + this.subnets = subnets; + } + + public ProviderVlanNetwork getProviderVlanNetwork() { + return providerVlanNetwork; + } + + public void setProviderVlanNetwork(ProviderVlanNetwork providerVlanNetwork) { + this.providerVlanNetwork = providerVlanNetwork; + } + + public ContrailNetwork getContrailNetwork() { + return contrailNetwork; + } + + public void setContrailNetwork(ContrailNetwork contrailNetwork) { + this.contrailNetwork = contrailNetwork; + } + + public Boolean getBackout() { + return backout; + } + + public void setBackout(Boolean backout) { + this.backout = backout; + } + + public Map<String, String> getNetworkParams() { + return networkParams; + } + + public void setNetworkParams(Map<String, String> networkParams) { + this.networkParams = networkParams; + } + + public MsoRequest getMsoRequest() { + return msoRequest; + } + + public void setMsoRequest(MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } + + public boolean isContrailRequest() { + return (networkTechnology == NetworkTechnology.CONTRAIL) && (contrailNetwork != null); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkResponse.java new file mode 100644 index 0000000000..d1531bf1ff --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkResponse.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.nwrest; + + + +import java.util.Map; +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("updateNetworkResponse") +@XmlRootElement(name = "updateNetworkResponse") +@NoJackson +public class UpdateNetworkResponse extends NetworkResponseCommon { + + private String networkId; + private String neutronNetworkId; + private Map<String, String> subnetMap; + + public UpdateNetworkResponse() { + } + + public UpdateNetworkResponse(String networkId, String neutronNetworkId, + Map<String, String> subnetMap, String messageId) { + super(messageId); + this.networkId = networkId; + this.neutronNetworkId = neutronNetworkId; + this.subnetMap = subnetMap; + } + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + public String getNeutronNetworkId() { + return neutronNetworkId; + } + + public void setNeutronNetworkId(String neutronNetworkId) { + this.neutronNetworkId = neutronNetworkId; + } + + public Map<String, String> getSubnetMap() { + return subnetMap; + } + + public void setSubnetMap(Map<String, String> subnetMap) { + this.subnetMap = subnetMap; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/CreateTenantError.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/CreateTenantError.java new file mode 100644 index 0000000000..2a624a8934 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/CreateTenantError.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenantrest; + + + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +@XmlRootElement(name = "createTenantError") +@NoJackson +public class CreateTenantError implements Serializable { + private static final long serialVersionUID = 7305288262646805568L; + private String message; + private MsoExceptionCategory category; + private Boolean rolledBack; + + public CreateTenantError () {} + + public CreateTenantError (String message) { + this.message = message; + } + + public CreateTenantError (String message, MsoExceptionCategory category, boolean rolledBack) { + this.message = message; + this.category = category; + this.rolledBack = rolledBack; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public MsoExceptionCategory getCategory () { + return category; + } + + public void setCategory (MsoExceptionCategory category) { + this.category = category; + } + + public Boolean getRolledBack() { + return rolledBack; + } + + public void setRolledBack(Boolean rolledBack) { + this.rolledBack = rolledBack; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/CreateTenantRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/CreateTenantRequest.java new file mode 100644 index 0000000000..3bfaf05b15 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/CreateTenantRequest.java @@ -0,0 +1,98 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenantrest; + + + +import org.openecomp.mso.entity.MsoRequest; +import java.util.Map; +import java.util.HashMap; +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; + +@XmlRootElement(name = "createTenantRequest") +@NoJackson +public class CreateTenantRequest extends TenantRequestCommon { + private String cloudSiteId; + private String tenantName; + private Boolean failIfExists; + private Boolean backout; + private Map<String,String> metadata = new HashMap<String, String>(); + private MsoRequest msoRequest = new MsoRequest(); + + public CreateTenantRequest() {} + + public String getCloudSiteId() { + return cloudSiteId; + } + + public void setCloudSiteId(String cloudSiteId) { + this.cloudSiteId = cloudSiteId; + } + + public String getTenantName() { + return tenantName; + } + + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + + public Boolean getFailIfExists() { + return failIfExists; + } + + public void setFailIfExists(Boolean failIfExists) { + this.failIfExists = failIfExists; + } + + public Boolean getBackout() { + return backout; + } + + public void setBackout(Boolean backout) { + this.backout = backout; + } + + public Map<String, String> getMetadata() { + return metadata; + } + + public void setMetadata(Map<String, String> metadata) { + this.metadata = metadata; + } + + public MsoRequest getMsoRequest() { + return msoRequest; + } + + public void setMsoRequest(MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } + + @Override + public String toString() { + return "CreateTenantRequest [cloudSiteId=" + cloudSiteId + + ", tenantName=" + tenantName + ", failIfExists=" + + failIfExists + ", backout=" + backout + ", metadata=" + + metadata + "]"; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/CreateTenantResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/CreateTenantResponse.java new file mode 100644 index 0000000000..d25d2b47c8 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/CreateTenantResponse.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenantrest; + + + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; + +@XmlRootElement(name = "createTenantResponse") +@NoJackson +public class CreateTenantResponse implements Serializable { + private static final long serialVersionUID = -456155026754759682L; + private String cloudSiteId; + private String tenantId; + private Boolean tenantCreated; + private TenantRollback tenantRollback = new TenantRollback(); + + public CreateTenantResponse() {} + + public CreateTenantResponse(String cloudSiteId, String tenantId, + Boolean tenantCreated, TenantRollback tenantRollback) { + this.cloudSiteId = cloudSiteId; + this.tenantId = tenantId; + this.tenantCreated = tenantCreated; + this.tenantRollback = tenantRollback; + } + + public String getCloudSiteId() { + return cloudSiteId; + } + + public void setCloudSiteId(String cloudSiteId) { + this.cloudSiteId = cloudSiteId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public Boolean getTenantCreated() { + return tenantCreated; + } + + public void setTenantCreated(Boolean tenantCreated) { + this.tenantCreated = tenantCreated; + } + + public TenantRollback getTenantRollback() { + return tenantRollback; + } + + public void setTenantRollback(TenantRollback tenantRollback) { + this.tenantRollback = tenantRollback; + } + + @Override + public String toString() { + return "CreateTenantResponse [cloudSiteId=" + cloudSiteId + + ", tenantId=" + tenantId + ", tenantCreated=" + tenantCreated + + ", tenantRollback=" + tenantRollback.toString() + "]"; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantError.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantError.java new file mode 100644 index 0000000000..e55e58f294 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantError.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenantrest; + + + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +@XmlRootElement(name = "deleteTenantError") +@NoJackson +public class DeleteTenantError implements Serializable { + private static final long serialVersionUID = -5778340182805870809L; + private String message; + private MsoExceptionCategory category; + private Boolean rolledBack; + + public DeleteTenantError () {} + + public DeleteTenantError (String message) { + this.message = message; + } + + public DeleteTenantError (String message, MsoExceptionCategory category, boolean rolledBack) { + this.message = message; + this.category = category; + this.rolledBack = rolledBack; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public MsoExceptionCategory getCategory () { + return category; + } + + public void setCategory (MsoExceptionCategory category) { + this.category = category; + } + + public Boolean getRolledBack() { + return rolledBack; + } + + public void setRolledBack(Boolean rolledBack) { + this.rolledBack = rolledBack; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantRequest.java new file mode 100644 index 0000000000..8efb10b83f --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantRequest.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenantrest; + + + +import org.openecomp.mso.entity.MsoRequest; +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; + +@XmlRootElement(name = "deleteTenantRequest") +@NoJackson +public class DeleteTenantRequest extends TenantRequestCommon { + + private String cloudSiteId; + private String tenantId; + + private MsoRequest msoRequest = new MsoRequest(); + + public DeleteTenantRequest() {} + + public String getCloudSiteId() { + return cloudSiteId; + } + + public void setCloudSiteId(String cloudSiteId) { + this.cloudSiteId = cloudSiteId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public MsoRequest getMsoRequest() { + return msoRequest; + } + + public void setMsoRequest(MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantResponse.java new file mode 100644 index 0000000000..f2a1d38171 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantResponse.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenantrest; + + + +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; + +@XmlRootElement(name = "deleteTenantResponse") +@NoJackson +public class DeleteTenantResponse { + + private Boolean tenantDeleted; + + public DeleteTenantResponse() {} + + public Boolean getTenantDeleted() { + return tenantDeleted; + } + + public void setTenantDeleted(Boolean tenantDeleted) { + this.tenantDeleted = tenantDeleted; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/HealthCheckHandler.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/HealthCheckHandler.java new file mode 100644 index 0000000000..531a683aca --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/HealthCheckHandler.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenantrest; + + + +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Response; + +import org.apache.http.HttpStatus; + +import org.openecomp.mso.logger.MsoLogger; + +@Path("/") +public class HealthCheckHandler { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>"; + private static final Response HEALTH_CHECK_RESPONSE = Response.status (HttpStatus.SC_OK) + .entity (CHECK_HTML) + .build (); + @HEAD + @GET + @Path("/healthcheck") + @Produces("text/html") + public Response healthcheck () { + msoLogger.debug ("Health check call in Tenant Adapter"); + return HEALTH_CHECK_RESPONSE; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/QueryTenantError.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/QueryTenantError.java new file mode 100644 index 0000000000..100df47018 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/QueryTenantError.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenantrest; + + + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +@XmlRootElement(name = "queryTenantError") +@NoJackson +public class QueryTenantError implements Serializable { + private static final long serialVersionUID = 7358240830662453507L; + private String message; + private MsoExceptionCategory category; + + public QueryTenantError () {} + + public QueryTenantError (String message) { + this.message = message; + } + + public QueryTenantError (String message, MsoExceptionCategory category) { + this.message = message; + this.category = category; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public MsoExceptionCategory getCategory () { + return category; + } + + public void setCategory (MsoExceptionCategory category) { + this.category = category; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/QueryTenantResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/QueryTenantResponse.java new file mode 100644 index 0000000000..5fb5db7b5e --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/QueryTenantResponse.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenantrest; + + + +import java.util.Map; +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; + +@XmlRootElement(name = "queryTenantResponse") +@NoJackson +public class QueryTenantResponse extends TenantRequestCommon { + private String tenantId; + private String tenantName; + private Map<String,String> metadata; + + public QueryTenantResponse() {} + + public QueryTenantResponse (String id, String name, Map<String,String> metadata) { + this.tenantId = id; + this.tenantName = name; + this.metadata = metadata; + } + + public String getTenantId() { + return tenantId; + } + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getTenantName() { + return tenantName; + } + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + + public Map<String, String> getMetadata() { + return metadata; + } + public void setMetadata(Map<String, String> metadata) { + this.metadata = metadata; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantError.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantError.java new file mode 100644 index 0000000000..0327cefbd5 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantError.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenantrest; + + + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +@XmlRootElement(name = "rollbackTenantError") +@NoJackson +public class RollbackTenantError implements Serializable { + private static final long serialVersionUID = -5313713674529615223L; + private String message; + private MsoExceptionCategory category; + private Boolean rolledBack; + + public RollbackTenantError () {} + + public RollbackTenantError (String message) { + this.message = message; + } + + public RollbackTenantError (String message, MsoExceptionCategory category, boolean rolledBack) { + this.message = message; + this.category = category; + this.rolledBack = rolledBack; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public MsoExceptionCategory getCategory () { + return category; + } + + public void setCategory (MsoExceptionCategory category) { + this.category = category; + } + + public Boolean getRolledBack() { + return rolledBack; + } + + public void setRolledBack(Boolean rolledBack) { + this.rolledBack = rolledBack; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantRequest.java new file mode 100644 index 0000000000..a78da38692 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantRequest.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenantrest; + + + +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; + +@XmlRootElement(name = "rollbackTenantRequest") +@NoJackson +public class RollbackTenantRequest extends TenantRequestCommon { + + private TenantRollback tenantRollback; + + public RollbackTenantRequest() {} + + public TenantRollback getTenantRollback() { + return tenantRollback; + } + + public void setTenantRollback(TenantRollback tenantRollback) { + this.tenantRollback = tenantRollback; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantResponse.java new file mode 100644 index 0000000000..ec9632fbc5 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantResponse.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenantrest; + + + +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; + +@XmlRootElement(name = "rollbackTenantResponse") +@NoJackson +public class RollbackTenantResponse { + + private Boolean tenantRolledback; + + public RollbackTenantResponse() {} + + public Boolean getTenantRolledback() { + return tenantRolledback; + } + + public void setTenantRolledback(Boolean tenantRolledback) { + this.tenantRolledback = tenantRolledback; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponse.java new file mode 100644 index 0000000000..5a79243e42 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponse.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenantrest; + + + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; + +@XmlRootElement(name = "createTenantResponse") +@NoJackson +public class TenantExceptionResponse implements Serializable { + + private static final long serialVersionUID = -9062290006520066109L; + + private String message; + private MsoExceptionCategory category; + private Boolean rolledBack; + + public TenantExceptionResponse () {} + + public TenantExceptionResponse (String message) { + this.message = message; + } + + public TenantExceptionResponse (String message, MsoExceptionCategory category, boolean rolledBack) { + this.message = message; + this.category = category; + this.rolledBack = rolledBack; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public MsoExceptionCategory getCategory () { + return category; + } + + public void setCategory (MsoExceptionCategory category) { + this.category = category; + } + + public Boolean getRolledBack() { + return rolledBack; + } + + public void setRolledBack(Boolean rolledBack) { + this.rolledBack = rolledBack; + } + +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantRequestCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantRequestCommon.java new file mode 100644 index 0000000000..972d5eb6fa --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantRequestCommon.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenantrest; + + +import java.io.ByteArrayOutputStream; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; + +public class TenantRequestCommon { + public String toJsonString() { + try { + String jsonString = null; + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + jsonString = mapper.writeValueAsString(this); + return jsonString; + } catch (Exception e) { + // Shouldn't happen... + e.printStackTrace(); + return ""; + } + } + + public String toXmlString() { + try { + ByteArrayOutputStream bs = new ByteArrayOutputStream(); + JAXBContext context = JAXBContext.newInstance(this.getClass()); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //pretty print XML + marshaller.marshal(this, bs); + return bs.toString(); + } catch (Exception e) { + // Shouldn't happen... + e.printStackTrace(); + return ""; + } + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantRollback.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantRollback.java new file mode 100644 index 0000000000..3d346afabe --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantRollback.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenantrest; + + + +import javax.xml.bind.annotation.XmlRootElement; + +import org.openecomp.mso.entity.MsoRequest; +import org.jboss.resteasy.annotations.providers.NoJackson; + +/** + * Javabean representing the rollback criteria following a "Create Tenant" + * operation. This structure can be passed back to the "Rollback Tenant" + * operation to undo the effects of the create. + * + * + */ + +@XmlRootElement(name = "rollbackTenantRequest") +@NoJackson +public class TenantRollback extends TenantRequestCommon { + private String tenantId; + private String cloudId; + private boolean tenantCreated = false; + private MsoRequest msoRequest; + + public TenantRollback() {} + + public String getTenantId() { + return tenantId; + } + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getCloudId() { + return cloudId; + } + public void setCloudId(String cloudId) { + this.cloudId = cloudId; + } + + public boolean getTenantCreated() { + return tenantCreated; + } + public void setTenantCreated(boolean tenantCreated) { + this.tenantCreated = tenantCreated; + } + + public MsoRequest getMsoRequest() { + return msoRequest; + } + public void setMsoRequest (MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } + + @Override + public String toString() { + return "VnfRollback: cloud=" + cloudId + ", tenant=" + tenantId + + ", tenantCreated=" + tenantCreated; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleRequest.java new file mode 100644 index 0000000000..f337c4c9de --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleRequest.java @@ -0,0 +1,212 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import org.openecomp.mso.entity.MsoRequest; + +import java.util.Map; +import java.util.HashMap; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jboss.resteasy.annotations.providers.NoJackson; + +import org.codehaus.jackson.map.annotate.JsonRootName; + +/* README +* 1) Used JAXB/Jettison - see @NoJackson annotation on class to get RootElements REad by RestEasy +* 2) due to 1) Maps need to use this format + +"vfModuleParams": {"entry": [ + {"key": "network_id", + "value": "59ed7b41-2983-413f-ba93-e7d437433916"}, + {"key": "subnet_id", + "value": "086c9298-5c57-49b7-bb2b-6fd5730c5d92"}, + {"key": "server_name_0", + "value": "RaaVnf1"} + ]}, + * 3) to output json see toJSonString method below which required the @JsonRootName annotation and the WRAP_ROOT feature enabled + * 4) Tryong to work with RESTEASY JACKSON and JAXB/JETTISON to conform to Json input/output specs +*/ +@JsonRootName("createVfModuleRequest") +@XmlRootElement(name = "createVfModuleRequest") +@NoJackson +public class CreateVfModuleRequest extends VfRequestCommon { + private String cloudSiteId; + private String tenantId; + + private String vnfId; + private String vnfType; + private String vnfVersion; + + private String vfModuleId; + private String vfModuleName; + private String vfModuleType; + + private String volumeGroupId; + private String volumeGroupStackId; + private String baseVfModuleId; + private String baseVfModuleStackId; + + private String requestType; + private Boolean failIfExists; + private Boolean backout; + + private Map<String,String> vfModuleParams = new HashMap<String, String>(); + private MsoRequest msoRequest = new MsoRequest(); + + public String getCloudSiteId() { + return cloudSiteId; + } + + public void setCloudSiteId(String cloudSiteId) { + this.cloudSiteId = cloudSiteId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVfModuleName() { + return vfModuleName; + } + + public void setVfModuleName(String vfModuleName) { + this.vfModuleName = vfModuleName; + } + + public String getVnfType() { + return vnfType; + } + + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + + public String getVnfVersion() { + return vnfVersion; + } + + public void setVnfVersion(String vnfVersion) { + this.vnfVersion = vnfVersion; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + public String getVfModuleType() { + return vfModuleType; + } + + public void setVfModuleType(String vfModuleType) { + this.vfModuleType = vfModuleType; + } + + public String getVolumeGroupId() { + return volumeGroupId; + } + + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + + public String getVolumeGroupStackId() { + return volumeGroupStackId; + } + + public void setVolumeGroupStackId(String volumeGroupStackId) { + this.volumeGroupStackId = volumeGroupStackId; + } + + public String getBaseVfModuleId() { + return baseVfModuleId; + } + + public void setBaseVfModuleId(String baseVfModuleId) { + this.baseVfModuleId = baseVfModuleId; + } + + public String getBaseVfModuleStackId() { + return baseVfModuleStackId; + } + + public void setBaseVfModuleStackId(String baseVfModuleStackId) { + this.baseVfModuleStackId = baseVfModuleStackId; + } + + public String getRequestType() { + return requestType; + } + + public void setRequestType(String requestType) { + this.requestType = requestType; + } + + public Boolean getFailIfExists() { + return failIfExists; + } + + public void setFailIfExists(Boolean failIfExists) { + this.failIfExists = failIfExists; + } + + public Boolean getBackout() { + return backout; + } + + public void setBackout(Boolean backout) { + this.backout = backout; + } + + public Map<String, String> getVfModuleParams() { + return vfModuleParams; + } + + public void setVfModuleParams(Map<String, String> vfModuleParams) { + this.vfModuleParams = vfModuleParams; + } + + public MsoRequest getMsoRequest() { + return msoRequest; + } + + public void setMsoRequest(MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleResponse.java new file mode 100644 index 0000000000..566a136712 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleResponse.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("createVfModuleResponse") +@XmlRootElement(name = "createVfModuleResponse") +@NoJackson +public class CreateVfModuleResponse extends VfResponseCommon { + private String vnfId; + private String vfModuleId; + private String vfModuleStackId; + private Boolean vfModuleCreated; + private Map<String,String> vfModuleOutputs = new HashMap<String, String>(); + private VfModuleRollback rollback = new VfModuleRollback(); + + public CreateVfModuleResponse() { + super(); + } + + public CreateVfModuleResponse(String vnfId, String vfModuleId, + String vfModuleStackId, Boolean vfModuleCreated, + Map<String, String> vfModuleOutputs, VfModuleRollback rollback, + String messageId) { + super(messageId); + this.vnfId = vnfId; + this.vfModuleId = vfModuleId; + this.vfModuleStackId = vfModuleStackId; + this.vfModuleCreated = vfModuleCreated; + this.vfModuleOutputs = vfModuleOutputs; + this.rollback = rollback; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + public String getVfModuleStackId() { + return vfModuleStackId; + } + + public void setVfModuleStackId(String vfModuleStackId) { + this.vfModuleStackId = vfModuleStackId; + } + + public Boolean getVfModuleCreated() { + return vfModuleCreated; + } + + public void setVfModuleCreated(Boolean vfModuleCreated) { + this.vfModuleCreated = vfModuleCreated; + } + + public Map<String, String> getVfModuleOutputs() { + return vfModuleOutputs; + } + + public void setVfModuleOutputs(Map<String, String> vfModuleOutputs) { + this.vfModuleOutputs = vfModuleOutputs; + } + + public VfModuleRollback getRollback() { + return rollback; + } + + public void setRollback(VfModuleRollback rollback) { + this.rollback = rollback; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupRequest.java new file mode 100644 index 0000000000..b93a26031f --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupRequest.java @@ -0,0 +1,141 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import org.openecomp.mso.entity.MsoRequest; + +@JsonRootName("createVolumeGroupRequest") +@XmlRootElement(name = "createVolumeGroupRequest") +@NoJackson +public class CreateVolumeGroupRequest extends VfRequestCommon { + private String cloudSiteId; + private String tenantId; + private String volumeGroupName; + private String volumeGroupId; + private String vnfType; + private String vnfVersion; + private String vfModuleType; + private Map<String,String> volumeGroupParams = new HashMap<String, String>(); + private Boolean failIfExists; + private Boolean suppressBackout; + private MsoRequest msoRequest = new MsoRequest(); + + public CreateVolumeGroupRequest() { + super(); + } + + public String getCloudSiteId() { + return cloudSiteId; + } + + public void setCloudSiteId(String cloudSiteId) { + this.cloudSiteId = cloudSiteId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getVnfType() { + return vnfType; + } + + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + + public String getVnfVersion() { + return vnfVersion; + } + + public void setVnfVersion(String vnfVersion) { + this.vnfVersion = vnfVersion; + } + + public String getVfModuleType() { + return vfModuleType; + } + + public void setVfModuleType(String vfModuleType) { + this.vfModuleType = vfModuleType; + } + + public Map<String, String> getVolumeGroupParams() { + return volumeGroupParams; + } + + public void setVolumeGroupParams(Map<String, String> volumeGroupParams) { + this.volumeGroupParams = volumeGroupParams; + } + + public String getVolumeGroupName() { + return volumeGroupName; + } + + public void setVolumeGroupName(String volumeGroupName) { + this.volumeGroupName = volumeGroupName; + } + + public String getVolumeGroupId() { + return volumeGroupId; + } + + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + + public Boolean getFailIfExists() { + return failIfExists; + } + + public void setFailIfExists(Boolean failIfExists) { + this.failIfExists = failIfExists; + } + + public Boolean getSuppressBackout() { + return suppressBackout; + } + + public void setSuppressBackout(Boolean suppressBackout) { + this.suppressBackout = suppressBackout; + } + + public MsoRequest getMsoRequest() { + return msoRequest; + } + + public void setMsoRequest(MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupResponse.java new file mode 100644 index 0000000000..abf599b13d --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupResponse.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.jboss.resteasy.annotations.providers.NoJackson; + +@JsonRootName("createVolumeGroupResponse") +@XmlRootElement(name = "createVolumeGroupResponse") +@NoJackson +public class CreateVolumeGroupResponse extends VfResponseCommon { + private String volumeGroupId; + private String volumeGroupStackId; + private Boolean volumeGroupCreated; + private Map<String,String> volumeGroupOutputs = new HashMap<String, String>(); + private VolumeGroupRollback volumeGroupRollback = new VolumeGroupRollback(); + + public CreateVolumeGroupResponse() { + super(); + } + + public CreateVolumeGroupResponse( + String volumeGroupId, + String volumeGroupStackId, + Boolean volumeGroupCreated, + Map<String, String> volumeGroupOutputs, + VolumeGroupRollback volumeGroupRollback, + String messageId) + { + super(messageId); + this.volumeGroupId = volumeGroupId; + this.volumeGroupStackId = volumeGroupStackId; + this.volumeGroupCreated = volumeGroupCreated; + this.volumeGroupOutputs = volumeGroupOutputs; + this.volumeGroupRollback = volumeGroupRollback; + } + + public String getVolumeGroupId() { + return volumeGroupId; + } + + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + + public String getVolumeGroupStackId() { + return volumeGroupStackId; + } + + public void setVolumeGroupStackId(String volumeGroupStackId) { + this.volumeGroupStackId = volumeGroupStackId; + } + + public Boolean getVolumeGroupCreated() { + return volumeGroupCreated; + } + + public void setVolumeGroupCreated(Boolean volumeGroupCreated) { + this.volumeGroupCreated = volumeGroupCreated; + } + + public Map<String, String> getVolumeGroupOutputs() { + return volumeGroupOutputs; + } + + public void setVolumeGroupOutputs(Map<String, String> volumeGroupOutputs) { + this.volumeGroupOutputs = volumeGroupOutputs; + } + + public VolumeGroupRollback getVolumeGroupRollback() { + return volumeGroupRollback; + } + + public void setVolumeGroupRollback(VolumeGroupRollback volumeGroupRollback) { + this.volumeGroupRollback = volumeGroupRollback; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleRequest.java new file mode 100644 index 0000000000..14ecd5e654 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleRequest.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import org.openecomp.mso.entity.MsoRequest; + +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("deleteVfModuleRequest") +@XmlRootElement(name = "deleteVfModuleRequest") +@NoJackson +public class DeleteVfModuleRequest extends VfRequestCommon { + private String cloudSiteId; + private String tenantId; + private String vnfId; + private String vfModuleId; + private String vfModuleStackId; + + private MsoRequest msoRequest = new MsoRequest(); + + public DeleteVfModuleRequest() { + super(); + } + + public String getCloudSiteId() { + return cloudSiteId; + } + + public void setCloudSiteId(String cloudSiteId) { + this.cloudSiteId = cloudSiteId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + public String getVfModuleStackId() { + return vfModuleStackId; + } + + public void setVfModuleStackId(String vfModuleStackId) { + this.vfModuleStackId = vfModuleStackId; + } + + public MsoRequest getMsoRequest() { + return msoRequest; + } + + public void setMsoRequest(MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleResponse.java new file mode 100644 index 0000000000..a3d00a95cd --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleResponse.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("deleteVfModuleResponse") +@XmlRootElement(name = "deleteVfModuleResponse") +@NoJackson +public class DeleteVfModuleResponse extends VfResponseCommon { + private String vnfId; + private String vfModuleId; + private Boolean vfModuleDeleted; + + public DeleteVfModuleResponse() { + super(); + } + + public DeleteVfModuleResponse(String vnfId, String vfModuleId, Boolean vfModuleDeleted, String messageId) { + super(messageId); + this.vnfId = vnfId; + this.vfModuleId = vfModuleId; + this.vfModuleDeleted = vfModuleDeleted; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + public Boolean getVfModuleDeleted() { + return vfModuleDeleted; + } + + public void setVfModuleDeleted(Boolean vfModuleDeleted) { + this.vfModuleDeleted = vfModuleDeleted; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupRequest.java new file mode 100644 index 0000000000..01dc8ffa38 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupRequest.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import org.openecomp.mso.entity.MsoRequest; + +@JsonRootName("deleteVolumeGroupRequest") +@XmlRootElement(name = "deleteVolumeGroupRequest") +@NoJackson +public class DeleteVolumeGroupRequest extends VfRequestCommon { + private String cloudSiteId; + private String tenantId; + private String volumeGroupId; + private String volumeGroupStackId; + private MsoRequest msoRequest = new MsoRequest(); + + public DeleteVolumeGroupRequest() { + super(); + } + + public String getCloudSiteId() { + return cloudSiteId; + } + + public void setCloudSiteId(String cloudSiteId) { + this.cloudSiteId = cloudSiteId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getVolumeGroupId() { + return volumeGroupId; + } + + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + + public String getVolumeGroupStackId() { + return volumeGroupStackId; + } + + public void setVolumeGroupStackId(String volumeGroupStackId) { + this.volumeGroupStackId = volumeGroupStackId; + } + + public MsoRequest getMsoRequest() { + return msoRequest; + } + + public void setMsoRequest(MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupResponse.java new file mode 100644 index 0000000000..738abd6923 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupResponse.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.jboss.resteasy.annotations.providers.NoJackson; + +@JsonRootName("deleteVolumeGroupResponse") +@XmlRootElement(name = "deleteVolumeGroupResponse") +@NoJackson +public class DeleteVolumeGroupResponse extends VfResponseCommon { + private Boolean volumeGroupDeleted; + + public DeleteVolumeGroupResponse() { + super(); + } + + public DeleteVolumeGroupResponse(Boolean volumeGroupDeleted, String messageId) { + super(messageId); + this.volumeGroupDeleted = volumeGroupDeleted; + } + + public Boolean getVolumeGroupDeleted() { + return volumeGroupDeleted; + } + + public void setVolumeGroupDeleted(Boolean volumeGroupDeleted) { + this.volumeGroupDeleted = volumeGroupDeleted; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java new file mode 100644 index 0000000000..91da93065d --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import java.util.Map; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.ObjectMapper; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import org.openecomp.mso.openstack.beans.VnfStatus; + +@XmlRootElement(name = "queryVfModuleResponse") +@NoJackson +public class QueryVfModuleResponse { + private String vnfId; + private String vfModuleId; + private String vfModuleStackId; + private VnfStatus vnfStatus; + private Map<String,String> vfModuleOutputs; + + public QueryVfModuleResponse() { + super(); + } + + public QueryVfModuleResponse(String vnfId, String vfModuleId, + String vfModuleStackId, VnfStatus vnfStatus, + Map<String, String> vfModuleOutputs) { + super(); + this.vnfId = vnfId; + this.vfModuleId = vfModuleId; + this.vfModuleStackId = vfModuleStackId; + this.vnfStatus = vnfStatus; + this.vfModuleOutputs = vfModuleOutputs; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + public String getVfModuleStackId() { + return vfModuleStackId; + } + + public void setVfModuleStackId(String vfModuleStackId) { + this.vfModuleStackId = vfModuleStackId; + } + + public VnfStatus getVnfStatus() { + return vnfStatus; + } + + public void setVnfStatus(VnfStatus vnfStatus) { + this.vnfStatus = vnfStatus; + } + + public Map<String, String> getVfModuleOutputs() { + return vfModuleOutputs; + } + + public void setVfModuleOutputs(Map<String, String> vfModuleOutputs) { + this.vfModuleOutputs = vfModuleOutputs; + } + + public String toJsonString() { + String jsonString = null; + try { + ObjectMapper mapper = new ObjectMapper(); + jsonString = mapper.writeValueAsString(this); + } + catch (Exception e) {} + return jsonString; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVolumeGroupResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVolumeGroupResponse.java new file mode 100644 index 0000000000..5e0d8bbe90 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVolumeGroupResponse.java @@ -0,0 +1,100 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import java.util.Map; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import org.openecomp.mso.openstack.beans.VnfStatus; + +@XmlRootElement(name = "queryVolumeGroupResponse") +@NoJackson +public class QueryVolumeGroupResponse { + private String volumeGroupId; + private String volumeGroupStackId; + private VnfStatus volumeGroupStatus; + private Map<String,String> volumeGroupOutputs; + + public QueryVolumeGroupResponse() { + } + + public QueryVolumeGroupResponse( + String volumeGroupId, + String volumeGroupStackId, + VnfStatus volumeGroupStatus, + Map<String, String> volumeGroupOutputs) + { + super(); + this.volumeGroupId = volumeGroupId; + this.volumeGroupStackId = volumeGroupStackId; + this.volumeGroupStatus = volumeGroupStatus; + this.volumeGroupOutputs = volumeGroupOutputs; + } + + public String getVolumeGroupId() { + return volumeGroupId; + } + + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + + public String getVolumeGroupStackId() { + return volumeGroupStackId; + } + + public void setVolumeGroupStackId(String volumeGroupStackId) { + this.volumeGroupStackId = volumeGroupStackId; + } + + public VnfStatus getVolumeGroupStatus() { + return volumeGroupStatus; + } + + public void setVolumeGroupStatus(VnfStatus volumeGroupStatus) { + this.volumeGroupStatus = volumeGroupStatus; + } + + public Map<String, String> getVolumeGroupOutputs() { + return volumeGroupOutputs; + } + + public void setVolumeGroupOutputs(Map<String, String> volumeGroupOutputs) { + this.volumeGroupOutputs = volumeGroupOutputs; + } + + public String toJsonString() { + String jsonString = null; + try { + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + jsonString = mapper.writeValueAsString(this); + } + catch (Exception e) {} + return jsonString; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleRequest.java new file mode 100644 index 0000000000..3365a05907 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleRequest.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("rollbackVfModuleRequest") +@XmlRootElement(name = "rollbackVfModuleRequest") +@NoJackson +public class RollbackVfModuleRequest extends VfRequestCommon { + private VfModuleRollback vfModuleRollback; + + public RollbackVfModuleRequest() { + super(); + } + + public VfModuleRollback getVfModuleRollback() { + return vfModuleRollback; + } + + public void setVfModuleRollback(VfModuleRollback vfModuleRollback) { + this.vfModuleRollback = vfModuleRollback; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleResponse.java new file mode 100644 index 0000000000..d877d667c8 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleResponse.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("rollbackVfModuleResponse") +@XmlRootElement(name = "rollbackVfModuleResponse") +@NoJackson +public class RollbackVfModuleResponse extends VfResponseCommon { + private Boolean vfModuleRolledback; + + public RollbackVfModuleResponse() { + super(); + } + + public RollbackVfModuleResponse(Boolean vfModuleRolledback, String messageId) { + super(messageId); + this.vfModuleRolledback = vfModuleRolledback; + } + + public Boolean getVfModuleRolledback() { + return vfModuleRolledback; + } + + public void setVfModuleRolledback(Boolean vfModuleRolledback) { + this.vfModuleRolledback = vfModuleRolledback; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupRequest.java new file mode 100644 index 0000000000..cb877bb858 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupRequest.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.jboss.resteasy.annotations.providers.NoJackson; + +@JsonRootName("rollbackVolumeGroupRequest") +@XmlRootElement(name = "rollbackVolumeGroupRequest") +@NoJackson +public class RollbackVolumeGroupRequest extends VfRequestCommon { + private VolumeGroupRollback volumeGroupRollback; + + public RollbackVolumeGroupRequest() { + super(); + } + + public VolumeGroupRollback getVolumeGroupRollback() { + return volumeGroupRollback; + } + + public void setVolumeGroupRollback(VolumeGroupRollback volumeGroupRollback) { + this.volumeGroupRollback = volumeGroupRollback; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupResponse.java new file mode 100644 index 0000000000..603b7581c0 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupResponse.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.jboss.resteasy.annotations.providers.NoJackson; + +@JsonRootName("rollbackVolumeGroupResponse") +@XmlRootElement(name = "rollbackVolumeGroupResponse") +@NoJackson +public class RollbackVolumeGroupResponse extends VfResponseCommon { + private Boolean volumeGroupRolledBack; + + public RollbackVolumeGroupResponse() { + super(); + } + + public RollbackVolumeGroupResponse(Boolean volumeGroupRolledBack, String messageId) { + super(messageId); + this.volumeGroupRolledBack = volumeGroupRolledBack; + } + + public Boolean getVolumeGroupRolledBack() { + return volumeGroupRolledBack; + } + + public void setVolumeGroupRolledBack(Boolean volumeGroupRolledBack) { + this.volumeGroupRolledBack = volumeGroupRolledBack; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleRequest.java new file mode 100644 index 0000000000..a234e749ba --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleRequest.java @@ -0,0 +1,205 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import org.openecomp.mso.entity.MsoRequest; + +import java.util.Map; +import java.util.HashMap; +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("updateVfModuleRequest") +@XmlRootElement(name = "updateVfModuleRequest") +@NoJackson +public class UpdateVfModuleRequest extends VfRequestCommon { + + private String cloudSiteId; + private String tenantId; + + private String vnfId; + private String vnfType; + private String vnfVersion; + + private String vfModuleName; + private String vfModuleType; + private String vfModuleId; + private String vfModuleStackId; + + private String volumeGroupId; + private String volumeGroupStackId; + + private String baseVfModuleId; + private String baseVfModuleStackId; + + private String requestType; + private Boolean failIfExists; + private Boolean backout; + + private Map<String,String> vfModuleParams = new HashMap<String, String>(); + private MsoRequest msoRequest = new MsoRequest(); + + public String getCloudSiteId() { + return cloudSiteId; + } + + public void setCloudSiteId(String cloudSiteId) { + this.cloudSiteId = cloudSiteId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVfModuleName() { + return vfModuleName; + } + + public void setVfModuleName(String vfModuleName) { + this.vfModuleName = vfModuleName; + } + + public String getVnfType() { + return vnfType; + } + + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + + public String getVnfVersion() { + return vnfVersion; + } + + public void setVnfVersion(String vnfVersion) { + this.vnfVersion = vnfVersion; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + public String getVfModuleType() { + return vfModuleType; + } + + public void setVfModuleType(String vfModuleType) { + this.vfModuleType = vfModuleType; + } + + public String getVfModuleStackId() { + return vfModuleStackId; + } + + public void setVfModuleStackId(String vfModuleStackId) { + this.vfModuleStackId = vfModuleStackId; + } + + public String getVolumeGroupId() { + return volumeGroupId; + } + + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + + public String getVolumeGroupStackId() { + return volumeGroupStackId; + } + + public void setVolumeGroupStackId(String volumeGroupStackId) { + this.volumeGroupStackId = volumeGroupStackId; + } + + public String getBaseVfModuleId() { + return baseVfModuleId; + } + + public void setBaseVfModuleId(String baseVfModuleId) { + this.baseVfModuleId = baseVfModuleId; + } + + public String getBaseVfModuleStackId() { + return baseVfModuleStackId; + } + + public void setBaseVfModuleStackId(String baseVfModuleStackId) { + this.baseVfModuleStackId = baseVfModuleStackId; + } + + public String getRequestType() { + return requestType; + } + + public void setRequestType(String requestType) { + this.requestType = requestType; + } + + public Boolean getFailIfExists() { + return failIfExists; + } + + public void setFailIfExists(Boolean failIfExists) { + this.failIfExists = failIfExists; + } + + public Boolean getBackout() { + return backout; + } + + public void setBackout(Boolean backout) { + this.backout = backout; + } + + public Map<String, String> getVfModuleParams() { + return vfModuleParams; + } + + public void setVfModuleParams(Map<String, String> vfModuleParams) { + this.vfModuleParams = vfModuleParams; + } + + public MsoRequest getMsoRequest() { + return msoRequest; + } + + public void setMsoRequest(MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleResponse.java new file mode 100644 index 0000000000..af162b2e98 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleResponse.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import java.util.HashMap; +import java.util.Map; +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("updateVfModuleResponse") +@XmlRootElement(name = "updateVfModuleResponse") +@NoJackson +public class UpdateVfModuleResponse extends VfResponseCommon { + private String vnfId; + private String vfModuleId; + private String vfModuleStackId; + private Map<String,String> vfModuleOutputs = new HashMap<String, String>(); + + public UpdateVfModuleResponse() { + super(); + } + + public UpdateVfModuleResponse(String vnfId, String vfModuleId, + String vfModuleStackId, + Map<String, String> vfModuleOutputs, + String messageId) { + super(messageId); + this.vnfId = vnfId; + this.vfModuleId = vfModuleId; + this.vfModuleStackId = vfModuleStackId; + this.vfModuleOutputs = vfModuleOutputs; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + public String getVfModuleStackId() { + return vfModuleStackId; + } + + public void setVfModuleStackId(String vfModuleStackId) { + this.vfModuleStackId = vfModuleStackId; + } + + public Map<String, String> getVfModuleOutputs() { + return vfModuleOutputs; + } + + public void setVfModuleOutputs(Map<String, String> vfModuleOutputs) { + this.vfModuleOutputs = vfModuleOutputs; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupRequest.java new file mode 100644 index 0000000000..50c60b30d6 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupRequest.java @@ -0,0 +1,123 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import org.openecomp.mso.entity.MsoRequest; + +@JsonRootName("updateVolumeGroupRequest") +@XmlRootElement(name = "updateVolumeGroupRequest") +@NoJackson +public class UpdateVolumeGroupRequest extends VfRequestCommon { + private String cloudSiteId; + private String tenantId; + private String volumeGroupId; + private String volumeGroupStackId; + private String vnfType; + private String vnfVersion; + private String vfModuleType; + private Map<String,String> volumeGroupParams = new HashMap<String, String>(); + private MsoRequest msoRequest = new MsoRequest(); + + public UpdateVolumeGroupRequest() { + super(); + } + + public String getCloudSiteId() { + return cloudSiteId; + } + + public void setCloudSiteId(String cloudSiteId) { + this.cloudSiteId = cloudSiteId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getVolumeGroupId() { + return volumeGroupId; + } + + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + + public String getVolumeGroupStackId() { + return volumeGroupStackId; + } + + public void setVolumeGroupStackId(String volumeGroupStackId) { + this.volumeGroupStackId = volumeGroupStackId; + } + + public String getVnfType() { + return vnfType; + } + + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + + public String getVnfVersion() { + return vnfVersion; + } + + public void setVnfVersion(String vnfVersion) { + this.vnfVersion = vnfVersion; + } + + public String getVfModuleType() { + return vfModuleType; + } + + public void setVfModuleType(String vfModuleType) { + this.vfModuleType = vfModuleType; + } + + public Map<String, String> getVolumeGroupParams() { + return volumeGroupParams; + } + + public void setVolumeGroupParams(Map<String, String> volumeGroupParams) { + this.volumeGroupParams = volumeGroupParams; + } + + public MsoRequest getMsoRequest() { + return msoRequest; + } + + public void setMsoRequest(MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupResponse.java new file mode 100644 index 0000000000..2bd210f131 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupResponse.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.jboss.resteasy.annotations.providers.NoJackson; + +@JsonRootName("updateVolumeGroupResponse") +@XmlRootElement(name = "updateVolumeGroupResponse") +@NoJackson +public class UpdateVolumeGroupResponse extends VfResponseCommon { + private String volumeGroupId; + private String volumeGroupStackId; + private Map<String,String> volumeGroupOutputs; + + public UpdateVolumeGroupResponse() { + super(); + this.volumeGroupOutputs = new HashMap<String, String>(); + } + + public UpdateVolumeGroupResponse( + String volumeGroupId, + String volumeGroupStackId, + Map<String, String> volumeGroupOutputs, + String messageId) + { + super(messageId); + this.volumeGroupId = volumeGroupId; + this.volumeGroupStackId = volumeGroupStackId; + this.volumeGroupOutputs = volumeGroupOutputs; + } + + public String getVolumeGroupId() { + return volumeGroupId; + } + + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + + public String getVolumeGroupStackId() { + return volumeGroupStackId; + } + + public void setVolumeGroupStackId(String volumeGroupStackId) { + this.volumeGroupStackId = volumeGroupStackId; + } + + public Map<String, String> getVolumeGroupOutputs() { + return volumeGroupOutputs; + } + + public void setVolumeGroupOutputs(Map<String, String> volumeGroupOutputs) { + this.volumeGroupOutputs = volumeGroupOutputs; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfModuleExceptionResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfModuleExceptionResponse.java new file mode 100644 index 0000000000..419d1df566 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfModuleExceptionResponse.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +@XmlRootElement(name = "vfModuleException") +@NoJackson +public class VfModuleExceptionResponse extends VfResponseCommon implements Serializable { + private static final long serialVersionUID = -9062290006520066109L; + + private String message; + private MsoExceptionCategory category; + private Boolean rolledBack; + + public VfModuleExceptionResponse () {} + + public VfModuleExceptionResponse (String message) { + this.message = message; + } + + public VfModuleExceptionResponse (String message, MsoExceptionCategory category, boolean rolledBack, String messageid) { + super(messageid); + this.message = message; + this.category = category; + this.rolledBack = rolledBack; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public MsoExceptionCategory getCategory () { + return category; + } + + public void setCategory (MsoExceptionCategory category) { + this.category = category; + } + + public Boolean getRolledBack() { + return rolledBack; + } + + public void setRolledBack(Boolean rolledBack) { + this.rolledBack = rolledBack; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfModuleRollback.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfModuleRollback.java new file mode 100644 index 0000000000..84ef7146fd --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfModuleRollback.java @@ -0,0 +1,123 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import javax.xml.bind.annotation.XmlRootElement; + +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.VnfRollback; +import org.jboss.resteasy.annotations.providers.NoJackson; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("VfModuleRollback") +@XmlRootElement(name = "VfModuleRollback") +@NoJackson +public class VfModuleRollback { + private String vnfId; + private String vfModuleId; + private String vfModuleStackId; + private boolean vfModuleCreated = false; + private String tenantId; + private String cloudSiteId; + private MsoRequest msoRequest; + private String messageId; + + public VfModuleRollback() { + } + + public VfModuleRollback(VnfRollback vrb, String vfModuleId, String vfModuleStackId, String messageId) + { + this.vnfId = vrb.getVnfId(); + this.vfModuleId = vfModuleId; + this.vfModuleStackId = vfModuleStackId; + this.vfModuleCreated = vrb.getVnfCreated(); + this.tenantId = vrb.getTenantId(); + this.cloudSiteId = vrb.getCloudSiteId(); + this.msoRequest = vrb.getMsoRequest(); + this.messageId = messageId; + } + + public VfModuleRollback(String vnfId, String vfModuleId, + String vfModuleStackId, boolean vfModuleCreated, String tenantId, + String cloudSiteId, + MsoRequest msoRequest, + String messageId) { + super(); + this.vnfId = vnfId; + this.vfModuleId = vfModuleId; + this.vfModuleStackId = vfModuleStackId; + this.vfModuleCreated = vfModuleCreated; + this.tenantId = tenantId; + this.cloudSiteId = cloudSiteId; + this.msoRequest = msoRequest; + this.messageId = messageId; + } + + public String getVnfId() { + return vnfId; + } + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + public String getVfModuleId() { + return vfModuleId; + } + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + public String getVfModuleStackId() { + return vfModuleStackId; + } + public void setVfModuleStackId(String vfModuleStackId) { + this.vfModuleStackId = vfModuleStackId; + } + public boolean isVfModuleCreated() { + return vfModuleCreated; + } + public void setVfModuleCreated(boolean vfModuleCreated) { + this.vfModuleCreated = vfModuleCreated; + } + public String getTenantId() { + return tenantId; + } + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + public String getCloudSiteId() { + return cloudSiteId; + } + public void setCloudSiteId(String cloudSiteId) { + this.cloudSiteId = cloudSiteId; + } + public MsoRequest getMsoRequest() { + return msoRequest; + } + public void setMsoRequest(MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } + public String getMessageId() { + return messageId; + } + public void setMessageId(String messageId) { + this.messageId = messageId; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommon.java new file mode 100644 index 0000000000..e315444eb3 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommon.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +/** + * Everything that is common between all VfModule and VolumeGroup Requests. + */ +public abstract class VfRequestCommon extends VfResponseCommon { + private Boolean skipAAI; + private String notificationUrl; + + public Boolean getSkipAAI() { + return skipAAI; + } + + public void setSkipAAI(Boolean skipAAI) { + this.skipAAI = skipAAI; + } + + public String getNotificationUrl() { + return notificationUrl; + } + + public void setNotificationUrl(String notificationUrl) { + this.notificationUrl = notificationUrl; + } + + public boolean isSynchronous() { + return notificationUrl == null || (notificationUrl != null && notificationUrl.isEmpty()); + } + + // getMessageId, setMessageId, toJsonString, toJsonString are all defined in VfResponseCommon. +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfResponseCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfResponseCommon.java new file mode 100644 index 0000000000..96a83e41fd --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfResponseCommon.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import java.io.ByteArrayOutputStream; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; + +/** + * Everything that is common between all VfModule and VolumeGroup Responses, + * except for QueryVfModuleResponse and QueryVolumeGroupResponse. + */ +public abstract class VfResponseCommon { + private String messageId; + + public VfResponseCommon() { + messageId = null; + } + + public VfResponseCommon(String messageId) { + this.messageId = messageId; + } + + public String getMessageId() { + return messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String toJsonString() { + try { + String jsonString = null; + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + jsonString = mapper.writeValueAsString(this); + return jsonString; + } catch (Exception e) { + // Shouldn't happen... + e.printStackTrace(); + return ""; + } + } + + public String toXmlString() { + try { + ByteArrayOutputStream bs = new ByteArrayOutputStream(); + JAXBContext context = JAXBContext.newInstance(this.getClass()); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //pretty print XML + marshaller.marshal(this, bs); + return bs.toString(); + } catch (Exception e) { + // Shouldn't happen... + e.printStackTrace(); + return ""; + } + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupExceptionResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupExceptionResponse.java new file mode 100644 index 0000000000..bc4e54b3a2 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupExceptionResponse.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jboss.resteasy.annotations.providers.NoJackson; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +@XmlRootElement(name = "volumeGroupException") +@NoJackson +public class VolumeGroupExceptionResponse extends VfModuleExceptionResponse { + // Exactly the same as a VfModuleExceptionResponse + + private static final long serialVersionUID = 1168681288205898800L; + + public VolumeGroupExceptionResponse() { + super(); + } + + public VolumeGroupExceptionResponse(String message) { + super(message); + } + + public VolumeGroupExceptionResponse(String message, MsoExceptionCategory category, boolean rolledBack, String messageid) { + super(message, category, rolledBack, messageid); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupRollback.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupRollback.java new file mode 100644 index 0000000000..bda222159e --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupRollback.java @@ -0,0 +1,130 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnfrest; + + +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import org.openecomp.mso.entity.MsoRequest; + +@JsonRootName("VolumeGroupRollback") +@XmlRootElement(name = "VolumeGroupRollback") +@NoJackson +public class VolumeGroupRollback { +// “volumeGroupRollback”: { +// “volumeGroupId”: “<A&AI_ VOLUME_GROUP_ID>”, +// “volumeGroupStackId”: “<VOLUME_GROUP _STACK_ID>”, +// “tenantId”: “<TENANT_ID>”, +// “cloudSiteId”: “<CLOUD_CLLI>”, +// “volumeGroupCreated”: TRUE|FALSE, +// “msoRequest”: { +// “requestId”: “<REQUEST_ID>”, +// “serviceInstanceId”: “<SERVICE_INSTANCE_ID>” +// } +//}, + + private String volumeGroupId; + private String volumeGroupStackId; + private String tenantId; + private String cloudSiteId; + private boolean volumeGroupCreated = false; + private MsoRequest msoRequest; + private String messageId; + + public VolumeGroupRollback() { + } + + public VolumeGroupRollback(VolumeGroupRollback vrb, String volumeGroupStackId, String messageId) + { + this.volumeGroupId = vrb.getVolumeGroupId(); + this.volumeGroupStackId = volumeGroupStackId; + this.tenantId = vrb.getTenantId(); + this.cloudSiteId = vrb.getCloudSiteId(); + this.volumeGroupCreated = vrb.isVolumeGroupCreated(); + this.msoRequest = vrb.getMsoRequest(); + this.messageId = messageId; + } + + public VolumeGroupRollback( + String volumeGroupId, + String volumeGroupStackId, + boolean volumeGroupCreated, + String tenantId, + String cloudSiteId, + MsoRequest msoRequest, + String messageId) + { + super(); + this.volumeGroupId = volumeGroupId; + this.volumeGroupStackId = volumeGroupStackId; + this.volumeGroupCreated = volumeGroupCreated; + this.tenantId = tenantId; + this.cloudSiteId = cloudSiteId; + this.msoRequest = msoRequest; + this.messageId = messageId; + } + + public String getVolumeGroupId() { + return volumeGroupId; + } + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + public String getVolumeGroupStackId() { + return volumeGroupStackId; + } + public void setVolumeGroupStackId(String volumeGroupStackId) { + this.volumeGroupStackId = volumeGroupStackId; + } + public String getTenantId() { + return tenantId; + } + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + public String getCloudSiteId() { + return cloudSiteId; + } + public void setCloudSiteId(String cloudSiteId) { + this.cloudSiteId = cloudSiteId; + } + public boolean isVolumeGroupCreated() { + return volumeGroupCreated; + } + public void setVolumeGroupCreated(boolean volumeGroupCreated) { + this.volumeGroupCreated = volumeGroupCreated; + } + public MsoRequest getMsoRequest() { + return msoRequest; + } + public void setMsoRequest(MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } + public String getMessageId() { + return messageId; + } + public void setMessageId(String messageId) { + this.messageId = messageId; + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/ContrailNetworkESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/ContrailNetworkESTest.java new file mode 100644 index 0000000000..50992bfd11 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/ContrailNetworkESTest.java @@ -0,0 +1,178 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:28:01 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.LinkedList; +import java.util.List; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class ContrailNetworkESTest extends ContrailNetworkESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + ContrailNetwork contrailNetwork0 = new ContrailNetwork((String) null, (String) null, (List<String>) null, (List<String>) null, (List<String>) null); + String string0 = contrailNetwork0.getShared(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + LinkedList<String> linkedList0 = new LinkedList<String>(); + ContrailNetwork contrailNetwork0 = new ContrailNetwork((String) null, "!1.", (List<String>) linkedList0, (List<String>) linkedList0, (List<String>) linkedList0); + List<String> list0 = contrailNetwork0.getRouteTargets(); + assertTrue(list0.isEmpty()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + LinkedList<String> linkedList0 = new LinkedList<String>(); + linkedList0.offer("Q"); + ContrailNetwork contrailNetwork0 = new ContrailNetwork("Q", "|", (List<String>) linkedList0, (List<String>) linkedList0, (List<String>) linkedList0); + contrailNetwork0.getRouteTargets(); + assertEquals("Q", contrailNetwork0.getShared()); + assertEquals("|", contrailNetwork0.getExternal()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + LinkedList<String> linkedList0 = new LinkedList<String>(); + ContrailNetwork contrailNetwork0 = new ContrailNetwork("", "RIEp7.g7I,Oi", (List<String>) linkedList0, (List<String>) linkedList0, (List<String>) linkedList0); + contrailNetwork0.getRouteTableFqdns(); + assertEquals("RIEp7.g7I,Oi", contrailNetwork0.getExternal()); + assertEquals("", contrailNetwork0.getShared()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + LinkedList<String> linkedList0 = new LinkedList<String>(); + linkedList0.offer("Q"); + ContrailNetwork contrailNetwork0 = new ContrailNetwork("Q", "|", (List<String>) linkedList0, (List<String>) linkedList0, (List<String>) linkedList0); + contrailNetwork0.getRouteTableFqdns(); + assertEquals("Q", contrailNetwork0.getShared()); + assertEquals("|", contrailNetwork0.getExternal()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + LinkedList<String> linkedList0 = new LinkedList<String>(); + ContrailNetwork contrailNetwork0 = new ContrailNetwork("", "", (List<String>) linkedList0, (List<String>) linkedList0, (List<String>) linkedList0); + List<String> list0 = contrailNetwork0.getPolicyFqdns(); + assertTrue(list0.isEmpty()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + LinkedList<String> linkedList0 = new LinkedList<String>(); + linkedList0.add((String) null); + ContrailNetwork contrailNetwork0 = new ContrailNetwork("false", "52", (List<String>) linkedList0, (List<String>) linkedList0, (List<String>) linkedList0); + contrailNetwork0.getPolicyFqdns(); + assertEquals("52", contrailNetwork0.getExternal()); + assertEquals("false", contrailNetwork0.getShared()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + ContrailNetwork contrailNetwork0 = new ContrailNetwork("", "", (List<String>) null, (List<String>) null, (List<String>) null); + String string0 = contrailNetwork0.getExternal(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + ContrailNetwork contrailNetwork0 = new ContrailNetwork(); + contrailNetwork0.getPolicyFqdns(); + assertEquals("false", contrailNetwork0.getExternal()); + assertEquals("false", contrailNetwork0.getShared()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + ContrailNetwork contrailNetwork0 = new ContrailNetwork(); + contrailNetwork0.getRouteTableFqdns(); + assertEquals("false", contrailNetwork0.getExternal()); + assertEquals("false", contrailNetwork0.getShared()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + ContrailNetwork contrailNetwork0 = new ContrailNetwork(); + contrailNetwork0.getRouteTargets(); + assertEquals("false", contrailNetwork0.getShared()); + assertEquals("false", contrailNetwork0.getExternal()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + ContrailNetwork contrailNetwork0 = new ContrailNetwork((String) null, (String) null, (List<String>) null, (List<String>) null, (List<String>) null); + String string0 = contrailNetwork0.getExternal(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + ContrailNetwork contrailNetwork0 = new ContrailNetwork(); + contrailNetwork0.setRouteTableFqdns((List<String>) null); + assertEquals("false", contrailNetwork0.getShared()); + assertEquals("false", contrailNetwork0.getExternal()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + ContrailNetwork contrailNetwork0 = new ContrailNetwork(); + contrailNetwork0.setPolicyFqdns((List<String>) null); + assertEquals("false", contrailNetwork0.getShared()); + assertEquals("false", contrailNetwork0.getExternal()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + ContrailNetwork contrailNetwork0 = new ContrailNetwork(); + contrailNetwork0.setRouteTargets((List<String>) null); + assertEquals("false", contrailNetwork0.getShared()); + assertEquals("false", contrailNetwork0.getExternal()); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + ContrailNetwork contrailNetwork0 = new ContrailNetwork(); + assertEquals("false", contrailNetwork0.getShared()); + + contrailNetwork0.setShared(""); + contrailNetwork0.getShared(); + assertEquals("false", contrailNetwork0.getExternal()); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + ContrailNetwork contrailNetwork0 = new ContrailNetwork(); + assertEquals("false", contrailNetwork0.getExternal()); + + contrailNetwork0.setExternal("fhtl}["); + assertEquals("false", contrailNetwork0.getShared()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + ContrailNetwork contrailNetwork0 = new ContrailNetwork(); + String string0 = contrailNetwork0.getShared(); + assertEquals("false", contrailNetwork0.getExternal()); + assertEquals("false", string0); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + ContrailNetwork contrailNetwork0 = new ContrailNetwork(); + String string0 = contrailNetwork0.getExternal(); + assertEquals("false", string0); + assertEquals("false", contrailNetwork0.getShared()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/ContrailNetworkESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/ContrailNetworkESTestscaffolding.java new file mode 100644 index 0000000000..125b3f4360 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/ContrailNetworkESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:28:01 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class ContrailNetworkESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.ContrailNetwork"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ContrailNetworkESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.nwrest.ContrailNetwork" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkErrorESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkErrorESTest.java new file mode 100644 index 0000000000..0f7b51184f --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkErrorESTest.java @@ -0,0 +1,37 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:21:05 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class CreateNetworkErrorESTest extends CreateNetworkErrorESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + CreateNetworkError createNetworkError0 = new CreateNetworkError(); + assertNull(createNetworkError0.getMessageId()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.INTERNAL; + CreateNetworkError createNetworkError0 = new CreateNetworkError(".iOuG[TmaW", msoExceptionCategory0, false, "&j1e*8kgmi]:2n?("); + assertEquals("&j1e*8kgmi]:2n?(", createNetworkError0.getMessageId()); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + CreateNetworkError createNetworkError0 = new CreateNetworkError(""); + assertNull(createNetworkError0.getCategory()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkErrorESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkErrorESTestscaffolding.java new file mode 100644 index 0000000000..50422e6783 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkErrorESTestscaffolding.java @@ -0,0 +1,87 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:21:05 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class CreateNetworkErrorESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.CreateNetworkError"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(CreateNetworkErrorESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.nwrest.CreateNetworkError", + "org.openecomp.mso.adapters.nwrest.NetworkResponseCommon", + "org.openecomp.mso.adapters.nwrest.NetworkExceptionResponse", + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(CreateNetworkErrorESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.nwrest.CreateNetworkError" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkRequestESTest.java new file mode 100644 index 0000000000..eb99054393 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkRequestESTest.java @@ -0,0 +1,356 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:05:55 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.Subnet; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class CreateNetworkRequestESTest extends CreateNetworkRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setTenantId("gTN<#W#q}?BdTz"); + String string0 = createNetworkRequest0.getTenantId(); + assertEquals("gTN<#W#q}?BdTz", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + LinkedList<Subnet> linkedList0 = new LinkedList<Subnet>(); + Subnet subnet0 = new Subnet(); + linkedList0.add(0, subnet0); + createNetworkRequest0.setSubnets(linkedList0); + List<Subnet> list0 = createNetworkRequest0.getSubnets(); + assertFalse(list0.isEmpty()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + ProviderVlanNetwork providerVlanNetwork0 = new ProviderVlanNetwork("", (List<Integer>) null); + createNetworkRequest0.setProviderVlanNetwork(providerVlanNetwork0); + ProviderVlanNetwork providerVlanNetwork1 = createNetworkRequest0.getProviderVlanNetwork(); + assertSame(providerVlanNetwork1, providerVlanNetwork0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setNetworkTypeVersion("Zt;$+0,06"); + String string0 = createNetworkRequest0.getNetworkTypeVersion(); + assertEquals("Zt;$+0,06", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setNetworkTypeVersion(""); + String string0 = createNetworkRequest0.getNetworkTypeVersion(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setNetworkType("+34spiczRb5|Z"); + String string0 = createNetworkRequest0.getNetworkType(); + assertEquals("+34spiczRb5|Z", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setNetworkType(""); + String string0 = createNetworkRequest0.getNetworkType(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setNetworkParams((Map<String, String>) null); + Map<String, String> map0 = createNetworkRequest0.getNetworkParams(); + assertNull(map0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + createNetworkRequest0.setNetworkParams(hashMap0); + hashMap0.put("B]gM^ `p!", "Subnet [subnetName="); + Map<String, String> map0 = createNetworkRequest0.getNetworkParams(); + assertEquals(1, map0.size()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setNetworkName("5rW0L[ye %khIOB;(P"); + String string0 = createNetworkRequest0.getNetworkName(); + assertEquals("5rW0L[ye %khIOB;(P", string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setNetworkName(""); + String string0 = createNetworkRequest0.getNetworkName(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setNetworkId(""); + String string0 = createNetworkRequest0.getNetworkId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setFailIfExists((Boolean) null); + Boolean boolean0 = createNetworkRequest0.getFailIfExists(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + ContrailNetwork contrailNetwork0 = new ContrailNetwork((String) null, (String) null, (List<String>) null, (List<String>) null, (List<String>) null); + createNetworkRequest0.setContrailNetwork(contrailNetwork0); + ContrailNetwork contrailNetwork1 = createNetworkRequest0.getContrailNetwork(); + assertNull(contrailNetwork1.getShared()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setCloudSiteId("5ISVyjyr^WpJF"); + String string0 = createNetworkRequest0.getCloudSiteId(); + assertEquals("5ISVyjyr^WpJF", string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setCloudSiteId(""); + String string0 = createNetworkRequest0.getCloudSiteId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setBackout((Boolean) null); + Boolean boolean0 = createNetworkRequest0.getBackout(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + Boolean boolean0 = createNetworkRequest0.getSkipAAI(); + createNetworkRequest0.setBackout(boolean0); + Boolean boolean1 = createNetworkRequest0.getBackout(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + // Undeclared exception! + try { + createNetworkRequest0.setNetworkTechnology(""); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // No enum constant org.openecomp.mso.adapters.nwrest.NetworkTechnology. + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + String string0 = createNetworkRequest0.getNetworkType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + String string0 = createNetworkRequest0.getNetworkTechnology(); + assertEquals("NEUTRON", string0); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + Boolean boolean0 = createNetworkRequest0.getFailIfExists(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + ProviderVlanNetwork providerVlanNetwork0 = createNetworkRequest0.getProviderVlanNetwork(); + assertNull(providerVlanNetwork0); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + MsoRequest msoRequest0 = createNetworkRequest0.getMsoRequest(); + assertNull(msoRequest0.getServiceInstanceId()); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + String string0 = createNetworkRequest0.getNetworkName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + String string0 = createNetworkRequest0.getNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + List<Subnet> list0 = createNetworkRequest0.getSubnets(); + assertNull(list0); + } + + @Test(timeout = 4000) + public void test27() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + String string0 = createNetworkRequest0.getNetworkTypeVersion(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test28() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + boolean boolean0 = createNetworkRequest0.isContrailRequest(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test29() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + Map<String, String> map0 = createNetworkRequest0.getNetworkParams(); + createNetworkRequest0.setNetworkParams(map0); + assertNull(createNetworkRequest0.getNetworkName()); + } + + @Test(timeout = 4000) + public void test30() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setTenantId(""); + String string0 = createNetworkRequest0.getTenantId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test31() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + LinkedList<Subnet> linkedList0 = new LinkedList<Subnet>(); + createNetworkRequest0.setSubnets(linkedList0); + List<Subnet> list0 = createNetworkRequest0.getSubnets(); + assertTrue(list0.isEmpty()); + } + + @Test(timeout = 4000) + public void test32() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + ContrailNetwork contrailNetwork0 = createNetworkRequest0.getContrailNetwork(); + assertNull(contrailNetwork0); + } + + @Test(timeout = 4000) + public void test33() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + Boolean boolean0 = Boolean.valueOf(true); + createNetworkRequest0.setFailIfExists(boolean0); + Boolean boolean1 = createNetworkRequest0.getFailIfExists(); + assertTrue(boolean1); + } + + @Test(timeout = 4000) + public void test34() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + String string0 = createNetworkRequest0.getTenantId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test35() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + String string0 = createNetworkRequest0.getCloudSiteId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test36() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setNetworkId(", allocationPools="); + String string0 = createNetworkRequest0.getNetworkId(); + assertEquals(", allocationPools=", string0); + } + + @Test(timeout = 4000) + public void test37() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + // Undeclared exception! + try { + createNetworkRequest0.setNetworkTechnology((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // Name is null + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test38() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + createNetworkRequest0.setMsoRequest((MsoRequest) null); + MsoRequest msoRequest0 = createNetworkRequest0.getMsoRequest(); + assertNull(msoRequest0); + } + + @Test(timeout = 4000) + public void test39() throws Throwable { + CreateNetworkRequest createNetworkRequest0 = new CreateNetworkRequest(); + Boolean boolean0 = createNetworkRequest0.getBackout(); + assertTrue(boolean0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkRequestESTestscaffolding.java new file mode 100644 index 0000000000..d58834422d --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkRequestESTestscaffolding.java @@ -0,0 +1,246 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:05:55 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class CreateNetworkRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.CreateNetworkRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(CreateNetworkRequestESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.map.JsonSerializableWithType", + "org.codehaus.jackson.map.HandlerInstantiator", + "org.codehaus.jackson.map.deser.StdDeserializerProvider", + "org.codehaus.jackson.map.SerializerFactory", + "org.codehaus.jackson.map.SerializerProvider", + "org.codehaus.jackson.map.type.TypeBindings", + "org.codehaus.jackson.map.SerializationConfig", + "org.codehaus.jackson.map.introspect.AnnotationMap", + "org.codehaus.jackson.JsonProcessingException", + "org.codehaus.jackson.map.introspect.Annotated", + "org.codehaus.jackson.io.InputDecorator", + "org.codehaus.jackson.map.Module", + "org.codehaus.jackson.map.util.Annotations", + "org.codehaus.jackson.map.type.TypeModifier", + "org.codehaus.jackson.sym.NameN", + "org.codehaus.jackson.JsonGenerator", + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$1", + "org.codehaus.jackson.map.JsonSerializable", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.node.BaseJsonNode", + "org.codehaus.jackson.map.ObjectReader", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.map.DeserializerProvider", + "org.codehaus.jackson.node.ValueNode", + "org.codehaus.jackson.map.ser.BeanSerializerFactory", + "org.codehaus.jackson.map.JsonSerializer", + "org.codehaus.jackson.map.introspect.AnnotatedWithParams", + "org.codehaus.jackson.map.AnnotationIntrospector", + "org.codehaus.jackson.map.MappingJsonFactory", + "org.codehaus.jackson.map.MapperConfig$Impl", + "org.codehaus.jackson.sym.Name1", + "org.codehaus.jackson.sym.Name2", + "org.openecomp.mso.openstack.beans.Subnet", + "org.codehaus.jackson.sym.Name3", + "org.codehaus.jackson.map.introspect.MethodFilter", + "org.codehaus.jackson.map.ser.StdSerializerProvider", + "org.codehaus.jackson.map.deser.StdDeserializationContext", + "org.codehaus.jackson.type.TypeReference", + "org.codehaus.jackson.map.ClassIntrospector", + "org.codehaus.jackson.map.AnnotationIntrospector$Pair", + "org.codehaus.jackson.map.PropertyNamingStrategy$LowerCaseWithUnderscoresStrategy", + "org.codehaus.jackson.map.MapperConfig$ConfigFeature", + "org.codehaus.jackson.map.SerializationConfig$Feature", + "org.codehaus.jackson.Versioned", + "org.codehaus.jackson.io.IOContext", + "org.codehaus.jackson.map.type.TypeBase", + "org.codehaus.jackson.map.ser.BasicSerializerFactory", + "org.codehaus.jackson.map.PropertyNamingStrategy", + "org.codehaus.jackson.node.ContainerNode", + "org.codehaus.jackson.map.jsontype.NamedType", + "org.codehaus.jackson.map.ser.FilterProvider", + "org.codehaus.jackson.map.introspect.AnnotatedConstructor", + "org.codehaus.jackson.map.DeserializationConfig", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.openecomp.mso.adapters.nwrest.NetworkRequestCommon", + "org.codehaus.jackson.map.type.TypeFactory", + "org.codehaus.jackson.impl.ReaderBasedParser", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer$TableInfo", + "org.codehaus.jackson.JsonEncoding", + "org.codehaus.jackson.map.type.MapLikeType", + "org.codehaus.jackson.map.JsonDeserializer", + "org.codehaus.jackson.map.PropertyNamingStrategy$PropertyNamingStrategyBase", + "org.codehaus.jackson.node.ObjectNode", + "org.codehaus.jackson.map.ser.std.SerializerBase", + "org.codehaus.jackson.map.type.CollectionLikeType", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$MinimalMethodFilter", + "org.codehaus.jackson.map.DeserializationConfig$Feature", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer$Bucket", + "org.codehaus.jackson.map.introspect.AnnotatedMethodMap", + "org.codehaus.jackson.impl.JsonParserMinimalBase", + "org.codehaus.jackson.map.type.TypeParser", + "org.codehaus.jackson.map.introspect.POJOPropertiesCollector", + "org.codehaus.jackson.JsonParseException", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$SetterMethodFilter", + "org.codehaus.jackson.map.introspect.VisibilityChecker", + "org.codehaus.jackson.map.introspect.AnnotatedField", + "org.codehaus.jackson.impl.JsonGeneratorBase", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.util.ByteArrayBuilder", + "org.codehaus.jackson.map.ser.impl.FailingSerializer", + "org.codehaus.jackson.PrettyPrinter", + "org.codehaus.jackson.JsonToken", + "org.codehaus.jackson.map.jsontype.SubtypeResolver", + "org.codehaus.jackson.map.type.SimpleType", + "org.codehaus.jackson.impl.Utf8Generator", + "org.codehaus.jackson.node.NumericNode", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$SetterAndGetterMethodFilter", + "org.codehaus.jackson.JsonNode", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.codehaus.jackson.map.ObjectWriter", + "org.codehaus.jackson.schema.SchemaAware", + "org.codehaus.jackson.io.OutputDecorator", + "org.openecomp.mso.adapters.nwrest.CreateNetworkRequest", + "org.codehaus.jackson.FormatSchema", + "org.codehaus.jackson.format.MatchStrength", + "org.codehaus.jackson.ObjectCodec", + "org.codehaus.jackson.map.introspect.AnnotatedMethod", + "org.codehaus.jackson.JsonGenerationException", + "org.codehaus.jackson.format.InputAccessor", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.node.ArrayNode", + "org.codehaus.jackson.util.BufferRecycler", + "org.codehaus.jackson.io.SegmentedStringWriter", + "org.openecomp.mso.adapters.nwrest.NetworkTechnology", + "org.codehaus.jackson.map.jsontype.TypeResolverBuilder", + "org.codehaus.jackson.map.type.HierarchicType", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$GetterMethodFilter", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.map.BeanDescription", + "org.codehaus.jackson.JsonParser$1", + "org.codehaus.jackson.impl.WriterBasedGenerator", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.sym.Name", + "org.codehaus.jackson.Version", + "org.codehaus.jackson.io.CharacterEscapes", + "org.codehaus.jackson.map.introspect.BasicBeanDescription", + "org.codehaus.jackson.schema.JsonSchema", + "org.codehaus.jackson.util.TokenBuffer", + "org.codehaus.jackson.map.annotate.JsonSerialize$Inclusion", + "org.codehaus.jackson.map.MappingIterator", + "org.codehaus.jackson.map.DeserializationContext", + "org.codehaus.jackson.map.ObjectMapper$DefaultTyping", + "org.codehaus.jackson.impl.JsonParserBase", + "org.codehaus.jackson.map.JsonMappingException", + "org.codehaus.jackson.map.introspect.AnnotatedMember", + "org.codehaus.jackson.node.JsonNodeFactory", + "org.codehaus.jackson.type.JavaType", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.annotate.JsonTypeInfo$As", + "org.codehaus.jackson.map.annotate.JsonRootName", + "org.codehaus.jackson.JsonParser", + "org.codehaus.jackson.node.NullNode", + "org.codehaus.jackson.map.InjectableValues", + "org.codehaus.jackson.map.jsontype.impl.StdSubtypeResolver", + "org.openecomp.mso.entity.MsoRequest", + "org.codehaus.jackson.node.TreeTraversingParser", + "org.codehaus.jackson.map.type.CollectionType", + "org.codehaus.jackson.map.MapperConfig", + "org.codehaus.jackson.map.Module$SetupContext", + "org.codehaus.jackson.map.introspect.VisibilityChecker$1", + "org.codehaus.jackson.io.UTF8Writer", + "org.openecomp.mso.adapters.nwrest.ContrailNetwork", + "org.codehaus.jackson.map.type.MapType", + "org.openecomp.mso.adapters.nwrest.ProviderVlanNetwork", + "org.codehaus.jackson.annotate.JsonAutoDetect", + "org.codehaus.jackson.map.type.ArrayType", + "org.codehaus.jackson.map.ClassIntrospector$MixInResolver" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(CreateNetworkRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.nwrest.NetworkTechnology", + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkResponseESTest.java new file mode 100644 index 0000000000..f946c1ebda --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkResponseESTest.java @@ -0,0 +1,241 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:26:16 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.openstack.beans.NetworkRollback; +import java.util.HashMap; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class CreateNetworkResponseESTest extends CreateNetworkResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + createNetworkResponse0.setSubnetMap(hashMap0); + Map<String, String> map0 = createNetworkResponse0.getSubnetMap(); + assertTrue(map0.isEmpty()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + hashMap0.put("", (String) null); + createNetworkResponse0.setSubnetMap(hashMap0); + Map<String, String> map0 = createNetworkResponse0.getSubnetMap(); + assertFalse(map0.isEmpty()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + createNetworkResponse0.setRollback((NetworkRollback) null); + NetworkRollback networkRollback0 = createNetworkResponse0.getRollback(); + assertNull(networkRollback0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNetworkCreated(true); + createNetworkResponse0.setRollback(networkRollback0); + NetworkRollback networkRollback1 = createNetworkResponse0.getRollback(); + assertNull(networkRollback1.getNetworkName()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + Boolean boolean0 = Boolean.FALSE; + NetworkRollback networkRollback0 = new NetworkRollback(); + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse("RmsrRU", "D=<", "D=<", "RmsrRU", boolean0, (Map<String, String>) null, networkRollback0, "0V"); + String string0 = createNetworkResponse0.getNeutronNetworkId(); + assertEquals("RmsrRU", createNetworkResponse0.getNetworkFqdn()); + assertEquals("D=<", createNetworkResponse0.getNetworkStackId()); + assertEquals("RmsrRU", createNetworkResponse0.getNetworkId()); + assertEquals("D=<", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + Boolean boolean0 = Boolean.FALSE; + NetworkRollback networkRollback0 = new NetworkRollback(); + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse("", "", "SouUi*E=\"K.O", "", boolean0, (Map<String, String>) null, networkRollback0, ""); + String string0 = createNetworkResponse0.getNeutronNetworkId(); + assertEquals("", createNetworkResponse0.getNetworkFqdn()); + assertEquals("", string0); + assertEquals("", createNetworkResponse0.getNetworkId()); + assertEquals("SouUi*E=\"K.O", createNetworkResponse0.getNetworkStackId()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + Boolean boolean0 = Boolean.valueOf(true); + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse("", "", "", "NetworkRollback [networkId=", boolean0, (Map<String, String>) null, (NetworkRollback) null, (String) null); + String string0 = createNetworkResponse0.getNetworkStackId(); + assertEquals("", createNetworkResponse0.getNeutronNetworkId()); + assertEquals("", createNetworkResponse0.getNetworkId()); + assertNotNull(string0); + assertEquals("NetworkRollback [networkId=", createNetworkResponse0.getNetworkFqdn()); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + Boolean boolean0 = Boolean.valueOf(", tenantId="); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + NetworkRollback networkRollback0 = new NetworkRollback(); + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(", tenantId=", "L", "L", ", tenantId=", boolean0, (Map<String, String>) hashMap0, networkRollback0, "o+oNP;9q:Yc_JWzxM"); + String string0 = createNetworkResponse0.getNetworkId(); + assertEquals("L", createNetworkResponse0.getNetworkStackId()); + assertEquals(", tenantId=", string0); + assertEquals("L", createNetworkResponse0.getNeutronNetworkId()); + assertEquals(", tenantId=", createNetworkResponse0.getNetworkFqdn()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + Boolean boolean0 = Boolean.valueOf(true); + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse("", "", "", "NetworkRollback [networkId=", boolean0, (Map<String, String>) null, (NetworkRollback) null, (String) null); + String string0 = createNetworkResponse0.getNetworkId(); + assertEquals("", createNetworkResponse0.getNetworkStackId()); + assertNotNull(string0); + assertEquals("NetworkRollback [networkId=", createNetworkResponse0.getNetworkFqdn()); + assertEquals("", string0); + assertEquals("", createNetworkResponse0.getNeutronNetworkId()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + createNetworkResponse0.setNetworkFqdn(",E4f.8o)&~"); + String string0 = createNetworkResponse0.getNetworkFqdn(); + assertEquals(",E4f.8o)&~", string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + createNetworkResponse0.setNetworkFqdn(""); + String string0 = createNetworkResponse0.getNetworkFqdn(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + Boolean boolean0 = createNetworkResponse0.getNetworkCreated(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + Boolean boolean0 = Boolean.FALSE; + NetworkRollback networkRollback0 = new NetworkRollback(); + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse("", "", "SouUi*E=\"K.O", "", boolean0, (Map<String, String>) null, networkRollback0, ""); + createNetworkResponse0.getNetworkCreated(); + assertEquals("", createNetworkResponse0.getNetworkFqdn()); + assertEquals("", createNetworkResponse0.getNeutronNetworkId()); + assertEquals("SouUi*E=\"K.O", createNetworkResponse0.getNetworkStackId()); + assertEquals("", createNetworkResponse0.getNetworkId()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + String string0 = createNetworkResponse0.getNetworkStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + String string0 = createNetworkResponse0.getNeutronNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + String string0 = createNetworkResponse0.getNetworkFqdn(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + createNetworkResponse0.setNetworkStackId("]xrJb:cD,G(|6B0("); + String string0 = createNetworkResponse0.getNetworkStackId(); + assertEquals("]xrJb:cD,G(|6B0(", string0); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + String string0 = createNetworkResponse0.getNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + Boolean boolean0 = Boolean.valueOf(true); + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse("", "", "", "NetworkRollback [networkId=", boolean0, (Map<String, String>) null, (NetworkRollback) null, (String) null); + createNetworkResponse0.getNetworkCreated(); + assertEquals("NetworkRollback [networkId=", createNetworkResponse0.getNetworkFqdn()); + assertEquals("", createNetworkResponse0.getNetworkStackId()); + assertEquals("", createNetworkResponse0.getNetworkId()); + assertEquals("", createNetworkResponse0.getNeutronNetworkId()); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + Map<String, String> map0 = createNetworkResponse0.getSubnetMap(); + assertNull(map0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + NetworkRollback networkRollback0 = createNetworkResponse0.getRollback(); + assertFalse(networkRollback0.getNetworkCreated()); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + createNetworkResponse0.setNetworkId("]xrJb:cD,G(|6B0("); + assertNull(createNetworkResponse0.getNetworkStackId()); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + Boolean boolean0 = Boolean.valueOf(", tenantId="); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + NetworkRollback networkRollback0 = new NetworkRollback(); + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(", tenantId=", "L", "L", ", tenantId=", boolean0, (Map<String, String>) hashMap0, networkRollback0, "o+oNP;9q:Yc_JWzxM"); + assertEquals("L", createNetworkResponse0.getNeutronNetworkId()); + + createNetworkResponse0.setNeutronNetworkId(", tenantId="); + assertEquals(", tenantId=", createNetworkResponse0.getNetworkId()); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + CreateNetworkResponse createNetworkResponse0 = new CreateNetworkResponse(); + Boolean boolean0 = Boolean.TRUE; + createNetworkResponse0.setNetworkCreated(boolean0); + assertNull(createNetworkResponse0.getNetworkStackId()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkResponseESTestscaffolding.java new file mode 100644 index 0000000000..be0fbf8edb --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/CreateNetworkResponseESTestscaffolding.java @@ -0,0 +1,100 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:26:16 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class CreateNetworkResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.CreateNetworkResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(CreateNetworkResponseESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.nwrest.NetworkResponseCommon", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.openstack.beans.NetworkRollback", + "org.openecomp.mso.adapters.nwrest.CreateNetworkResponse", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(CreateNetworkResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkErrorESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkErrorESTest.java new file mode 100644 index 0000000000..ad5a65b9f3 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkErrorESTest.java @@ -0,0 +1,37 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:20:47 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class DeleteNetworkErrorESTest extends DeleteNetworkErrorESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.IO; + DeleteNetworkError deleteNetworkError0 = new DeleteNetworkError("9X", msoExceptionCategory0, false, "ew9AjW>{Sk."); + assertEquals("9X", deleteNetworkError0.getMessage()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + DeleteNetworkError deleteNetworkError0 = new DeleteNetworkError(); + assertNull(deleteNetworkError0.getCategory()); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + DeleteNetworkError deleteNetworkError0 = new DeleteNetworkError("9X"); + assertNull(deleteNetworkError0.getCategory()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkErrorESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkErrorESTestscaffolding.java new file mode 100644 index 0000000000..56788169f6 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkErrorESTestscaffolding.java @@ -0,0 +1,87 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:20:47 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class DeleteNetworkErrorESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.DeleteNetworkError"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DeleteNetworkErrorESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.nwrest.NetworkResponseCommon", + "org.openecomp.mso.adapters.nwrest.NetworkExceptionResponse", + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.adapters.nwrest.DeleteNetworkError", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(DeleteNetworkErrorESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.nwrest.DeleteNetworkError" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkRequestESTest.java new file mode 100644 index 0000000000..67867b4b38 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkRequestESTest.java @@ -0,0 +1,149 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:26:39 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.entity.MsoRequest; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class DeleteNetworkRequestESTest extends DeleteNetworkRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + deleteNetworkRequest0.setTenantId("jaxb.formatted.output"); + String string0 = deleteNetworkRequest0.getTenantId(); + assertEquals("jaxb.formatted.output", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + deleteNetworkRequest0.setNetworkType("v6GIJ"); + String string0 = deleteNetworkRequest0.getNetworkType(); + assertEquals("v6GIJ", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + deleteNetworkRequest0.setNetworkType(""); + String string0 = deleteNetworkRequest0.getNetworkType(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + deleteNetworkRequest0.setNetworkStackId(":E:r|{0%c~Z5LYz0S8"); + String string0 = deleteNetworkRequest0.getNetworkStackId(); + assertEquals(":E:r|{0%c~Z5LYz0S8", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + deleteNetworkRequest0.setNetworkStackId(""); + String string0 = deleteNetworkRequest0.getNetworkStackId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + deleteNetworkRequest0.setNetworkId("jaxb.formatted.output"); + String string0 = deleteNetworkRequest0.getNetworkId(); + assertEquals("jaxb.formatted.output", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + deleteNetworkRequest0.setMsoRequest((MsoRequest) null); + MsoRequest msoRequest0 = deleteNetworkRequest0.getMsoRequest(); + assertNull(msoRequest0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + deleteNetworkRequest0.setCloudSiteId(""); + String string0 = deleteNetworkRequest0.getCloudSiteId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + String string0 = deleteNetworkRequest0.getNetworkStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + String string0 = deleteNetworkRequest0.getNetworkType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + deleteNetworkRequest0.setNetworkId(""); + String string0 = deleteNetworkRequest0.getNetworkId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + String string0 = deleteNetworkRequest0.getCloudSiteId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + deleteNetworkRequest0.setTenantId(""); + String string0 = deleteNetworkRequest0.getTenantId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + String string0 = deleteNetworkRequest0.getNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + String string0 = deleteNetworkRequest0.getTenantId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + deleteNetworkRequest0.setCloudSiteId("'+#+m"); + String string0 = deleteNetworkRequest0.getCloudSiteId(); + assertEquals("'+#+m", string0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + DeleteNetworkRequest deleteNetworkRequest0 = new DeleteNetworkRequest(); + MsoRequest msoRequest0 = deleteNetworkRequest0.getMsoRequest(); + deleteNetworkRequest0.setMsoRequest(msoRequest0); + assertTrue(deleteNetworkRequest0.isSynchronous()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkRequestESTestscaffolding.java new file mode 100644 index 0000000000..0dc2789a37 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkRequestESTestscaffolding.java @@ -0,0 +1,99 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:26:39 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class DeleteNetworkRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.DeleteNetworkRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DeleteNetworkRequestESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.nwrest.NetworkRequestCommon", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.adapters.nwrest.DeleteNetworkRequest", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(DeleteNetworkRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkResponseESTest.java new file mode 100644 index 0000000000..ef93be54d8 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkResponseESTest.java @@ -0,0 +1,73 @@ +/* + * This file was automatically generated by EvoSuite + * Thu Nov 10 15:50:13 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class DeleteNetworkResponseESTest extends DeleteNetworkResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + DeleteNetworkResponse deleteNetworkResponse0 = new DeleteNetworkResponse(); + String string0 = deleteNetworkResponse0.getNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + Boolean boolean0 = Boolean.valueOf("!$j-,Qjk_"); + DeleteNetworkResponse deleteNetworkResponse0 = new DeleteNetworkResponse("!$j-,Qjk_", boolean0, "!$j-,Qjk_"); + String string0 = deleteNetworkResponse0.getNetworkId(); + assertEquals("!$j-,Qjk_", string0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + Boolean boolean0 = Boolean.valueOf("!$j-,Qjk_"); + DeleteNetworkResponse deleteNetworkResponse0 = new DeleteNetworkResponse("!$j-,Qjk_", boolean0, "!$j-,Qjk_"); + Boolean boolean1 = Boolean.TRUE; + deleteNetworkResponse0.setNetworkDeleted(boolean1); + Boolean boolean2 = deleteNetworkResponse0.getNetworkDeleted(); + assertFalse(boolean2.equals((Object)boolean0)); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + Boolean boolean0 = Boolean.FALSE; + DeleteNetworkResponse deleteNetworkResponse0 = new DeleteNetworkResponse("", boolean0, ""); + String string0 = deleteNetworkResponse0.getNetworkId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + Boolean boolean0 = Boolean.FALSE; + DeleteNetworkResponse deleteNetworkResponse0 = new DeleteNetworkResponse("", boolean0, ""); + Boolean boolean1 = deleteNetworkResponse0.getNetworkDeleted(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + Boolean boolean0 = Boolean.FALSE; + DeleteNetworkResponse deleteNetworkResponse0 = new DeleteNetworkResponse("", boolean0, ""); + deleteNetworkResponse0.setNetworkId(""); + assertEquals("", deleteNetworkResponse0.getMessageId()); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + DeleteNetworkResponse deleteNetworkResponse0 = new DeleteNetworkResponse(); + Boolean boolean0 = deleteNetworkResponse0.getNetworkDeleted(); + assertNull(boolean0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkResponseESTestscaffolding.java new file mode 100644 index 0000000000..7c89224e1a --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkResponseESTestscaffolding.java @@ -0,0 +1,98 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Thu Nov 10 15:50:13 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class DeleteNetworkResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.DeleteNetworkResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DeleteNetworkResponseESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.nwrest.NetworkResponseCommon", + "org.openecomp.mso.adapters.nwrest.DeleteNetworkResponse", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(DeleteNetworkResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/NetworkExceptionResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/NetworkExceptionResponseESTest.java new file mode 100644 index 0000000000..3f23287e0f --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/NetworkExceptionResponseESTest.java @@ -0,0 +1,86 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:19:39 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class NetworkExceptionResponseESTest extends NetworkExceptionResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.IO; + NetworkExceptionResponse networkExceptionResponse0 = new NetworkExceptionResponse("('zix", msoExceptionCategory0, true, "3)w4."); + Boolean boolean0 = networkExceptionResponse0.getRolledBack(); + assertEquals("('zix", networkExceptionResponse0.getMessage()); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.INTERNAL; + NetworkExceptionResponse networkExceptionResponse0 = new NetworkExceptionResponse("9L(TNeou", msoExceptionCategory0, false, "9L(TNeou"); + Boolean boolean0 = networkExceptionResponse0.getRolledBack(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + NetworkExceptionResponse networkExceptionResponse0 = new NetworkExceptionResponse(""); + String string0 = networkExceptionResponse0.getMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + NetworkExceptionResponse networkExceptionResponse0 = new NetworkExceptionResponse(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.IO; + networkExceptionResponse0.setCategory(msoExceptionCategory0); + MsoExceptionCategory msoExceptionCategory1 = networkExceptionResponse0.getCategory(); + assertEquals(MsoExceptionCategory.IO, msoExceptionCategory1); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + NetworkExceptionResponse networkExceptionResponse0 = new NetworkExceptionResponse(); + Boolean boolean0 = networkExceptionResponse0.getRolledBack(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + NetworkExceptionResponse networkExceptionResponse0 = new NetworkExceptionResponse(""); + networkExceptionResponse0.getCategory(); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + NetworkExceptionResponse networkExceptionResponse0 = new NetworkExceptionResponse(); + networkExceptionResponse0.setMessage("USERDATA"); + String string0 = networkExceptionResponse0.getMessage(); + assertEquals("USERDATA", string0); + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + NetworkExceptionResponse networkExceptionResponse0 = new NetworkExceptionResponse(); + networkExceptionResponse0.setRolledBack((Boolean) null); + assertNull(networkExceptionResponse0.getCategory()); + } + + @Test(timeout = 4000) + public void test8() throws Throwable { + NetworkExceptionResponse networkExceptionResponse0 = new NetworkExceptionResponse(); + String string0 = networkExceptionResponse0.getMessage(); + assertNull(string0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/NetworkExceptionResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/NetworkExceptionResponseESTestscaffolding.java new file mode 100644 index 0000000000..8cc13647f0 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/NetworkExceptionResponseESTestscaffolding.java @@ -0,0 +1,96 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:19:39 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class NetworkExceptionResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.NetworkExceptionResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(NetworkExceptionResponseESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.nwrest.NetworkResponseCommon", + "org.openecomp.mso.adapters.nwrest.NetworkExceptionResponse", + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(NetworkExceptionResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/ProviderVlanNetworkESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/ProviderVlanNetworkESTest.java new file mode 100644 index 0000000000..871683ad6f --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/ProviderVlanNetworkESTest.java @@ -0,0 +1,81 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:29:16 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.LinkedList; +import java.util.List; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class ProviderVlanNetworkESTest extends ProviderVlanNetworkESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + ProviderVlanNetwork providerVlanNetwork0 = new ProviderVlanNetwork(); + List<Integer> list0 = providerVlanNetwork0.getVlans(); + assertNull(list0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + LinkedList<Integer> linkedList0 = new LinkedList<Integer>(); + Integer integer0 = new Integer((-1244)); + linkedList0.add(integer0); + ProviderVlanNetwork providerVlanNetwork0 = new ProviderVlanNetwork("PF?v'FLs", (List<Integer>) linkedList0); + List<Integer> list0 = providerVlanNetwork0.getVlans(); + assertEquals(1, list0.size()); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + ProviderVlanNetwork providerVlanNetwork0 = new ProviderVlanNetwork(); + String string0 = providerVlanNetwork0.getPhysicalNetworkName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + ProviderVlanNetwork providerVlanNetwork0 = new ProviderVlanNetwork("I;{", (List<Integer>) null); + String string0 = providerVlanNetwork0.getPhysicalNetworkName(); + assertEquals("I;{", string0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + ProviderVlanNetwork providerVlanNetwork0 = new ProviderVlanNetwork("I;{", (List<Integer>) null); + providerVlanNetwork0.setPhysicalNetworkName("h8H"); + assertEquals("h8H", providerVlanNetwork0.getPhysicalNetworkName()); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + LinkedList<Integer> linkedList0 = new LinkedList<Integer>(); + ProviderVlanNetwork providerVlanNetwork0 = new ProviderVlanNetwork("", (List<Integer>) linkedList0); + String string0 = providerVlanNetwork0.getPhysicalNetworkName(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + ProviderVlanNetwork providerVlanNetwork0 = new ProviderVlanNetwork(); + LinkedList<Integer> linkedList0 = new LinkedList<Integer>(); + providerVlanNetwork0.setVlans(linkedList0); + assertEquals(0, linkedList0.size()); + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + LinkedList<Integer> linkedList0 = new LinkedList<Integer>(); + ProviderVlanNetwork providerVlanNetwork0 = new ProviderVlanNetwork("3UmMF;h", (List<Integer>) linkedList0); + List<Integer> list0 = providerVlanNetwork0.getVlans(); + assertTrue(list0.isEmpty()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/ProviderVlanNetworkESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/ProviderVlanNetworkESTestscaffolding.java new file mode 100644 index 0000000000..93149f6b50 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/ProviderVlanNetworkESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:29:16 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class ProviderVlanNetworkESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.ProviderVlanNetwork"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ProviderVlanNetworkESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.nwrest.ProviderVlanNetwork" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/QueryNetworkErrorESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/QueryNetworkErrorESTest.java new file mode 100644 index 0000000000..645d506936 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/QueryNetworkErrorESTest.java @@ -0,0 +1,23 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:17:33 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class QueryNetworkErrorESTest extends QueryNetworkErrorESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + QueryNetworkError queryNetworkError0 = new QueryNetworkError(); + assertNull(queryNetworkError0.getMessage()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/QueryNetworkErrorESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/QueryNetworkErrorESTestscaffolding.java new file mode 100644 index 0000000000..700d2aaf74 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/QueryNetworkErrorESTestscaffolding.java @@ -0,0 +1,87 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:17:33 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class QueryNetworkErrorESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.QueryNetworkError"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(QueryNetworkErrorESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.nwrest.NetworkResponseCommon", + "org.openecomp.mso.adapters.nwrest.NetworkExceptionResponse", + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.openecomp.mso.adapters.nwrest.QueryNetworkError" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(QueryNetworkErrorESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.nwrest.QueryNetworkError" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponseESTest.java new file mode 100644 index 0000000000..be18fcc1c4 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponseESTest.java @@ -0,0 +1,296 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:16:38 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.openecomp.mso.openstack.beans.NetworkStatus; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class QueryNetworkResponseESTest extends QueryNetworkResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + NetworkStatus networkStatus0 = NetworkStatus.DOWN; + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse("'Y=Kq<f!!gJ{1Q6v", "", "", networkStatus0, (Map<String, String>) hashMap0); + LinkedList<Integer> linkedList0 = new LinkedList<Integer>(); + queryNetworkResponse0.setVlans(linkedList0); + queryNetworkResponse0.getVlans(); + assertEquals("", queryNetworkResponse0.getNetworkStackId()); + assertEquals("'Y=Kq<f!!gJ{1Q6v", queryNetworkResponse0.getNetworkId()); + assertEquals("", queryNetworkResponse0.getNeutronNetworkId()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + LinkedList<Integer> linkedList0 = new LinkedList<Integer>(); + Integer integer0 = new Integer(1256); + linkedList0.add(integer0); + queryNetworkResponse0.setVlans(linkedList0); + List<Integer> list0 = queryNetworkResponse0.getVlans(); + assertFalse(list0.isEmpty()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + NetworkStatus networkStatus0 = NetworkStatus.UNKNOWN; + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(" v7FX_$8q *", "~MSM=Lj 78BbfMF4", " v7FX_$8q *", networkStatus0, (Map<String, String>) hashMap0); + queryNetworkResponse0.setSubnetIdMap(hashMap0); + queryNetworkResponse0.getSubnetIdMap(); + assertEquals(" v7FX_$8q *", queryNetworkResponse0.getNetworkId()); + assertEquals("~MSM=Lj 78BbfMF4", queryNetworkResponse0.getNeutronNetworkId()); + assertEquals(" v7FX_$8q *", queryNetworkResponse0.getNetworkStackId()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + NetworkStatus networkStatus0 = NetworkStatus.UNKNOWN; + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse("6+6JBO^tv]?e;D6`Hh", "+QU\"j=Jt>;9w<w[9~c.", "6+6JBO^tv]?e;D6`Hh", networkStatus0, (Map<String, String>) hashMap0); + queryNetworkResponse0.setSubnetIdMap(hashMap0); + hashMap0.put((String) null, (String) null); + queryNetworkResponse0.getSubnetIdMap(); + assertEquals("6+6JBO^tv]?e;D6`Hh", queryNetworkResponse0.getNetworkId()); + assertEquals("6+6JBO^tv]?e;D6`Hh", queryNetworkResponse0.getNetworkStackId()); + assertEquals("+QU\"j=Jt>;9w<w[9~c.", queryNetworkResponse0.getNeutronNetworkId()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + LinkedList<String> linkedList0 = new LinkedList<String>(); + linkedList0.push("s<z*H=#g"); + queryNetworkResponse0.setRouteTargets(linkedList0); + List<String> list0 = queryNetworkResponse0.getRouteTargets(); + assertFalse(list0.isEmpty()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + NetworkStatus networkStatus0 = NetworkStatus.UNKNOWN; + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse("", "ACTIVE", "ACTIVE", networkStatus0, (Map<String, String>) null); + String string0 = queryNetworkResponse0.getNeutronNetworkId(); + assertEquals("", queryNetworkResponse0.getNetworkId()); + assertEquals("ACTIVE", queryNetworkResponse0.getNetworkStackId()); + assertEquals("ACTIVE", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + NetworkStatus networkStatus0 = NetworkStatus.DOWN; + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse("'Y=Kq<f!!gJ{1Q6v", "", "", networkStatus0, (Map<String, String>) hashMap0); + String string0 = queryNetworkResponse0.getNeutronNetworkId(); + assertEquals("", string0); + assertEquals("", queryNetworkResponse0.getNetworkStackId()); + assertEquals("'Y=Kq<f!!gJ{1Q6v", queryNetworkResponse0.getNetworkId()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + NetworkStatus networkStatus0 = NetworkStatus.UNKNOWN; + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse("ZLW;0Nz", "ZLW;0Nz", "ZLW;0Nz", networkStatus0, (Map<String, String>) null); + String string0 = queryNetworkResponse0.getNetworkStackId(); + assertEquals("ZLW;0Nz", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + NetworkStatus networkStatus0 = NetworkStatus.DOWN; + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse("", "", "", networkStatus0, (Map<String, String>) null); + String string0 = queryNetworkResponse0.getNetworkStackId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + NetworkStatus networkStatus0 = NetworkStatus.UNKNOWN; + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(" v7FX_$8q *", "~MSM=Lj 78BbfMF4", " v7FX_$8q *", networkStatus0, (Map<String, String>) hashMap0); + queryNetworkResponse0.getNetworkOutputs(); + assertEquals("~MSM=Lj 78BbfMF4", queryNetworkResponse0.getNeutronNetworkId()); + assertEquals(" v7FX_$8q *", queryNetworkResponse0.getNetworkStackId()); + assertEquals(" v7FX_$8q *", queryNetworkResponse0.getNetworkId()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + NetworkStatus networkStatus0 = NetworkStatus.UNKNOWN; + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse("6+6JBO^tv]?e;D6`Hh", "+QU\"j=Jt>;9w<w[9~c.", "6+6JBO^tv]?e;D6`Hh", networkStatus0, (Map<String, String>) hashMap0); + hashMap0.put((String) null, (String) null); + queryNetworkResponse0.getNetworkOutputs(); + assertEquals("6+6JBO^tv]?e;D6`Hh", queryNetworkResponse0.getNetworkId()); + assertEquals("+QU\"j=Jt>;9w<w[9~c.", queryNetworkResponse0.getNeutronNetworkId()); + assertEquals("6+6JBO^tv]?e;D6`Hh", queryNetworkResponse0.getNetworkStackId()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + queryNetworkResponse0.setNetworkId(""); + String string0 = queryNetworkResponse0.getNetworkId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + Boolean boolean0 = new Boolean(false); + queryNetworkResponse0.setNetworkExists(boolean0); + Boolean boolean1 = queryNetworkResponse0.getNetworkExists(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + queryNetworkResponse0.setNeutronNetworkId("org.openecomp.mso.openstack.beans.NetworkStatus"); + assertNull(queryNetworkResponse0.getNetworkId()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + String string0 = queryNetworkResponse0.getNetworkStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + Boolean boolean0 = queryNetworkResponse0.getNetworkExists(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + Map<String, String> map0 = queryNetworkResponse0.getSubnetIdMap(); + assertNull(map0); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + // Undeclared exception! + try { + queryNetworkResponse0.toJsonString(); + fail("Expecting exception: VerifyError"); + + } catch(VerifyError e) { + // + // (class: org/codehaus/jackson/map/MapperConfig, method: <clinit> signature: ()V) Bad type in putfield/putstatic + // + verifyException("org.codehaus.jackson.map.ObjectMapper", e); + } + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + Map<String, String> map0 = queryNetworkResponse0.getNetworkOutputs(); + assertNull(map0); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + List<Integer> list0 = queryNetworkResponse0.getVlans(); + assertNull(list0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + NetworkStatus networkStatus0 = NetworkStatus.DOWN; + queryNetworkResponse0.setNetworkStatus(networkStatus0); + NetworkStatus networkStatus1 = queryNetworkResponse0.getNetworkStatus(); + assertEquals(NetworkStatus.DOWN, networkStatus1); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + List<String> list0 = queryNetworkResponse0.getRouteTargets(); + assertNull(list0); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + String string0 = queryNetworkResponse0.getNeutronNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + Boolean boolean0 = Boolean.TRUE; + queryNetworkResponse0.setNetworkExists(boolean0); + Boolean boolean1 = queryNetworkResponse0.getNetworkExists(); + assertTrue(boolean1); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + queryNetworkResponse0.setNetworkStackId((String) null); + assertNull(queryNetworkResponse0.getNeutronNetworkId()); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + String string0 = queryNetworkResponse0.getNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + queryNetworkResponse0.setNetworkOutputs((Map<String, String>) null); + assertNull(queryNetworkResponse0.getNeutronNetworkId()); + } + + @Test(timeout = 4000) + public void test27() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + queryNetworkResponse0.getNetworkStatus(); + } + + @Test(timeout = 4000) + public void test28() throws Throwable { + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse(); + LinkedList<String> linkedList0 = new LinkedList<String>(); + queryNetworkResponse0.setRouteTargets(linkedList0); + List<String> list0 = queryNetworkResponse0.getRouteTargets(); + assertTrue(list0.isEmpty()); + } + + @Test(timeout = 4000) + public void test29() throws Throwable { + NetworkStatus networkStatus0 = NetworkStatus.ERROR; + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + QueryNetworkResponse queryNetworkResponse0 = new QueryNetworkResponse("Cm6LuDyY", "Cm6LuDyY", "O5]9 [Se?X,q", networkStatus0, (Map<String, String>) hashMap0); + String string0 = queryNetworkResponse0.getNetworkId(); + assertEquals("Cm6LuDyY", string0); + assertEquals("O5]9 [Se?X,q", queryNetworkResponse0.getNetworkStackId()); + assertEquals("Cm6LuDyY", queryNetworkResponse0.getNeutronNetworkId()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponseESTestscaffolding.java new file mode 100644 index 0000000000..9f554d3e14 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponseESTestscaffolding.java @@ -0,0 +1,194 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:16:38 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class QueryNetworkResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.QueryNetworkResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(QueryNetworkResponseESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.map.JsonSerializableWithType", + "org.codehaus.jackson.map.deser.StdDeserializerProvider", + "org.codehaus.jackson.map.SerializerFactory", + "org.codehaus.jackson.map.SerializerProvider", + "org.codehaus.jackson.map.SerializationConfig", + "org.codehaus.jackson.JsonProcessingException", + "org.codehaus.jackson.map.introspect.AnnotationMap", + "org.codehaus.jackson.map.introspect.Annotated", + "org.codehaus.jackson.map.util.Annotations", + "org.codehaus.jackson.sym.NameN", + "org.codehaus.jackson.JsonGenerator", + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector", + "org.openecomp.mso.adapters.nwrest.QueryNetworkResponse", + "org.codehaus.jackson.map.JsonSerializable", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.node.BaseJsonNode", + "org.codehaus.jackson.map.DeserializerProvider", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.node.ValueNode", + "org.codehaus.jackson.map.ser.BeanSerializerFactory", + "org.codehaus.jackson.map.introspect.AnnotatedWithParams", + "org.codehaus.jackson.map.AnnotationIntrospector", + "org.codehaus.jackson.map.MappingJsonFactory", + "org.codehaus.jackson.map.MapperConfig$Impl", + "org.codehaus.jackson.sym.Name1", + "org.codehaus.jackson.sym.Name2", + "org.codehaus.jackson.sym.Name3", + "org.codehaus.jackson.map.introspect.MethodFilter", + "org.codehaus.jackson.map.ser.StdSerializerProvider", + "org.codehaus.jackson.map.deser.StdDeserializationContext", + "org.codehaus.jackson.map.ClassIntrospector", + "org.codehaus.jackson.map.AnnotationIntrospector$Pair", + "org.codehaus.jackson.Versioned", + "org.codehaus.jackson.map.type.TypeBase", + "org.codehaus.jackson.map.ser.BasicSerializerFactory", + "org.codehaus.jackson.node.ContainerNode", + "org.codehaus.jackson.map.introspect.NopAnnotationIntrospector", + "org.codehaus.jackson.map.DeserializationConfig", + "org.codehaus.jackson.map.introspect.AnnotatedConstructor", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory", + "org.codehaus.jackson.impl.ReaderBasedParser", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer$TableInfo", + "org.codehaus.jackson.map.type.MapLikeType", + "org.codehaus.jackson.node.ObjectNode", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$MinimalMethodFilter", + "org.codehaus.jackson.map.type.CollectionLikeType", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer$Bucket", + "org.codehaus.jackson.impl.JsonParserMinimalBase", + "org.codehaus.jackson.map.type.TypeParser", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$SetterMethodFilter", + "org.codehaus.jackson.map.introspect.VisibilityChecker", + "org.codehaus.jackson.map.introspect.AnnotatedField", + "org.codehaus.jackson.impl.JsonGeneratorBase", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.util.ByteArrayBuilder", + "org.codehaus.jackson.PrettyPrinter", + "org.codehaus.jackson.map.jsontype.SubtypeResolver", + "org.codehaus.jackson.map.type.SimpleType", + "org.openecomp.mso.openstack.beans.NetworkStatus", + "org.codehaus.jackson.map.util.StdDateFormat", + "org.codehaus.jackson.impl.Utf8Generator", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$SetterAndGetterMethodFilter", + "org.codehaus.jackson.JsonNode", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.codehaus.jackson.ObjectCodec", + "org.codehaus.jackson.map.introspect.AnnotatedMethod", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.node.ArrayNode", + "org.codehaus.jackson.io.SegmentedStringWriter", + "org.codehaus.jackson.map.jsontype.TypeResolverBuilder", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$GetterMethodFilter", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.map.BeanDescription", + "org.codehaus.jackson.impl.WriterBasedGenerator", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.sym.Name", + "org.codehaus.jackson.map.introspect.BasicBeanDescription", + "org.codehaus.jackson.util.TokenBuffer", + "org.codehaus.jackson.map.DeserializationContext", + "org.codehaus.jackson.impl.JsonParserBase", + "org.codehaus.jackson.map.JsonMappingException", + "org.codehaus.jackson.map.introspect.AnnotatedMember", + "org.codehaus.jackson.type.JavaType", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.JsonParser", + "org.codehaus.jackson.node.NullNode", + "org.codehaus.jackson.map.jsontype.impl.StdSubtypeResolver", + "org.codehaus.jackson.node.TreeTraversingParser", + "org.codehaus.jackson.map.type.CollectionType", + "org.codehaus.jackson.map.MapperConfig", + "org.codehaus.jackson.map.Module$SetupContext", + "org.codehaus.jackson.io.UTF8Writer", + "org.codehaus.jackson.map.type.MapType", + "org.codehaus.jackson.annotate.JsonAutoDetect", + "org.codehaus.jackson.map.type.ArrayType", + "org.codehaus.jackson.map.ClassIntrospector$MixInResolver" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(QueryNetworkResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkErrorESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkErrorESTest.java new file mode 100644 index 0000000000..5880bdbfca --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkErrorESTest.java @@ -0,0 +1,37 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:27:07 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RollbackNetworkErrorESTest extends RollbackNetworkErrorESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.USERDATA; + RollbackNetworkError rollbackNetworkError0 = new RollbackNetworkError("$/e2Fa;", msoExceptionCategory0, false, "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory"); + assertEquals("$/e2Fa;", rollbackNetworkError0.getMessage()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + RollbackNetworkError rollbackNetworkError0 = new RollbackNetworkError(); + assertNull(rollbackNetworkError0.getMessageId()); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + RollbackNetworkError rollbackNetworkError0 = new RollbackNetworkError("6.4B5l)6k@iZM"); + assertNull(rollbackNetworkError0.getCategory()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkErrorESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkErrorESTestscaffolding.java new file mode 100644 index 0000000000..647a917d52 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkErrorESTestscaffolding.java @@ -0,0 +1,87 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:27:07 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RollbackNetworkErrorESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.RollbackNetworkError"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RollbackNetworkErrorESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.nwrest.RollbackNetworkError", + "org.openecomp.mso.adapters.nwrest.NetworkResponseCommon", + "org.openecomp.mso.adapters.nwrest.NetworkExceptionResponse", + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(RollbackNetworkErrorESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.nwrest.RollbackNetworkError" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkRequestESTest.java new file mode 100644 index 0000000000..255a18e826 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkRequestESTest.java @@ -0,0 +1,44 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:15:37 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.openstack.beans.NetworkRollback; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RollbackNetworkRequestESTest extends RollbackNetworkRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + RollbackNetworkRequest rollbackNetworkRequest0 = new RollbackNetworkRequest(); + NetworkRollback networkRollback0 = new NetworkRollback(); + rollbackNetworkRequest0.setNetworkRollback(networkRollback0); + networkRollback0.setNetworkCreated(true); + NetworkRollback networkRollback1 = rollbackNetworkRequest0.getNetworkRollback(); + assertNull(networkRollback1.getNeutronNetworkId()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + RollbackNetworkRequest rollbackNetworkRequest0 = new RollbackNetworkRequest(); + NetworkRollback networkRollback0 = new NetworkRollback(); + rollbackNetworkRequest0.setNetworkRollback(networkRollback0); + NetworkRollback networkRollback1 = rollbackNetworkRequest0.getNetworkRollback(); + assertNull(networkRollback1.getNeutronNetworkId()); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + RollbackNetworkRequest rollbackNetworkRequest0 = new RollbackNetworkRequest(); + NetworkRollback networkRollback0 = rollbackNetworkRequest0.getNetworkRollback(); + assertNull(networkRollback0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkRequestESTestscaffolding.java new file mode 100644 index 0000000000..3290c92f58 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkRequestESTestscaffolding.java @@ -0,0 +1,100 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:15:37 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RollbackNetworkRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.RollbackNetworkRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RollbackNetworkRequestESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.nwrest.NetworkRequestCommon", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.adapters.nwrest.RollbackNetworkRequest", + "org.openecomp.mso.openstack.beans.NetworkRollback", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(RollbackNetworkRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkResponseESTest.java new file mode 100644 index 0000000000..ba571a1356 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkResponseESTest.java @@ -0,0 +1,42 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:20:37 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RollbackNetworkResponseESTest extends RollbackNetworkResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + Boolean boolean0 = Boolean.TRUE; + RollbackNetworkResponse rollbackNetworkResponse0 = new RollbackNetworkResponse(boolean0, ""); + Boolean boolean1 = rollbackNetworkResponse0.getNetworkRolledBack(); + assertTrue(boolean1); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + Boolean boolean0 = Boolean.TRUE; + RollbackNetworkResponse rollbackNetworkResponse0 = new RollbackNetworkResponse(boolean0, ""); + Boolean boolean1 = new Boolean(""); + rollbackNetworkResponse0.setNetworkRolledBack(boolean1); + Boolean boolean2 = rollbackNetworkResponse0.getNetworkRolledBack(); + assertFalse(boolean2); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + RollbackNetworkResponse rollbackNetworkResponse0 = new RollbackNetworkResponse(); + Boolean boolean0 = rollbackNetworkResponse0.getNetworkRolledBack(); + assertNull(boolean0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkResponseESTestscaffolding.java new file mode 100644 index 0000000000..7efb29e91a --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/RollbackNetworkResponseESTestscaffolding.java @@ -0,0 +1,98 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:20:37 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RollbackNetworkResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.RollbackNetworkResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RollbackNetworkResponseESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.nwrest.NetworkResponseCommon", + "org.openecomp.mso.adapters.nwrest.RollbackNetworkResponse", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(RollbackNetworkResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkErrorESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkErrorESTest.java new file mode 100644 index 0000000000..4f24306501 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkErrorESTest.java @@ -0,0 +1,37 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:22:12 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class UpdateNetworkErrorESTest extends UpdateNetworkErrorESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + UpdateNetworkError updateNetworkError0 = new UpdateNetworkError(); + assertNull(updateNetworkError0.getMessageId()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + UpdateNetworkError updateNetworkError0 = new UpdateNetworkError(""); + assertNull(updateNetworkError0.getCategory()); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + UpdateNetworkError updateNetworkError0 = new UpdateNetworkError("", msoExceptionCategory0, false, ""); + assertEquals("", updateNetworkError0.getMessage()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkErrorESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkErrorESTestscaffolding.java new file mode 100644 index 0000000000..91bae26302 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkErrorESTestscaffolding.java @@ -0,0 +1,87 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:22:12 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class UpdateNetworkErrorESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.UpdateNetworkError"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(UpdateNetworkErrorESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.nwrest.UpdateNetworkError", + "org.openecomp.mso.adapters.nwrest.NetworkResponseCommon", + "org.openecomp.mso.adapters.nwrest.NetworkExceptionResponse", + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(UpdateNetworkErrorESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.nwrest.UpdateNetworkError" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequestESTest.java new file mode 100644 index 0000000000..f7703d5853 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequestESTest.java @@ -0,0 +1,353 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:13:39 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.Subnet; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class UpdateNetworkRequestESTest extends UpdateNetworkRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setNetworkTechnology("NEUTRON"); + assertNull(updateNetworkRequest0.getNetworkStackId()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setTenantId(""); + String string0 = updateNetworkRequest0.getTenantId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + LinkedList<Subnet> linkedList0 = new LinkedList<Subnet>(); + Subnet subnet0 = new Subnet(); + linkedList0.addLast(subnet0); + updateNetworkRequest0.setSubnets(linkedList0); + List<Subnet> list0 = updateNetworkRequest0.getSubnets(); + assertEquals(1, list0.size()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + LinkedList<Integer> linkedList0 = new LinkedList<Integer>(); + ProviderVlanNetwork providerVlanNetwork0 = new ProviderVlanNetwork("NEUTRON", (List<Integer>) linkedList0); + updateNetworkRequest0.setProviderVlanNetwork(providerVlanNetwork0); + ProviderVlanNetwork providerVlanNetwork1 = updateNetworkRequest0.getProviderVlanNetwork(); + assertSame(providerVlanNetwork1, providerVlanNetwork0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setNetworkTypeVersion("$7/{y&^~o(,9x11)BHX"); + String string0 = updateNetworkRequest0.getNetworkTypeVersion(); + assertEquals("$7/{y&^~o(,9x11)BHX", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setNetworkTypeVersion(""); + String string0 = updateNetworkRequest0.getNetworkTypeVersion(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setNetworkType("IW4N;?_XL%q;"); + String string0 = updateNetworkRequest0.getNetworkType(); + assertEquals("IW4N;?_XL%q;", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setNetworkStackId("Allocation_pool [start="); + String string0 = updateNetworkRequest0.getNetworkStackId(); + assertEquals("Allocation_pool [start=", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setNetworkStackId(""); + String string0 = updateNetworkRequest0.getNetworkStackId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + hashMap0.put("", ""); + updateNetworkRequest0.setNetworkParams(hashMap0); + Map<String, String> map0 = updateNetworkRequest0.getNetworkParams(); + assertFalse(map0.isEmpty()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setNetworkName("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<updateNetworkRequest>\n <skipAAI>false</skipAAI>\n <backout>true</backout>\n <msoRequest/>\n <networkParams/>\n <networkTechnology>NEUTRON</networkTechnology>\n</updateNetworkRequest>\n"); + String string0 = updateNetworkRequest0.getNetworkName(); + assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<updateNetworkRequest>\n <skipAAI>false</skipAAI>\n <backout>true</backout>\n <msoRequest/>\n <networkParams/>\n <networkTechnology>NEUTRON</networkTechnology>\n</updateNetworkRequest>\n", string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setNetworkName(""); + String string0 = updateNetworkRequest0.getNetworkName(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setNetworkId(""); + String string0 = updateNetworkRequest0.getNetworkId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setMsoRequest((MsoRequest) null); + MsoRequest msoRequest0 = updateNetworkRequest0.getMsoRequest(); + assertNull(msoRequest0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + ContrailNetwork contrailNetwork0 = new ContrailNetwork(); + updateNetworkRequest0.setContrailNetwork(contrailNetwork0); + ContrailNetwork contrailNetwork1 = updateNetworkRequest0.getContrailNetwork(); + assertEquals("false", contrailNetwork1.getShared()); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setCloudSiteId("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<updateNetworkRequest>\n <skipAAI>false</skipAAI>\n <backout>true</backout>\n <msoRequest>\n <requestId></requestId>\n <serviceInstanceId></serviceInstanceId>\n </msoRequest>\n <networkParams/>\n <networkTechnology>NEUTRON</networkTechnology>\n</updateNetworkRequest>\n"); + String string0 = updateNetworkRequest0.getCloudSiteId(); + assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<updateNetworkRequest>\n <skipAAI>false</skipAAI>\n <backout>true</backout>\n <msoRequest>\n <requestId></requestId>\n <serviceInstanceId></serviceInstanceId>\n </msoRequest>\n <networkParams/>\n <networkTechnology>NEUTRON</networkTechnology>\n</updateNetworkRequest>\n", string0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setBackout((Boolean) null); + Boolean boolean0 = updateNetworkRequest0.getBackout(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + Boolean boolean0 = Boolean.valueOf(false); + updateNetworkRequest0.setBackout(boolean0); + Boolean boolean1 = updateNetworkRequest0.getBackout(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + // Undeclared exception! + try { + updateNetworkRequest0.setNetworkTechnology((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.adapters.nwrest.UpdateNetworkRequest", e); + } + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + ContrailNetwork contrailNetwork0 = updateNetworkRequest0.getContrailNetwork(); + assertNull(contrailNetwork0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + List<Subnet> list0 = updateNetworkRequest0.getSubnets(); + assertNull(list0); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + Boolean boolean0 = updateNetworkRequest0.getBackout(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + String string0 = updateNetworkRequest0.getNetworkType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + String string0 = updateNetworkRequest0.getTenantId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + MsoRequest msoRequest0 = updateNetworkRequest0.getMsoRequest(); + assertNull(msoRequest0.getServiceInstanceId()); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + String string0 = updateNetworkRequest0.getNetworkName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + String string0 = updateNetworkRequest0.getNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test27() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + Map<String, String> map0 = updateNetworkRequest0.getNetworkParams(); + assertEquals(0, map0.size()); + } + + @Test(timeout = 4000) + public void test28() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + ProviderVlanNetwork providerVlanNetwork0 = updateNetworkRequest0.getProviderVlanNetwork(); + assertNull(providerVlanNetwork0); + } + + @Test(timeout = 4000) + public void test29() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + String string0 = updateNetworkRequest0.getCloudSiteId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test30() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + String string0 = updateNetworkRequest0.getNetworkTechnology(); + assertEquals("NEUTRON", string0); + } + + @Test(timeout = 4000) + public void test31() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + String string0 = updateNetworkRequest0.getNetworkTypeVersion(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test32() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + String string0 = updateNetworkRequest0.getNetworkStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test33() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + boolean boolean0 = updateNetworkRequest0.isContrailRequest(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test34() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setNetworkId("}!c9td^-G>0|Ac"); + String string0 = updateNetworkRequest0.getNetworkId(); + assertEquals("}!c9td^-G>0|Ac", string0); + } + + @Test(timeout = 4000) + public void test35() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + LinkedList<Subnet> linkedList0 = new LinkedList<Subnet>(); + updateNetworkRequest0.setSubnets(linkedList0); + List<Subnet> list0 = updateNetworkRequest0.getSubnets(); + assertTrue(list0.isEmpty()); + } + + @Test(timeout = 4000) + public void test36() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setNetworkTechnology("X$XC7&D7JVmMj3FS."); + assertTrue(updateNetworkRequest0.isSynchronous()); + } + + @Test(timeout = 4000) + public void test37() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setCloudSiteId(""); + String string0 = updateNetworkRequest0.getCloudSiteId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test38() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setTenantId("X$XC7&D7JVmMj3FS."); + String string0 = updateNetworkRequest0.getTenantId(); + assertEquals("X$XC7&D7JVmMj3FS.", string0); + } + + @Test(timeout = 4000) + public void test39() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setNetworkParams((Map<String, String>) null); + Map<String, String> map0 = updateNetworkRequest0.getNetworkParams(); + assertNull(map0); + } + + @Test(timeout = 4000) + public void test40() throws Throwable { + UpdateNetworkRequest updateNetworkRequest0 = new UpdateNetworkRequest(); + updateNetworkRequest0.setNetworkType(""); + String string0 = updateNetworkRequest0.getNetworkType(); + assertEquals("", string0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequestESTestscaffolding.java new file mode 100644 index 0000000000..0965197d05 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequestESTestscaffolding.java @@ -0,0 +1,246 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:13:39 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class UpdateNetworkRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.UpdateNetworkRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(UpdateNetworkRequestESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.map.JsonSerializableWithType", + "org.codehaus.jackson.map.HandlerInstantiator", + "org.codehaus.jackson.map.deser.StdDeserializerProvider", + "org.codehaus.jackson.map.SerializerFactory", + "org.codehaus.jackson.map.SerializerProvider", + "org.codehaus.jackson.map.type.TypeBindings", + "org.codehaus.jackson.map.SerializationConfig", + "org.codehaus.jackson.map.introspect.AnnotationMap", + "org.codehaus.jackson.JsonProcessingException", + "org.codehaus.jackson.map.introspect.Annotated", + "org.codehaus.jackson.io.InputDecorator", + "org.codehaus.jackson.map.Module", + "org.codehaus.jackson.map.util.Annotations", + "org.codehaus.jackson.map.type.TypeModifier", + "org.codehaus.jackson.sym.NameN", + "org.codehaus.jackson.JsonGenerator", + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$1", + "org.codehaus.jackson.map.JsonSerializable", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.node.BaseJsonNode", + "org.codehaus.jackson.map.ObjectReader", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.map.DeserializerProvider", + "org.codehaus.jackson.node.ValueNode", + "org.codehaus.jackson.map.ser.BeanSerializerFactory", + "org.codehaus.jackson.map.JsonSerializer", + "org.codehaus.jackson.map.introspect.AnnotatedWithParams", + "org.codehaus.jackson.map.AnnotationIntrospector", + "org.codehaus.jackson.map.MappingJsonFactory", + "org.codehaus.jackson.map.MapperConfig$Impl", + "org.codehaus.jackson.sym.Name1", + "org.codehaus.jackson.sym.Name2", + "org.openecomp.mso.openstack.beans.Subnet", + "org.codehaus.jackson.sym.Name3", + "org.codehaus.jackson.map.introspect.MethodFilter", + "org.codehaus.jackson.map.ser.StdSerializerProvider", + "org.codehaus.jackson.map.deser.StdDeserializationContext", + "org.codehaus.jackson.type.TypeReference", + "org.codehaus.jackson.map.ClassIntrospector", + "org.codehaus.jackson.map.AnnotationIntrospector$Pair", + "org.codehaus.jackson.map.PropertyNamingStrategy$LowerCaseWithUnderscoresStrategy", + "org.codehaus.jackson.map.MapperConfig$ConfigFeature", + "org.codehaus.jackson.map.SerializationConfig$Feature", + "org.codehaus.jackson.Versioned", + "org.codehaus.jackson.io.IOContext", + "org.codehaus.jackson.map.type.TypeBase", + "org.codehaus.jackson.map.ser.BasicSerializerFactory", + "org.codehaus.jackson.map.PropertyNamingStrategy", + "org.codehaus.jackson.node.ContainerNode", + "org.codehaus.jackson.map.jsontype.NamedType", + "org.codehaus.jackson.map.ser.FilterProvider", + "org.codehaus.jackson.map.introspect.AnnotatedConstructor", + "org.codehaus.jackson.map.DeserializationConfig", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.openecomp.mso.adapters.nwrest.NetworkRequestCommon", + "org.codehaus.jackson.map.type.TypeFactory", + "org.codehaus.jackson.impl.ReaderBasedParser", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer$TableInfo", + "org.codehaus.jackson.JsonEncoding", + "org.codehaus.jackson.map.type.MapLikeType", + "org.codehaus.jackson.map.JsonDeserializer", + "org.codehaus.jackson.map.PropertyNamingStrategy$PropertyNamingStrategyBase", + "org.codehaus.jackson.node.ObjectNode", + "org.codehaus.jackson.map.ser.std.SerializerBase", + "org.codehaus.jackson.map.type.CollectionLikeType", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$MinimalMethodFilter", + "org.codehaus.jackson.map.DeserializationConfig$Feature", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer$Bucket", + "org.codehaus.jackson.map.introspect.AnnotatedMethodMap", + "org.codehaus.jackson.impl.JsonParserMinimalBase", + "org.codehaus.jackson.map.type.TypeParser", + "org.codehaus.jackson.map.introspect.POJOPropertiesCollector", + "org.codehaus.jackson.JsonParseException", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$SetterMethodFilter", + "org.codehaus.jackson.map.introspect.VisibilityChecker", + "org.codehaus.jackson.map.introspect.AnnotatedField", + "org.codehaus.jackson.impl.JsonGeneratorBase", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.util.ByteArrayBuilder", + "org.codehaus.jackson.map.ser.impl.FailingSerializer", + "org.codehaus.jackson.PrettyPrinter", + "org.codehaus.jackson.JsonToken", + "org.codehaus.jackson.map.jsontype.SubtypeResolver", + "org.codehaus.jackson.map.type.SimpleType", + "org.codehaus.jackson.impl.Utf8Generator", + "org.codehaus.jackson.node.NumericNode", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$SetterAndGetterMethodFilter", + "org.codehaus.jackson.JsonNode", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.codehaus.jackson.map.ObjectWriter", + "org.codehaus.jackson.schema.SchemaAware", + "org.codehaus.jackson.io.OutputDecorator", + "org.codehaus.jackson.FormatSchema", + "org.codehaus.jackson.format.MatchStrength", + "org.codehaus.jackson.ObjectCodec", + "org.codehaus.jackson.map.introspect.AnnotatedMethod", + "org.codehaus.jackson.JsonGenerationException", + "org.codehaus.jackson.format.InputAccessor", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.node.ArrayNode", + "org.codehaus.jackson.util.BufferRecycler", + "org.codehaus.jackson.io.SegmentedStringWriter", + "org.openecomp.mso.adapters.nwrest.NetworkTechnology", + "org.codehaus.jackson.map.jsontype.TypeResolverBuilder", + "org.codehaus.jackson.map.type.HierarchicType", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$GetterMethodFilter", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.map.BeanDescription", + "org.codehaus.jackson.JsonParser$1", + "org.codehaus.jackson.impl.WriterBasedGenerator", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.sym.Name", + "org.codehaus.jackson.Version", + "org.codehaus.jackson.io.CharacterEscapes", + "org.codehaus.jackson.map.introspect.BasicBeanDescription", + "org.codehaus.jackson.schema.JsonSchema", + "org.codehaus.jackson.util.TokenBuffer", + "org.codehaus.jackson.map.annotate.JsonSerialize$Inclusion", + "org.codehaus.jackson.map.MappingIterator", + "org.codehaus.jackson.map.DeserializationContext", + "org.codehaus.jackson.map.ObjectMapper$DefaultTyping", + "org.codehaus.jackson.impl.JsonParserBase", + "org.codehaus.jackson.map.JsonMappingException", + "org.codehaus.jackson.map.introspect.AnnotatedMember", + "org.codehaus.jackson.node.JsonNodeFactory", + "org.codehaus.jackson.type.JavaType", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.annotate.JsonTypeInfo$As", + "org.codehaus.jackson.map.annotate.JsonRootName", + "org.codehaus.jackson.JsonParser", + "org.codehaus.jackson.node.NullNode", + "org.codehaus.jackson.map.InjectableValues", + "org.codehaus.jackson.map.jsontype.impl.StdSubtypeResolver", + "org.openecomp.mso.entity.MsoRequest", + "org.codehaus.jackson.node.TreeTraversingParser", + "org.codehaus.jackson.map.type.CollectionType", + "org.openecomp.mso.adapters.nwrest.UpdateNetworkRequest", + "org.codehaus.jackson.map.MapperConfig", + "org.codehaus.jackson.map.Module$SetupContext", + "org.codehaus.jackson.map.introspect.VisibilityChecker$1", + "org.codehaus.jackson.io.UTF8Writer", + "org.openecomp.mso.adapters.nwrest.ContrailNetwork", + "org.codehaus.jackson.map.type.MapType", + "org.openecomp.mso.adapters.nwrest.ProviderVlanNetwork", + "org.codehaus.jackson.annotate.JsonAutoDetect", + "org.codehaus.jackson.map.type.ArrayType", + "org.codehaus.jackson.map.ClassIntrospector$MixInResolver" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(UpdateNetworkRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.nwrest.NetworkTechnology", + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkResponseESTest.java new file mode 100644 index 0000000000..a3e417804c --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkResponseESTest.java @@ -0,0 +1,105 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:27:07 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class UpdateNetworkResponseESTest extends UpdateNetworkResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + UpdateNetworkResponse updateNetworkResponse0 = new UpdateNetworkResponse("|YT76&e:{$$La`3", "", (Map<String, String>) hashMap0, "h#%+?1`[X0M#}D0#1"); + updateNetworkResponse0.getSubnetMap(); + assertEquals("", updateNetworkResponse0.getNeutronNetworkId()); + assertEquals("|YT76&e:{$$La`3", updateNetworkResponse0.getNetworkId()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + UpdateNetworkResponse updateNetworkResponse0 = new UpdateNetworkResponse("|YT76&e:{$$La`3", "", (Map<String, String>) hashMap0, "h#%+?1`[X0M#}D0#1"); + hashMap0.put((String) null, "|YT76&e:{$$La`3"); + updateNetworkResponse0.getSubnetMap(); + assertEquals("", updateNetworkResponse0.getNeutronNetworkId()); + assertEquals("|YT76&e:{$$La`3", updateNetworkResponse0.getNetworkId()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + UpdateNetworkResponse updateNetworkResponse0 = new UpdateNetworkResponse(); + String string0 = updateNetworkResponse0.getNeutronNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + UpdateNetworkResponse updateNetworkResponse0 = new UpdateNetworkResponse(); + String string0 = updateNetworkResponse0.getNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + UpdateNetworkResponse updateNetworkResponse0 = new UpdateNetworkResponse("", "", (Map<String, String>) null, ""); + String string0 = updateNetworkResponse0.getNetworkId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + UpdateNetworkResponse updateNetworkResponse0 = new UpdateNetworkResponse("+xyc4(mUPnyf\"U)b", "+xyc4(mUPnyf\"U)b", (Map<String, String>) null, "K:spgI9eR/g*L\"*8OY"); + String string0 = updateNetworkResponse0.getNetworkId(); + assertEquals("+xyc4(mUPnyf\"U)b", string0); + assertEquals("+xyc4(mUPnyf\"U)b", updateNetworkResponse0.getNeutronNetworkId()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + UpdateNetworkResponse updateNetworkResponse0 = new UpdateNetworkResponse(); + Map<String, String> map0 = updateNetworkResponse0.getSubnetMap(); + assertNull(map0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + UpdateNetworkResponse updateNetworkResponse0 = new UpdateNetworkResponse(); + updateNetworkResponse0.setNetworkId(""); + assertNull(updateNetworkResponse0.getNeutronNetworkId()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + UpdateNetworkResponse updateNetworkResponse0 = new UpdateNetworkResponse(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + updateNetworkResponse0.setSubnetMap(hashMap0); + assertTrue(hashMap0.isEmpty()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + UpdateNetworkResponse updateNetworkResponse0 = new UpdateNetworkResponse("", "", (Map<String, String>) null, "?B\"6@FJt`=0vemyZk"); + String string0 = updateNetworkResponse0.getNeutronNetworkId(); + assertEquals("", updateNetworkResponse0.getNetworkId()); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + UpdateNetworkResponse updateNetworkResponse0 = new UpdateNetworkResponse(); + updateNetworkResponse0.setNeutronNetworkId("~<;oyAz"); + String string0 = updateNetworkResponse0.getNeutronNetworkId(); + assertEquals("~<;oyAz", string0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkResponseESTestscaffolding.java new file mode 100644 index 0000000000..1df83e9527 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkResponseESTestscaffolding.java @@ -0,0 +1,98 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:27:07 GMT 2016 + */ + +package org.openecomp.mso.adapters.nwrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class UpdateNetworkResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.nwrest.UpdateNetworkResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(UpdateNetworkResponseESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.nwrest.NetworkResponseCommon", + "org.openecomp.mso.adapters.nwrest.UpdateNetworkResponse", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(UpdateNetworkResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantErrorESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantErrorESTest.java new file mode 100644 index 0000000000..31981957f5 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantErrorESTest.java @@ -0,0 +1,93 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:11:09 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class CreateTenantErrorESTest extends CreateTenantErrorESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + CreateTenantError createTenantError0 = new CreateTenantError("1lR", msoExceptionCategory0, true); + Boolean boolean0 = createTenantError0.getRolledBack(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + CreateTenantError createTenantError0 = new CreateTenantError("]n~ZI>O", msoExceptionCategory0, false); + Boolean boolean0 = createTenantError0.getRolledBack(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + CreateTenantError createTenantError0 = new CreateTenantError("1lR"); + String string0 = createTenantError0.getMessage(); + assertEquals("1lR", string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + CreateTenantError createTenantError0 = new CreateTenantError("1lR"); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + createTenantError0.setCategory(msoExceptionCategory0); + MsoExceptionCategory msoExceptionCategory1 = createTenantError0.getCategory(); + assertEquals(MsoExceptionCategory.OPENSTACK, msoExceptionCategory1); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + CreateTenantError createTenantError0 = new CreateTenantError(); + assertNull(createTenantError0.getMessage()); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + CreateTenantError createTenantError0 = new CreateTenantError("1lR"); + createTenantError0.setRolledBack((Boolean) null); + assertNull(createTenantError0.getCategory()); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + CreateTenantError createTenantError0 = new CreateTenantError("1lR"); + Boolean boolean0 = createTenantError0.getRolledBack(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + CreateTenantError createTenantError0 = new CreateTenantError("1lR"); + createTenantError0.getCategory(); + } + + @Test(timeout = 4000) + public void test8() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + CreateTenantError createTenantError0 = new CreateTenantError((String) null, msoExceptionCategory0, false); + String string0 = createTenantError0.getMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test9() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + CreateTenantError createTenantError0 = new CreateTenantError((String) null, msoExceptionCategory0, false); + createTenantError0.setMessage(""); + String string0 = createTenantError0.getMessage(); + assertEquals("", string0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantErrorESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantErrorESTestscaffolding.java new file mode 100644 index 0000000000..49198893b3 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantErrorESTestscaffolding.java @@ -0,0 +1,85 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:11:09 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class CreateTenantErrorESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.tenantrest.CreateTenantError"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(CreateTenantErrorESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.tenantrest.CreateTenantError", + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(CreateTenantErrorESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.tenantrest.CreateTenantError" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantRequestESTest.java new file mode 100644 index 0000000000..244194b817 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantRequestESTest.java @@ -0,0 +1,165 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:17:07 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.entity.MsoRequest; +import java.util.HashMap; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class CreateTenantRequestESTest extends CreateTenantRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + createTenantRequest0.setTenantName(""); + String string0 = createTenantRequest0.getTenantName(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + createTenantRequest0.setMsoRequest((MsoRequest) null); + MsoRequest msoRequest0 = createTenantRequest0.getMsoRequest(); + assertNull(msoRequest0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + createTenantRequest0.setMetadata((Map<String, String>) null); + Map<String, String> map0 = createTenantRequest0.getMetadata(); + assertNull(map0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + hashMap0.put("+xMNxiyZP", (String) null); + createTenantRequest0.setMetadata(hashMap0); + Map<String, String> map0 = createTenantRequest0.getMetadata(); + assertFalse(map0.isEmpty()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + Boolean boolean0 = new Boolean(true); + createTenantRequest0.setFailIfExists(boolean0); + Boolean boolean1 = createTenantRequest0.getFailIfExists(); + assertTrue(boolean1); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + Boolean boolean0 = new Boolean("%Rg\"4z\"aLm@>#"); + createTenantRequest0.setFailIfExists(boolean0); + Boolean boolean1 = createTenantRequest0.getFailIfExists(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + createTenantRequest0.setCloudSiteId("[E;Tr]]/"); + String string0 = createTenantRequest0.getCloudSiteId(); + assertEquals("[E;Tr]]/", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + createTenantRequest0.setCloudSiteId(""); + String string0 = createTenantRequest0.getCloudSiteId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + Boolean boolean0 = new Boolean(true); + createTenantRequest0.setBackout(boolean0); + Boolean boolean1 = createTenantRequest0.getBackout(); + assertTrue(boolean1); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + Boolean boolean0 = Boolean.valueOf("I?$u7"); + createTenantRequest0.setBackout(boolean0); + Boolean boolean1 = createTenantRequest0.getBackout(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + Boolean boolean0 = createTenantRequest0.getBackout(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + Boolean boolean0 = createTenantRequest0.getFailIfExists(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + String string0 = createTenantRequest0.getTenantName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + String string0 = createTenantRequest0.getCloudSiteId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + String string0 = createTenantRequest0.toString(); + assertEquals("CreateTenantRequest [cloudSiteId=null, tenantName=null, failIfExists=null, backout=null, metadata={}]", string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + MsoRequest msoRequest0 = createTenantRequest0.getMsoRequest(); + createTenantRequest0.setMsoRequest(msoRequest0); + assertNull(createTenantRequest0.getTenantName()); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + createTenantRequest0.setTenantName("Z:%{KRDa=c\"`"); + String string0 = createTenantRequest0.getTenantName(); + assertEquals("Z:%{KRDa=c\"`", string0); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + CreateTenantRequest createTenantRequest0 = new CreateTenantRequest(); + Map<String, String> map0 = createTenantRequest0.getMetadata(); + createTenantRequest0.setMetadata(map0); + assertEquals(0, map0.size()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantRequestESTestscaffolding.java new file mode 100644 index 0000000000..357047d502 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantRequestESTestscaffolding.java @@ -0,0 +1,97 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:17:07 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class CreateTenantRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.tenantrest.CreateTenantRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(CreateTenantRequestESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.adapters.tenantrest.TenantRequestCommon", + "org.openecomp.mso.adapters.tenantrest.CreateTenantRequest", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(CreateTenantRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantResponseESTest.java new file mode 100644 index 0000000000..b7c8e720f6 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantResponseESTest.java @@ -0,0 +1,148 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:18:27 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class CreateTenantResponseESTest extends CreateTenantResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + Boolean boolean0 = Boolean.valueOf((String) null); + TenantRollback tenantRollback0 = new TenantRollback(); + CreateTenantResponse createTenantResponse0 = new CreateTenantResponse("<MtZQZIH{-M@", "<MtZQZIH{-M@", boolean0, tenantRollback0); + String string0 = createTenantResponse0.toString(); + assertEquals("CreateTenantResponse [cloudSiteId=<MtZQZIH{-M@, tenantId=<MtZQZIH{-M@, tenantCreated=false, tenantRollback=VnfRollback: cloud=null, tenant=null, tenantCreated=false]", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + Boolean boolean0 = Boolean.valueOf((String) null); + TenantRollback tenantRollback0 = new TenantRollback(); + tenantRollback0.setTenantCreated(true); + CreateTenantResponse createTenantResponse0 = new CreateTenantResponse("<MtZQZIH{-M@", "<MtZQZIH{-M@", boolean0, tenantRollback0); + TenantRollback tenantRollback1 = createTenantResponse0.getTenantRollback(); + assertSame(tenantRollback0, tenantRollback1); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + CreateTenantResponse createTenantResponse0 = new CreateTenantResponse(); + createTenantResponse0.setTenantId(""); + String string0 = createTenantResponse0.getTenantId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + CreateTenantResponse createTenantResponse0 = new CreateTenantResponse(); + Boolean boolean0 = createTenantResponse0.getTenantCreated(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + Boolean boolean0 = Boolean.valueOf(""); + TenantRollback tenantRollback0 = new TenantRollback(); + CreateTenantResponse createTenantResponse0 = new CreateTenantResponse("", "", boolean0, tenantRollback0); + Boolean boolean1 = createTenantResponse0.getTenantCreated(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + CreateTenantResponse createTenantResponse0 = new CreateTenantResponse(); + createTenantResponse0.setCloudSiteId(""); + String string0 = createTenantResponse0.getCloudSiteId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + CreateTenantResponse createTenantResponse0 = new CreateTenantResponse(); + createTenantResponse0.setTenantRollback((TenantRollback) null); + TenantRollback tenantRollback0 = createTenantResponse0.getTenantRollback(); + assertNull(tenantRollback0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + CreateTenantResponse createTenantResponse0 = new CreateTenantResponse(); + String string0 = createTenantResponse0.getTenantId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + CreateTenantResponse createTenantResponse0 = new CreateTenantResponse(); + TenantRollback tenantRollback0 = createTenantResponse0.getTenantRollback(); + assertFalse(tenantRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + Boolean boolean0 = Boolean.valueOf(true); + TenantRollback tenantRollback0 = new TenantRollback(); + CreateTenantResponse createTenantResponse0 = new CreateTenantResponse("2@/.nLo", "2@/.nLo", boolean0, tenantRollback0); + Boolean boolean1 = createTenantResponse0.getTenantCreated(); + assertTrue(boolean1); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + Boolean boolean0 = new Boolean(""); + CreateTenantResponse createTenantResponse0 = new CreateTenantResponse("8{", "U<b`ZSrD;4T", boolean0, (TenantRollback) null); + // Undeclared exception! + try { + createTenantResponse0.toString(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.adapters.tenantrest.CreateTenantResponse", e); + } + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + CreateTenantResponse createTenantResponse0 = new CreateTenantResponse(); + createTenantResponse0.setCloudSiteId("uj>\"L98"); + String string0 = createTenantResponse0.getCloudSiteId(); + assertEquals("uj>\"L98", string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + CreateTenantResponse createTenantResponse0 = new CreateTenantResponse(); + String string0 = createTenantResponse0.getCloudSiteId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + CreateTenantResponse createTenantResponse0 = new CreateTenantResponse(); + createTenantResponse0.setTenantId("uj>\"L98"); + String string0 = createTenantResponse0.getTenantId(); + assertEquals("uj>\"L98", string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + CreateTenantResponse createTenantResponse0 = new CreateTenantResponse(); + Boolean boolean0 = Boolean.valueOf((String) null); + createTenantResponse0.setTenantCreated(boolean0); + assertNull(createTenantResponse0.getTenantId()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantResponseESTestscaffolding.java new file mode 100644 index 0000000000..71fe644d5d --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/CreateTenantResponseESTestscaffolding.java @@ -0,0 +1,87 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:18:27 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class CreateTenantResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.tenantrest.CreateTenantResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(CreateTenantResponseESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.tenantrest.CreateTenantResponse", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.adapters.tenantrest.TenantRequestCommon", + "org.openecomp.mso.adapters.tenantrest.TenantRollback", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(CreateTenantResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.tenantrest.CreateTenantResponse" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantErrorESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantErrorESTest.java new file mode 100644 index 0000000000..54c187b1df --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantErrorESTest.java @@ -0,0 +1,86 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:21:42 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class DeleteTenantErrorESTest extends DeleteTenantErrorESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + DeleteTenantError deleteTenantError0 = new DeleteTenantError(); + deleteTenantError0.setMessage(""); + String string0 = deleteTenantError0.getMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + DeleteTenantError deleteTenantError0 = new DeleteTenantError(); + deleteTenantError0.setRolledBack((Boolean) null); + assertNull(deleteTenantError0.getMessage()); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + DeleteTenantError deleteTenantError0 = new DeleteTenantError(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.USERDATA; + deleteTenantError0.setCategory(msoExceptionCategory0); + MsoExceptionCategory msoExceptionCategory1 = deleteTenantError0.getCategory(); + assertEquals(MsoExceptionCategory.USERDATA, msoExceptionCategory1); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + DeleteTenantError deleteTenantError0 = new DeleteTenantError(); + Boolean boolean0 = deleteTenantError0.getRolledBack(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + DeleteTenantError deleteTenantError0 = new DeleteTenantError(); + MsoExceptionCategory msoExceptionCategory0 = deleteTenantError0.getCategory(); + DeleteTenantError deleteTenantError1 = new DeleteTenantError((String) null, msoExceptionCategory0, true); + Boolean boolean0 = deleteTenantError1.getRolledBack(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + DeleteTenantError deleteTenantError0 = new DeleteTenantError((String) null, (MsoExceptionCategory) null, false); + Boolean boolean0 = deleteTenantError0.getRolledBack(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + DeleteTenantError deleteTenantError0 = new DeleteTenantError("lgbv,d=W|mN,b"); + assertNull(deleteTenantError0.getCategory()); + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + DeleteTenantError deleteTenantError0 = new DeleteTenantError(); + String string0 = deleteTenantError0.getMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test8() throws Throwable { + DeleteTenantError deleteTenantError0 = new DeleteTenantError(); + deleteTenantError0.setMessage("lgbv,d=W|mN,b"); + String string0 = deleteTenantError0.getMessage(); + assertEquals("lgbv,d=W|mN,b", string0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantErrorESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantErrorESTestscaffolding.java new file mode 100644 index 0000000000..46033773a3 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantErrorESTestscaffolding.java @@ -0,0 +1,85 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:21:42 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class DeleteTenantErrorESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.tenantrest.DeleteTenantError"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DeleteTenantErrorESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.openecomp.mso.adapters.tenantrest.DeleteTenantError" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(DeleteTenantErrorESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.tenantrest.DeleteTenantError" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantRequestESTest.java new file mode 100644 index 0000000000..3ad1b05199 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantRequestESTest.java @@ -0,0 +1,79 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:11:58 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.entity.MsoRequest; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class DeleteTenantRequestESTest extends DeleteTenantRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + DeleteTenantRequest deleteTenantRequest0 = new DeleteTenantRequest(); + deleteTenantRequest0.setTenantId(""); + String string0 = deleteTenantRequest0.getTenantId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + DeleteTenantRequest deleteTenantRequest0 = new DeleteTenantRequest(); + deleteTenantRequest0.setMsoRequest((MsoRequest) null); + MsoRequest msoRequest0 = deleteTenantRequest0.getMsoRequest(); + assertNull(msoRequest0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + DeleteTenantRequest deleteTenantRequest0 = new DeleteTenantRequest(); + deleteTenantRequest0.setCloudSiteId(""); + String string0 = deleteTenantRequest0.getCloudSiteId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + DeleteTenantRequest deleteTenantRequest0 = new DeleteTenantRequest(); + String string0 = deleteTenantRequest0.getCloudSiteId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + DeleteTenantRequest deleteTenantRequest0 = new DeleteTenantRequest(); + MsoRequest msoRequest0 = deleteTenantRequest0.getMsoRequest(); + assertNull(msoRequest0.getServiceInstanceId()); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + DeleteTenantRequest deleteTenantRequest0 = new DeleteTenantRequest(); + deleteTenantRequest0.setTenantId("jaxb.formatted.output"); + String string0 = deleteTenantRequest0.getTenantId(); + assertEquals("jaxb.formatted.output", string0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + DeleteTenantRequest deleteTenantRequest0 = new DeleteTenantRequest(); + String string0 = deleteTenantRequest0.getTenantId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + DeleteTenantRequest deleteTenantRequest0 = new DeleteTenantRequest(); + deleteTenantRequest0.setCloudSiteId("7hA.^5Lo<M_u"); + String string0 = deleteTenantRequest0.getCloudSiteId(); + assertEquals("7hA.^5Lo<M_u", string0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantRequestESTestscaffolding.java new file mode 100644 index 0000000000..ecd83298af --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantRequestESTestscaffolding.java @@ -0,0 +1,97 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:11:58 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class DeleteTenantRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.tenantrest.DeleteTenantRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DeleteTenantRequestESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.tenantrest.DeleteTenantRequest", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.adapters.tenantrest.TenantRequestCommon", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(DeleteTenantRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantResponseESTest.java new file mode 100644 index 0000000000..79ca972678 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantResponseESTest.java @@ -0,0 +1,42 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:19:42 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class DeleteTenantResponseESTest extends DeleteTenantResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + DeleteTenantResponse deleteTenantResponse0 = new DeleteTenantResponse(); + Boolean boolean0 = Boolean.valueOf(""); + deleteTenantResponse0.setTenantDeleted(boolean0); + Boolean boolean1 = deleteTenantResponse0.getTenantDeleted(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + DeleteTenantResponse deleteTenantResponse0 = new DeleteTenantResponse(); + Boolean boolean0 = deleteTenantResponse0.getTenantDeleted(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + DeleteTenantResponse deleteTenantResponse0 = new DeleteTenantResponse(); + Boolean boolean0 = new Boolean(true); + deleteTenantResponse0.setTenantDeleted(boolean0); + Boolean boolean1 = deleteTenantResponse0.getTenantDeleted(); + assertTrue(boolean1); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantResponseESTestscaffolding.java new file mode 100644 index 0000000000..057d669aac --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/DeleteTenantResponseESTestscaffolding.java @@ -0,0 +1,79 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:19:42 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class DeleteTenantResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.tenantrest.DeleteTenantResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DeleteTenantResponseESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.tenantrest.DeleteTenantResponse", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/HealthCheckHandlerESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/HealthCheckHandlerESTest.java new file mode 100644 index 0000000000..b42f9da103 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/HealthCheckHandlerESTest.java @@ -0,0 +1,25 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:28:25 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.jboss.resteasy.specimpl.BuiltResponse; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class HealthCheckHandlerESTest extends HealthCheckHandlerESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + HealthCheckHandler healthCheckHandler0 = new HealthCheckHandler(); + BuiltResponse builtResponse0 = (BuiltResponse)healthCheckHandler0.healthcheck(); + assertFalse(builtResponse0.isClosed()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/HealthCheckHandlerESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/HealthCheckHandlerESTestscaffolding.java new file mode 100644 index 0000000000..c53bc98139 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/HealthCheckHandlerESTestscaffolding.java @@ -0,0 +1,107 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:28:25 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class HealthCheckHandlerESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.tenantrest.HealthCheckHandler"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(HealthCheckHandlerESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.logger.MsoLogger", + "org.openecomp.mso.logger.MessageEnum", + "com.att.eelf.i18n.EELFResolvableErrorEnum", + "org.openecomp.mso.logger.MsoLogger$ResponseCode", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.logger.MsoLogger$StatusCode", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "com.att.eelf.configuration.EELFManager", + "org.openecomp.mso.logger.MsoLogger$ErrorCode", + "com.att.eelf.configuration.EELFLogger", + "com.att.eelf.i18n.EELFMsgs", + "com.att.eelf.configuration.EELFLogger$Level", + "org.jboss.resteasy.specimpl.BuiltResponse", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "com.att.eelf.configuration.SLF4jWrapper", + "org.openecomp.mso.adapters.tenantrest.HealthCheckHandler", + "com.att.eelf.i18n.EELFResourceManager" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(HealthCheckHandlerESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.openecomp.mso.logger.MsoLogger", + "com.att.eelf.i18n.EELFResourceManager", + "com.att.eelf.i18n.EELFMsgs", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "com.att.eelf.configuration.EELFLogger$Level", + "com.att.eelf.configuration.EELFManager", + "org.openecomp.mso.logger.MessageEnum", + "org.openecomp.mso.adapters.tenantrest.HealthCheckHandler" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/QueryTenantErrorESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/QueryTenantErrorESTest.java new file mode 100644 index 0000000000..1695ad3afb --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/QueryTenantErrorESTest.java @@ -0,0 +1,62 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:23:14 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class QueryTenantErrorESTest extends QueryTenantErrorESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + QueryTenantError queryTenantError0 = new QueryTenantError(); + String string0 = queryTenantError0.getMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + QueryTenantError queryTenantError0 = new QueryTenantError("", msoExceptionCategory0); + assertEquals("", queryTenantError0.getMessage()); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + QueryTenantError queryTenantError0 = new QueryTenantError(); + queryTenantError0.setMessage("Io21y\"Bvi"); + String string0 = queryTenantError0.getMessage(); + assertEquals("Io21y\"Bvi", string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + QueryTenantError queryTenantError0 = new QueryTenantError(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + queryTenantError0.setCategory(msoExceptionCategory0); + MsoExceptionCategory msoExceptionCategory1 = queryTenantError0.getCategory(); + assertEquals(MsoExceptionCategory.OPENSTACK, msoExceptionCategory1); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + QueryTenantError queryTenantError0 = new QueryTenantError(""); + String string0 = queryTenantError0.getMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + QueryTenantError queryTenantError0 = new QueryTenantError(); + queryTenantError0.getCategory(); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/QueryTenantErrorESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/QueryTenantErrorESTestscaffolding.java new file mode 100644 index 0000000000..e7bbd3deb0 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/QueryTenantErrorESTestscaffolding.java @@ -0,0 +1,85 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:23:14 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class QueryTenantErrorESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.tenantrest.QueryTenantError"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(QueryTenantErrorESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.adapters.tenantrest.QueryTenantError", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(QueryTenantErrorESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.tenantrest.QueryTenantError" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/QueryTenantResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/QueryTenantResponseESTest.java new file mode 100644 index 0000000000..86ae5efab2 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/QueryTenantResponseESTest.java @@ -0,0 +1,99 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:16:12 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class QueryTenantResponseESTest extends QueryTenantResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + QueryTenantResponse queryTenantResponse0 = new QueryTenantResponse(); + String string0 = queryTenantResponse0.getTenantName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + QueryTenantResponse queryTenantResponse0 = new QueryTenantResponse("", "jaxb.formatted.output", (Map<String, String>) null); + String string0 = queryTenantResponse0.getTenantName(); + assertEquals("jaxb.formatted.output", string0); + assertEquals("", queryTenantResponse0.getTenantId()); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + QueryTenantResponse queryTenantResponse0 = new QueryTenantResponse("/d/SGl|KH4#n", "", (Map<String, String>) hashMap0); + String string0 = queryTenantResponse0.getTenantId(); + assertEquals("", queryTenantResponse0.getTenantName()); + assertEquals("/d/SGl|KH4#n", string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + QueryTenantResponse queryTenantResponse0 = new QueryTenantResponse(":!JHcoDwU", ":!JHcoDwU", (Map<String, String>) hashMap0); + Map<String, String> map0 = queryTenantResponse0.getMetadata(); + assertTrue(map0.isEmpty()); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + QueryTenantResponse queryTenantResponse0 = new QueryTenantResponse(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + hashMap0.put("3Lk\"uS,GJ", "3Lk\"uS,GJ"); + queryTenantResponse0.setMetadata(hashMap0); + Map<String, String> map0 = queryTenantResponse0.getMetadata(); + assertEquals(1, map0.size()); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + QueryTenantResponse queryTenantResponse0 = new QueryTenantResponse("b", "", (Map<String, String>) hashMap0); + String string0 = queryTenantResponse0.getTenantName(); + assertEquals("", string0); + assertEquals("b", queryTenantResponse0.getTenantId()); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + QueryTenantResponse queryTenantResponse0 = new QueryTenantResponse(); + String string0 = queryTenantResponse0.getTenantId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + QueryTenantResponse queryTenantResponse0 = new QueryTenantResponse(); + Map<String, String> map0 = queryTenantResponse0.getMetadata(); + assertNull(map0); + } + + @Test(timeout = 4000) + public void test8() throws Throwable { + QueryTenantResponse queryTenantResponse0 = new QueryTenantResponse(); + queryTenantResponse0.setTenantName("hKe?S+T{hz:~0"); + assertEquals("hKe?S+T{hz:~0", queryTenantResponse0.getTenantName()); + } + + @Test(timeout = 4000) + public void test9() throws Throwable { + QueryTenantResponse queryTenantResponse0 = new QueryTenantResponse(); + queryTenantResponse0.setTenantId(""); + String string0 = queryTenantResponse0.getTenantId(); + assertEquals("", string0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/QueryTenantResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/QueryTenantResponseESTestscaffolding.java new file mode 100644 index 0000000000..960abf7500 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/QueryTenantResponseESTestscaffolding.java @@ -0,0 +1,96 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:16:12 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class QueryTenantResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.tenantrest.QueryTenantResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(QueryTenantResponseESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.tenantrest.TenantRequestCommon", + "org.openecomp.mso.adapters.tenantrest.QueryTenantResponse", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(QueryTenantResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantErrorESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantErrorESTest.java new file mode 100644 index 0000000000..b1232f3856 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantErrorESTest.java @@ -0,0 +1,92 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:22:42 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RollbackTenantErrorESTest extends RollbackTenantErrorESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + RollbackTenantError rollbackTenantError0 = new RollbackTenantError(); + Boolean boolean0 = rollbackTenantError0.getRolledBack(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + RollbackTenantError rollbackTenantError0 = new RollbackTenantError("w8nm;2F^\"Z", (MsoExceptionCategory) null, true); + Boolean boolean0 = rollbackTenantError0.getRolledBack(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + RollbackTenantError rollbackTenantError0 = new RollbackTenantError(); + String string0 = rollbackTenantError0.getMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + RollbackTenantError rollbackTenantError0 = new RollbackTenantError("=i_>GLf`"); + String string0 = rollbackTenantError0.getMessage(); + assertEquals("=i_>GLf`", string0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + RollbackTenantError rollbackTenantError0 = new RollbackTenantError(); + rollbackTenantError0.getCategory(); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + RollbackTenantError rollbackTenantError0 = new RollbackTenantError("", msoExceptionCategory0, false); + rollbackTenantError0.setCategory(msoExceptionCategory0); + assertEquals(MsoExceptionCategory.OPENSTACK, rollbackTenantError0.getCategory()); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + RollbackTenantError rollbackTenantError0 = new RollbackTenantError("", msoExceptionCategory0, false); + MsoExceptionCategory msoExceptionCategory1 = rollbackTenantError0.getCategory(); + assertEquals(MsoExceptionCategory.OPENSTACK, msoExceptionCategory1); + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + RollbackTenantError rollbackTenantError0 = new RollbackTenantError("", msoExceptionCategory0, false); + String string0 = rollbackTenantError0.getMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test8() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + RollbackTenantError rollbackTenantError0 = new RollbackTenantError("", msoExceptionCategory0, false); + Boolean boolean0 = rollbackTenantError0.getRolledBack(); + rollbackTenantError0.setRolledBack(boolean0); + assertEquals(MsoExceptionCategory.OPENSTACK, rollbackTenantError0.getCategory()); + } + + @Test(timeout = 4000) + public void test9() throws Throwable { + RollbackTenantError rollbackTenantError0 = new RollbackTenantError(); + rollbackTenantError0.setMessage("org.openecomp.mso.openstack.exceptions.MsoExceptionCategory"); + assertEquals("org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", rollbackTenantError0.getMessage()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantErrorESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantErrorESTestscaffolding.java new file mode 100644 index 0000000000..8ca1cb047b --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantErrorESTestscaffolding.java @@ -0,0 +1,85 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:22:42 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RollbackTenantErrorESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.tenantrest.RollbackTenantError"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RollbackTenantErrorESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.openecomp.mso.adapters.tenantrest.RollbackTenantError", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(RollbackTenantErrorESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.tenantrest.RollbackTenantError" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantRequestESTest.java new file mode 100644 index 0000000000..c846222423 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantRequestESTest.java @@ -0,0 +1,43 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:26:04 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RollbackTenantRequestESTest extends RollbackTenantRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + RollbackTenantRequest rollbackTenantRequest0 = new RollbackTenantRequest(); + TenantRollback tenantRollback0 = new TenantRollback(); + rollbackTenantRequest0.setTenantRollback(tenantRollback0); + tenantRollback0.setTenantCreated(true); + TenantRollback tenantRollback1 = rollbackTenantRequest0.getTenantRollback(); + assertTrue(tenantRollback1.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + RollbackTenantRequest rollbackTenantRequest0 = new RollbackTenantRequest(); + TenantRollback tenantRollback0 = new TenantRollback(); + rollbackTenantRequest0.setTenantRollback(tenantRollback0); + TenantRollback tenantRollback1 = rollbackTenantRequest0.getTenantRollback(); + assertSame(tenantRollback1, tenantRollback0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + RollbackTenantRequest rollbackTenantRequest0 = new RollbackTenantRequest(); + TenantRollback tenantRollback0 = rollbackTenantRequest0.getTenantRollback(); + assertNull(tenantRollback0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantRequestESTestscaffolding.java new file mode 100644 index 0000000000..fa9d0c6ef1 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantRequestESTestscaffolding.java @@ -0,0 +1,98 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:26:04 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RollbackTenantRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.tenantrest.RollbackTenantRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RollbackTenantRequestESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.adapters.tenantrest.TenantRequestCommon", + "org.openecomp.mso.adapters.tenantrest.RollbackTenantRequest", + "org.openecomp.mso.adapters.tenantrest.TenantRollback", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(RollbackTenantRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantResponseESTest.java new file mode 100644 index 0000000000..3669382f3a --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantResponseESTest.java @@ -0,0 +1,42 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:19:02 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RollbackTenantResponseESTest extends RollbackTenantResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + RollbackTenantResponse rollbackTenantResponse0 = new RollbackTenantResponse(); + Boolean boolean0 = Boolean.TRUE; + rollbackTenantResponse0.setTenantRolledback(boolean0); + Boolean boolean1 = rollbackTenantResponse0.getTenantRolledback(); + assertTrue(boolean1); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + RollbackTenantResponse rollbackTenantResponse0 = new RollbackTenantResponse(); + Boolean boolean0 = Boolean.valueOf(":;W(ksM>u2+"); + rollbackTenantResponse0.setTenantRolledback(boolean0); + Boolean boolean1 = rollbackTenantResponse0.getTenantRolledback(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + RollbackTenantResponse rollbackTenantResponse0 = new RollbackTenantResponse(); + Boolean boolean0 = rollbackTenantResponse0.getTenantRolledback(); + assertNull(boolean0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantResponseESTestscaffolding.java new file mode 100644 index 0000000000..975ce058af --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantResponseESTestscaffolding.java @@ -0,0 +1,79 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:19:02 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RollbackTenantResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.tenantrest.RollbackTenantResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RollbackTenantResponseESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.tenantrest.RollbackTenantResponse", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponseESTest.java new file mode 100644 index 0000000000..1694ca2ae7 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponseESTest.java @@ -0,0 +1,97 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:25:22 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class TenantExceptionResponseESTest extends TenantExceptionResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + TenantExceptionResponse tenantExceptionResponse0 = new TenantExceptionResponse((String) null, msoExceptionCategory0, true); + Boolean boolean0 = tenantExceptionResponse0.getRolledBack(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + TenantExceptionResponse tenantExceptionResponse0 = new TenantExceptionResponse("sxH3DHvAo$"); + String string0 = tenantExceptionResponse0.getMessage(); + assertEquals("sxH3DHvAo$", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + TenantExceptionResponse tenantExceptionResponse0 = new TenantExceptionResponse((String) null, msoExceptionCategory0, true); + MsoExceptionCategory msoExceptionCategory1 = tenantExceptionResponse0.getCategory(); + assertSame(msoExceptionCategory0, msoExceptionCategory1); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + TenantExceptionResponse tenantExceptionResponse0 = new TenantExceptionResponse(""); + tenantExceptionResponse0.setMessage("1LGUz =Y?.wyJ"); + assertNull(tenantExceptionResponse0.getCategory()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + TenantExceptionResponse tenantExceptionResponse0 = new TenantExceptionResponse(""); + Boolean boolean0 = tenantExceptionResponse0.getRolledBack(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + TenantExceptionResponse tenantExceptionResponse0 = new TenantExceptionResponse(""); + tenantExceptionResponse0.setCategory((MsoExceptionCategory) null); + assertEquals("", tenantExceptionResponse0.getMessage()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + TenantExceptionResponse tenantExceptionResponse0 = new TenantExceptionResponse(); + String string0 = tenantExceptionResponse0.getMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + TenantExceptionResponse tenantExceptionResponse0 = new TenantExceptionResponse(""); + String string0 = tenantExceptionResponse0.getMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.INTERNAL; + TenantExceptionResponse tenantExceptionResponse0 = new TenantExceptionResponse("", msoExceptionCategory0, false); + Boolean boolean0 = tenantExceptionResponse0.getRolledBack(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + TenantExceptionResponse tenantExceptionResponse0 = new TenantExceptionResponse(""); + tenantExceptionResponse0.setRolledBack((Boolean) null); + assertNull(tenantExceptionResponse0.getCategory()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + TenantExceptionResponse tenantExceptionResponse0 = new TenantExceptionResponse(""); + tenantExceptionResponse0.getCategory(); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponseESTestscaffolding.java new file mode 100644 index 0000000000..712eea38a0 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponseESTestscaffolding.java @@ -0,0 +1,85 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:25:22 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class TenantExceptionResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.tenantrest.TenantExceptionResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(TenantExceptionResponseESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.tenantrest.TenantExceptionResponse", + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(TenantExceptionResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.tenantrest.TenantExceptionResponse" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/TenantRollbackESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/TenantRollbackESTest.java new file mode 100644 index 0000000000..48b4e04bb0 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/TenantRollbackESTest.java @@ -0,0 +1,104 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:14:33 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.entity.MsoRequest; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class TenantRollbackESTest extends TenantRollbackESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + TenantRollback tenantRollback0 = new TenantRollback(); + tenantRollback0.setTenantId("e'W6mm;1{:,"); + tenantRollback0.getTenantId(); + assertFalse(tenantRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + TenantRollback tenantRollback0 = new TenantRollback(); + assertFalse(tenantRollback0.getTenantCreated()); + + tenantRollback0.setTenantCreated(true); + boolean boolean0 = tenantRollback0.getTenantCreated(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + TenantRollback tenantRollback0 = new TenantRollback(); + tenantRollback0.setCloudId("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<rollbackTenantRequest>\n <tenantCreated>false</tenantCreated>\n</rollbackTenantRequest>\n"); + tenantRollback0.getCloudId(); + assertFalse(tenantRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + TenantRollback tenantRollback0 = new TenantRollback(); + tenantRollback0.setCloudId(""); + tenantRollback0.getCloudId(); + assertFalse(tenantRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + TenantRollback tenantRollback0 = new TenantRollback(); + tenantRollback0.getMsoRequest(); + assertFalse(tenantRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + TenantRollback tenantRollback0 = new TenantRollback(); + boolean boolean0 = tenantRollback0.getTenantCreated(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + TenantRollback tenantRollback0 = new TenantRollback(); + tenantRollback0.getCloudId(); + assertFalse(tenantRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + TenantRollback tenantRollback0 = new TenantRollback(); + tenantRollback0.getTenantId(); + assertFalse(tenantRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + TenantRollback tenantRollback0 = new TenantRollback(); + MsoRequest msoRequest0 = new MsoRequest(); + tenantRollback0.setMsoRequest(msoRequest0); + tenantRollback0.getMsoRequest(); + assertFalse(tenantRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + TenantRollback tenantRollback0 = new TenantRollback(); + tenantRollback0.setTenantId(""); + tenantRollback0.getTenantId(); + assertFalse(tenantRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + TenantRollback tenantRollback0 = new TenantRollback(); + String string0 = tenantRollback0.toString(); + assertEquals("VnfRollback: cloud=null, tenant=null, tenantCreated=false", string0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/TenantRollbackESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/TenantRollbackESTestscaffolding.java new file mode 100644 index 0000000000..c75ee49c43 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/tenantrest/TenantRollbackESTestscaffolding.java @@ -0,0 +1,97 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:14:33 GMT 2016 + */ + +package org.openecomp.mso.adapters.tenantrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class TenantRollbackESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.tenantrest.TenantRollback"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(TenantRollbackESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.adapters.tenantrest.TenantRequestCommon", + "org.openecomp.mso.adapters.tenantrest.TenantRollback", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(TenantRollbackESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleRequestESTest.java new file mode 100644 index 0000000000..daaf4f0b49 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleRequestESTest.java @@ -0,0 +1,661 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:13:00 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.openecomp.mso.entity.MsoRequest; +import java.util.HashMap; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class CreateVfModuleRequestESTest extends CreateVfModuleRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + assertNull(createVfModuleRequest0.getVnfId()); + + createVfModuleRequest0.setVnfVersion("sJ%kzC"); + createVfModuleRequest0.getVolumeGroupId(); + createVfModuleRequest0.setTenantId((String) null); + createVfModuleRequest0.setRequestType((String) null); + createVfModuleRequest0.getVnfVersion(); + createVfModuleRequest0.setVnfType((String) null); + createVfModuleRequest0.getBaseVfModuleId(); + createVfModuleRequest0.getBaseVfModuleId(); + MsoRequest msoRequest0 = new MsoRequest(); + createVfModuleRequest0.setMsoRequest(msoRequest0); + createVfModuleRequest0.getBackout(); + createVfModuleRequest0.toXmlString(); + Boolean.logicalAnd(false, false); + createVfModuleRequest0.setBackout((Boolean) null); + createVfModuleRequest0.getVolumeGroupId(); + createVfModuleRequest0.getVfModuleType(); + createVfModuleRequest0.setBaseVfModuleStackId(""); + createVfModuleRequest0.setRequestType("&$7s5#"); + assertTrue(createVfModuleRequest0.isSynchronous()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setBaseVfModuleStackId("gi,pZwt!/Q"); + createVfModuleRequest0.setTenantId("<(b"); + createVfModuleRequest0.setVfModuleName(""); + createVfModuleRequest0.setVnfId(""); + createVfModuleRequest0.getVnfId(); + createVfModuleRequest0.getBackout(); + createVfModuleRequest0.setRequestType(""); + createVfModuleRequest0.getTenantId(); + createVfModuleRequest0.setVfModuleId("gi,pZwt!/Q"); + createVfModuleRequest0.getVfModuleParams(); + createVfModuleRequest0.getVolumeGroupStackId(); + String string0 = createVfModuleRequest0.getVolumeGroupId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.getFailIfExists(); + createVfModuleRequest0.setFailIfExists((Boolean) null); + assertTrue(createVfModuleRequest0.isSynchronous()); + + createVfModuleRequest0.setVnfId(""); + createVfModuleRequest0.setTenantId("P%"); + createVfModuleRequest0.setTenantId("vqbsX2ysx.>]T "); + createVfModuleRequest0.getBaseVfModuleStackId(); + createVfModuleRequest0.getBaseVfModuleStackId(); + createVfModuleRequest0.getCloudSiteId(); + createVfModuleRequest0.getVfModuleParams(); + String string0 = createVfModuleRequest0.getTenantId(); + assertEquals("vqbsX2ysx.>]T ", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setMessageId(""); + createVfModuleRequest0.setVfModuleName(""); + createVfModuleRequest0.setVnfType(""); + MsoRequest msoRequest0 = new MsoRequest(); + msoRequest0.setRequestId(""); + createVfModuleRequest0.setMsoRequest(msoRequest0); + createVfModuleRequest0.getBaseVfModuleId(); + Boolean boolean0 = Boolean.TRUE; + Boolean.getBoolean(""); + createVfModuleRequest0.setBaseVfModuleId("$I<po0F7W[gG2}iD,."); + createVfModuleRequest0.setBackout(boolean0); + CreateVfModuleRequest createVfModuleRequest1 = new CreateVfModuleRequest(); + createVfModuleRequest0.toXmlString(); + createVfModuleRequest1.setBaseVfModuleStackId("$I<po0F7W[gG2}iD,."); + createVfModuleRequest0.getVfModuleName(); + Boolean boolean1 = createVfModuleRequest0.getBackout(); + assertTrue(boolean1); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + MsoRequest msoRequest0 = new MsoRequest(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + createVfModuleRequest0.setVfModuleParams(hashMap0); + createVfModuleRequest0.setMsoRequest(msoRequest0); + createVfModuleRequest0.setTenantId(""); + Map<String, String> map0 = createVfModuleRequest0.getVfModuleParams(); + createVfModuleRequest0.setVfModuleParams(map0); + createVfModuleRequest0.setVolumeGroupStackId("E8"); + createVfModuleRequest0.setVfModuleId(""); + createVfModuleRequest0.setVfModuleParams((Map<String, String>) null); + createVfModuleRequest0.getVfModuleId(); + createVfModuleRequest0.setVfModuleParams((Map<String, String>) null); + createVfModuleRequest0.setVfModuleType("@<W6qx4|DZ(CMN`JzXQ"); + assertEquals("", createVfModuleRequest0.getTenantId()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setBaseVfModuleStackId("jaxb.formatted.output"); + Boolean boolean0 = Boolean.valueOf(false); + Boolean.compare(false, false); + createVfModuleRequest0.setVfModuleType(""); + Boolean.logicalXor(false, true); + Boolean.logicalOr(true, true); + Boolean.compare(false, false); + createVfModuleRequest0.setFailIfExists(boolean0); + createVfModuleRequest0.setVfModuleName("bMZ`m<$@<x?!ofbD`!"); + createVfModuleRequest0.setVfModuleType(""); + createVfModuleRequest0.getFailIfExists(); + createVfModuleRequest0.setTenantId(""); + createVfModuleRequest0.setVnfId(""); + createVfModuleRequest0.getBaseVfModuleStackId(); + createVfModuleRequest0.getMsoRequest(); + createVfModuleRequest0.getTenantId(); + MsoRequest msoRequest0 = createVfModuleRequest0.getMsoRequest(); + msoRequest0.setServiceInstanceId(""); + createVfModuleRequest0.getVnfType(); + createVfModuleRequest0.getVnfType(); + createVfModuleRequest0.setVfModuleName(""); + msoRequest0.setRequestId((String) null); + createVfModuleRequest0.setMsoRequest(msoRequest0); + createVfModuleRequest0.setVfModuleId((String) null); + createVfModuleRequest0.setBaseVfModuleId(""); + createVfModuleRequest0.getBackout(); + createVfModuleRequest0.setRequestType(""); + assertNull(createVfModuleRequest0.getVnfType()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setVolumeGroupId("C}GH#3Zrrwj]-VWQfx"); + createVfModuleRequest0.setVnfType("jaxb.formatted.output"); + createVfModuleRequest0.setRequestType("jaxb.formatted.output"); + createVfModuleRequest0.getBackout(); + String string0 = createVfModuleRequest0.getVolumeGroupId(); + assertEquals("C}GH#3Zrrwj]-VWQfx", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + createVfModuleRequest0.setVfModuleParams(hashMap0); + Boolean boolean0 = Boolean.valueOf(false); + Boolean.logicalXor(false, false); + createVfModuleRequest0.setFailIfExists(boolean0); + createVfModuleRequest0.setVolumeGroupId((String) null); + createVfModuleRequest0.setRequestType("jaxb.formatted.output"); + createVfModuleRequest0.getRequestType(); + String string0 = createVfModuleRequest0.getTenantId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setVnfType("4$IXyLo,UL9"); + createVfModuleRequest0.getVfModuleName(); + MsoRequest msoRequest0 = new MsoRequest(); + msoRequest0.setServiceInstanceId("4$IXyLo,UL9"); + createVfModuleRequest0.toXmlString(); + msoRequest0.setServiceInstanceId(""); + msoRequest0.setRequestId("4$IXyLo,UL9"); + Boolean boolean0 = Boolean.valueOf("4$IXyLo,UL9"); + Boolean.getBoolean("4$IXyLo,UL9"); + createVfModuleRequest0.setBackout(boolean0); + msoRequest0.setServiceInstanceId("t.d]=Q;m"); + msoRequest0.setRequestId(""); + createVfModuleRequest0.setMsoRequest(msoRequest0); + createVfModuleRequest0.setVolumeGroupId(""); + createVfModuleRequest0.getVolumeGroupId(); + createVfModuleRequest0.getBaseVfModuleStackId(); + createVfModuleRequest0.getVnfId(); + createVfModuleRequest0.getCloudSiteId(); + createVfModuleRequest0.setVfModuleType("Hc<-mV"); + assertNull(createVfModuleRequest0.getMessageId()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setBaseVfModuleStackId(":N_M0a[eewxveG"); + createVfModuleRequest0.setMessageId("qajtT(\"^v~n0>3Q/F9"); + Boolean boolean0 = Boolean.valueOf(":N_M0a[eewxveG"); + Boolean.compare(true, true); + createVfModuleRequest0.setFailIfExists(boolean0); + createVfModuleRequest0.setVfModuleId(""); + createVfModuleRequest0.setBaseVfModuleId(""); + createVfModuleRequest0.setVnfId("&uC#o/="); + createVfModuleRequest0.setVfModuleName("jaxb.formatted.output"); + createVfModuleRequest0.setVnfType("jaxb.formatted.output"); + createVfModuleRequest0.getVnfId(); + createVfModuleRequest0.getBaseVfModuleId(); + createVfModuleRequest0.setVfModuleId(""); + createVfModuleRequest0.setVfModuleId("'l b#"); + assertNull(createVfModuleRequest0.getVolumeGroupId()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + Map<String, String> map0 = createVfModuleRequest0.getVfModuleParams(); + createVfModuleRequest0.setVnfId("Mi!"); + createVfModuleRequest0.setVolumeGroupId((String) null); + createVfModuleRequest0.setVfModuleParams(map0); + createVfModuleRequest0.setBaseVfModuleStackId("Mi!"); + createVfModuleRequest0.getVnfId(); + createVfModuleRequest0.getBaseVfModuleStackId(); + createVfModuleRequest0.getVolumeGroupId(); + createVfModuleRequest0.setVfModuleId((String) null); + assertNull(createVfModuleRequest0.getVolumeGroupStackId()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.toXmlString(); + createVfModuleRequest0.setVolumeGroupId(""); + createVfModuleRequest0.getBaseVfModuleId(); + createVfModuleRequest0.toXmlString(); + createVfModuleRequest0.setVfModuleType("~o"); + createVfModuleRequest0.setRequestType(""); + createVfModuleRequest0.getVfModuleName(); + Boolean boolean0 = new Boolean(false); + createVfModuleRequest0.setFailIfExists(boolean0); + createVfModuleRequest0.getRequestType(); + createVfModuleRequest0.setVfModuleId(""); + createVfModuleRequest0.setVfModuleId(""); + assertEquals("", createVfModuleRequest0.getVolumeGroupId()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + Map<String, String> map0 = createVfModuleRequest0.getVfModuleParams(); + createVfModuleRequest0.setVfModuleParams(map0); + createVfModuleRequest0.getBaseVfModuleId(); + createVfModuleRequest0.getTenantId(); + createVfModuleRequest0.getCloudSiteId(); + createVfModuleRequest0.setVolumeGroupStackId((String) null); + createVfModuleRequest0.getBackout(); + createVfModuleRequest0.getVfModuleType(); + createVfModuleRequest0.setVnfId("3TEn*yZmhM~PV>H"); + createVfModuleRequest0.getFailIfExists(); + createVfModuleRequest0.setCloudSiteId(""); + createVfModuleRequest0.getCloudSiteId(); + String string0 = createVfModuleRequest0.getVnfVersion(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setVnfVersion("!oK"); + createVfModuleRequest0.setCloudSiteId((String) null); + createVfModuleRequest0.setVfModuleType(""); + createVfModuleRequest0.getRequestType(); + createVfModuleRequest0.setVfModuleId((String) null); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + createVfModuleRequest0.setNotificationUrl((String) null); + hashMap0.put("", (String) null); + createVfModuleRequest0.setVfModuleParams(hashMap0); + hashMap0.put("!oK", ""); + createVfModuleRequest0.setVfModuleParams(hashMap0); + createVfModuleRequest0.getVnfType(); + createVfModuleRequest0.getVfModuleParams(); + String string0 = createVfModuleRequest0.getVnfId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + Boolean boolean0 = Boolean.TRUE; + Boolean.getBoolean((String) null); + Boolean.logicalOr(true, false); + createVfModuleRequest0.setSkipAAI(boolean0); + Boolean boolean1 = createVfModuleRequest0.getSkipAAI(); + createVfModuleRequest0.setSkipAAI(boolean1); + createVfModuleRequest0.setBaseVfModuleId("u=(R@E]!q2rk"); + createVfModuleRequest0.setVnfId(""); + createVfModuleRequest0.setVfModuleId("u=(R@E]!q2rk"); + createVfModuleRequest0.setVolumeGroupId("u=(R@E]!q2rk"); + createVfModuleRequest0.setBaseVfModuleStackId((String) null); + createVfModuleRequest0.setCloudSiteId("^)DR(@$VIDb"); + createVfModuleRequest0.setVnfId("^)DR(@$VIDb"); + createVfModuleRequest0.getVfModuleParams(); + createVfModuleRequest0.getVfModuleId(); + createVfModuleRequest0.getBaseVfModuleId(); + String string0 = createVfModuleRequest0.getVnfType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setRequestType(""); + createVfModuleRequest0.setRequestType(""); + createVfModuleRequest0.getMsoRequest(); + createVfModuleRequest0.setBaseVfModuleStackId(""); + createVfModuleRequest0.setVolumeGroupStackId(":S"); + createVfModuleRequest0.getBaseVfModuleStackId(); + CreateVfModuleRequest createVfModuleRequest1 = new CreateVfModuleRequest(); + createVfModuleRequest1.getFailIfExists(); + Boolean.compare(false, false); + // Undeclared exception! + try { + createVfModuleRequest1.toJsonString(); + fail("Expecting exception: VerifyError"); + + } catch(VerifyError e) { + // + // (class: org/codehaus/jackson/map/MapperConfig, method: <clinit> signature: ()V) Bad type in putfield/putstatic + // + verifyException("org.codehaus.jackson.map.ObjectMapper", e); + } + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setVnfType(""); + assertNull(createVfModuleRequest0.getBaseVfModuleStackId()); + + MsoRequest msoRequest0 = new MsoRequest("", (String) null); + msoRequest0.setServiceInstanceId(""); + msoRequest0.setRequestId("y/H`4"); + createVfModuleRequest0.setMsoRequest(msoRequest0); + createVfModuleRequest0.setVolumeGroupStackId("1!1@Hk"); + createVfModuleRequest0.setNotificationUrl(""); + createVfModuleRequest0.getVnfType(); + createVfModuleRequest0.getRequestType(); + createVfModuleRequest0.getBackout(); + createVfModuleRequest0.getVolumeGroupStackId(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + createVfModuleRequest0.setVfModuleParams(hashMap0); + assertNull(createVfModuleRequest0.getVnfVersion()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setVnfVersion(""); + createVfModuleRequest0.setVolumeGroupStackId("g[TSR)[o{D\"(-N"); + createVfModuleRequest0.getFailIfExists(); + MsoRequest msoRequest0 = new MsoRequest("", ""); + msoRequest0.setServiceInstanceId("{l*;T:T"); + createVfModuleRequest0.setMsoRequest(msoRequest0); + createVfModuleRequest0.setVnfType(""); + createVfModuleRequest0.setMessageId(""); + createVfModuleRequest0.setBaseVfModuleId("6="); + createVfModuleRequest0.setRequestType(""); + createVfModuleRequest0.getVnfVersion(); + createVfModuleRequest0.setVolumeGroupStackId(""); + createVfModuleRequest0.getVolumeGroupStackId(); + createVfModuleRequest0.setVnfType(""); + createVfModuleRequest0.setVfModuleId("7vlbM({1@v[1?Q^A;"); + assertNull(createVfModuleRequest0.getBaseVfModuleStackId()); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + MsoRequest msoRequest0 = new MsoRequest(); + createVfModuleRequest0.setMsoRequest(msoRequest0); + createVfModuleRequest0.getVfModuleName(); + Boolean boolean0 = Boolean.FALSE; + Boolean.logicalOr(true, true); + createVfModuleRequest0.setBackout(boolean0); + createVfModuleRequest0.setVnfVersion(""); + createVfModuleRequest0.setVnfVersion(""); + createVfModuleRequest0.getMsoRequest(); + String string0 = createVfModuleRequest0.getVnfVersion(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + Boolean boolean0 = new Boolean(""); + Boolean.logicalOr(true, false); + createVfModuleRequest0.setBackout(boolean0); + createVfModuleRequest0.setTenantId(""); + createVfModuleRequest0.getBackout(); + createVfModuleRequest0.setVfModuleName("rdQqc>V^"); + assertTrue(createVfModuleRequest0.isSynchronous()); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + Map<String, String> map0 = createVfModuleRequest0.getVfModuleParams(); + Boolean boolean0 = Boolean.valueOf(""); + boolean boolean1 = Boolean.logicalXor(false, false); + createVfModuleRequest0.setSkipAAI(boolean0); + createVfModuleRequest0.setVfModuleParams(map0); + createVfModuleRequest0.getVfModuleType(); + createVfModuleRequest0.setVnfId(""); + createVfModuleRequest0.getBackout(); + createVfModuleRequest0.getBaseVfModuleId(); + createVfModuleRequest0.getVfModuleParams(); + Boolean boolean2 = new Boolean(true); + createVfModuleRequest0.setFailIfExists(boolean2); + Boolean boolean3 = createVfModuleRequest0.getFailIfExists(); + assertFalse(boolean3.equals((Object)boolean1)); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setVfModuleId(",XO#k)z!8GWX&8V+O"); + createVfModuleRequest0.setCloudSiteId((String) null); + createVfModuleRequest0.setRequestType(",XO#k)z!8GWX&8V+O"); + createVfModuleRequest0.setMsoRequest((MsoRequest) null); + createVfModuleRequest0.setRequestType(",XO#k)z!8GWX&8V+O"); + createVfModuleRequest0.setVolumeGroupStackId("'ug-"); + createVfModuleRequest0.setVnfType("s7~':&U/'F;]h"); + createVfModuleRequest0.setBaseVfModuleId("'ug-"); + createVfModuleRequest0.toXmlString(); + createVfModuleRequest0.setVnfId("NmH3Tn>J]!Fg%4@%uY"); + createVfModuleRequest0.setVnfId("'ug-"); + createVfModuleRequest0.setVolumeGroupId("'ug-"); + createVfModuleRequest0.setVolumeGroupId("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<createVfModuleRequest>\n <baseVfModuleId>'ug-</baseVfModuleId>\n <requestType>,XO#k)z!8GWX&8V+O</requestType>\n <vfModuleId>,XO#k)z!8GWX&8V+O</vfModuleId>\n <vfModuleParams/>\n <vnfType>s7~':&U/'F;]h</vnfType>\n <volumeGroupStackId>'ug-</volumeGroupStackId>\n</createVfModuleRequest>\n"); + createVfModuleRequest0.getVfModuleType(); + createVfModuleRequest0.getMsoRequest(); + createVfModuleRequest0.getVfModuleName(); + createVfModuleRequest0.getVfModuleId(); + Boolean boolean0 = Boolean.TRUE; + createVfModuleRequest0.setVfModuleName("p'k7"); + createVfModuleRequest0.setFailIfExists(boolean0); + createVfModuleRequest0.getBackout(); + createVfModuleRequest0.getVfModuleType(); + createVfModuleRequest0.setBackout(boolean0); + createVfModuleRequest0.setVfModuleId((String) null); + createVfModuleRequest0.getVfModuleParams(); + String string0 = createVfModuleRequest0.getVfModuleName(); + assertEquals("p'k7", string0); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setCloudSiteId(""); + assertNull(createVfModuleRequest0.getVfModuleType()); + + createVfModuleRequest0.setVfModuleId("-)#\"]O:7"); + createVfModuleRequest0.getRequestType(); + createVfModuleRequest0.getVfModuleName(); + createVfModuleRequest0.setVfModuleName("-)#\"]O:7"); + createVfModuleRequest0.setVnfVersion(""); + createVfModuleRequest0.getVfModuleId(); + Boolean boolean0 = new Boolean("$HZL"); + Boolean.logicalXor(false, true); + Boolean.getBoolean("-)#\"]O:7"); + Boolean.getBoolean("$HZL"); + createVfModuleRequest0.setBackout(boolean0); + CreateVfModuleRequest createVfModuleRequest1 = new CreateVfModuleRequest(); + CreateVfModuleRequest createVfModuleRequest2 = new CreateVfModuleRequest(); + assertTrue(createVfModuleRequest2.isSynchronous()); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setBaseVfModuleStackId(""); + createVfModuleRequest0.getFailIfExists(); + createVfModuleRequest0.setBackout((Boolean) null); + createVfModuleRequest0.setVfModuleName("^z)=F7B=ZvfaN"); + createVfModuleRequest0.getBackout(); + createVfModuleRequest0.setVnfVersion("^z)=F7B=ZvfaN"); + createVfModuleRequest0.setVolumeGroupId("jaxb.formatted.output"); + createVfModuleRequest0.setVfModuleType(""); + createVfModuleRequest0.getVfModuleName(); + createVfModuleRequest0.getVnfId(); + createVfModuleRequest0.setBaseVfModuleId(""); + createVfModuleRequest0.getVfModuleType(); + createVfModuleRequest0.getCloudSiteId(); + createVfModuleRequest0.setVolumeGroupId(""); + createVfModuleRequest0.setFailIfExists((Boolean) null); + String string0 = createVfModuleRequest0.getCloudSiteId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setVolumeGroupId("a72)-2"); + String string0 = createVfModuleRequest0.getVfModuleName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setVfModuleName("}2#uF?(<`4`}."); + assertNull(createVfModuleRequest0.getVnfVersion()); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setVfModuleParams((Map<String, String>) null); + createVfModuleRequest0.getBaseVfModuleId(); + createVfModuleRequest0.getVnfVersion(); + createVfModuleRequest0.setVolumeGroupStackId(""); + createVfModuleRequest0.setCloudSiteId("aZB6^K~Z,$Q1"); + createVfModuleRequest0.setVolumeGroupId(""); + createVfModuleRequest0.setBaseVfModuleId((String) null); + createVfModuleRequest0.getBackout(); + createVfModuleRequest0.getVfModuleParams(); + createVfModuleRequest0.setVolumeGroupStackId("\"tKNX~{9QfJ"); + String string0 = createVfModuleRequest0.getCloudSiteId(); + assertEquals("aZB6^K~Z,$Q1", string0); + } + + @Test(timeout = 4000) + public void test27() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setVnfType("Zp..9csA_m"); + createVfModuleRequest0.setVolumeGroupStackId("Zp..9csA_m"); + createVfModuleRequest0.setVnfId(""); + CreateVfModuleRequest createVfModuleRequest1 = new CreateVfModuleRequest(); + createVfModuleRequest1.setTenantId(""); + createVfModuleRequest1.setVnfVersion(""); + createVfModuleRequest0.setBaseVfModuleId("Zp..9csA_m"); + Boolean boolean0 = Boolean.FALSE; + createVfModuleRequest0.setBackout(boolean0); + createVfModuleRequest0.setVfModuleType(""); + String string0 = createVfModuleRequest0.getVnfType(); + assertEquals("Zp..9csA_m", string0); + } + + @Test(timeout = 4000) + public void test28() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setVolumeGroupStackId(""); + createVfModuleRequest0.setBaseVfModuleId(""); + String string0 = createVfModuleRequest0.getVnfType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test29() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.getVolumeGroupStackId(); + // Undeclared exception! + try { + createVfModuleRequest0.toJsonString(); + fail("Expecting exception: VerifyError"); + + } catch(VerifyError e) { + // + // (class: org/codehaus/jackson/map/MapperConfig, method: <clinit> signature: ()V) Bad type in putfield/putstatic + // + verifyException("org.codehaus.jackson.map.ObjectMapper", e); + } + } + + @Test(timeout = 4000) + public void test30() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setRequestType("]8]Fja*=.9+U"); + createVfModuleRequest0.setVnfVersion("]8]Fja*=.9+U"); + createVfModuleRequest0.setBackout((Boolean) null); + createVfModuleRequest0.setVnfType(""); + createVfModuleRequest0.setVfModuleType("]8]Fja*=.9+U"); + createVfModuleRequest0.setVfModuleId("2`+q>,#Bb"); + createVfModuleRequest0.setCloudSiteId("]8]Fja*=.9+U"); + createVfModuleRequest0.setVolumeGroupId("2`+q>,#Bb"); + createVfModuleRequest0.setVnfId("@=t[3*cN,^q "); + createVfModuleRequest0.getVfModuleType(); + createVfModuleRequest0.getTenantId(); + createVfModuleRequest0.getBackout(); + createVfModuleRequest0.setBaseVfModuleStackId("1w$l-"); + assertTrue(createVfModuleRequest0.isSynchronous()); + } + + @Test(timeout = 4000) + public void test31() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setBaseVfModuleId(""); + createVfModuleRequest0.getCloudSiteId(); + createVfModuleRequest0.setRequestType((String) null); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + createVfModuleRequest0.setVfModuleParams(hashMap0); + assertNull(createVfModuleRequest0.getBaseVfModuleStackId()); + } + + @Test(timeout = 4000) + public void test32() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + MsoRequest msoRequest0 = createVfModuleRequest0.getMsoRequest(); + createVfModuleRequest0.setMsoRequest(msoRequest0); + assertNull(createVfModuleRequest0.getVfModuleName()); + } + + @Test(timeout = 4000) + public void test33() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.setVnfVersion(""); + String string0 = createVfModuleRequest0.getVfModuleId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test34() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.getVolumeGroupId(); + createVfModuleRequest0.setVfModuleType((String) null); + createVfModuleRequest0.setVnfId(""); + assertNull(createVfModuleRequest0.getVnfVersion()); + } + + @Test(timeout = 4000) + public void test35() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.toXmlString(); + createVfModuleRequest0.setVfModuleType(""); + String string0 = createVfModuleRequest0.getVnfVersion(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test36() throws Throwable { + CreateVfModuleRequest createVfModuleRequest0 = new CreateVfModuleRequest(); + createVfModuleRequest0.getVfModuleType(); + createVfModuleRequest0.getVfModuleParams(); + createVfModuleRequest0.setTenantId((String) null); + assertNull(createVfModuleRequest0.getBaseVfModuleId()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleRequestESTestscaffolding.java new file mode 100644 index 0000000000..685cb06f9e --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleRequestESTestscaffolding.java @@ -0,0 +1,197 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:13:00 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class CreateVfModuleRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.CreateVfModuleRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(CreateVfModuleRequestESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.map.JsonSerializableWithType", + "org.openecomp.mso.adapters.vnfrest.CreateVfModuleRequest", + "org.codehaus.jackson.map.deser.StdDeserializerProvider", + "org.codehaus.jackson.map.SerializerFactory", + "org.codehaus.jackson.map.SerializerProvider", + "org.codehaus.jackson.map.SerializationConfig", + "org.codehaus.jackson.JsonProcessingException", + "org.codehaus.jackson.map.introspect.AnnotationMap", + "org.codehaus.jackson.map.introspect.Annotated", + "org.codehaus.jackson.map.util.Annotations", + "org.codehaus.jackson.sym.NameN", + "org.codehaus.jackson.JsonGenerator", + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector", + "org.codehaus.jackson.map.JsonSerializable", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.node.BaseJsonNode", + "org.codehaus.jackson.map.DeserializerProvider", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.node.ValueNode", + "org.codehaus.jackson.map.ser.BeanSerializerFactory", + "org.codehaus.jackson.map.introspect.AnnotatedWithParams", + "org.codehaus.jackson.map.AnnotationIntrospector", + "org.codehaus.jackson.map.MappingJsonFactory", + "org.codehaus.jackson.map.MapperConfig$Impl", + "org.codehaus.jackson.sym.Name1", + "org.codehaus.jackson.sym.Name2", + "org.codehaus.jackson.sym.Name3", + "org.codehaus.jackson.map.introspect.MethodFilter", + "org.codehaus.jackson.map.ser.StdSerializerProvider", + "org.codehaus.jackson.map.deser.StdDeserializationContext", + "org.codehaus.jackson.map.ClassIntrospector", + "org.codehaus.jackson.map.AnnotationIntrospector$Pair", + "org.codehaus.jackson.Versioned", + "org.codehaus.jackson.map.type.TypeBase", + "org.codehaus.jackson.map.ser.BasicSerializerFactory", + "org.codehaus.jackson.node.ContainerNode", + "org.codehaus.jackson.map.introspect.NopAnnotationIntrospector", + "org.codehaus.jackson.map.DeserializationConfig", + "org.codehaus.jackson.map.introspect.AnnotatedConstructor", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory", + "org.codehaus.jackson.impl.ReaderBasedParser", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer$TableInfo", + "org.codehaus.jackson.map.type.MapLikeType", + "org.codehaus.jackson.node.ObjectNode", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$MinimalMethodFilter", + "org.codehaus.jackson.map.type.CollectionLikeType", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer$Bucket", + "org.codehaus.jackson.impl.JsonParserMinimalBase", + "org.codehaus.jackson.map.type.TypeParser", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$SetterMethodFilter", + "org.codehaus.jackson.map.introspect.VisibilityChecker", + "org.codehaus.jackson.map.introspect.AnnotatedField", + "org.codehaus.jackson.impl.JsonGeneratorBase", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.util.ByteArrayBuilder", + "org.codehaus.jackson.PrettyPrinter", + "org.codehaus.jackson.map.jsontype.SubtypeResolver", + "org.codehaus.jackson.map.type.SimpleType", + "org.codehaus.jackson.map.util.StdDateFormat", + "org.codehaus.jackson.impl.Utf8Generator", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$SetterAndGetterMethodFilter", + "org.codehaus.jackson.JsonNode", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.codehaus.jackson.ObjectCodec", + "org.codehaus.jackson.map.introspect.AnnotatedMethod", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.node.ArrayNode", + "org.codehaus.jackson.io.SegmentedStringWriter", + "org.codehaus.jackson.map.jsontype.TypeResolverBuilder", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$GetterMethodFilter", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.map.BeanDescription", + "org.codehaus.jackson.impl.WriterBasedGenerator", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.sym.Name", + "org.codehaus.jackson.map.introspect.BasicBeanDescription", + "org.codehaus.jackson.util.TokenBuffer", + "org.codehaus.jackson.map.DeserializationContext", + "org.codehaus.jackson.impl.JsonParserBase", + "org.codehaus.jackson.map.JsonMappingException", + "org.codehaus.jackson.map.introspect.AnnotatedMember", + "org.codehaus.jackson.type.JavaType", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.annotate.JsonRootName", + "org.codehaus.jackson.JsonParser", + "org.codehaus.jackson.node.NullNode", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.codehaus.jackson.map.jsontype.impl.StdSubtypeResolver", + "org.openecomp.mso.entity.MsoRequest", + "org.codehaus.jackson.node.TreeTraversingParser", + "org.codehaus.jackson.map.type.CollectionType", + "org.codehaus.jackson.map.MapperConfig", + "org.openecomp.mso.adapters.vnfrest.VfRequestCommon", + "org.codehaus.jackson.map.Module$SetupContext", + "org.codehaus.jackson.io.UTF8Writer", + "org.codehaus.jackson.map.type.MapType", + "org.codehaus.jackson.annotate.JsonAutoDetect", + "org.codehaus.jackson.map.type.ArrayType", + "org.codehaus.jackson.map.ClassIntrospector$MixInResolver" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(CreateVfModuleRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleResponseESTest.java new file mode 100644 index 0000000000..b6719ef398 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleResponseESTest.java @@ -0,0 +1,193 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:29:29 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.VnfRollback; +import java.util.HashMap; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class CreateVfModuleResponseESTest extends CreateVfModuleResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + createVfModuleResponse0.setVnfId("IJ@"); + String string0 = createVfModuleResponse0.getVnfId(); + assertEquals("IJ@", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + Boolean boolean0 = Boolean.TRUE; + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse("", "", "", boolean0, (Map<String, String>) hashMap0, (VfModuleRollback) null, ""); + String string0 = createVfModuleResponse0.getVnfId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + createVfModuleResponse0.setVfModuleStackId(", tenantCreated="); + String string0 = createVfModuleResponse0.getVfModuleStackId(); + assertEquals(", tenantCreated=", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + Boolean boolean0 = new Boolean(true); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse("j|[9Y&=Ke", ", tenant=", "", boolean0, (Map<String, String>) hashMap0, (VfModuleRollback) null, ", tenant="); + String string0 = createVfModuleResponse0.getVfModuleStackId(); + assertEquals(", tenant=", createVfModuleResponse0.getVfModuleId()); + assertEquals("", string0); + assertEquals("j|[9Y&=Ke", createVfModuleResponse0.getVnfId()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + Boolean boolean0 = new Boolean(""); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse("Dz?II3`92;Y(@b$'\"", "Dz?II3`92;Y(@b$'\"", "", boolean0, (Map<String, String>) null, vfModuleRollback0, "Dz?II3`92;Y(@b$'\""); + createVfModuleResponse0.getVfModuleOutputs(); + assertEquals("", createVfModuleResponse0.getVfModuleStackId()); + assertEquals("Dz?II3`92;Y(@b$'\"", createVfModuleResponse0.getVfModuleId()); + assertEquals("Dz?II3`92;Y(@b$'\"", createVfModuleResponse0.getVnfId()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + hashMap0.put("01.rc\"}EZ", "01.rc\"}EZ"); + createVfModuleResponse0.setVfModuleOutputs(hashMap0); + Map<String, String> map0 = createVfModuleResponse0.getVfModuleOutputs(); + assertFalse(map0.isEmpty()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + Boolean boolean0 = new Boolean(true); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse("j|[9Y&=Ke", ", tenant=", "", boolean0, (Map<String, String>) hashMap0, (VfModuleRollback) null, ", tenant="); + String string0 = createVfModuleResponse0.getVfModuleId(); + assertEquals("", createVfModuleResponse0.getVfModuleStackId()); + assertEquals(", tenant=", string0); + assertEquals("j|[9Y&=Ke", createVfModuleResponse0.getVnfId()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + Boolean boolean0 = Boolean.TRUE; + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse("", "", "", boolean0, (Map<String, String>) hashMap0, (VfModuleRollback) null, ""); + String string0 = createVfModuleResponse0.getVfModuleId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + Boolean boolean0 = createVfModuleResponse0.getVfModuleCreated(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + Boolean boolean0 = new Boolean(true); + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + Map<String, String> map0 = createVfModuleResponse0.getVfModuleOutputs(); + MsoRequest msoRequest0 = new MsoRequest("a", ""); + VnfRollback vnfRollback0 = new VnfRollback("a", "", (String) null, true, false, msoRequest0, "", (String) null, "a"); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, "a", "", "W[dY"); + CreateVfModuleResponse createVfModuleResponse1 = new CreateVfModuleResponse("a", "", "", boolean0, (Map<String, String>) map0, vfModuleRollback0, "Q"); + createVfModuleResponse1.getVfModuleCreated(); + assertEquals("", createVfModuleResponse1.getVfModuleStackId()); + assertEquals("", createVfModuleResponse1.getVfModuleId()); + assertEquals("a", createVfModuleResponse1.getVnfId()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + createVfModuleResponse0.setRollback((VfModuleRollback) null); + VfModuleRollback vfModuleRollback0 = createVfModuleResponse0.getRollback(); + assertNull(vfModuleRollback0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + Boolean boolean0 = Boolean.FALSE; + MsoRequest msoRequest0 = new MsoRequest(); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback("", "", "GC", true, "", "", msoRequest0, ""); + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse("", "", "", boolean0, (Map<String, String>) null, vfModuleRollback0, "xoOjQ;h*'Qx&0ys4"); + createVfModuleResponse0.getRollback(); + assertEquals("", createVfModuleResponse0.getVnfId()); + assertEquals("", createVfModuleResponse0.getVfModuleStackId()); + assertEquals("", createVfModuleResponse0.getVfModuleId()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + Boolean boolean0 = new Boolean(""); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse("Dz?II3`92;Y(@b$'\"", "Dz?II3`92;Y(@b$'\"", "", boolean0, (Map<String, String>) null, vfModuleRollback0, "Dz?II3`92;Y(@b$'\""); + createVfModuleResponse0.getVfModuleCreated(); + assertEquals("Dz?II3`92;Y(@b$'\"", createVfModuleResponse0.getVfModuleId()); + assertEquals("", createVfModuleResponse0.getVfModuleStackId()); + assertEquals("Dz?II3`92;Y(@b$'\"", createVfModuleResponse0.getVnfId()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + String string0 = createVfModuleResponse0.getVnfId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + String string0 = createVfModuleResponse0.getVfModuleId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + VfModuleRollback vfModuleRollback0 = createVfModuleResponse0.getRollback(); + assertNull(vfModuleRollback0.getCloudSiteId()); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + String string0 = createVfModuleResponse0.getVfModuleStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + createVfModuleResponse0.setVfModuleCreated((Boolean) null); + assertNull(createVfModuleResponse0.getVfModuleStackId()); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + createVfModuleResponse0.setVfModuleId((String) null); + assertNull(createVfModuleResponse0.getVnfId()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleResponseESTestscaffolding.java new file mode 100644 index 0000000000..2e7c295a80 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVfModuleResponseESTestscaffolding.java @@ -0,0 +1,101 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:29:29 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class CreateVfModuleResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.CreateVfModuleResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(CreateVfModuleResponseESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.openstack.beans.VnfRollback", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.adapters.vnfrest.VfModuleRollback", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName", + "org.openecomp.mso.adapters.vnfrest.CreateVfModuleResponse" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(CreateVfModuleResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupRequestESTest.java new file mode 100644 index 0000000000..42a4ff7a0d --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupRequestESTest.java @@ -0,0 +1,367 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:25:19 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.entity.MsoRequest; +import java.util.HashMap; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.System; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class CreateVolumeGroupRequestESTest extends CreateVolumeGroupRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + assertNull(createVolumeGroupRequest0.getVnfVersion()); + + CreateVolumeGroupRequest createVolumeGroupRequest1 = new CreateVolumeGroupRequest(); + MsoRequest msoRequest0 = createVolumeGroupRequest1.getMsoRequest(); + createVolumeGroupRequest0.setMsoRequest(msoRequest0); + Boolean boolean0 = new Boolean(true); + createVolumeGroupRequest0.toXmlString(); + createVolumeGroupRequest0.setVnfVersion("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<createVolumeGroupRequest>\n <msoRequest/>\n <volumeGroupParams/>\n</createVolumeGroupRequest>\n"); + Boolean.compare(true, false); + createVolumeGroupRequest0.setFailIfExists(boolean0); + createVolumeGroupRequest0.getTenantId(); + createVolumeGroupRequest0.getSuppressBackout(); + createVolumeGroupRequest0.getVnfVersion(); + createVolumeGroupRequest1.getVnfVersion(); + createVolumeGroupRequest1.getVolumeGroupName(); + Boolean boolean1 = createVolumeGroupRequest0.getSuppressBackout(); + assertNull(boolean1); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + Boolean boolean0 = Boolean.FALSE; + Boolean.getBoolean("p?:e~"); + createVolumeGroupRequest0.setFailIfExists(boolean0); + createVolumeGroupRequest0.toXmlString(); + createVolumeGroupRequest0.setVnfVersion("\r>M+*VxIe4t0"); + createVolumeGroupRequest0.getFailIfExists(); + createVolumeGroupRequest0.toXmlString(); + createVolumeGroupRequest0.setVolumeGroupId(""); + createVolumeGroupRequest0.getVfModuleType(); + createVolumeGroupRequest0.getSuppressBackout(); + createVolumeGroupRequest0.setVnfVersion(""); + createVolumeGroupRequest0.getVolumeGroupName(); + createVolumeGroupRequest0.setMsoRequest((MsoRequest) null); + createVolumeGroupRequest0.setTenantId((String) null); + createVolumeGroupRequest0.getTenantId(); + createVolumeGroupRequest0.setMsoRequest((MsoRequest) null); + assertNull(createVolumeGroupRequest0.getVolumeGroupName()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + Boolean boolean0 = Boolean.valueOf(true); + createVolumeGroupRequest0.setFailIfExists(boolean0); + createVolumeGroupRequest0.setVnfVersion(""); + createVolumeGroupRequest0.getFailIfExists(); + createVolumeGroupRequest0.getVnfVersion(); + Boolean boolean1 = createVolumeGroupRequest0.getFailIfExists(); + assertTrue(boolean1); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.setVfModuleType("@ 8T"); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + createVolumeGroupRequest0.setVolumeGroupParams(hashMap0); + createVolumeGroupRequest0.getSuppressBackout(); + createVolumeGroupRequest0.setVolumeGroupId("@ 8T"); + createVolumeGroupRequest0.setVolumeGroupId("@ 8T"); + createVolumeGroupRequest0.setVolumeGroupName("@ 8T"); + createVolumeGroupRequest0.getVolumeGroupName(); + createVolumeGroupRequest0.getVnfType(); + String string0 = createVolumeGroupRequest0.getVolumeGroupName(); + String string1 = createVolumeGroupRequest0.getVfModuleType(); + assertTrue(string1.equals((Object)string0)); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.setVnfType(""); + createVolumeGroupRequest0.setVolumeGroupId("I<\"*}"); + createVolumeGroupRequest0.setTenantId(""); + createVolumeGroupRequest0.setMessageId("gZK#x[BqFD"); + createVolumeGroupRequest0.getVnfType(); + createVolumeGroupRequest0.getTenantId(); + Boolean boolean0 = new Boolean(true); + Boolean.logicalOr(true, true); + createVolumeGroupRequest0.setSuppressBackout(boolean0); + createVolumeGroupRequest0.setFailIfExists(boolean0); + assertTrue(createVolumeGroupRequest0.isSynchronous()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.getSkipAAI(); + createVolumeGroupRequest0.setFailIfExists((Boolean) null); + createVolumeGroupRequest0.setVfModuleType(""); + createVolumeGroupRequest0.setNotificationUrl(""); + createVolumeGroupRequest0.setVnfType((String) null); + CreateVolumeGroupRequest createVolumeGroupRequest1 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.getSuppressBackout(); + MsoRequest msoRequest0 = new MsoRequest(); + createVolumeGroupRequest0.setMsoRequest(msoRequest0); + String string0 = createVolumeGroupRequest0.getVfModuleType(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + MsoRequest msoRequest0 = createVolumeGroupRequest0.getMsoRequest(); + createVolumeGroupRequest0.setMsoRequest(msoRequest0); + assertNull(createVolumeGroupRequest0.getVnfType()); + + createVolumeGroupRequest0.getVnfVersion(); + createVolumeGroupRequest0.getTenantId(); + Boolean boolean0 = Boolean.TRUE; + createVolumeGroupRequest0.setSkipAAI(boolean0); + createVolumeGroupRequest0.setSuppressBackout(boolean0); + Boolean boolean1 = createVolumeGroupRequest0.getSuppressBackout(); + createVolumeGroupRequest0.setVnfVersion(""); + Boolean.compare(false, false); + createVolumeGroupRequest0.setSuppressBackout(boolean1); + assertNull(createVolumeGroupRequest0.getVolumeGroupName()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + hashMap0.put("", ""); + createVolumeGroupRequest0.setVolumeGroupParams(hashMap0); + createVolumeGroupRequest0.getVolumeGroupParams(); + createVolumeGroupRequest0.setVfModuleType("jaxb.formatted.output"); + assertNull(createVolumeGroupRequest0.getVnfType()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + CreateVolumeGroupRequest createVolumeGroupRequest1 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest1.getSkipAAI(); + createVolumeGroupRequest0.setFailIfExists((Boolean) null); + createVolumeGroupRequest0.setVnfType("Hi&CG{k}/*QY9RvXr"); + createVolumeGroupRequest1.setMessageId(""); + createVolumeGroupRequest1.setVnfType("xUUBE/B}M{1"); + String string0 = createVolumeGroupRequest1.getVnfType(); + assertEquals("xUUBE/B}M{1", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.setCloudSiteId(""); + createVolumeGroupRequest0.setVolumeGroupId(""); + createVolumeGroupRequest0.setMessageId(""); + createVolumeGroupRequest0.setVfModuleType(""); + String string0 = createVolumeGroupRequest0.getCloudSiteId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + CreateVolumeGroupRequest createVolumeGroupRequest1 = new CreateVolumeGroupRequest(); + Map<String, String> map0 = createVolumeGroupRequest1.getVolumeGroupParams(); + createVolumeGroupRequest1.setVolumeGroupParams(map0); + createVolumeGroupRequest0.setTenantId("$m="); + createVolumeGroupRequest0.setVolumeGroupParams(map0); + createVolumeGroupRequest1.getSuppressBackout(); + createVolumeGroupRequest0.getTenantId(); + createVolumeGroupRequest1.setVolumeGroupId((String) null); + createVolumeGroupRequest0.getVfModuleType(); + createVolumeGroupRequest0.getSuppressBackout(); + createVolumeGroupRequest0.setFailIfExists((Boolean) null); + createVolumeGroupRequest0.getSuppressBackout(); + createVolumeGroupRequest0.setSuppressBackout((Boolean) null); + createVolumeGroupRequest0.getVnfType(); + String string0 = createVolumeGroupRequest1.getVfModuleType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + MsoRequest msoRequest0 = new MsoRequest("V", ""); + createVolumeGroupRequest0.setMsoRequest(msoRequest0); + createVolumeGroupRequest0.setVolumeGroupId("V"); + createVolumeGroupRequest0.getVolumeGroupId(); + Map<String, String> map0 = createVolumeGroupRequest0.getVolumeGroupParams(); + assertEquals(0, map0.size()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.setCloudSiteId("q^BO"); + createVolumeGroupRequest0.setCloudSiteId(")|yH"); + Boolean boolean0 = new Boolean(true); + Boolean.logicalXor(true, true); + createVolumeGroupRequest0.setSuppressBackout(boolean0); + createVolumeGroupRequest0.setVnfVersion("1SaWHwHs.6GKc|"); + createVolumeGroupRequest0.getCloudSiteId(); + CreateVolumeGroupRequest createVolumeGroupRequest1 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.getCloudSiteId(); + CreateVolumeGroupRequest createVolumeGroupRequest2 = new CreateVolumeGroupRequest(); + assertNull(createVolumeGroupRequest2.getVfModuleType()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + Boolean boolean0 = Boolean.valueOf(true); + createVolumeGroupRequest0.setVolumeGroupId(""); + createVolumeGroupRequest0.setFailIfExists(boolean0); + createVolumeGroupRequest0.setSuppressBackout(boolean0); + createVolumeGroupRequest0.getVolumeGroupName(); + CreateVolumeGroupRequest createVolumeGroupRequest1 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.getVolumeGroupId(); + createVolumeGroupRequest0.setVolumeGroupId((String) null); + createVolumeGroupRequest1.setTenantId("k|l4f6h+M:_"); + assertNull(createVolumeGroupRequest1.getVnfVersion()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.toXmlString(); + createVolumeGroupRequest0.setMsoRequest((MsoRequest) null); + createVolumeGroupRequest0.setVfModuleType(""); + createVolumeGroupRequest0.getFailIfExists(); + createVolumeGroupRequest0.setSuppressBackout((Boolean) null); + createVolumeGroupRequest0.setSuppressBackout((Boolean) null); + createVolumeGroupRequest0.getMsoRequest(); + createVolumeGroupRequest0.setMsoRequest((MsoRequest) null); + createVolumeGroupRequest0.setVnfVersion("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<createVolumeGroupRequest>\n <msoRequest/>\n <volumeGroupParams/>\n</createVolumeGroupRequest>\n"); + createVolumeGroupRequest0.getVolumeGroupId(); + String string0 = createVolumeGroupRequest0.getVolumeGroupName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.setVolumeGroupId("C}BU:zm--=1Md"); + Boolean boolean0 = Boolean.valueOf(false); + createVolumeGroupRequest0.setSuppressBackout(boolean0); + createVolumeGroupRequest0.setVnfVersion(""); + createVolumeGroupRequest0.setVfModuleType("i%IbRNJ6X^k'i&e+s"); + createVolumeGroupRequest0.setVnfType(""); + createVolumeGroupRequest0.getSuppressBackout(); + createVolumeGroupRequest0.setVolumeGroupId("i%IbRNJ6X^k'i&e+s"); + createVolumeGroupRequest0.setTenantId(""); + createVolumeGroupRequest0.setVolumeGroupId(""); + createVolumeGroupRequest0.setVnfVersion("VK&a"); + createVolumeGroupRequest0.setTenantId(""); + assertEquals("", createVolumeGroupRequest0.getVolumeGroupId()); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + String string0 = createVolumeGroupRequest0.getVnfVersion(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + String string0 = createVolumeGroupRequest0.getTenantId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.setVolumeGroupId(""); + assertNull(createVolumeGroupRequest0.getVolumeGroupName()); + + String string0 = createVolumeGroupRequest0.getCloudSiteId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.getVolumeGroupParams(); + createVolumeGroupRequest0.getVnfType(); + createVolumeGroupRequest0.setCloudSiteId(""); + assertEquals("", createVolumeGroupRequest0.getCloudSiteId()); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.getFailIfExists(); + createVolumeGroupRequest0.setSuppressBackout((Boolean) null); + assertNull(createVolumeGroupRequest0.getVnfType()); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.setNotificationUrl(""); + createVolumeGroupRequest0.setVolumeGroupParams((Map<String, String>) null); + createVolumeGroupRequest0.getFailIfExists(); + Boolean.compare(true, true); + createVolumeGroupRequest0.setFailIfExists((Boolean) null); + createVolumeGroupRequest0.getFailIfExists(); + createVolumeGroupRequest0.setVolumeGroupName(""); + createVolumeGroupRequest0.getVolumeGroupName(); + createVolumeGroupRequest0.getVolumeGroupParams(); + System.setCurrentTimeMillis(0); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.getSuppressBackout(); + createVolumeGroupRequest0.setFailIfExists((Boolean) null); + assertNull(createVolumeGroupRequest0.getVfModuleType()); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.setVolumeGroupName(""); + assertNull(createVolumeGroupRequest0.getNotificationUrl()); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + createVolumeGroupRequest0.toXmlString(); + String string0 = createVolumeGroupRequest0.getVolumeGroupId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + Map<String, String> map0 = createVolumeGroupRequest0.getVolumeGroupParams(); + assertTrue(map0.isEmpty()); + + createVolumeGroupRequest0.setVolumeGroupParams(map0); + assertNull(createVolumeGroupRequest0.getVolumeGroupName()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupRequestESTestscaffolding.java new file mode 100644 index 0000000000..2cd4efca2b --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupRequestESTestscaffolding.java @@ -0,0 +1,100 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:25:19 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class CreateVolumeGroupRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(CreateVolumeGroupRequestESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnfrest.VfRequestCommon", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupRequest", + "org.openecomp.mso.entity.MsoRequest", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(CreateVolumeGroupRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupResponseESTest.java new file mode 100644 index 0000000000..141d7f8504 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupResponseESTest.java @@ -0,0 +1,141 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:22:14 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class CreateVolumeGroupResponseESTest extends CreateVolumeGroupResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + CreateVolumeGroupResponse createVolumeGroupResponse0 = new CreateVolumeGroupResponse(); + createVolumeGroupResponse0.setVolumeGroupStackId("#soQ+\"O.VGnL"); + String string0 = createVolumeGroupResponse0.getVolumeGroupStackId(); + assertEquals("#soQ+\"O.VGnL", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + CreateVolumeGroupResponse createVolumeGroupResponse0 = new CreateVolumeGroupResponse(); + createVolumeGroupResponse0.setVolumeGroupOutputs((Map<String, String>) null); + Map<String, String> map0 = createVolumeGroupResponse0.getVolumeGroupOutputs(); + assertNull(map0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + CreateVolumeGroupResponse createVolumeGroupResponse0 = new CreateVolumeGroupResponse(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + hashMap0.put(",MyEf", ",MyEf"); + createVolumeGroupResponse0.setVolumeGroupOutputs(hashMap0); + Map<String, String> map0 = createVolumeGroupResponse0.getVolumeGroupOutputs(); + assertFalse(map0.isEmpty()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + CreateVolumeGroupResponse createVolumeGroupResponse0 = new CreateVolumeGroupResponse(); + createVolumeGroupResponse0.setVolumeGroupId(".X(v-Tvwzh&"); + String string0 = createVolumeGroupResponse0.getVolumeGroupId(); + assertEquals(".X(v-Tvwzh&", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + CreateVolumeGroupResponse createVolumeGroupResponse0 = new CreateVolumeGroupResponse(); + createVolumeGroupResponse0.setVolumeGroupId(""); + String string0 = createVolumeGroupResponse0.getVolumeGroupId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + CreateVolumeGroupResponse createVolumeGroupResponse0 = new CreateVolumeGroupResponse(); + Boolean boolean0 = Boolean.valueOf(true); + createVolumeGroupResponse0.setVolumeGroupCreated(boolean0); + Boolean boolean1 = createVolumeGroupResponse0.getVolumeGroupCreated(); + assertTrue(boolean1); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + CreateVolumeGroupResponse createVolumeGroupResponse0 = new CreateVolumeGroupResponse(); + Boolean boolean0 = new Boolean("^MG80I,4g3M>=01Xp"); + createVolumeGroupResponse0.setVolumeGroupCreated(boolean0); + Boolean boolean1 = createVolumeGroupResponse0.getVolumeGroupCreated(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + CreateVolumeGroupResponse createVolumeGroupResponse0 = new CreateVolumeGroupResponse(); + createVolumeGroupResponse0.setVolumeGroupStackId(""); + String string0 = createVolumeGroupResponse0.getVolumeGroupStackId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + CreateVolumeGroupResponse createVolumeGroupResponse0 = new CreateVolumeGroupResponse(); + VolumeGroupRollback volumeGroupRollback0 = createVolumeGroupResponse0.getVolumeGroupRollback(); + volumeGroupRollback0.setVolumeGroupCreated(true); + VolumeGroupRollback volumeGroupRollback1 = createVolumeGroupResponse0.getVolumeGroupRollback(); + assertSame(volumeGroupRollback1, volumeGroupRollback0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + CreateVolumeGroupResponse createVolumeGroupResponse0 = new CreateVolumeGroupResponse(); + createVolumeGroupResponse0.setVolumeGroupRollback((VolumeGroupRollback) null); + VolumeGroupRollback volumeGroupRollback0 = createVolumeGroupResponse0.getVolumeGroupRollback(); + assertNull(volumeGroupRollback0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + CreateVolumeGroupResponse createVolumeGroupResponse0 = new CreateVolumeGroupResponse(); + Boolean boolean0 = createVolumeGroupResponse0.getVolumeGroupCreated(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + CreateVolumeGroupResponse createVolumeGroupResponse0 = new CreateVolumeGroupResponse(); + String string0 = createVolumeGroupResponse0.getVolumeGroupStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + CreateVolumeGroupResponse createVolumeGroupResponse0 = new CreateVolumeGroupResponse(); + String string0 = createVolumeGroupResponse0.getVolumeGroupId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + CreateVolumeGroupResponse createVolumeGroupResponse0 = new CreateVolumeGroupResponse(); + Map<String, String> map0 = createVolumeGroupResponse0.getVolumeGroupOutputs(); + createVolumeGroupResponse0.setVolumeGroupOutputs(map0); + assertNull(createVolumeGroupResponse0.getVolumeGroupId()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + CreateVolumeGroupResponse createVolumeGroupResponse0 = new CreateVolumeGroupResponse(); + Map<String, String> map0 = createVolumeGroupResponse0.getVolumeGroupOutputs(); + CreateVolumeGroupResponse createVolumeGroupResponse1 = new CreateVolumeGroupResponse("", "", (Boolean) null, map0, (VolumeGroupRollback) null, ""); + assertEquals("", createVolumeGroupResponse1.getVolumeGroupStackId()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupResponseESTestscaffolding.java new file mode 100644 index 0000000000..990517d29a --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/CreateVolumeGroupResponseESTestscaffolding.java @@ -0,0 +1,100 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:22:14 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class CreateVolumeGroupResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(CreateVolumeGroupResponseESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.adapters.vnfrest.VolumeGroupRollback", + "org.openecomp.mso.entity.MsoRequest", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupResponse", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(CreateVolumeGroupResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleRequestESTest.java new file mode 100644 index 0000000000..8c2d6b7594 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleRequestESTest.java @@ -0,0 +1,149 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:28:35 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.entity.MsoRequest; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class DeleteVfModuleRequestESTest extends DeleteVfModuleRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + deleteVfModuleRequest0.setVnfId("5=?YJsH"); + String string0 = deleteVfModuleRequest0.getVnfId(); + assertEquals("5=?YJsH", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + deleteVfModuleRequest0.setVfModuleStackId("}VSDk5?"); + String string0 = deleteVfModuleRequest0.getVfModuleStackId(); + assertEquals("}VSDk5?", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + deleteVfModuleRequest0.setVfModuleId("Si8s(O0S8"); + String string0 = deleteVfModuleRequest0.getVfModuleId(); + assertEquals("Si8s(O0S8", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + deleteVfModuleRequest0.setTenantId(""); + String string0 = deleteVfModuleRequest0.getTenantId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + deleteVfModuleRequest0.setMsoRequest((MsoRequest) null); + MsoRequest msoRequest0 = deleteVfModuleRequest0.getMsoRequest(); + assertNull(msoRequest0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + deleteVfModuleRequest0.setCloudSiteId(""); + String string0 = deleteVfModuleRequest0.getCloudSiteId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + String string0 = deleteVfModuleRequest0.getVfModuleId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + String string0 = deleteVfModuleRequest0.getCloudSiteId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + deleteVfModuleRequest0.setTenantId("[!?QZiHc2["); + String string0 = deleteVfModuleRequest0.getTenantId(); + assertEquals("[!?QZiHc2[", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + deleteVfModuleRequest0.setVnfId(""); + String string0 = deleteVfModuleRequest0.getVnfId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + deleteVfModuleRequest0.setCloudSiteId("jaxb.formatted.output"); + String string0 = deleteVfModuleRequest0.getCloudSiteId(); + assertEquals("jaxb.formatted.output", string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + String string0 = deleteVfModuleRequest0.getTenantId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + String string0 = deleteVfModuleRequest0.getVnfId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + deleteVfModuleRequest0.setVfModuleId(""); + String string0 = deleteVfModuleRequest0.getVfModuleId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + deleteVfModuleRequest0.setVfModuleStackId(""); + String string0 = deleteVfModuleRequest0.getVfModuleStackId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + MsoRequest msoRequest0 = deleteVfModuleRequest0.getMsoRequest(); + deleteVfModuleRequest0.setMsoRequest(msoRequest0); + assertNull(deleteVfModuleRequest0.getVnfId()); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + String string0 = deleteVfModuleRequest0.getVfModuleStackId(); + assertNull(string0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleRequestESTestscaffolding.java new file mode 100644 index 0000000000..3090fbc4d1 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleRequestESTestscaffolding.java @@ -0,0 +1,100 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:28:35 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class DeleteVfModuleRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.DeleteVfModuleRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DeleteVfModuleRequestESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnfrest.VfRequestCommon", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.adapters.vnfrest.DeleteVfModuleRequest", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(DeleteVfModuleRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleResponseESTest.java new file mode 100644 index 0000000000..e141f4b4e1 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleResponseESTest.java @@ -0,0 +1,112 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:11:34 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class DeleteVfModuleResponseESTest extends DeleteVfModuleResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse(); + String string0 = deleteVfModuleResponse0.getVnfId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + Boolean boolean0 = new Boolean(true); + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse("", "", boolean0, ""); + String string0 = deleteVfModuleResponse0.getVnfId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse(); + String string0 = deleteVfModuleResponse0.getVfModuleId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + Boolean boolean0 = Boolean.valueOf(""); + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse("", "", boolean0, ""); + String string0 = deleteVfModuleResponse0.getVfModuleId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse(); + Boolean boolean0 = deleteVfModuleResponse0.getVfModuleDeleted(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + Boolean boolean0 = Boolean.valueOf(""); + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse("", "", boolean0, ""); + Boolean boolean1 = deleteVfModuleResponse0.getVfModuleDeleted(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + Boolean boolean0 = Boolean.valueOf(true); + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse("0ID1Ty#VhJ)'G`m%:", "ZtG4nF]b8,X8", boolean0, "V)B9%\"dq&%l{_Ou@"); + String string0 = deleteVfModuleResponse0.getVfModuleId(); + assertEquals("ZtG4nF]b8,X8", string0); + assertEquals("0ID1Ty#VhJ)'G`m%:", deleteVfModuleResponse0.getVnfId()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse(); + Boolean boolean0 = Boolean.valueOf(""); + deleteVfModuleResponse0.setVfModuleDeleted(boolean0); + assertNull(deleteVfModuleResponse0.getVfModuleId()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse(); + deleteVfModuleResponse0.setVfModuleId("D:`0Q"); + assertNull(deleteVfModuleResponse0.getMessageId()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + Boolean boolean0 = Boolean.FALSE; + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse("%cklg~Aa", "h*U[;Rpm9k o5[<", boolean0, "%cklg~Aa"); + String string0 = deleteVfModuleResponse0.getVnfId(); + assertEquals("h*U[;Rpm9k o5[<", deleteVfModuleResponse0.getVfModuleId()); + assertEquals("%cklg~Aa", string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + Boolean boolean0 = Boolean.valueOf(true); + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse("0ID1Ty#VhJ)'G`m%:", "ZtG4nF]b8,X8", boolean0, "V)B9%\"dq&%l{_Ou@"); + deleteVfModuleResponse0.getVfModuleDeleted(); + assertEquals("ZtG4nF]b8,X8", deleteVfModuleResponse0.getVfModuleId()); + assertEquals("0ID1Ty#VhJ)'G`m%:", deleteVfModuleResponse0.getVnfId()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + Boolean boolean0 = Boolean.valueOf(""); + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse("", "", boolean0, ""); + deleteVfModuleResponse0.setVnfId(""); + assertEquals("", deleteVfModuleResponse0.getVnfId()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleResponseESTestscaffolding.java new file mode 100644 index 0000000000..c1b3717fbc --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVfModuleResponseESTestscaffolding.java @@ -0,0 +1,98 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:11:34 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class DeleteVfModuleResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.DeleteVfModuleResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DeleteVfModuleResponseESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.adapters.vnfrest.DeleteVfModuleResponse", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(DeleteVfModuleResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupRequestESTest.java new file mode 100644 index 0000000000..e9d6d0e041 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupRequestESTest.java @@ -0,0 +1,126 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:17:10 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.entity.MsoRequest; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class DeleteVolumeGroupRequestESTest extends DeleteVolumeGroupRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + deleteVolumeGroupRequest0.setVolumeGroupStackId(""); + String string0 = deleteVolumeGroupRequest0.getVolumeGroupStackId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + deleteVolumeGroupRequest0.setVolumeGroupId(""); + String string0 = deleteVolumeGroupRequest0.getVolumeGroupId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + deleteVolumeGroupRequest0.setTenantId("yv3_q/ h?N"); + String string0 = deleteVolumeGroupRequest0.getTenantId(); + assertEquals("yv3_q/ h?N", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + deleteVolumeGroupRequest0.setMsoRequest((MsoRequest) null); + MsoRequest msoRequest0 = deleteVolumeGroupRequest0.getMsoRequest(); + assertNull(msoRequest0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + deleteVolumeGroupRequest0.setCloudSiteId("u'!&M 10_"); + String string0 = deleteVolumeGroupRequest0.getCloudSiteId(); + assertEquals("u'!&M 10_", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + String string0 = deleteVolumeGroupRequest0.getVolumeGroupId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + deleteVolumeGroupRequest0.setVolumeGroupId(")wf3_"); + String string0 = deleteVolumeGroupRequest0.getVolumeGroupId(); + assertEquals(")wf3_", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + deleteVolumeGroupRequest0.setVolumeGroupStackId("jaxb.formatted.output"); + String string0 = deleteVolumeGroupRequest0.getVolumeGroupStackId(); + assertEquals("jaxb.formatted.output", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + deleteVolumeGroupRequest0.setTenantId(""); + String string0 = deleteVolumeGroupRequest0.getTenantId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + MsoRequest msoRequest0 = deleteVolumeGroupRequest0.getMsoRequest(); + deleteVolumeGroupRequest0.setMsoRequest(msoRequest0); + assertNull(msoRequest0.getRequestId()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + deleteVolumeGroupRequest0.setCloudSiteId(""); + String string0 = deleteVolumeGroupRequest0.getCloudSiteId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + String string0 = deleteVolumeGroupRequest0.getVolumeGroupStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + String string0 = deleteVolumeGroupRequest0.getCloudSiteId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + String string0 = deleteVolumeGroupRequest0.getTenantId(); + assertNull(string0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupRequestESTestscaffolding.java new file mode 100644 index 0000000000..844120296b --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupRequestESTestscaffolding.java @@ -0,0 +1,100 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:17:10 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class DeleteVolumeGroupRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DeleteVolumeGroupRequestESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnfrest.VfRequestCommon", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupRequest", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(DeleteVolumeGroupRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupResponseESTest.java new file mode 100644 index 0000000000..2947693f9c --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupResponseESTest.java @@ -0,0 +1,42 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:18:54 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class DeleteVolumeGroupResponseESTest extends DeleteVolumeGroupResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + Boolean boolean0 = new Boolean(true); + DeleteVolumeGroupResponse deleteVolumeGroupResponse0 = new DeleteVolumeGroupResponse(boolean0, (String) null); + Boolean boolean1 = new Boolean(""); + deleteVolumeGroupResponse0.setVolumeGroupDeleted(boolean1); + Boolean boolean2 = deleteVolumeGroupResponse0.getVolumeGroupDeleted(); + assertFalse(boolean2.equals((Object)boolean0)); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + DeleteVolumeGroupResponse deleteVolumeGroupResponse0 = new DeleteVolumeGroupResponse(); + Boolean boolean0 = deleteVolumeGroupResponse0.getVolumeGroupDeleted(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + Boolean boolean0 = new Boolean(true); + DeleteVolumeGroupResponse deleteVolumeGroupResponse0 = new DeleteVolumeGroupResponse(boolean0, (String) null); + Boolean boolean1 = deleteVolumeGroupResponse0.getVolumeGroupDeleted(); + assertTrue(boolean1); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupResponseESTestscaffolding.java new file mode 100644 index 0000000000..f0476f61ce --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/DeleteVolumeGroupResponseESTestscaffolding.java @@ -0,0 +1,98 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:18:54 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class DeleteVolumeGroupResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DeleteVolumeGroupResponseESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupResponse", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(DeleteVolumeGroupResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponseESTest.java new file mode 100644 index 0000000000..61e98845b3 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponseESTest.java @@ -0,0 +1,170 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:15:19 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.openecomp.mso.openstack.beans.VnfStatus; +import java.util.HashMap; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class QueryVfModuleResponseESTest extends QueryVfModuleResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse(); + queryVfModuleResponse0.setVnfId("K@Avo(l_W.<jd$"); + String string0 = queryVfModuleResponse0.getVnfId(); + assertEquals("K@Avo(l_W.<jd$", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + VnfStatus vnfStatus0 = VnfStatus.UNKNOWN; + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse("", "", "/iul.p>pa`w<:0tL", vnfStatus0, (Map<String, String>) hashMap0); + String string0 = queryVfModuleResponse0.getVnfId(); + assertEquals("/iul.p>pa`w<:0tL", queryVfModuleResponse0.getVfModuleStackId()); + assertEquals("", string0); + assertEquals("", queryVfModuleResponse0.getVfModuleId()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + VnfStatus vnfStatus0 = VnfStatus.UNKNOWN; + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse("", "", "", vnfStatus0, (Map<String, String>) null); + String string0 = queryVfModuleResponse0.getVfModuleStackId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + VnfStatus vnfStatus0 = VnfStatus.UNKNOWN; + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse("", "", "/iul.p>pa`w<:0tL", vnfStatus0, (Map<String, String>) hashMap0); + queryVfModuleResponse0.getVfModuleOutputs(); + assertEquals("", queryVfModuleResponse0.getVnfId()); + assertEquals("/iul.p>pa`w<:0tL", queryVfModuleResponse0.getVfModuleStackId()); + assertEquals("", queryVfModuleResponse0.getVfModuleId()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + VnfStatus vnfStatus0 = VnfStatus.UNKNOWN; + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse("", "", "q'&!##_pFRAIJ4uo]*=", vnfStatus0, (Map<String, String>) hashMap0); + hashMap0.put("q'&!##_pFRAIJ4uo]*=", ""); + queryVfModuleResponse0.getVfModuleOutputs(); + assertEquals("", queryVfModuleResponse0.getVfModuleId()); + assertEquals("q'&!##_pFRAIJ4uo]*=", queryVfModuleResponse0.getVfModuleStackId()); + assertEquals("", queryVfModuleResponse0.getVnfId()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + VnfStatus vnfStatus0 = VnfStatus.FAILED; + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse("C5aGYYh%|7be0.E!NHp", "C5aGYYh%|7be0.E!NHp", "C5aGYYh%|7be0.E!NHp", vnfStatus0, (Map<String, String>) hashMap0); + String string0 = queryVfModuleResponse0.getVfModuleId(); + assertEquals("C5aGYYh%|7be0.E!NHp", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse(); + VnfStatus vnfStatus0 = VnfStatus.NOTFOUND; + queryVfModuleResponse0.setVnfStatus(vnfStatus0); + VnfStatus vnfStatus1 = queryVfModuleResponse0.getVnfStatus(); + assertSame(vnfStatus1, vnfStatus0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse(); + String string0 = queryVfModuleResponse0.getVfModuleId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse(); + queryVfModuleResponse0.setVfModuleId("\"Sdeh"); + assertNull(queryVfModuleResponse0.getVfModuleStackId()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse(); + String string0 = queryVfModuleResponse0.getVnfId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse(); + Map<String, String> map0 = queryVfModuleResponse0.getVfModuleOutputs(); + assertNull(map0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse(); + queryVfModuleResponse0.setVfModuleStackId("\"Sdeh"); + String string0 = queryVfModuleResponse0.getVfModuleStackId(); + assertEquals("\"Sdeh", string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse(); + // Undeclared exception! + try { + queryVfModuleResponse0.toJsonString(); + fail("Expecting exception: VerifyError"); + + } catch(VerifyError e) { + // + // (class: org/codehaus/jackson/map/MapperConfig, method: <clinit> signature: ()V) Bad type in putfield/putstatic + // + verifyException("org.codehaus.jackson.map.ObjectMapper", e); + } + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + queryVfModuleResponse0.setVfModuleOutputs(hashMap0); + assertNull(queryVfModuleResponse0.getVfModuleId()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse(); + String string0 = queryVfModuleResponse0.getVfModuleStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + VnfStatus vnfStatus0 = VnfStatus.ACTIVE; + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse((String) null, "", "", vnfStatus0, (Map<String, String>) null); + String string0 = queryVfModuleResponse0.getVfModuleId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + QueryVfModuleResponse queryVfModuleResponse0 = new QueryVfModuleResponse(); + queryVfModuleResponse0.getVnfStatus(); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponseESTestscaffolding.java new file mode 100644 index 0000000000..fcad1ead16 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponseESTestscaffolding.java @@ -0,0 +1,194 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:15:19 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class QueryVfModuleResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.QueryVfModuleResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(QueryVfModuleResponseESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.map.JsonSerializableWithType", + "org.codehaus.jackson.map.deser.StdDeserializerProvider", + "org.codehaus.jackson.map.SerializerFactory", + "org.codehaus.jackson.map.SerializerProvider", + "org.codehaus.jackson.map.SerializationConfig", + "org.codehaus.jackson.JsonProcessingException", + "org.codehaus.jackson.map.introspect.AnnotationMap", + "org.openecomp.mso.adapters.vnfrest.QueryVfModuleResponse", + "org.codehaus.jackson.map.introspect.Annotated", + "org.codehaus.jackson.map.util.Annotations", + "org.codehaus.jackson.sym.NameN", + "org.codehaus.jackson.JsonGenerator", + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector", + "org.codehaus.jackson.map.JsonSerializable", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.node.BaseJsonNode", + "org.codehaus.jackson.map.DeserializerProvider", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.node.ValueNode", + "org.codehaus.jackson.map.ser.BeanSerializerFactory", + "org.codehaus.jackson.map.introspect.AnnotatedWithParams", + "org.codehaus.jackson.map.AnnotationIntrospector", + "org.codehaus.jackson.map.MappingJsonFactory", + "org.codehaus.jackson.map.MapperConfig$Impl", + "org.codehaus.jackson.sym.Name1", + "org.codehaus.jackson.sym.Name2", + "org.codehaus.jackson.sym.Name3", + "org.codehaus.jackson.map.introspect.MethodFilter", + "org.codehaus.jackson.map.ser.StdSerializerProvider", + "org.codehaus.jackson.map.deser.StdDeserializationContext", + "org.codehaus.jackson.map.ClassIntrospector", + "org.codehaus.jackson.map.AnnotationIntrospector$Pair", + "org.codehaus.jackson.Versioned", + "org.codehaus.jackson.map.type.TypeBase", + "org.codehaus.jackson.map.ser.BasicSerializerFactory", + "org.codehaus.jackson.node.ContainerNode", + "org.codehaus.jackson.map.introspect.NopAnnotationIntrospector", + "org.codehaus.jackson.map.DeserializationConfig", + "org.codehaus.jackson.map.introspect.AnnotatedConstructor", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory", + "org.codehaus.jackson.impl.ReaderBasedParser", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer$TableInfo", + "org.codehaus.jackson.map.type.MapLikeType", + "org.codehaus.jackson.node.ObjectNode", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$MinimalMethodFilter", + "org.codehaus.jackson.map.type.CollectionLikeType", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer$Bucket", + "org.codehaus.jackson.impl.JsonParserMinimalBase", + "org.codehaus.jackson.map.type.TypeParser", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$SetterMethodFilter", + "org.codehaus.jackson.map.introspect.VisibilityChecker", + "org.codehaus.jackson.map.introspect.AnnotatedField", + "org.codehaus.jackson.impl.JsonGeneratorBase", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.util.ByteArrayBuilder", + "org.codehaus.jackson.PrettyPrinter", + "org.codehaus.jackson.map.jsontype.SubtypeResolver", + "org.codehaus.jackson.map.type.SimpleType", + "org.codehaus.jackson.map.util.StdDateFormat", + "org.codehaus.jackson.impl.Utf8Generator", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$SetterAndGetterMethodFilter", + "org.codehaus.jackson.JsonNode", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.openstack.beans.VnfStatus", + "org.codehaus.jackson.ObjectCodec", + "org.codehaus.jackson.map.introspect.AnnotatedMethod", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.node.ArrayNode", + "org.codehaus.jackson.io.SegmentedStringWriter", + "org.codehaus.jackson.map.jsontype.TypeResolverBuilder", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$GetterMethodFilter", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.map.BeanDescription", + "org.codehaus.jackson.impl.WriterBasedGenerator", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.sym.Name", + "org.codehaus.jackson.map.introspect.BasicBeanDescription", + "org.codehaus.jackson.util.TokenBuffer", + "org.codehaus.jackson.map.DeserializationContext", + "org.codehaus.jackson.impl.JsonParserBase", + "org.codehaus.jackson.map.JsonMappingException", + "org.codehaus.jackson.map.introspect.AnnotatedMember", + "org.codehaus.jackson.type.JavaType", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.JsonParser", + "org.codehaus.jackson.node.NullNode", + "org.codehaus.jackson.map.jsontype.impl.StdSubtypeResolver", + "org.codehaus.jackson.node.TreeTraversingParser", + "org.codehaus.jackson.map.type.CollectionType", + "org.codehaus.jackson.map.MapperConfig", + "org.codehaus.jackson.map.Module$SetupContext", + "org.codehaus.jackson.io.UTF8Writer", + "org.codehaus.jackson.map.type.MapType", + "org.codehaus.jackson.annotate.JsonAutoDetect", + "org.codehaus.jackson.map.type.ArrayType", + "org.codehaus.jackson.map.ClassIntrospector$MixInResolver" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(QueryVfModuleResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleRequestESTest.java new file mode 100644 index 0000000000..326205981a --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleRequestESTest.java @@ -0,0 +1,48 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:14:23 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.VnfRollback; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RollbackVfModuleRequestESTest extends RollbackVfModuleRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + RollbackVfModuleRequest rollbackVfModuleRequest0 = new RollbackVfModuleRequest(); + MsoRequest msoRequest0 = new MsoRequest(); + VnfRollback vnfRollback0 = new VnfRollback("iL", "cG!", "", true, true, msoRequest0, "cG!", "", (String) null); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, "", "", (String) null); + rollbackVfModuleRequest0.setVfModuleRollback(vfModuleRollback0); + VfModuleRollback vfModuleRollback1 = rollbackVfModuleRequest0.getVfModuleRollback(); + assertEquals("", vfModuleRollback1.getVfModuleStackId()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + RollbackVfModuleRequest rollbackVfModuleRequest0 = new RollbackVfModuleRequest(); + MsoRequest msoRequest0 = new MsoRequest("MJ|D", "MJ|D"); + VnfRollback vnfRollback0 = new VnfRollback("jaxb.formatted.output", "jaxb.formatted.output", "jaxb.formatted.output", false, false, msoRequest0, "", "", ""); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, (String) null, "jaxb.formatted.output", "jaxb.formatted.output"); + rollbackVfModuleRequest0.setVfModuleRollback(vfModuleRollback0); + VfModuleRollback vfModuleRollback1 = rollbackVfModuleRequest0.getVfModuleRollback(); + assertEquals("jaxb.formatted.output", vfModuleRollback1.getTenantId()); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + RollbackVfModuleRequest rollbackVfModuleRequest0 = new RollbackVfModuleRequest(); + VfModuleRollback vfModuleRollback0 = rollbackVfModuleRequest0.getVfModuleRollback(); + assertNull(vfModuleRollback0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleRequestESTestscaffolding.java new file mode 100644 index 0000000000..aae081ec17 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleRequestESTestscaffolding.java @@ -0,0 +1,102 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:14:23 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RollbackVfModuleRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.RollbackVfModuleRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RollbackVfModuleRequestESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnfrest.VfRequestCommon", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.openstack.beans.VnfRollback", + "org.openecomp.mso.adapters.vnfrest.VfModuleRollback", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.openecomp.mso.adapters.vnfrest.RollbackVfModuleRequest", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(RollbackVfModuleRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleResponseESTest.java new file mode 100644 index 0000000000..f0e6c09f43 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleResponseESTest.java @@ -0,0 +1,48 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:20:06 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RollbackVfModuleResponseESTest extends RollbackVfModuleResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + Boolean boolean0 = new Boolean(true); + RollbackVfModuleResponse rollbackVfModuleResponse0 = new RollbackVfModuleResponse(boolean0, "W$Bqj~ \u0000}YvH"); + Boolean boolean1 = rollbackVfModuleResponse0.getVfModuleRolledback(); + assertTrue(boolean1); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + Boolean boolean0 = new Boolean("nR:)\"X2$B@=Yf<Y~Z"); + RollbackVfModuleResponse rollbackVfModuleResponse0 = new RollbackVfModuleResponse(boolean0, ""); + Boolean boolean1 = rollbackVfModuleResponse0.getVfModuleRolledback(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + Boolean boolean0 = new Boolean("nR:)\"X2$B@=Yf<Y~Z"); + RollbackVfModuleResponse rollbackVfModuleResponse0 = new RollbackVfModuleResponse(boolean0, ""); + rollbackVfModuleResponse0.setVfModuleRolledback(boolean0); + assertEquals("", rollbackVfModuleResponse0.getMessageId()); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + RollbackVfModuleResponse rollbackVfModuleResponse0 = new RollbackVfModuleResponse(); + Boolean boolean0 = rollbackVfModuleResponse0.getVfModuleRolledback(); + assertNull(boolean0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleResponseESTestscaffolding.java new file mode 100644 index 0000000000..e2202d86b0 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVfModuleResponseESTestscaffolding.java @@ -0,0 +1,98 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:20:06 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RollbackVfModuleResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.RollbackVfModuleResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RollbackVfModuleResponseESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.adapters.vnfrest.RollbackVfModuleResponse", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(RollbackVfModuleResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupRequestESTest.java new file mode 100644 index 0000000000..89ff8debce --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupRequestESTest.java @@ -0,0 +1,31 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:23:56 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RollbackVolumeGroupRequestESTest extends RollbackVolumeGroupRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + RollbackVolumeGroupRequest rollbackVolumeGroupRequest0 = new RollbackVolumeGroupRequest(); + rollbackVolumeGroupRequest0.setVolumeGroupRollback((VolumeGroupRollback) null); + assertNull(rollbackVolumeGroupRequest0.getMessageId()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + RollbackVolumeGroupRequest rollbackVolumeGroupRequest0 = new RollbackVolumeGroupRequest(); + VolumeGroupRollback volumeGroupRollback0 = rollbackVolumeGroupRequest0.getVolumeGroupRollback(); + assertNull(volumeGroupRollback0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupRequestESTestscaffolding.java new file mode 100644 index 0000000000..7b4fcaad4d --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupRequestESTestscaffolding.java @@ -0,0 +1,101 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:23:56 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RollbackVolumeGroupRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.RollbackVolumeGroupRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RollbackVolumeGroupRequestESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnfrest.VfRequestCommon", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.adapters.vnfrest.VolumeGroupRollback", + "org.openecomp.mso.entity.MsoRequest", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName", + "org.openecomp.mso.adapters.vnfrest.RollbackVolumeGroupRequest" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(RollbackVolumeGroupRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupResponseESTest.java new file mode 100644 index 0000000000..c6804b22aa --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupResponseESTest.java @@ -0,0 +1,47 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:15:06 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RollbackVolumeGroupResponseESTest extends RollbackVolumeGroupResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + Boolean boolean0 = new Boolean(true); + RollbackVolumeGroupResponse rollbackVolumeGroupResponse0 = new RollbackVolumeGroupResponse(boolean0, ""); + Boolean boolean1 = rollbackVolumeGroupResponse0.getVolumeGroupRolledBack(); + assertTrue(boolean1); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + Boolean boolean0 = Boolean.FALSE; + RollbackVolumeGroupResponse rollbackVolumeGroupResponse0 = new RollbackVolumeGroupResponse(boolean0, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<rollbackVolumeGroupResponse>\n <messageId></messageId>\n <volumeGroupRolledBack>true</volumeGroupRolledBack>\n</rollbackVolumeGroupResponse>\n"); + Boolean boolean1 = rollbackVolumeGroupResponse0.getVolumeGroupRolledBack(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + RollbackVolumeGroupResponse rollbackVolumeGroupResponse0 = new RollbackVolumeGroupResponse(); + rollbackVolumeGroupResponse0.setVolumeGroupRolledBack((Boolean) null); + assertNull(rollbackVolumeGroupResponse0.getMessageId()); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + RollbackVolumeGroupResponse rollbackVolumeGroupResponse0 = new RollbackVolumeGroupResponse(); + Boolean boolean0 = rollbackVolumeGroupResponse0.getVolumeGroupRolledBack(); + assertNull(boolean0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupResponseESTestscaffolding.java new file mode 100644 index 0000000000..d2acc793eb --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/RollbackVolumeGroupResponseESTestscaffolding.java @@ -0,0 +1,98 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:15:06 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RollbackVolumeGroupResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.RollbackVolumeGroupResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RollbackVolumeGroupResponseESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.adapters.vnfrest.RollbackVolumeGroupResponse", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(RollbackVolumeGroupResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleRequestESTest.java new file mode 100644 index 0000000000..0702294be8 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleRequestESTest.java @@ -0,0 +1,746 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:24:18 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.openecomp.mso.entity.MsoRequest; +import java.util.HashMap; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.System; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class UpdateVfModuleRequestESTest extends UpdateVfModuleRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.toXmlString(); + updateVfModuleRequest0.setVfModuleId("xM"); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + updateVfModuleRequest0.setVnfType("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<updateVfModuleRequest>\n <msoRequest/>\n <vfModuleParams/>\n</updateVfModuleRequest>\n"); + hashMap0.entrySet(); + updateVfModuleRequest0.setVfModuleParams(hashMap0); + updateVfModuleRequest0.getVnfType(); + updateVfModuleRequest0.setVfModuleId("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<updateVfModuleRequest>\n <msoRequest/>\n <vfModuleParams/>\n</updateVfModuleRequest>\n"); + updateVfModuleRequest0.setVolumeGroupStackId("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<updateVfModuleRequest>\n <msoRequest/>\n <vfModuleParams/>\n</updateVfModuleRequest>\n"); + updateVfModuleRequest0.setCloudSiteId("$i@h"); + updateVfModuleRequest0.setVfModuleParams(hashMap0); + updateVfModuleRequest0.setTenantId("$i@h"); + MsoRequest msoRequest0 = new MsoRequest(); + msoRequest0.setServiceInstanceId("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<updateVfModuleRequest>\n <msoRequest/>\n <vfModuleParams/>\n</updateVfModuleRequest>\n"); + updateVfModuleRequest0.setMsoRequest(msoRequest0); + Boolean boolean0 = new Boolean("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<updateVfModuleRequest>\n <msoRequest/>\n <vfModuleParams/>\n</updateVfModuleRequest>\n"); + updateVfModuleRequest0.setFailIfExists(boolean0); + updateVfModuleRequest0.getVfModuleStackId(); + updateVfModuleRequest0.getRequestType(); + updateVfModuleRequest0.setBaseVfModuleId("$i@h"); + updateVfModuleRequest0.setVfModuleId((String) null); + updateVfModuleRequest0.getVolumeGroupStackId(); + String string0 = updateVfModuleRequest0.getTenantId(); + assertEquals("$i@h", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setVnfType(">LosD~A.W]T\"Ht"); + updateVfModuleRequest0.setVfModuleStackId(""); + updateVfModuleRequest0.setVnfType(">LosD~A.W]T\"Ht"); + updateVfModuleRequest0.setBaseVfModuleStackId("rG\"Rcq79:TWr}bI"); + updateVfModuleRequest0.getVfModuleName(); + updateVfModuleRequest0.setVnfVersion((String) null); + updateVfModuleRequest0.setVfModuleType((String) null); + updateVfModuleRequest0.getVnfType(); + String string0 = updateVfModuleRequest0.getVfModuleType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setVfModuleStackId(""); + updateVfModuleRequest0.getVfModuleId(); + updateVfModuleRequest0.setVolumeGroupId(""); + updateVfModuleRequest0.setVfModuleId(";Zz^*Eup;I8"); + updateVfModuleRequest0.getTenantId(); + updateVfModuleRequest0.setVfModuleName((String) null); + updateVfModuleRequest0.getFailIfExists(); + updateVfModuleRequest0.getVnfId(); + updateVfModuleRequest0.getVfModuleId(); + updateVfModuleRequest0.setVfModuleType((String) null); + updateVfModuleRequest0.getBackout(); + updateVfModuleRequest0.setVfModuleId("p H/yV<46O"); + updateVfModuleRequest0.setVnfId(""); + assertNull(updateVfModuleRequest0.getVolumeGroupStackId()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setBaseVfModuleId("y|.n5Xbo!qUzw"); + updateVfModuleRequest0.setRequestType("y|.n5Xbo!qUzw"); + updateVfModuleRequest0.setBaseVfModuleId(""); + updateVfModuleRequest0.getBaseVfModuleStackId(); + updateVfModuleRequest0.getBaseVfModuleId(); + MsoRequest msoRequest0 = updateVfModuleRequest0.getMsoRequest(); + updateVfModuleRequest0.getBackout(); + updateVfModuleRequest0.setSkipAAI((Boolean) null); + updateVfModuleRequest0.setMsoRequest(msoRequest0); + updateVfModuleRequest0.getBackout(); + updateVfModuleRequest0.setRequestType(""); + updateVfModuleRequest0.getVfModuleStackId(); + updateVfModuleRequest0.setMsoRequest(msoRequest0); + updateVfModuleRequest0.setTenantId(""); + assertNull(updateVfModuleRequest0.getVfModuleName()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setVfModuleStackId("jaxb.formatted.output"); + updateVfModuleRequest0.setVfModuleName("jaxb.formatted.output"); + Boolean boolean0 = Boolean.valueOf(""); + Boolean.logicalXor(false, false); + updateVfModuleRequest0.setFailIfExists(boolean0); + updateVfModuleRequest0.getBackout(); + updateVfModuleRequest0.setVfModuleType("jaxb.formatted.output"); + Boolean.logicalOr(true, true); + updateVfModuleRequest0.setBackout((Boolean) null); + updateVfModuleRequest0.getVfModuleStackId(); + updateVfModuleRequest0.getVfModuleName(); + updateVfModuleRequest0.setVolumeGroupId("jaxb.formatted.output"); + updateVfModuleRequest0.getBaseVfModuleStackId(); + updateVfModuleRequest0.setRequestType(".zGbDU h'`XYM2"); + updateVfModuleRequest0.getVfModuleStackId(); + updateVfModuleRequest0.setBaseVfModuleStackId(""); + updateVfModuleRequest0.getBackout(); + updateVfModuleRequest0.getVolumeGroupId(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + updateVfModuleRequest0.setVfModuleParams(hashMap0); + updateVfModuleRequest0.setBaseVfModuleId(""); + assertNull(updateVfModuleRequest0.getVfModuleId()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + Boolean boolean0 = updateVfModuleRequest0.getFailIfExists(); + assertNull(boolean0); + + updateVfModuleRequest0.getVnfId(); + updateVfModuleRequest0.setVnfVersion((String) null); + updateVfModuleRequest0.setBaseVfModuleId((String) null); + updateVfModuleRequest0.setVfModuleStackId(""); + updateVfModuleRequest0.getVfModuleStackId(); + // Undeclared exception! + try { + updateVfModuleRequest0.toJsonString(); + fail("Expecting exception: VerifyError"); + + } catch(VerifyError e) { + // + // (class: org/codehaus/jackson/map/MapperConfig, method: <clinit> signature: ()V) Bad type in putfield/putstatic + // + verifyException("org.codehaus.jackson.map.ObjectMapper", e); + } + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setVfModuleStackId("tnNRSR)XN"); + updateVfModuleRequest0.setCloudSiteId(""); + updateVfModuleRequest0.setVnfId(""); + updateVfModuleRequest0.setVfModuleType(""); + updateVfModuleRequest0.setVfModuleStackId(""); + MsoRequest msoRequest0 = new MsoRequest(); + msoRequest0.setServiceInstanceId(""); + updateVfModuleRequest0.setMsoRequest(msoRequest0); + updateVfModuleRequest0.setVfModuleName("*$x.GUPO|E:0LZ<"); + String string0 = updateVfModuleRequest0.getVfModuleType(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.getVfModuleName(); + updateVfModuleRequest0.getFailIfExists(); + updateVfModuleRequest0.setBackout((Boolean) null); + updateVfModuleRequest0.getVfModuleName(); + updateVfModuleRequest0.setVolumeGroupStackId((String) null); + updateVfModuleRequest0.setRequestType("td"); + updateVfModuleRequest0.getRequestType(); + updateVfModuleRequest0.setVolumeGroupId((String) null); + updateVfModuleRequest0.getBaseVfModuleStackId(); + MsoRequest msoRequest0 = updateVfModuleRequest0.getMsoRequest(); + updateVfModuleRequest0.setMsoRequest(msoRequest0); + assertNull(updateVfModuleRequest0.getVolumeGroupStackId()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setVolumeGroupStackId(""); + updateVfModuleRequest0.setVfModuleType(""); + updateVfModuleRequest0.setVnfVersion(""); + updateVfModuleRequest0.getVolumeGroupId(); + MsoRequest msoRequest0 = new MsoRequest("jaxb.formatted.output", (String) null); + msoRequest0.setServiceInstanceId((String) null); + Boolean boolean0 = Boolean.FALSE; + updateVfModuleRequest0.setSkipAAI(boolean0); + msoRequest0.setServiceInstanceId((String) null); + msoRequest0.setServiceInstanceId(""); + updateVfModuleRequest0.setVolumeGroupId("9oR~ "); + updateVfModuleRequest0.setMsoRequest(msoRequest0); + updateVfModuleRequest0.getVfModuleStackId(); + updateVfModuleRequest0.setVfModuleName(""); + updateVfModuleRequest0.getFailIfExists(); + updateVfModuleRequest0.getVfModuleName(); + updateVfModuleRequest0.getFailIfExists(); + updateVfModuleRequest0.getRequestType(); + String string0 = updateVfModuleRequest0.getRequestType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + hashMap0.put("8bJYY1&kKT", "8bJYY1&kKT"); + hashMap0.entrySet(); + updateVfModuleRequest0.setVfModuleParams(hashMap0); + updateVfModuleRequest0.toXmlString(); + updateVfModuleRequest0.setVolumeGroupId((String) null); + updateVfModuleRequest0.getMsoRequest(); + Boolean boolean0 = new Boolean(true); + Boolean.logicalAnd(true, true); + updateVfModuleRequest0.setBackout(boolean0); + updateVfModuleRequest0.getBackout(); + Boolean boolean1 = Boolean.valueOf(true); + Boolean.logicalXor(true, true); + updateVfModuleRequest0.setFailIfExists(boolean1); + assertNull(updateVfModuleRequest0.getVolumeGroupId()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setVfModuleType(" h&a.O(2wp'tIm%yKJY"); + MsoRequest msoRequest0 = updateVfModuleRequest0.getMsoRequest(); + updateVfModuleRequest0.setMsoRequest(msoRequest0); + updateVfModuleRequest0.getVolumeGroupId(); + updateVfModuleRequest0.getVolumeGroupId(); + String string0 = updateVfModuleRequest0.getVfModuleType(); + assertEquals(" h&a.O(2wp'tIm%yKJY", string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setTenantId(""); + updateVfModuleRequest0.setVolumeGroupStackId(""); + updateVfModuleRequest0.setBaseVfModuleStackId(""); + updateVfModuleRequest0.setVolumeGroupId(""); + updateVfModuleRequest0.setBaseVfModuleId("Q)H$p?i^[$S\u0003_Q"); + updateVfModuleRequest0.setVnfVersion(""); + updateVfModuleRequest0.setTenantId("Q)H$p?i^[$S\u0003_Q"); + updateVfModuleRequest0.setVfModuleId(""); + updateVfModuleRequest0.getRequestType(); + updateVfModuleRequest0.setVfModuleType("("); + String string0 = updateVfModuleRequest0.getVolumeGroupStackId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.getCloudSiteId(); + Map<String, String> map0 = updateVfModuleRequest0.getVfModuleParams(); + updateVfModuleRequest0.setTenantId((String) null); + updateVfModuleRequest0.setBaseVfModuleStackId((String) null); + updateVfModuleRequest0.getBaseVfModuleId(); + updateVfModuleRequest0.getTenantId(); + updateVfModuleRequest0.setVfModuleStackId(""); + updateVfModuleRequest0.setVfModuleParams(map0); + updateVfModuleRequest0.setBaseVfModuleId("og~*KEPst]:7"); + updateVfModuleRequest0.setVfModuleStackId(""); + updateVfModuleRequest0.setVnfId(""); + Boolean boolean0 = new Boolean(false); + updateVfModuleRequest0.setBackout(boolean0); + updateVfModuleRequest0.setVnfType(""); + String string0 = updateVfModuleRequest0.getBaseVfModuleId(); + assertEquals("og~*KEPst]:7", string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + hashMap0.put("tW$,C`\"=2HoY\"N", "tW$,C`\"=2HoY\"N"); + updateVfModuleRequest0.setVfModuleParams(hashMap0); + updateVfModuleRequest0.setBaseVfModuleId((String) null); + updateVfModuleRequest0.setBaseVfModuleId(""); + updateVfModuleRequest0.getVnfVersion(); + MsoRequest msoRequest0 = updateVfModuleRequest0.getMsoRequest(); + updateVfModuleRequest0.setMsoRequest(msoRequest0); + msoRequest0.setRequestId("HA"); + msoRequest0.setServiceInstanceId("}Fo|8N"); + msoRequest0.setRequestId(""); + updateVfModuleRequest0.setMsoRequest(msoRequest0); + Map<String, String> map0 = updateVfModuleRequest0.getVfModuleParams(); + assertFalse(map0.isEmpty()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setTenantId(""); + updateVfModuleRequest0.setMessageId(""); + updateVfModuleRequest0.toXmlString(); + updateVfModuleRequest0.setVfModuleType(""); + updateVfModuleRequest0.setBaseVfModuleId(""); + updateVfModuleRequest0.setVolumeGroupId(""); + updateVfModuleRequest0.setVfModuleType((String) null); + updateVfModuleRequest0.setNotificationUrl((String) null); + updateVfModuleRequest0.setBaseVfModuleStackId(""); + updateVfModuleRequest0.setBaseVfModuleId(""); + updateVfModuleRequest0.getBaseVfModuleStackId(); + Boolean boolean0 = Boolean.FALSE; + Boolean.logicalOr(false, false); + updateVfModuleRequest0.setFailIfExists(boolean0); + updateVfModuleRequest0.getRequestType(); + updateVfModuleRequest0.setBaseVfModuleStackId("4N9!j*vkAv["); + updateVfModuleRequest0.setMessageId((String) null); + String string0 = updateVfModuleRequest0.getVnfType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setBaseVfModuleStackId("jaxb.formatted.output"); + updateVfModuleRequest0.getVnfId(); + updateVfModuleRequest0.getSkipAAI(); + Boolean.getBoolean((String) null); + updateVfModuleRequest0.setFailIfExists((Boolean) null); + updateVfModuleRequest0.getBaseVfModuleStackId(); + updateVfModuleRequest0.setVfModuleStackId((String) null); + Map<String, String> map0 = updateVfModuleRequest0.getVfModuleParams(); + updateVfModuleRequest0.setVfModuleParams(map0); + String string0 = updateVfModuleRequest0.getRequestType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + Boolean boolean0 = Boolean.FALSE; + updateVfModuleRequest0.setTenantId(""); + updateVfModuleRequest0.setVnfId("^"); + Boolean.logicalAnd(false, false); + Boolean.logicalOr(false, true); + Boolean.logicalXor(false, false); + updateVfModuleRequest0.setCloudSiteId(", )iA\"g F{9C"); + Boolean boolean1 = Boolean.valueOf(""); + updateVfModuleRequest0.setFailIfExists(boolean1); + updateVfModuleRequest0.setFailIfExists(boolean0); + updateVfModuleRequest0.getVfModuleParams(); + String string0 = updateVfModuleRequest0.getTenantId(); + updateVfModuleRequest0.setBaseVfModuleStackId(""); + updateVfModuleRequest0.getVfModuleParams(); + updateVfModuleRequest0.getVnfId(); + updateVfModuleRequest0.getFailIfExists(); + updateVfModuleRequest0.getVnfVersion(); + updateVfModuleRequest0.setVfModuleStackId("^"); + updateVfModuleRequest0.setVolumeGroupId(""); + updateVfModuleRequest0.setBaseVfModuleStackId(""); + String string1 = updateVfModuleRequest0.getCloudSiteId(); + assertFalse(string1.equals((Object)string0)); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setNotificationUrl("XC8g/I"); + updateVfModuleRequest0.setVfModuleParams((Map<String, String>) null); + updateVfModuleRequest0.setRequestType(""); + updateVfModuleRequest0.setVfModuleType(""); + updateVfModuleRequest0.getFailIfExists(); + updateVfModuleRequest0.setBackout((Boolean) null); + updateVfModuleRequest0.setTenantId(""); + updateVfModuleRequest0.setVfModuleStackId(""); + updateVfModuleRequest0.setMsoRequest((MsoRequest) null); + updateVfModuleRequest0.getRequestType(); + updateVfModuleRequest0.getBaseVfModuleId(); + updateVfModuleRequest0.setVfModuleType((String) null); + updateVfModuleRequest0.setVfModuleType(""); + updateVfModuleRequest0.setTenantId((String) null); + updateVfModuleRequest0.getTenantId(); + updateVfModuleRequest0.getMsoRequest(); + updateVfModuleRequest0.setVnfVersion(""); + updateVfModuleRequest0.getVfModuleName(); + updateVfModuleRequest0.setVfModuleType((String) null); + String string0 = updateVfModuleRequest0.getVolumeGroupStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setVfModuleId(""); + updateVfModuleRequest0.setRequestType(""); + updateVfModuleRequest0.getVfModuleName(); + updateVfModuleRequest0.setVolumeGroupStackId("?|d!=PZ_"); + updateVfModuleRequest0.getMsoRequest(); + updateVfModuleRequest0.setVnfType(""); + updateVfModuleRequest0.setVnfType((String) null); + updateVfModuleRequest0.getRequestType(); + updateVfModuleRequest0.getFailIfExists(); + updateVfModuleRequest0.setTenantId(""); + assertEquals("", updateVfModuleRequest0.getRequestType()); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.getVfModuleName(); + Boolean boolean0 = new Boolean(""); + updateVfModuleRequest0.setBaseVfModuleId((String) null); + Boolean.getBoolean(""); + Boolean.getBoolean(""); + MsoRequest msoRequest0 = new MsoRequest(); + updateVfModuleRequest0.setMsoRequest(msoRequest0); + updateVfModuleRequest0.setBackout(boolean0); + updateVfModuleRequest0.getBackout(); + updateVfModuleRequest0.setVolumeGroupId("jaxb.formatted.output"); + updateVfModuleRequest0.getVolumeGroupId(); + updateVfModuleRequest0.setVolumeGroupId(""); + updateVfModuleRequest0.getBackout(); + updateVfModuleRequest0.getCloudSiteId(); + updateVfModuleRequest0.getBackout(); + updateVfModuleRequest0.getVolumeGroupId(); + updateVfModuleRequest0.setVnfType(""); + updateVfModuleRequest0.getVnfVersion(); + updateVfModuleRequest0.setVnfVersion("nSI5S-r/)Nt{7E"); + updateVfModuleRequest0.setTenantId((String) null); + assertNull(updateVfModuleRequest0.getVnfId()); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setVolumeGroupId("1}p^{.,|o6fiV%T=nE"); + updateVfModuleRequest0.getVfModuleId(); + updateVfModuleRequest0.getBaseVfModuleId(); + updateVfModuleRequest0.setRequestType((String) null); + updateVfModuleRequest0.setVnfId("()4#Rt0S|Ok?6LpP6d"); + updateVfModuleRequest0.setCloudSiteId((String) null); + updateVfModuleRequest0.setVnfId("OTV[DjNZt,,%"); + updateVfModuleRequest0.setVnfId((String) null); + updateVfModuleRequest0.setVnfType((String) null); + updateVfModuleRequest0.getRequestType(); + updateVfModuleRequest0.getVolumeGroupId(); + MsoRequest msoRequest0 = updateVfModuleRequest0.getMsoRequest(); + updateVfModuleRequest0.setMsoRequest(msoRequest0); + updateVfModuleRequest0.getBackout(); + updateVfModuleRequest0.setBackout((Boolean) null); + updateVfModuleRequest0.getVnfVersion(); + updateVfModuleRequest0.setVfModuleId("()4#Rt0S|Ok?6LpP6d"); + String string0 = updateVfModuleRequest0.getBaseVfModuleStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.getVolumeGroupId(); + updateVfModuleRequest0.setVnfVersion((String) null); + updateVfModuleRequest0.getVfModuleName(); + updateVfModuleRequest0.setBaseVfModuleId(""); + updateVfModuleRequest0.setCloudSiteId(""); + updateVfModuleRequest0.getVnfType(); + updateVfModuleRequest0.setVolumeGroupStackId(""); + updateVfModuleRequest0.setVolumeGroupId(""); + updateVfModuleRequest0.setVolumeGroupId(""); + updateVfModuleRequest0.getVfModuleId(); + updateVfModuleRequest0.getTenantId(); + UpdateVfModuleRequest updateVfModuleRequest1 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.getVolumeGroupId(); + updateVfModuleRequest1.getVfModuleStackId(); + updateVfModuleRequest1.getVolumeGroupStackId(); + Boolean boolean0 = new Boolean(false); + updateVfModuleRequest0.setBackout(boolean0); + assertNull(updateVfModuleRequest0.getRequestType()); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + Boolean boolean0 = new Boolean("[b#W!$Hl5#Z"); + updateVfModuleRequest0.setFailIfExists(boolean0); + String string0 = updateVfModuleRequest0.getCloudSiteId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.getVolumeGroupStackId(); + updateVfModuleRequest0.getVnfVersion(); + updateVfModuleRequest0.setVfModuleStackId("V|x2kON!8h|bBCf,\"I"); + assertNull(updateVfModuleRequest0.getVnfType()); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.getVnfVersion(); + String string0 = updateVfModuleRequest0.getVfModuleName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setTenantId("3G"); + updateVfModuleRequest0.getSkipAAI(); + updateVfModuleRequest0.toXmlString(); + updateVfModuleRequest0.setBackout((Boolean) null); + updateVfModuleRequest0.getVfModuleParams(); + updateVfModuleRequest0.setVnfId("MnBvF"); + updateVfModuleRequest0.setTenantId("NX5yxi"); + updateVfModuleRequest0.getVnfId(); + updateVfModuleRequest0.getBaseVfModuleStackId(); + updateVfModuleRequest0.getVfModuleParams(); + MsoRequest msoRequest0 = updateVfModuleRequest0.getMsoRequest(); + assertNull(msoRequest0.getRequestId()); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.getVfModuleId(); + updateVfModuleRequest0.setBaseVfModuleId(""); + assertNull(updateVfModuleRequest0.getVfModuleName()); + } + + @Test(timeout = 4000) + public void test27() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setVnfId(""); + assertNull(updateVfModuleRequest0.getVolumeGroupStackId()); + + updateVfModuleRequest0.getFailIfExists(); + updateVfModuleRequest0.setFailIfExists((Boolean) null); + updateVfModuleRequest0.setMessageId((String) null); + updateVfModuleRequest0.setVolumeGroupId(""); + updateVfModuleRequest0.getVfModuleType(); + updateVfModuleRequest0.setVnfVersion("4x"); + String string0 = updateVfModuleRequest0.getVnfVersion(); + updateVfModuleRequest0.setBaseVfModuleStackId("[Oc:_#*]&+4`o"); + String string1 = updateVfModuleRequest0.getVnfId(); + assertFalse(string1.equals((Object)string0)); + } + + @Test(timeout = 4000) + public void test28() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + MsoRequest msoRequest0 = updateVfModuleRequest0.getMsoRequest(); + updateVfModuleRequest0.setMsoRequest(msoRequest0); + assertNull(updateVfModuleRequest0.getVnfVersion()); + } + + @Test(timeout = 4000) + public void test29() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.getRequestType(); + Boolean boolean0 = updateVfModuleRequest0.getBackout(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test30() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setCloudSiteId(""); + updateVfModuleRequest0.setVfModuleParams((Map<String, String>) null); + updateVfModuleRequest0.getBaseVfModuleStackId(); + updateVfModuleRequest0.setVnfVersion(""); + updateVfModuleRequest0.getVfModuleParams(); + updateVfModuleRequest0.setBaseVfModuleId(""); + updateVfModuleRequest0.getCloudSiteId(); + updateVfModuleRequest0.setVfModuleParams((Map<String, String>) null); + updateVfModuleRequest0.getVnfVersion(); + updateVfModuleRequest0.getVfModuleStackId(); + updateVfModuleRequest0.getVolumeGroupId(); + updateVfModuleRequest0.setCloudSiteId((String) null); + updateVfModuleRequest0.getMsoRequest(); + updateVfModuleRequest0.setBaseVfModuleStackId(""); + updateVfModuleRequest0.getVfModuleParams(); + updateVfModuleRequest0.setVolumeGroupStackId("[9~u'kSpnk!"); + assertNull(updateVfModuleRequest0.getMessageId()); + } + + @Test(timeout = 4000) + public void test31() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.getFailIfExists(); + updateVfModuleRequest0.setVnfType(""); + updateVfModuleRequest0.setBackout((Boolean) null); + updateVfModuleRequest0.setBaseVfModuleId(""); + updateVfModuleRequest0.getVfModuleParams(); + updateVfModuleRequest0.getVnfId(); + updateVfModuleRequest0.setVfModuleId(""); + updateVfModuleRequest0.setVfModuleStackId(""); + updateVfModuleRequest0.getVfModuleId(); + updateVfModuleRequest0.setCloudSiteId(""); + updateVfModuleRequest0.getMsoRequest(); + updateVfModuleRequest0.setVfModuleId(""); + updateVfModuleRequest0.getVnfType(); + Boolean boolean0 = updateVfModuleRequest0.getFailIfExists(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test32() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.getFailIfExists(); + updateVfModuleRequest0.setBackout((Boolean) null); + assertNull(updateVfModuleRequest0.getVnfId()); + } + + @Test(timeout = 4000) + public void test33() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setVfModuleName(""); + updateVfModuleRequest0.setBaseVfModuleStackId(""); + // Undeclared exception! + try { + updateVfModuleRequest0.toJsonString(); + fail("Expecting exception: VerifyError"); + + } catch(VerifyError e) { + // + // (class: org/codehaus/jackson/map/MapperConfig, method: <clinit> signature: ()V) Bad type in putfield/putstatic + // + verifyException("org.codehaus.jackson.map.ObjectMapper", e); + } + } + + @Test(timeout = 4000) + public void test34() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setVolumeGroupStackId("nY0b"); + assertNull(updateVfModuleRequest0.getRequestType()); + } + + @Test(timeout = 4000) + public void test35() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setVnfVersion("Ht/U"); + assertNull(updateVfModuleRequest0.getVolumeGroupId()); + } + + @Test(timeout = 4000) + public void test36() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setVnfType("W;cx8uJk]p#e&?c3PcO"); + updateVfModuleRequest0.setVfModuleType("z3qr`!V;?"); + updateVfModuleRequest0.setVfModuleName("W;cx8uJk]p#e&?c3PcO"); + assertNull(updateVfModuleRequest0.getRequestType()); + } + + @Test(timeout = 4000) + public void test37() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.toXmlString(); + String string0 = updateVfModuleRequest0.getBaseVfModuleStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test38() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setVfModuleName("W#m\"_5ykHHHo_@kq/"); + assertNull(updateVfModuleRequest0.getRequestType()); + } + + @Test(timeout = 4000) + public void test39() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setTenantId("?!vD=6S.7p/[;zX3i"); + assertNull(updateVfModuleRequest0.getMessageId()); + } + + @Test(timeout = 4000) + public void test40() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setCloudSiteId(""); + Map<String, String> map0 = updateVfModuleRequest0.getVfModuleParams(); + updateVfModuleRequest0.setVfModuleParams(map0); + updateVfModuleRequest0.setVfModuleParams(map0); + updateVfModuleRequest0.setVfModuleStackId(""); + assertNull(updateVfModuleRequest0.getRequestType()); + } + + @Test(timeout = 4000) + public void test41() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + Boolean boolean0 = Boolean.valueOf(true); + Boolean.logicalAnd(true, true); + Boolean.logicalXor(true, true); + Boolean.logicalAnd(true, true); + Boolean.logicalXor(true, false); + updateVfModuleRequest0.setFailIfExists(boolean0); + updateVfModuleRequest0.setFailIfExists(boolean0); + Boolean boolean1 = new Boolean(false); + Boolean.compare(true, true); + boolean boolean2 = Boolean.logicalAnd(true, true); + updateVfModuleRequest0.setSkipAAI(boolean1); + updateVfModuleRequest0.setBaseVfModuleId("O[9~5!"); + updateVfModuleRequest0.setVfModuleType((String) null); + updateVfModuleRequest0.getFailIfExists(); + updateVfModuleRequest0.getFailIfExists(); + System.setCurrentTimeMillis(3682L); + System.setCurrentTimeMillis(3682L); + System.setCurrentTimeMillis((-116L)); + System.setCurrentTimeMillis((-116L)); + System.setCurrentTimeMillis(0L); + System.setCurrentTimeMillis(0); + Boolean boolean3 = updateVfModuleRequest0.getFailIfExists(); + assertTrue(boolean3.equals((Object)boolean2)); + } + + @Test(timeout = 4000) + public void test42() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setBaseVfModuleId(""); + assertNull(updateVfModuleRequest0.getMessageId()); + } + + @Test(timeout = 4000) + public void test43() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + updateVfModuleRequest0.setRequestType(""); + updateVfModuleRequest0.setVfModuleType("ybR"); + assertEquals("ybR", updateVfModuleRequest0.getVfModuleType()); + } + + @Test(timeout = 4000) + public void test44() throws Throwable { + UpdateVfModuleRequest updateVfModuleRequest0 = new UpdateVfModuleRequest(); + UpdateVfModuleRequest updateVfModuleRequest1 = new UpdateVfModuleRequest(); + updateVfModuleRequest1.getSkipAAI(); + updateVfModuleRequest0.setFailIfExists((Boolean) null); + assertNull(updateVfModuleRequest0.getVfModuleName()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleRequestESTestscaffolding.java new file mode 100644 index 0000000000..7d23ee1ce5 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleRequestESTestscaffolding.java @@ -0,0 +1,197 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:24:18 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class UpdateVfModuleRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.UpdateVfModuleRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(UpdateVfModuleRequestESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.map.JsonSerializableWithType", + "org.codehaus.jackson.map.deser.StdDeserializerProvider", + "org.codehaus.jackson.map.SerializerFactory", + "org.codehaus.jackson.map.SerializerProvider", + "org.codehaus.jackson.map.SerializationConfig", + "org.codehaus.jackson.JsonProcessingException", + "org.codehaus.jackson.map.introspect.AnnotationMap", + "org.codehaus.jackson.map.introspect.Annotated", + "org.codehaus.jackson.map.util.Annotations", + "org.codehaus.jackson.sym.NameN", + "org.codehaus.jackson.JsonGenerator", + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector", + "org.codehaus.jackson.map.JsonSerializable", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.node.BaseJsonNode", + "org.codehaus.jackson.map.DeserializerProvider", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.node.ValueNode", + "org.codehaus.jackson.map.ser.BeanSerializerFactory", + "org.codehaus.jackson.map.introspect.AnnotatedWithParams", + "org.codehaus.jackson.map.AnnotationIntrospector", + "org.codehaus.jackson.map.MappingJsonFactory", + "org.codehaus.jackson.map.MapperConfig$Impl", + "org.codehaus.jackson.sym.Name1", + "org.codehaus.jackson.sym.Name2", + "org.codehaus.jackson.sym.Name3", + "org.codehaus.jackson.map.introspect.MethodFilter", + "org.codehaus.jackson.map.ser.StdSerializerProvider", + "org.codehaus.jackson.map.deser.StdDeserializationContext", + "org.codehaus.jackson.map.ClassIntrospector", + "org.codehaus.jackson.map.AnnotationIntrospector$Pair", + "org.codehaus.jackson.Versioned", + "org.codehaus.jackson.map.type.TypeBase", + "org.codehaus.jackson.map.ser.BasicSerializerFactory", + "org.codehaus.jackson.node.ContainerNode", + "org.codehaus.jackson.map.introspect.NopAnnotationIntrospector", + "org.codehaus.jackson.map.DeserializationConfig", + "org.codehaus.jackson.map.introspect.AnnotatedConstructor", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory", + "org.codehaus.jackson.impl.ReaderBasedParser", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer$TableInfo", + "org.codehaus.jackson.map.type.MapLikeType", + "org.codehaus.jackson.node.ObjectNode", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$MinimalMethodFilter", + "org.codehaus.jackson.map.type.CollectionLikeType", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer$Bucket", + "org.codehaus.jackson.impl.JsonParserMinimalBase", + "org.codehaus.jackson.map.type.TypeParser", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$SetterMethodFilter", + "org.codehaus.jackson.map.introspect.VisibilityChecker", + "org.codehaus.jackson.map.introspect.AnnotatedField", + "org.codehaus.jackson.impl.JsonGeneratorBase", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.util.ByteArrayBuilder", + "org.codehaus.jackson.PrettyPrinter", + "org.codehaus.jackson.map.jsontype.SubtypeResolver", + "org.codehaus.jackson.map.type.SimpleType", + "org.codehaus.jackson.map.util.StdDateFormat", + "org.codehaus.jackson.impl.Utf8Generator", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$SetterAndGetterMethodFilter", + "org.codehaus.jackson.JsonNode", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.codehaus.jackson.ObjectCodec", + "org.codehaus.jackson.map.introspect.AnnotatedMethod", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.node.ArrayNode", + "org.codehaus.jackson.io.SegmentedStringWriter", + "org.codehaus.jackson.map.jsontype.TypeResolverBuilder", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$GetterMethodFilter", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.map.BeanDescription", + "org.codehaus.jackson.impl.WriterBasedGenerator", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.sym.Name", + "org.codehaus.jackson.map.introspect.BasicBeanDescription", + "org.codehaus.jackson.util.TokenBuffer", + "org.codehaus.jackson.map.DeserializationContext", + "org.codehaus.jackson.impl.JsonParserBase", + "org.codehaus.jackson.map.JsonMappingException", + "org.codehaus.jackson.map.introspect.AnnotatedMember", + "org.codehaus.jackson.type.JavaType", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.annotate.JsonRootName", + "org.codehaus.jackson.JsonParser", + "org.openecomp.mso.adapters.vnfrest.UpdateVfModuleRequest", + "org.codehaus.jackson.node.NullNode", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.codehaus.jackson.map.jsontype.impl.StdSubtypeResolver", + "org.openecomp.mso.entity.MsoRequest", + "org.codehaus.jackson.node.TreeTraversingParser", + "org.codehaus.jackson.map.type.CollectionType", + "org.codehaus.jackson.map.MapperConfig", + "org.openecomp.mso.adapters.vnfrest.VfRequestCommon", + "org.codehaus.jackson.map.Module$SetupContext", + "org.codehaus.jackson.io.UTF8Writer", + "org.codehaus.jackson.map.type.MapType", + "org.codehaus.jackson.annotate.JsonAutoDetect", + "org.codehaus.jackson.map.type.ArrayType", + "org.codehaus.jackson.map.ClassIntrospector$MixInResolver" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(UpdateVfModuleRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleResponseESTest.java new file mode 100644 index 0000000000..2d48c57579 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleResponseESTest.java @@ -0,0 +1,149 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:18:01 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class UpdateVfModuleResponseESTest extends UpdateVfModuleResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + UpdateVfModuleResponse updateVfModuleResponse0 = new UpdateVfModuleResponse(); + String string0 = updateVfModuleResponse0.getVnfId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + UpdateVfModuleResponse updateVfModuleResponse0 = new UpdateVfModuleResponse("", "", "\"c2NA-]kge", (Map<String, String>) hashMap0, ""); + String string0 = updateVfModuleResponse0.getVnfId(); + assertEquals("\"c2NA-]kge", updateVfModuleResponse0.getVfModuleStackId()); + assertEquals("", updateVfModuleResponse0.getVfModuleId()); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + UpdateVfModuleResponse updateVfModuleResponse0 = new UpdateVfModuleResponse(); + String string0 = updateVfModuleResponse0.getVfModuleStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + UpdateVfModuleResponse updateVfModuleResponse0 = new UpdateVfModuleResponse("", "", "", (Map<String, String>) null, "eBT|~3\"z"); + updateVfModuleResponse0.getVfModuleOutputs(); + assertEquals("", updateVfModuleResponse0.getVfModuleStackId()); + assertEquals("", updateVfModuleResponse0.getVnfId()); + assertEquals("", updateVfModuleResponse0.getVfModuleId()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + UpdateVfModuleResponse updateVfModuleResponse0 = new UpdateVfModuleResponse((String) null, (String) null, "", (Map<String, String>) hashMap0, (String) null); + hashMap0.put((String) null, ""); + Map<String, String> map0 = updateVfModuleResponse0.getVfModuleOutputs(); + assertFalse(map0.isEmpty()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + UpdateVfModuleResponse updateVfModuleResponse0 = new UpdateVfModuleResponse(); + String string0 = updateVfModuleResponse0.getVfModuleId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + UpdateVfModuleResponse updateVfModuleResponse0 = new UpdateVfModuleResponse("}t3zhbFZl^dGLS@6+", "}t3zhbFZl^dGLS@6+", "}t3zhbFZl^dGLS@6+", (Map<String, String>) hashMap0, ""); + String string0 = updateVfModuleResponse0.getVfModuleId(); + assertNotNull(string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + UpdateVfModuleResponse updateVfModuleResponse0 = new UpdateVfModuleResponse(); + updateVfModuleResponse0.setVfModuleStackId("p|+"); + String string0 = updateVfModuleResponse0.getVfModuleStackId(); + assertEquals("p|+", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + UpdateVfModuleResponse updateVfModuleResponse0 = new UpdateVfModuleResponse((String) null, (String) null, "", (Map<String, String>) hashMap0, (String) null); + String string0 = updateVfModuleResponse0.getVfModuleStackId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + UpdateVfModuleResponse updateVfModuleResponse0 = new UpdateVfModuleResponse((String) null, (String) null, "", (Map<String, String>) hashMap0, (String) null); + updateVfModuleResponse0.setVnfId("trb"); + assertEquals("", updateVfModuleResponse0.getVfModuleStackId()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + UpdateVfModuleResponse updateVfModuleResponse0 = new UpdateVfModuleResponse("'o^@:C|OvN:", "'o^@:C|OvN:", "'o^@:C|OvN:", (Map<String, String>) hashMap0, "xcX3]w^"); + String string0 = updateVfModuleResponse0.getVnfId(); + assertEquals("'o^@:C|OvN:", updateVfModuleResponse0.getVfModuleStackId()); + assertEquals("'o^@:C|OvN:", updateVfModuleResponse0.getVfModuleId()); + assertEquals("'o^@:C|OvN:", string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + UpdateVfModuleResponse updateVfModuleResponse0 = new UpdateVfModuleResponse("lE0", "", "", (Map<String, String>) hashMap0, ""); + String string0 = updateVfModuleResponse0.getVfModuleId(); + assertEquals("", string0); + assertEquals("lE0", updateVfModuleResponse0.getVnfId()); + assertEquals("", updateVfModuleResponse0.getVfModuleStackId()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + UpdateVfModuleResponse updateVfModuleResponse0 = new UpdateVfModuleResponse("", "", "", (Map<String, String>) null, "eBT|~3\"z"); + assertEquals("", updateVfModuleResponse0.getVfModuleId()); + + updateVfModuleResponse0.setVfModuleId(""); + assertEquals("", updateVfModuleResponse0.getVnfId()); + assertEquals("", updateVfModuleResponse0.getVfModuleStackId()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + UpdateVfModuleResponse updateVfModuleResponse0 = new UpdateVfModuleResponse("", "", "", (Map<String, String>) null, "eBT|~3\"z"); + updateVfModuleResponse0.setVfModuleOutputs((Map<String, String>) null); + assertEquals("", updateVfModuleResponse0.getVfModuleId()); + assertEquals("", updateVfModuleResponse0.getVnfId()); + assertEquals("", updateVfModuleResponse0.getVfModuleStackId()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + UpdateVfModuleResponse updateVfModuleResponse0 = new UpdateVfModuleResponse("'o^@:C|OvN:", "'o^@:C|OvN:", "'o^@:C|OvN:", (Map<String, String>) hashMap0, "xcX3]w^"); + updateVfModuleResponse0.getVfModuleOutputs(); + assertEquals("'o^@:C|OvN:", updateVfModuleResponse0.getVfModuleStackId()); + assertEquals("'o^@:C|OvN:", updateVfModuleResponse0.getVfModuleId()); + assertEquals("'o^@:C|OvN:", updateVfModuleResponse0.getVnfId()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleResponseESTestscaffolding.java new file mode 100644 index 0000000000..4551abbcf4 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleResponseESTestscaffolding.java @@ -0,0 +1,98 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:18:01 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class UpdateVfModuleResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.UpdateVfModuleResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(UpdateVfModuleResponseESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName", + "org.openecomp.mso.adapters.vnfrest.UpdateVfModuleResponse" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(UpdateVfModuleResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupRequestESTest.java new file mode 100644 index 0000000000..5ee5d2ef20 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupRequestESTest.java @@ -0,0 +1,222 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:13:54 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.entity.MsoRequest; +import java.util.HashMap; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class UpdateVolumeGroupRequestESTest extends UpdateVolumeGroupRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setVolumeGroupStackId(""); + String string0 = updateVolumeGroupRequest0.getVolumeGroupStackId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setVolumeGroupParams((Map<String, String>) null); + Map<String, String> map0 = updateVolumeGroupRequest0.getVolumeGroupParams(); + assertNull(map0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + hashMap0.put("x; 6d0BPfz`", "x; 6d0BPfz`"); + updateVolumeGroupRequest0.setVolumeGroupParams(hashMap0); + Map<String, String> map0 = updateVolumeGroupRequest0.getVolumeGroupParams(); + assertFalse(map0.isEmpty()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setVolumeGroupId("jaxb.formatted.output"); + String string0 = updateVolumeGroupRequest0.getVolumeGroupId(); + assertEquals("jaxb.formatted.output", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setVnfVersion("VE"); + String string0 = updateVolumeGroupRequest0.getVnfVersion(); + assertEquals("VE", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setVnfType(";z<~4]OiR"); + String string0 = updateVolumeGroupRequest0.getVnfType(); + assertEquals(";z<~4]OiR", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setVnfType(""); + String string0 = updateVolumeGroupRequest0.getVnfType(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setVfModuleType("jaxb.formatted.output"); + String string0 = updateVolumeGroupRequest0.getVfModuleType(); + assertEquals("jaxb.formatted.output", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setTenantId("*\"Y)Ey _n!jPx[,gv"); + String string0 = updateVolumeGroupRequest0.getTenantId(); + assertEquals("*\"Y)Ey _n!jPx[,gv", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setCloudSiteId("kaFalmm'SWu=)x"); + String string0 = updateVolumeGroupRequest0.getCloudSiteId(); + assertEquals("kaFalmm'SWu=)x", string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + String string0 = updateVolumeGroupRequest0.getVnfVersion(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + String string0 = updateVolumeGroupRequest0.getVfModuleType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + String string0 = updateVolumeGroupRequest0.getCloudSiteId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + MsoRequest msoRequest0 = updateVolumeGroupRequest0.getMsoRequest(); + assertNull(msoRequest0.getRequestId()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + String string0 = updateVolumeGroupRequest0.getVnfType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + String string0 = updateVolumeGroupRequest0.getTenantId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setTenantId(""); + String string0 = updateVolumeGroupRequest0.getTenantId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setVolumeGroupStackId("%CmN&s3>7F)p/0"); + String string0 = updateVolumeGroupRequest0.getVolumeGroupStackId(); + assertEquals("%CmN&s3>7F)p/0", string0); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setVfModuleType(""); + String string0 = updateVolumeGroupRequest0.getVfModuleType(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setCloudSiteId(""); + String string0 = updateVolumeGroupRequest0.getCloudSiteId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setVnfVersion(""); + String string0 = updateVolumeGroupRequest0.getVnfVersion(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setMsoRequest((MsoRequest) null); + MsoRequest msoRequest0 = updateVolumeGroupRequest0.getMsoRequest(); + assertNull(msoRequest0); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + updateVolumeGroupRequest0.setVolumeGroupId(""); + String string0 = updateVolumeGroupRequest0.getVolumeGroupId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + Map<String, String> map0 = updateVolumeGroupRequest0.getVolumeGroupParams(); + updateVolumeGroupRequest0.setVolumeGroupParams(map0); + assertNull(updateVolumeGroupRequest0.getCloudSiteId()); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + String string0 = updateVolumeGroupRequest0.getVolumeGroupStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + UpdateVolumeGroupRequest updateVolumeGroupRequest0 = new UpdateVolumeGroupRequest(); + String string0 = updateVolumeGroupRequest0.getVolumeGroupId(); + assertNull(string0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupRequestESTestscaffolding.java new file mode 100644 index 0000000000..048f6b9f06 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupRequestESTestscaffolding.java @@ -0,0 +1,100 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:13:54 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class UpdateVolumeGroupRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(UpdateVolumeGroupRequestESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnfrest.VfRequestCommon", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupRequest", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(UpdateVolumeGroupRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupResponseESTest.java new file mode 100644 index 0000000000..ccf0983f58 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupResponseESTest.java @@ -0,0 +1,99 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:23:04 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class UpdateVolumeGroupResponseESTest extends UpdateVolumeGroupResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + UpdateVolumeGroupResponse updateVolumeGroupResponse0 = new UpdateVolumeGroupResponse("", "F`m", (Map<String, String>) hashMap0, ""); + String string0 = updateVolumeGroupResponse0.getVolumeGroupStackId(); + assertEquals("", updateVolumeGroupResponse0.getVolumeGroupId()); + assertEquals("F`m", string0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + UpdateVolumeGroupResponse updateVolumeGroupResponse0 = new UpdateVolumeGroupResponse("", "F`m", (Map<String, String>) hashMap0, ""); + hashMap0.put("9GcmH1su}s&bc=", ""); + updateVolumeGroupResponse0.getVolumeGroupOutputs(); + assertEquals("F`m", updateVolumeGroupResponse0.getVolumeGroupStackId()); + assertEquals("", updateVolumeGroupResponse0.getVolumeGroupId()); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + UpdateVolumeGroupResponse updateVolumeGroupResponse0 = new UpdateVolumeGroupResponse(); + String string0 = updateVolumeGroupResponse0.getVolumeGroupId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + UpdateVolumeGroupResponse updateVolumeGroupResponse0 = new UpdateVolumeGroupResponse("TzCXEX\"l?\"8x", "", (Map<String, String>) hashMap0, "TzCXEX\"l?\"8x"); + String string0 = updateVolumeGroupResponse0.getVolumeGroupId(); + assertEquals("", updateVolumeGroupResponse0.getVolumeGroupStackId()); + assertEquals("TzCXEX\"l?\"8x", string0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + UpdateVolumeGroupResponse updateVolumeGroupResponse0 = new UpdateVolumeGroupResponse(); + Map<String, String> map0 = updateVolumeGroupResponse0.getVolumeGroupOutputs(); + updateVolumeGroupResponse0.setVolumeGroupOutputs(map0); + assertNull(updateVolumeGroupResponse0.getVolumeGroupStackId()); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + UpdateVolumeGroupResponse updateVolumeGroupResponse0 = new UpdateVolumeGroupResponse(); + updateVolumeGroupResponse0.setVolumeGroupStackId(""); + String string0 = updateVolumeGroupResponse0.getVolumeGroupStackId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + UpdateVolumeGroupResponse updateVolumeGroupResponse0 = new UpdateVolumeGroupResponse(); + String string0 = updateVolumeGroupResponse0.getVolumeGroupStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + UpdateVolumeGroupResponse updateVolumeGroupResponse0 = new UpdateVolumeGroupResponse("", "", (Map<String, String>) null, ""); + Map<String, String> map0 = updateVolumeGroupResponse0.getVolumeGroupOutputs(); + assertNull(map0); + } + + @Test(timeout = 4000) + public void test8() throws Throwable { + UpdateVolumeGroupResponse updateVolumeGroupResponse0 = new UpdateVolumeGroupResponse("", "", (Map<String, String>) null, ""); + updateVolumeGroupResponse0.setVolumeGroupId("@(Ux]`8WPh"); + assertEquals("@(Ux]`8WPh", updateVolumeGroupResponse0.getVolumeGroupId()); + } + + @Test(timeout = 4000) + public void test9() throws Throwable { + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + UpdateVolumeGroupResponse updateVolumeGroupResponse0 = new UpdateVolumeGroupResponse("", "", (Map<String, String>) hashMap0, ""); + String string0 = updateVolumeGroupResponse0.getVolumeGroupId(); + assertEquals("", string0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupResponseESTestscaffolding.java new file mode 100644 index 0000000000..c53ea4cb9a --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/UpdateVolumeGroupResponseESTestscaffolding.java @@ -0,0 +1,98 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:23:04 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class UpdateVolumeGroupResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(UpdateVolumeGroupResponseESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupResponse", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(UpdateVolumeGroupResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfModuleExceptionResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfModuleExceptionResponseESTest.java new file mode 100644 index 0000000000..66144bace6 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfModuleExceptionResponseESTest.java @@ -0,0 +1,141 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:24:56 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class VfModuleExceptionResponseESTest extends VfModuleExceptionResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + VfModuleExceptionResponse vfModuleExceptionResponse0 = new VfModuleExceptionResponse("2m", msoExceptionCategory0, false, "2m"); + assertEquals(MsoExceptionCategory.OPENSTACK, vfModuleExceptionResponse0.getCategory()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + VfModuleExceptionResponse vfModuleExceptionResponse0 = new VfModuleExceptionResponse(); + assertNull(vfModuleExceptionResponse0.getCategory()); + + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.USERDATA; + Boolean boolean0 = new Boolean(false); + vfModuleExceptionResponse0.setMessage("jaxb.formatted.output"); + vfModuleExceptionResponse0.setRolledBack(boolean0); + vfModuleExceptionResponse0.setMessage("jaxb.formatted.output"); + vfModuleExceptionResponse0.setMessageId("jaxb.formatted.output"); + Boolean.logicalXor(false, false); + Boolean.getBoolean((String) null); + vfModuleExceptionResponse0.setRolledBack(boolean0); + vfModuleExceptionResponse0.setCategory(msoExceptionCategory0); + vfModuleExceptionResponse0.setMessageId("OPENSTACK"); + VfModuleExceptionResponse vfModuleExceptionResponse1 = new VfModuleExceptionResponse(); + Boolean boolean1 = vfModuleExceptionResponse0.getRolledBack(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.USERDATA; + VfModuleExceptionResponse vfModuleExceptionResponse0 = new VfModuleExceptionResponse("", msoExceptionCategory0, true, ""); + vfModuleExceptionResponse0.setMessageId(""); + Boolean boolean0 = vfModuleExceptionResponse0.getRolledBack(); + assertTrue(boolean0); + + Boolean.logicalAnd(false, false); + MsoExceptionCategory msoExceptionCategory1 = MsoExceptionCategory.USERDATA; + Boolean.logicalAnd(true, true); + vfModuleExceptionResponse0.setRolledBack(boolean0); + VfModuleExceptionResponse vfModuleExceptionResponse1 = new VfModuleExceptionResponse("&g.0W4Nah+8,", msoExceptionCategory1, true, ""); + vfModuleExceptionResponse0.setMessageId((String) null); + VfModuleExceptionResponse vfModuleExceptionResponse2 = new VfModuleExceptionResponse((String) null, msoExceptionCategory1, false, (String) null); + VfModuleExceptionResponse vfModuleExceptionResponse3 = new VfModuleExceptionResponse("&g.0W4Nah+8,"); + vfModuleExceptionResponse0.getMessage(); + VfModuleExceptionResponse vfModuleExceptionResponse4 = new VfModuleExceptionResponse(); + vfModuleExceptionResponse1.setRolledBack((Boolean) null); + assertEquals("&g.0W4Nah+8,", vfModuleExceptionResponse1.getMessage()); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + VfModuleExceptionResponse vfModuleExceptionResponse0 = new VfModuleExceptionResponse("org.openecomp.mso.openstack.exceptions.MsoExceptionCategory"); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.INTERNAL; + vfModuleExceptionResponse0.setCategory(msoExceptionCategory0); + String string0 = vfModuleExceptionResponse0.getMessage(); + assertEquals("org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", string0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.IO; + String string0 = ""; + VfModuleExceptionResponse vfModuleExceptionResponse0 = new VfModuleExceptionResponse("XOGaF|t", msoExceptionCategory0, true, ""); + // Undeclared exception! + try { + vfModuleExceptionResponse0.toJsonString(); + fail("Expecting exception: VerifyError"); + + } catch(VerifyError e) { + // + // (class: org/codehaus/jackson/map/MapperConfig, method: <clinit> signature: ()V) Bad type in putfield/putstatic + // + verifyException("org.codehaus.jackson.map.ObjectMapper", e); + } + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + VfModuleExceptionResponse vfModuleExceptionResponse0 = new VfModuleExceptionResponse(); + vfModuleExceptionResponse0.setMessage(""); + vfModuleExceptionResponse0.setMessage(""); + vfModuleExceptionResponse0.toXmlString(); + vfModuleExceptionResponse0.setMessage("org.openecomp.mso.adapters.vnfrest.VfModuleExceptionResponse"); + VfModuleExceptionResponse vfModuleExceptionResponse1 = new VfModuleExceptionResponse("org.openecomp.mso.adapters.vnfrest.VfModuleExceptionResponse"); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.INTERNAL; + vfModuleExceptionResponse1.toXmlString(); + vfModuleExceptionResponse1.setCategory(msoExceptionCategory0); + vfModuleExceptionResponse0.setMessage((String) null); + MsoExceptionCategory msoExceptionCategory1 = vfModuleExceptionResponse1.getCategory(); + VfModuleExceptionResponse vfModuleExceptionResponse2 = new VfModuleExceptionResponse(); + vfModuleExceptionResponse1.setCategory(msoExceptionCategory1); + VfModuleExceptionResponse vfModuleExceptionResponse3 = new VfModuleExceptionResponse("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<vfModuleException>\n <message>org.openecomp.mso.adapters.vnfrest.VfModuleExceptionResponse</message>\n</vfModuleException>\n"); + vfModuleExceptionResponse3.getRolledBack(); + vfModuleExceptionResponse3.getMessage(); + vfModuleExceptionResponse3.setRolledBack((Boolean) null); + Boolean boolean0 = Boolean.TRUE; + Boolean.getBoolean("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<vfModuleException>\n <message>org.openecomp.mso.adapters.vnfrest.VfModuleExceptionResponse</message>\n</vfModuleException>\n"); + vfModuleExceptionResponse0.setRolledBack(boolean0); + vfModuleExceptionResponse0.getCategory(); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + VfModuleExceptionResponse vfModuleExceptionResponse0 = new VfModuleExceptionResponse(); + vfModuleExceptionResponse0.setMessageId("cO)VBma"); + vfModuleExceptionResponse0.getMessage(); + VfModuleExceptionResponse vfModuleExceptionResponse1 = new VfModuleExceptionResponse(); + Boolean boolean0 = vfModuleExceptionResponse0.getRolledBack(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + VfModuleExceptionResponse vfModuleExceptionResponse0 = new VfModuleExceptionResponse("IxX(PnBaVq=pz", msoExceptionCategory0, false, ""); + Boolean boolean0 = Boolean.valueOf(false); + Boolean.logicalAnd(true, false); + vfModuleExceptionResponse0.setRolledBack(boolean0); + assertEquals("IxX(PnBaVq=pz", vfModuleExceptionResponse0.getMessage()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfModuleExceptionResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfModuleExceptionResponseESTestscaffolding.java new file mode 100644 index 0000000000..954f118e12 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfModuleExceptionResponseESTestscaffolding.java @@ -0,0 +1,196 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:24:56 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class VfModuleExceptionResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.VfModuleExceptionResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(VfModuleExceptionResponseESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.map.JsonSerializableWithType", + "org.codehaus.jackson.map.deser.StdDeserializerProvider", + "org.codehaus.jackson.map.SerializerFactory", + "org.codehaus.jackson.map.SerializerProvider", + "org.codehaus.jackson.map.SerializationConfig", + "org.codehaus.jackson.JsonProcessingException", + "org.codehaus.jackson.map.introspect.AnnotationMap", + "org.codehaus.jackson.map.introspect.Annotated", + "org.codehaus.jackson.map.util.Annotations", + "org.codehaus.jackson.sym.NameN", + "org.codehaus.jackson.JsonGenerator", + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector", + "org.codehaus.jackson.map.JsonSerializable", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.node.BaseJsonNode", + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.codehaus.jackson.map.DeserializerProvider", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.node.ValueNode", + "org.codehaus.jackson.map.ser.BeanSerializerFactory", + "org.codehaus.jackson.map.introspect.AnnotatedWithParams", + "org.codehaus.jackson.map.AnnotationIntrospector", + "org.codehaus.jackson.map.MappingJsonFactory", + "org.codehaus.jackson.map.MapperConfig$Impl", + "org.codehaus.jackson.sym.Name1", + "org.codehaus.jackson.sym.Name2", + "org.codehaus.jackson.sym.Name3", + "org.codehaus.jackson.map.introspect.MethodFilter", + "org.codehaus.jackson.map.ser.StdSerializerProvider", + "org.codehaus.jackson.map.deser.StdDeserializationContext", + "org.codehaus.jackson.map.ClassIntrospector", + "org.codehaus.jackson.map.AnnotationIntrospector$Pair", + "org.codehaus.jackson.Versioned", + "org.codehaus.jackson.map.type.TypeBase", + "org.codehaus.jackson.map.ser.BasicSerializerFactory", + "org.codehaus.jackson.node.ContainerNode", + "org.codehaus.jackson.map.introspect.NopAnnotationIntrospector", + "org.codehaus.jackson.map.DeserializationConfig", + "org.codehaus.jackson.map.introspect.AnnotatedConstructor", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory", + "org.codehaus.jackson.impl.ReaderBasedParser", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer$TableInfo", + "org.codehaus.jackson.map.type.MapLikeType", + "org.codehaus.jackson.node.ObjectNode", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$MinimalMethodFilter", + "org.codehaus.jackson.map.type.CollectionLikeType", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer$Bucket", + "org.codehaus.jackson.impl.JsonParserMinimalBase", + "org.codehaus.jackson.map.type.TypeParser", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$SetterMethodFilter", + "org.codehaus.jackson.map.introspect.VisibilityChecker", + "org.codehaus.jackson.map.introspect.AnnotatedField", + "org.codehaus.jackson.impl.JsonGeneratorBase", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.util.ByteArrayBuilder", + "org.codehaus.jackson.PrettyPrinter", + "org.codehaus.jackson.map.jsontype.SubtypeResolver", + "org.codehaus.jackson.map.type.SimpleType", + "org.codehaus.jackson.map.util.StdDateFormat", + "org.codehaus.jackson.impl.Utf8Generator", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$SetterAndGetterMethodFilter", + "org.codehaus.jackson.JsonNode", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.codehaus.jackson.ObjectCodec", + "org.codehaus.jackson.map.introspect.AnnotatedMethod", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.node.ArrayNode", + "org.codehaus.jackson.io.SegmentedStringWriter", + "org.codehaus.jackson.map.jsontype.TypeResolverBuilder", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$GetterMethodFilter", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.map.BeanDescription", + "org.codehaus.jackson.impl.WriterBasedGenerator", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.sym.Name", + "org.codehaus.jackson.map.introspect.BasicBeanDescription", + "org.codehaus.jackson.util.TokenBuffer", + "org.codehaus.jackson.map.DeserializationContext", + "org.codehaus.jackson.impl.JsonParserBase", + "org.codehaus.jackson.map.JsonMappingException", + "org.codehaus.jackson.map.introspect.AnnotatedMember", + "org.codehaus.jackson.type.JavaType", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.JsonParser", + "org.codehaus.jackson.node.NullNode", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.adapters.vnfrest.VfModuleExceptionResponse", + "org.codehaus.jackson.map.jsontype.impl.StdSubtypeResolver", + "org.codehaus.jackson.node.TreeTraversingParser", + "org.codehaus.jackson.map.type.CollectionType", + "org.codehaus.jackson.map.MapperConfig", + "org.codehaus.jackson.map.Module$SetupContext", + "org.codehaus.jackson.io.UTF8Writer", + "org.codehaus.jackson.map.type.MapType", + "org.codehaus.jackson.annotate.JsonAutoDetect", + "org.codehaus.jackson.map.type.ArrayType", + "org.codehaus.jackson.map.ClassIntrospector$MixInResolver" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(VfModuleExceptionResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory", + "org.openecomp.mso.adapters.vnfrest.VfModuleExceptionResponse" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfModuleRollbackESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfModuleRollbackESTest.java new file mode 100644 index 0000000000..1ba09e124f --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfModuleRollbackESTest.java @@ -0,0 +1,246 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:20:21 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.VnfRollback; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class VfModuleRollbackESTest extends VfModuleRollbackESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + boolean boolean0 = vfModuleRollback0.isVfModuleCreated(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback("", (String) null, "", false, "", "", msoRequest0, ""); + String string0 = vfModuleRollback0.getVnfId(); + assertNotNull(string0); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.setVfModuleStackId("ORmnn<.2+zb!'teC5"); + vfModuleRollback0.getVfModuleStackId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback("", (String) null, "", false, "", "", msoRequest0, ""); + String string0 = vfModuleRollback0.getVfModuleStackId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + assertNotNull(string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, "", "", ""); + String string0 = vfModuleRollback0.getVfModuleId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.setTenantId("ORmnn<.2+zb!'teC5"); + vfModuleRollback0.getTenantId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.setTenantId(""); + vfModuleRollback0.getTenantId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.getMsoRequest(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.getMessageId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, "", "", ""); + String string0 = vfModuleRollback0.getMessageId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.setCloudSiteId("yIF#jVMha"); + vfModuleRollback0.getCloudSiteId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback("^4s-K=q)*Tb/", "XG?<}b?*4B", "XG?<}b?*4B", false, "", "", (MsoRequest) null, (String) null); + String string0 = vfModuleRollback0.getCloudSiteId(); + assertEquals("", string0); + assertEquals("XG?<}b?*4B", vfModuleRollback0.getVfModuleId()); + assertEquals("", vfModuleRollback0.getTenantId()); + assertNotNull(string0); + assertEquals("^4s-K=q)*Tb/", vfModuleRollback0.getVnfId()); + assertEquals("XG?<}b?*4B", vfModuleRollback0.getVfModuleStackId()); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + VfModuleRollback vfModuleRollback0 = null; + try { + vfModuleRollback0 = new VfModuleRollback((VnfRollback) null, ", tenantCreated=", ", tenantCreated=", ", tenantCreated="); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.adapters.vnfrest.VfModuleRollback", e); + } + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + VnfRollback vnfRollback0 = new VnfRollback("", ", requestType = ", "", true, true, msoRequest0, " .~y_qT", "", ""); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, (String) null, (String) null, "TgLE(4jqRR&B*tjC*6"); + boolean boolean0 = vfModuleRollback0.isVfModuleCreated(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.getVnfId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.getCloudSiteId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + VnfRollback vnfRollback0 = new VnfRollback("", ", requestType = ", "", true, true, msoRequest0, " .~y_qT", "", ""); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, (String) null, (String) null, "TgLE(4jqRR&B*tjC*6"); + MsoRequest msoRequest1 = vfModuleRollback0.getMsoRequest(); + assertNull(msoRequest1.getRequestId()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + VnfRollback vnfRollback0 = new VnfRollback("", ", requestType = ", "", true, true, msoRequest0, " .~y_qT", "", ""); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, (String) null, (String) null, "TgLE(4jqRR&B*tjC*6"); + vfModuleRollback0.setVfModuleId("TUj9qO3IbhX0v~"); + String string0 = vfModuleRollback0.getVfModuleId(); + assertEquals("TUj9qO3IbhX0v~", string0); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + VnfRollback vnfRollback0 = new VnfRollback("", ", requestType = ", "", true, true, msoRequest0, " .~y_qT", "", ""); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, (String) null, (String) null, "TgLE(4jqRR&B*tjC*6"); + vfModuleRollback0.setMessageId(", tenantCreated="); + assertNull(vfModuleRollback0.getVfModuleId()); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.setVnfId("n+S7/*fyf8oP5jpt#"); + vfModuleRollback0.getVnfId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + VnfRollback vnfRollback0 = new VnfRollback("", ", requestType = ", "", true, true, msoRequest0, " .~y_qT", "", ""); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, (String) null, (String) null, "TgLE(4jqRR&B*tjC*6"); + vfModuleRollback0.setVfModuleCreated(true); + assertTrue(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + VnfRollback vnfRollback0 = new VnfRollback("", ", requestType = ", "", true, true, msoRequest0, " .~y_qT", "", ""); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, (String) null, (String) null, "TgLE(4jqRR&B*tjC*6"); + vfModuleRollback0.setMsoRequest(msoRequest0); + assertEquals(", requestType = ", vfModuleRollback0.getTenantId()); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + VnfRollback vnfRollback0 = new VnfRollback("", ", requestType = ", "", true, true, msoRequest0, " .~y_qT", "", ""); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, (String) null, (String) null, "TgLE(4jqRR&B*tjC*6"); + String string0 = vfModuleRollback0.getMessageId(); + assertEquals("TgLE(4jqRR&B*tjC*6", string0); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.getVfModuleStackId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + VnfRollback vnfRollback0 = new VnfRollback("", ", requestType = ", "", true, true, msoRequest0, " .~y_qT", "", ""); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, (String) null, (String) null, "TgLE(4jqRR&B*tjC*6"); + String string0 = vfModuleRollback0.getVfModuleId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.getTenantId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfModuleRollbackESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfModuleRollbackESTestscaffolding.java new file mode 100644 index 0000000000..b89667deff --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfModuleRollbackESTestscaffolding.java @@ -0,0 +1,83 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:20:21 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class VfModuleRollbackESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.VfModuleRollback"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(VfModuleRollbackESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.openstack.beans.VnfRollback", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.adapters.vnfrest.VfModuleRollback", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommonESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommonESTest.java new file mode 100644 index 0000000000..58a2d1c0cf --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommonESTest.java @@ -0,0 +1,88 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:10:46 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class VfRequestCommonESTest extends VfRequestCommonESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + Boolean boolean0 = Boolean.TRUE; + createVolumeGroupRequest0.setSkipAAI(boolean0); + Boolean boolean1 = createVolumeGroupRequest0.getSkipAAI(); + assertTrue(boolean1); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + deleteVfModuleRequest0.setNotificationUrl("ghhl_5"); + String string0 = deleteVfModuleRequest0.getNotificationUrl(); + assertEquals("ghhl_5", string0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + deleteVolumeGroupRequest0.setNotificationUrl(""); + String string0 = deleteVolumeGroupRequest0.getNotificationUrl(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + deleteVfModuleRequest0.setNotificationUrl(""); + boolean boolean0 = deleteVfModuleRequest0.isSynchronous(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + DeleteVolumeGroupRequest deleteVolumeGroupRequest0 = new DeleteVolumeGroupRequest(); + boolean boolean0 = deleteVolumeGroupRequest0.isSynchronous(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + Boolean boolean0 = createVolumeGroupRequest0.getSkipAAI(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + String string0 = deleteVfModuleRequest0.getNotificationUrl(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + DeleteVfModuleRequest deleteVfModuleRequest0 = new DeleteVfModuleRequest(); + deleteVfModuleRequest0.setNotificationUrl("ghhl_5"); + boolean boolean0 = deleteVfModuleRequest0.isSynchronous(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test8() throws Throwable { + CreateVolumeGroupRequest createVolumeGroupRequest0 = new CreateVolumeGroupRequest(); + Boolean boolean0 = new Boolean(""); + createVolumeGroupRequest0.setSkipAAI(boolean0); + Boolean boolean1 = createVolumeGroupRequest0.getSkipAAI(); + assertFalse(boolean1); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommonESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommonESTestscaffolding.java new file mode 100644 index 0000000000..61a986d991 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommonESTestscaffolding.java @@ -0,0 +1,104 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:10:46 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class VfRequestCommonESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.VfRequestCommon"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(VfRequestCommonESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnfrest.VfRequestCommon", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.codehaus.jackson.Versioned", + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupRequest", + "org.openecomp.mso.entity.MsoRequest", + "org.codehaus.jackson.map.introspect.VisibilityChecker", + "org.openecomp.mso.adapters.vnfrest.DeleteVfModuleRequest", + "org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupRequest", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(VfRequestCommonESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.introspect.AnnotatedClass", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector", + "org.codehaus.jackson.annotate.JsonAutoDetect$Visibility", + "org.codehaus.jackson.annotate.JsonMethod", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.map.ObjectMapper", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.JsonGenerator$Feature", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer", + "org.codehaus.jackson.sym.BytesToNameCanonicalizer", + "org.codehaus.jackson.map.type.TypeFactory" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupExceptionResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupExceptionResponseESTest.java new file mode 100644 index 0000000000..08fb7709e4 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupExceptionResponseESTest.java @@ -0,0 +1,37 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:27:29 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class VolumeGroupExceptionResponseESTest extends VolumeGroupExceptionResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + VolumeGroupExceptionResponse volumeGroupExceptionResponse0 = new VolumeGroupExceptionResponse(); + assertNull(volumeGroupExceptionResponse0.getMessageId()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.USERDATA; + VolumeGroupExceptionResponse volumeGroupExceptionResponse0 = new VolumeGroupExceptionResponse("L", msoExceptionCategory0, false, "M4"); + assertEquals("L", volumeGroupExceptionResponse0.getMessage()); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + VolumeGroupExceptionResponse volumeGroupExceptionResponse0 = new VolumeGroupExceptionResponse("M4"); + assertNull(volumeGroupExceptionResponse0.getCategory()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupExceptionResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupExceptionResponseESTestscaffolding.java new file mode 100644 index 0000000000..7046189b28 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupExceptionResponseESTestscaffolding.java @@ -0,0 +1,88 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:27:29 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class VolumeGroupExceptionResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.VolumeGroupExceptionResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(VolumeGroupExceptionResponseESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnfrest.VfResponseCommon", + "org.openecomp.mso.adapters.vnfrest.VfModuleExceptionResponse", + "org.openecomp.mso.adapters.vnfrest.VolumeGroupExceptionResponse", + "org.openecomp.mso.openstack.exceptions.MsoExceptionCategory", + "org.jboss.resteasy.annotations.providers.NoJackson" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(VolumeGroupExceptionResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.vnfrest.VfModuleExceptionResponse", + "org.openecomp.mso.adapters.vnfrest.VolumeGroupExceptionResponse" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupRollbackESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupRollbackESTest.java new file mode 100644 index 0000000000..7a4a386cc3 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupRollbackESTest.java @@ -0,0 +1,198 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:18:37 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.openecomp.mso.entity.MsoRequest; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class VolumeGroupRollbackESTest extends VolumeGroupRollbackESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + volumeGroupRollback0.setVolumeGroupStackId("F"); + volumeGroupRollback0.getVolumeGroupStackId(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + volumeGroupRollback0.setVolumeGroupId("?4I<}KM{|IP"); + volumeGroupRollback0.getVolumeGroupId(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest("", ""); + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback("", "", false, "", "", msoRequest0, ""); + volumeGroupRollback0.getVolumeGroupId(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback("q\"(B{+Ht7bO5", "q\"(B{+Ht7bO5", false, "q\"(B{+Ht7bO5", "q\"(B{+Ht7bO5", msoRequest0, "q\"(B{+Ht7bO5"); + volumeGroupRollback0.getTenantId(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + volumeGroupRollback0.setTenantId(""); + volumeGroupRollback0.getTenantId(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback("", "", true, "", "", msoRequest0, ""); + volumeGroupRollback0.getMsoRequest(); + assertTrue(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + volumeGroupRollback0.setMessageId("~O0>CjU'2WS"); + volumeGroupRollback0.getMessageId(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + volumeGroupRollback0.setMessageId(""); + volumeGroupRollback0.getMessageId(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + volumeGroupRollback0.setCloudSiteId("F"); + volumeGroupRollback0.getCloudSiteId(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = null; + try { + volumeGroupRollback0 = new VolumeGroupRollback((VolumeGroupRollback) null, "", ""); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.adapters.vnfrest.VolumeGroupRollback", e); + } + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + volumeGroupRollback0.getMsoRequest(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + boolean boolean0 = volumeGroupRollback0.isVolumeGroupCreated(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + volumeGroupRollback0.getVolumeGroupId(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + volumeGroupRollback0.getTenantId(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + volumeGroupRollback0.getCloudSiteId(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + volumeGroupRollback0.getMessageId(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + volumeGroupRollback0.setCloudSiteId(""); + volumeGroupRollback0.getCloudSiteId(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + volumeGroupRollback0.getVolumeGroupStackId(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + + volumeGroupRollback0.setVolumeGroupCreated(true); + boolean boolean0 = volumeGroupRollback0.isVolumeGroupCreated(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + volumeGroupRollback0.setVolumeGroupStackId(""); + volumeGroupRollback0.getVolumeGroupStackId(); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + MsoRequest msoRequest0 = new MsoRequest(); + volumeGroupRollback0.setMsoRequest(msoRequest0); + assertFalse(volumeGroupRollback0.isVolumeGroupCreated()); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + VolumeGroupRollback volumeGroupRollback0 = new VolumeGroupRollback(); + VolumeGroupRollback volumeGroupRollback1 = new VolumeGroupRollback(volumeGroupRollback0, "", "HC1I]xTWKN0*icHc]"); + assertEquals("", volumeGroupRollback1.getVolumeGroupStackId()); + assertFalse(volumeGroupRollback1.isVolumeGroupCreated()); + assertEquals("HC1I]xTWKN0*icHc]", volumeGroupRollback1.getMessageId()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupRollbackESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupRollbackESTestscaffolding.java new file mode 100644 index 0000000000..d88e9e7dee --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/vnfrest/VolumeGroupRollbackESTestscaffolding.java @@ -0,0 +1,82 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:18:37 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnfrest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class VolumeGroupRollbackESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnfrest.VolumeGroupRollback"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(VolumeGroupRollbackESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.vnfrest.VolumeGroupRollback", + "org.openecomp.mso.entity.MsoRequest", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-network-adapter-async-client/README.md b/adapters/mso-network-adapter-async-client/README.md new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/README.md diff --git a/adapters/mso-network-adapter-async-client/WebContent/META-INF/MANIFEST.MF b/adapters/mso-network-adapter-async-client/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..254272e1c0 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/adapters/mso-network-adapter-async-client/pom.xml b/adapters/mso-network-adapter-async-client/pom.xml new file mode 100644 index 0000000000..3b2cd4273d --- /dev/null +++ b/adapters/mso-network-adapter-async-client/pom.xml @@ -0,0 +1,90 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp.mso</groupId> + <artifactId>adapters</artifactId> + <version>0.0.4-SNAPSHOT</version> + </parent> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-network-adapter-async-client</artifactId> + <packaging>jar</packaging> + <name>mso-network-adapter-async-client</name> + <description>MSO Network Adapter Async Client</description> + + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <version>2.6</version> + <configuration> + <classesDirectory>target/classes</classesDirectory> + </configuration> + </plugin> + <plugin> + <groupId>org.jvnet.jax-ws-commons</groupId> + <artifactId>jaxws-maven-plugin</artifactId> + <version>2.3</version> + <executions> + <execution> + <id>generate-stubs</id> + <phase>process-classes</phase> + <goals> + <goal>wsimport</goal> + </goals> + <configuration> + <vmArgs> + <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> + </vmArgs> + <wsdlDirectory>src/main/resources</wsdlDirectory> + <wsdlFiles> + <wsdlFile>NetworkAdapterNotify.wsdl</wsdlFile> + </wsdlFiles> + <wsdlLocation>/NetworkAdapterNotify.wsdl</wsdlLocation> + <packageName>org.openecomp.mso.adapters.network.async.client</packageName> + <xnocompile>false</xnocompile> + <keep>true</keep> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <!--This plugin's configuration is used to store Eclipse m2e settings + only. It has no influence on the Maven build itself. --> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId> + org.jvnet.jax-ws-commons + </groupId> + <artifactId> + jaxws-maven-plugin + </artifactId> + <versionRange> + [2.3,) + </versionRange> + <goals> + <goal>wsimport</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore></ignore> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> +</project> diff --git a/adapters/mso-network-adapter-async-client/src/main/resources/NetworkAdapterNotify.wsdl b/adapters/mso-network-adapter-async-client/src/main/resources/NetworkAdapterNotify.wsdl new file mode 100644 index 0000000000..fe5346da49 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/main/resources/NetworkAdapterNotify.wsdl @@ -0,0 +1,295 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.7-b01 svn-revision#13316. --> +<definitions targetNamespace="http://com.att.mso/networkNotify" name="networkAdapterNotify" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:tns="http://com.att.mso/networkNotify" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> + <types> + <xs:schema version="1.0" targetNamespace="http://com.att.mso/networkNotify" xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:element name="createNetworkNotification" type="tns:createNetworkNotification"/> + + <xs:element name="createNetworkNotificationResponse" type="tns:createNetworkNotificationResponse"/> + + <xs:element name="deleteNetworkNotification" type="tns:deleteNetworkNotification"/> + + <xs:element name="deleteNetworkNotificationResponse" type="tns:deleteNetworkNotificationResponse"/> + + <xs:element name="queryNetworkNotification" type="tns:queryNetworkNotification"/> + + <xs:element name="queryNetworkNotificationResponse" type="tns:queryNetworkNotificationResponse"/> + + <xs:element name="rollbackNetworkNotification" type="tns:rollbackNetworkNotification"/> + + <xs:element name="rollbackNetworkNotificationResponse" type="tns:rollbackNetworkNotificationResponse"/> + + <xs:element name="updateNetworkNotification" type="tns:updateNetworkNotification"/> + + <xs:element name="updateNetworkNotificationResponse" type="tns:updateNetworkNotificationResponse"/> + + <xs:complexType name="queryNetworkNotification"> + <xs:sequence> + <xs:element name="messageId" type="xs:string"/> + <xs:element name="completed" type="xs:boolean"/> + <xs:element name="exception" type="tns:msoExceptionCategory" minOccurs="0"/> + <xs:element name="errorMessage" type="xs:string" minOccurs="0"/> + <xs:element name="networkExists" type="xs:boolean" minOccurs="0"/> + <xs:element name="networkId" type="xs:string" minOccurs="0"/> + <xs:element name="neutronNetworkId" type="xs:string" minOccurs="0"/> + <xs:element name="status" type="tns:networkStatus" minOccurs="0"/> + <xs:element name="vlans" type="xs:int" minOccurs="0" maxOccurs="unbounded"/> + <xs:element name="subnetIdMap" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="entry" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="key" minOccurs="0" type="xs:string"/> + <xs:element name="value" minOccurs="0" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="queryNetworkNotificationResponse"> + <xs:sequence/> + </xs:complexType> + + <xs:complexType name="deleteNetworkNotification"> + <xs:sequence> + <xs:element name="messageId" type="xs:string"/> + <xs:element name="completed" type="xs:boolean"/> + <xs:element name="exception" type="tns:msoExceptionCategory" minOccurs="0"/> + <xs:element name="errorMessage" type="xs:string" minOccurs="0"/> + <xs:element name="networkDeleted" type="xs:boolean" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="deleteNetworkNotificationResponse"> + <xs:sequence/> + </xs:complexType> + + <xs:complexType name="rollbackNetworkNotification"> + <xs:sequence> + <xs:element name="messageId" type="xs:string"/> + <xs:element name="completed" type="xs:boolean"/> + <xs:element name="exception" type="tns:msoExceptionCategory" minOccurs="0"/> + <xs:element name="errorMessage" type="xs:string" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="rollbackNetworkNotificationResponse"> + <xs:sequence/> + </xs:complexType> + + <xs:complexType name="createNetworkNotification"> + <xs:sequence> + <xs:element name="messageId" type="xs:string"/> + <xs:element name="completed" type="xs:boolean"/> + <xs:element name="exception" type="tns:msoExceptionCategory" minOccurs="0"/> + <xs:element name="errorMessage" type="xs:string" minOccurs="0"/> + <xs:element name="networkId" type="xs:string" minOccurs="0"/> + <xs:element name="neutronNetworkId" type="xs:string" minOccurs="0"/> + <xs:element name="subnetIdMap" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="entry" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="key" minOccurs="0" type="xs:string"/> + <xs:element name="value" minOccurs="0" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="rollback" type="tns:networkRollback" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="createNetworkNotificationResponse"> + <xs:sequence/> + </xs:complexType> + + <xs:complexType name="updateNetworkNotification"> + <xs:sequence> + <xs:element name="messageId" type="xs:string"/> + <xs:element name="completed" type="xs:boolean"/> + <xs:element name="exception" type="tns:msoExceptionCategory" minOccurs="0"/> + <xs:element name="errorMessage" type="xs:string" minOccurs="0"/> + <xs:element name="subnetIdMap" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="entry" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="key" minOccurs="0" type="xs:string"/> + <xs:element name="value" minOccurs="0" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="rollback" type="tns:networkRollback" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="updateNetworkNotificationResponse"> + <xs:sequence/> + </xs:complexType> + + <xs:complexType name="networkRollback"> + <xs:sequence> + <xs:element name="cloudId" type="xs:string" minOccurs="0"/> + <xs:element name="msoRequest" type="tns:msoRequest" minOccurs="0"/> + <xs:element name="networkCreated" type="xs:boolean"/> + <xs:element name="networkId" type="xs:string" minOccurs="0"/> + <xs:element name="networkStackId" type="xs:string" minOccurs="0"/> + <xs:element name="networkName" type="xs:string" minOccurs="0"/> + <xs:element name="networkType" type="xs:string" minOccurs="0"/> + <xs:element name="networkUpdated" type="xs:boolean"/> + <xs:element name="neutronNetworkId" type="xs:string" minOccurs="0"/> + <xs:element name="physicalNetwork" type="xs:string" minOccurs="0"/> + <xs:element name="tenantId" type="xs:string" minOccurs="0"/> + <xs:element name="vlans" type="xs:int" nillable="true" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="msoRequest"> + <xs:sequence> + <xs:element name="requestId" type="xs:string" minOccurs="0"/> + <xs:element name="serviceInstanceId" type="xs:string" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + + <xs:simpleType name="msoExceptionCategory"> + <xs:restriction base="xs:string"> + <xs:enumeration value="OPENSTACK"/> + <xs:enumeration value="IO"/> + <xs:enumeration value="INTERNAL"/> + <xs:enumeration value="USERDATA"/> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="networkStatus"> + <xs:restriction base="xs:string"> + <xs:enumeration value="NOTFOUND"/> + <xs:enumeration value="ACTIVE"/> + <xs:enumeration value="DOWN"/> + <xs:enumeration value="BUILD"/> + <xs:enumeration value="ERROR"/> + <xs:enumeration value="UNKNOWN"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> + </types> + <message name="rollbackNetworkNotification"> + <part name="parameters" element="tns:rollbackNetworkNotification"/> + </message> + <message name="rollbackNetworkNotificationResponse"> + <part name="parameters" element="tns:rollbackNetworkNotificationResponse"/> + </message> + <message name="queryNetworkNotification"> + <part name="parameters" element="tns:queryNetworkNotification"/> + </message> + <message name="queryNetworkNotificationResponse"> + <part name="parameters" element="tns:queryNetworkNotificationResponse"/> + </message> + <message name="createNetworkNotification"> + <part name="parameters" element="tns:createNetworkNotification"/> + </message> + <message name="createNetworkNotificationResponse"> + <part name="parameters" element="tns:createNetworkNotificationResponse"/> + </message> + <message name="deleteNetworkNotification"> + <part name="parameters" element="tns:deleteNetworkNotification"/> + </message> + <message name="deleteNetworkNotificationResponse"> + <part name="parameters" element="tns:deleteNetworkNotificationResponse"/> + </message> + <message name="updateNetworkNotification"> + <part name="parameters" element="tns:updateNetworkNotification"/> + </message> + <message name="updateNetworkNotificationResponse"> + <part name="parameters" element="tns:updateNetworkNotificationResponse"/> + </message> + <portType name="networkAdapterNotify"> + <operation name="rollbackNetworkNotification"> + <input wsam:Action="http://com.att.mso/notify/adapterNotify/rollbackNetworkNotificationRequest" message="tns:rollbackNetworkNotification"/> + <output wsam:Action="http://com.att.mso/notify/adapterNotify/rollbackNetworkNotificationResponse" message="tns:rollbackNetworkNotificationResponse"/> + </operation> + <operation name="queryNetworkNotification"> + <input wsam:Action="http://com.att.mso/notify/adapterNotify/queryNetworkNotificationRequest" message="tns:queryNetworkNotification"/> + <output wsam:Action="http://com.att.mso/notify/adapterNotify/queryNetworkNotificationResponse" message="tns:queryNetworkNotificationResponse"/> + </operation> + <operation name="createNetworkNotification"> + <input wsam:Action="http://com.att.mso/notify/adapterNotify/createNetworkNotificationRequest" message="tns:createNetworkNotification"/> + <output wsam:Action="http://com.att.mso/notify/adapterNotify/createNetworkNotificationResponse" message="tns:createNetworkNotificationResponse"/> + </operation> + <operation name="deleteNetworkNotification"> + <input wsam:Action="http://com.att.mso/notify/adapterNotify/deleteNetworkNotificationRequest" message="tns:deleteNetworkNotification"/> + <output wsam:Action="http://com.att.mso/notify/adapterNotify/deleteNetworkNotificationResponse" message="tns:deleteNetworkNotificationResponse"/> + </operation> + <operation name="updateNetworkNotification"> + <input wsam:Action="http://com.att.mso/notify/adapterNotify/updateNetworkNotificationRequest" message="tns:updateNetworkNotification"/> + <output wsam:Action="http://com.att.mso/notify/adapterNotify/updateNetworkNotificationResponse" message="tns:updateNetworkNotificationResponse"/> + </operation> + </portType> + <binding name="MsoNetworkAdapterAsyncImplPortBinding" type="tns:networkAdapterNotify"> + <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> + <operation name="rollbackNetworkNotification"> + <soap:operation soapAction=""/> + <input> + <soap:body use="literal"/> + </input> + <output> + <soap:body use="literal"/> + </output> + </operation> + <operation name="queryNetworkNotification"> + <soap:operation soapAction=""/> + <input> + <soap:body use="literal"/> + </input> + <output> + <soap:body use="literal"/> + </output> + </operation> + <operation name="createNetworkNotification"> + <soap:operation soapAction=""/> + <input> + <soap:body use="literal"/> + </input> + <output> + <soap:body use="literal"/> + </output> + </operation> + <operation name="deleteNetworkNotification"> + <soap:operation soapAction=""/> + <input> + <soap:body use="literal"/> + </input> + <output> + <soap:body use="literal"/> + </output> + </operation> + <operation name="updateNetworkNotification"> + <soap:operation soapAction=""/> + <input> + <soap:body use="literal"/> + </input> + <output> + <soap:body use="literal"/> + </output> + </operation> + </binding> + <service name="networkAdapterNotify"> + <port name="MsoNetworkAdapterAsyncImplPort" binding="tns:MsoNetworkAdapterAsyncImplPortBinding"> + <soap:address location="REPLACE_WITH_ACTUAL_URL"/> + </port> + </service> +</definitions> + diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/CreateNetworkNotificationESTest.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/CreateNetworkNotificationESTest.java new file mode 100644 index 0000000000..ce129e47d5 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/CreateNetworkNotificationESTest.java @@ -0,0 +1,213 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:38:53 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.List; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class CreateNetworkNotificationESTest extends CreateNetworkNotificationESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + CreateNetworkNotification.SubnetIdMap createNetworkNotification_SubnetIdMap0 = new CreateNetworkNotification.SubnetIdMap(); + createNetworkNotification0.setSubnetIdMap(createNetworkNotification_SubnetIdMap0); + CreateNetworkNotification.SubnetIdMap createNetworkNotification_SubnetIdMap1 = createNetworkNotification0.getSubnetIdMap(); + assertSame(createNetworkNotification_SubnetIdMap1, createNetworkNotification_SubnetIdMap0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + createNetworkNotification0.neutronNetworkId = "org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory"; + String string0 = createNetworkNotification0.getNeutronNetworkId(); + assertEquals("org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + createNetworkNotification0.neutronNetworkId = ""; + String string0 = createNetworkNotification0.getNeutronNetworkId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + createNetworkNotification0.setNetworkId("IO"); + String string0 = createNetworkNotification0.getNetworkId(); + assertEquals("IO", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + createNetworkNotification0.setMessageId(",x!0'6/o1Bj\"nxg JH"); + String string0 = createNetworkNotification0.getMessageId(); + assertEquals(",x!0'6/o1Bj\"nxg JH", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + createNetworkNotification0.messageId = ""; + String string0 = createNetworkNotification0.getMessageId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + createNetworkNotification0.errorMessage = ""; + String string0 = createNetworkNotification0.getErrorMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + String string0 = createNetworkNotification0.getNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + NetworkRollback networkRollback0 = createNetworkNotification0.getRollback(); + assertNull(networkRollback0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + boolean boolean0 = createNetworkNotification0.isCompleted(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + createNetworkNotification0.getException(); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + createNetworkNotification0.setErrorMessage("org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory"); + String string0 = createNetworkNotification0.getErrorMessage(); + assertEquals("org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory", string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + String string0 = createNetworkNotification0.getNeutronNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + createNetworkNotification0.setNeutronNetworkId(""); + assertNull(createNetworkNotification0.getErrorMessage()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + createNetworkNotification0.setException(msoExceptionCategory0); + MsoExceptionCategory msoExceptionCategory1 = createNetworkNotification0.getException(); + assertEquals(MsoExceptionCategory.OPENSTACK, msoExceptionCategory1); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + createNetworkNotification0.setRollback((NetworkRollback) null); + assertNull(createNetworkNotification0.getMessageId()); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + createNetworkNotification0.setCompleted(true); + boolean boolean0 = createNetworkNotification0.isCompleted(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + createNetworkNotification0.setNetworkId(""); + String string0 = createNetworkNotification0.getNetworkId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + CreateNetworkNotification.SubnetIdMap createNetworkNotification_SubnetIdMap0 = createNetworkNotification0.getSubnetIdMap(); + assertNull(createNetworkNotification_SubnetIdMap0); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + String string0 = createNetworkNotification0.getErrorMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + CreateNetworkNotification createNetworkNotification0 = new CreateNetworkNotification(); + String string0 = createNetworkNotification0.getMessageId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + CreateNetworkNotification.SubnetIdMap.Entry createNetworkNotification_SubnetIdMap_Entry0 = new CreateNetworkNotification.SubnetIdMap.Entry(); + createNetworkNotification_SubnetIdMap_Entry0.setKey(""); + assertEquals("", createNetworkNotification_SubnetIdMap_Entry0.getKey()); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + CreateNetworkNotification.SubnetIdMap.Entry createNetworkNotification_SubnetIdMap_Entry0 = new CreateNetworkNotification.SubnetIdMap.Entry(); + String string0 = createNetworkNotification_SubnetIdMap_Entry0.getValue(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + CreateNetworkNotification.SubnetIdMap.Entry createNetworkNotification_SubnetIdMap_Entry0 = new CreateNetworkNotification.SubnetIdMap.Entry(); + createNetworkNotification_SubnetIdMap_Entry0.setValue("'G^M#'lcLg6Gw}"); + assertNull(createNetworkNotification_SubnetIdMap_Entry0.getKey()); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + CreateNetworkNotification.SubnetIdMap.Entry createNetworkNotification_SubnetIdMap_Entry0 = new CreateNetworkNotification.SubnetIdMap.Entry(); + String string0 = createNetworkNotification_SubnetIdMap_Entry0.getKey(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + CreateNetworkNotification.SubnetIdMap createNetworkNotification_SubnetIdMap0 = new CreateNetworkNotification.SubnetIdMap(); + createNetworkNotification_SubnetIdMap0.getEntry(); + List<CreateNetworkNotification.SubnetIdMap.Entry> list0 = createNetworkNotification_SubnetIdMap0.getEntry(); + assertTrue(list0.isEmpty()); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/CreateNetworkNotificationESTestscaffolding.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/CreateNetworkNotificationESTestscaffolding.java new file mode 100644 index 0000000000..358324cb4b --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/CreateNetworkNotificationESTestscaffolding.java @@ -0,0 +1,83 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:38:53 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class CreateNetworkNotificationESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.network.async.client.CreateNetworkNotification"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(CreateNetworkNotificationESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.network.async.client.CreateNetworkNotification$SubnetIdMap", + "org.openecomp.mso.adapters.network.async.client.MsoRequest", + "org.openecomp.mso.adapters.network.async.client.NetworkRollback", + "org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory", + "org.openecomp.mso.adapters.network.async.client.CreateNetworkNotification$SubnetIdMap$Entry", + "org.openecomp.mso.adapters.network.async.client.CreateNetworkNotification" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/CreateNetworkNotificationResponseESTest.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/CreateNetworkNotificationResponseESTest.java new file mode 100644 index 0000000000..411bb0ed4f --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/CreateNetworkNotificationResponseESTest.java @@ -0,0 +1,20 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:37:26 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.junit.Test; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class CreateNetworkNotificationResponseESTest extends CreateNetworkNotificationResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + CreateNetworkNotificationResponse createNetworkNotificationResponse0 = new CreateNetworkNotificationResponse(); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/CreateNetworkNotificationResponseESTestscaffolding.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/CreateNetworkNotificationResponseESTestscaffolding.java new file mode 100644 index 0000000000..63ec1f4479 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/CreateNetworkNotificationResponseESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:37:26 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class CreateNetworkNotificationResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.network.async.client.CreateNetworkNotificationResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(CreateNetworkNotificationResponseESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.network.async.client.CreateNetworkNotificationResponse" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/DeleteNetworkNotificationESTest.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/DeleteNetworkNotificationESTest.java new file mode 100644 index 0000000000..2023b62d0e --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/DeleteNetworkNotificationESTest.java @@ -0,0 +1,114 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:34:29 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class DeleteNetworkNotificationESTest extends DeleteNetworkNotificationESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + DeleteNetworkNotification deleteNetworkNotification0 = new DeleteNetworkNotification(); + deleteNetworkNotification0.completed = true; + boolean boolean0 = deleteNetworkNotification0.isCompleted(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + DeleteNetworkNotification deleteNetworkNotification0 = new DeleteNetworkNotification(); + deleteNetworkNotification0.messageId = ""; + String string0 = deleteNetworkNotification0.getMessageId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + DeleteNetworkNotification deleteNetworkNotification0 = new DeleteNetworkNotification(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.IO; + deleteNetworkNotification0.setException(msoExceptionCategory0); + MsoExceptionCategory msoExceptionCategory1 = deleteNetworkNotification0.getException(); + assertEquals(MsoExceptionCategory.IO, msoExceptionCategory1); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + DeleteNetworkNotification deleteNetworkNotification0 = new DeleteNetworkNotification(); + deleteNetworkNotification0.setErrorMessage(""); + String string0 = deleteNetworkNotification0.getErrorMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + DeleteNetworkNotification deleteNetworkNotification0 = new DeleteNetworkNotification(); + deleteNetworkNotification0.setMessageId("doA"); + String string0 = deleteNetworkNotification0.getMessageId(); + assertEquals("doA", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + DeleteNetworkNotification deleteNetworkNotification0 = new DeleteNetworkNotification(); + deleteNetworkNotification0.setErrorMessage("aZ"); + String string0 = deleteNetworkNotification0.getErrorMessage(); + assertEquals("aZ", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + DeleteNetworkNotification deleteNetworkNotification0 = new DeleteNetworkNotification(); + String string0 = deleteNetworkNotification0.getErrorMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + DeleteNetworkNotification deleteNetworkNotification0 = new DeleteNetworkNotification(); + boolean boolean0 = deleteNetworkNotification0.isCompleted(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + DeleteNetworkNotification deleteNetworkNotification0 = new DeleteNetworkNotification(); + deleteNetworkNotification0.setNetworkDeleted((Boolean) null); + assertFalse(deleteNetworkNotification0.isCompleted()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + DeleteNetworkNotification deleteNetworkNotification0 = new DeleteNetworkNotification(); + Boolean boolean0 = deleteNetworkNotification0.isNetworkDeleted(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + DeleteNetworkNotification deleteNetworkNotification0 = new DeleteNetworkNotification(); + deleteNetworkNotification0.setCompleted(false); + assertFalse(deleteNetworkNotification0.isCompleted()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + DeleteNetworkNotification deleteNetworkNotification0 = new DeleteNetworkNotification(); + deleteNetworkNotification0.getException(); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + DeleteNetworkNotification deleteNetworkNotification0 = new DeleteNetworkNotification(); + String string0 = deleteNetworkNotification0.getMessageId(); + assertNull(string0); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/DeleteNetworkNotificationESTestscaffolding.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/DeleteNetworkNotificationESTestscaffolding.java new file mode 100644 index 0000000000..368b7d23c9 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/DeleteNetworkNotificationESTestscaffolding.java @@ -0,0 +1,79 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:34:29 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class DeleteNetworkNotificationESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.network.async.client.DeleteNetworkNotification"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DeleteNetworkNotificationESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.network.async.client.DeleteNetworkNotification", + "org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/DeleteNetworkNotificationResponseESTest.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/DeleteNetworkNotificationResponseESTest.java new file mode 100644 index 0000000000..f2a20f89e7 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/DeleteNetworkNotificationResponseESTest.java @@ -0,0 +1,20 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:37:19 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.junit.Test; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class DeleteNetworkNotificationResponseESTest extends DeleteNetworkNotificationResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + DeleteNetworkNotificationResponse deleteNetworkNotificationResponse0 = new DeleteNetworkNotificationResponse(); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/DeleteNetworkNotificationResponseESTestscaffolding.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/DeleteNetworkNotificationResponseESTestscaffolding.java new file mode 100644 index 0000000000..ff40a148d7 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/DeleteNetworkNotificationResponseESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:37:19 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class DeleteNetworkNotificationResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.network.async.client.DeleteNetworkNotificationResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DeleteNetworkNotificationResponseESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.network.async.client.DeleteNetworkNotificationResponse" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/MsoExceptionCategoryESTest.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/MsoExceptionCategoryESTest.java new file mode 100644 index 0000000000..90f41368f7 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/MsoExceptionCategoryESTest.java @@ -0,0 +1,97 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:36:01 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoExceptionCategoryESTest extends MsoExceptionCategoryESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoExceptionCategory[] msoExceptionCategoryArray0 = MsoExceptionCategory.values(); + assertNotNull(msoExceptionCategoryArray0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.valueOf("IO"); + assertEquals(MsoExceptionCategory.IO, msoExceptionCategory0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + // Undeclared exception! + try { + MsoExceptionCategory.valueOf((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // Name is null + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + // Undeclared exception! + try { + MsoExceptionCategory.valueOf(""); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // No enum constant org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory. + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + // Undeclared exception! + try { + MsoExceptionCategory.fromValue("v@;'v:U'4Kk;"); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // No enum constant org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory.v@;'v:U'4Kk; + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.fromValue("INTERNAL"); + String string0 = msoExceptionCategory0.value(); + assertEquals("INTERNAL", string0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + // Undeclared exception! + try { + MsoExceptionCategory.fromValue((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // Name is null + // + verifyException("java.lang.Enum", e); + } + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/MsoExceptionCategoryESTestscaffolding.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/MsoExceptionCategoryESTestscaffolding.java new file mode 100644 index 0000000000..aff7063169 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/MsoExceptionCategoryESTestscaffolding.java @@ -0,0 +1,83 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:36:01 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoExceptionCategoryESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoExceptionCategoryESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(MsoExceptionCategoryESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory" + ); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/MsoRequestESTest.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/MsoRequestESTest.java new file mode 100644 index 0000000000..3d53643207 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/MsoRequestESTest.java @@ -0,0 +1,72 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:33:43 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoRequestESTest extends MsoRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + msoRequest0.setServiceInstanceId(""); + String string0 = msoRequest0.getServiceInstanceId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + msoRequest0.requestId = ""; + msoRequest0.requestId = "0[73oqjz<&DT/q@"; + String string0 = msoRequest0.getRequestId(); + assertEquals("0[73oqjz<&DT/q@", string0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + msoRequest0.requestId = null; + msoRequest0.requestId = ""; + String string0 = msoRequest0.getRequestId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + msoRequest0.setRequestId(""); + assertEquals("", msoRequest0.getRequestId()); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + msoRequest0.setServiceInstanceId("0[73oqjz<&DT/q@"); + String string0 = msoRequest0.getServiceInstanceId(); + assertEquals("0[73oqjz<&DT/q@", string0); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + String string0 = msoRequest0.getServiceInstanceId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + String string0 = msoRequest0.getRequestId(); + assertNull(string0); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/MsoRequestESTestscaffolding.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/MsoRequestESTestscaffolding.java new file mode 100644 index 0000000000..266db77f23 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/MsoRequestESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:33:43 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.network.async.client.MsoRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoRequestESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.network.async.client.MsoRequest" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/NetworkRollbackESTest.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/NetworkRollbackESTest.java new file mode 100644 index 0000000000..524d5d0b5f --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/NetworkRollbackESTest.java @@ -0,0 +1,301 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:33:22 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.LinkedList; +import java.util.List; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class NetworkRollbackESTest extends NetworkRollbackESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.networkUpdated = true; + boolean boolean0 = networkRollback0.isNetworkUpdated(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + LinkedList<Integer> linkedList0 = new LinkedList<Integer>(); + linkedList0.add((Integer) null); + networkRollback0.vlans = (List<Integer>) linkedList0; + List<Integer> list0 = networkRollback0.getVlans(); + assertEquals(1, list0.size()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.tenantId = "&Ks9_, 2}e``"; + String string0 = networkRollback0.getTenantId(); + assertEquals("&Ks9_, 2}e``", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.tenantId = ""; + String string0 = networkRollback0.getTenantId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.physicalNetwork = "'@3 VI0"; + String string0 = networkRollback0.getPhysicalNetwork(); + assertEquals("'@3 VI0", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.physicalNetwork = ""; + String string0 = networkRollback0.getPhysicalNetwork(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.neutronNetworkId = ""; + String string0 = networkRollback0.getNeutronNetworkId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNetworkType("INXI`s_hhn8 |A"); + String string0 = networkRollback0.getNetworkType(); + assertEquals("INXI`s_hhn8 |A", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.networkType = ""; + String string0 = networkRollback0.getNetworkType(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.networkStackId = "{vfF!&8J>*u,6e"; + String string0 = networkRollback0.getNetworkStackId(); + assertEquals("{vfF!&8J>*u,6e", string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.networkStackId = ""; + String string0 = networkRollback0.getNetworkStackId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.networkName = "!mdg>u#"; + String string0 = networkRollback0.getNetworkName(); + assertEquals("!mdg>u#", string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNetworkName(""); + String string0 = networkRollback0.getNetworkName(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNetworkId(">jKMf7Ce<f,p<"); + String string0 = networkRollback0.getNetworkId(); + assertEquals(">jKMf7Ce<f,p<", string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNetworkId(""); + String string0 = networkRollback0.getNetworkId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + MsoRequest msoRequest0 = new MsoRequest(); + networkRollback0.msoRequest = msoRequest0; + MsoRequest msoRequest1 = networkRollback0.getMsoRequest(); + assertSame(msoRequest1, msoRequest0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.cloudId = "wzy(*<k&K@W"; + String string0 = networkRollback0.getCloudId(); + assertEquals("wzy(*<k&K@W", string0); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setCloudId(""); + String string0 = networkRollback0.getCloudId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + List<Integer> list0 = networkRollback0.getVlans(); + assertEquals(0, list0.size()); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + String string0 = networkRollback0.getNetworkName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNetworkCreated(true); + boolean boolean0 = networkRollback0.isNetworkCreated(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + String string0 = networkRollback0.getTenantId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setPhysicalNetwork("T(SG{/@|z:"); + assertNull(networkRollback0.getNetworkName()); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + MsoRequest msoRequest0 = networkRollback0.getMsoRequest(); + assertNull(msoRequest0); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + boolean boolean0 = networkRollback0.isNetworkCreated(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + String string0 = networkRollback0.getNetworkStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + String string0 = networkRollback0.getCloudId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test27() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNetworkUpdated(false); + assertFalse(networkRollback0.isNetworkUpdated()); + } + + @Test(timeout = 4000) + public void test28() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + String string0 = networkRollback0.getNetworkType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test29() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setMsoRequest((MsoRequest) null); + assertNull(networkRollback0.getNetworkType()); + } + + @Test(timeout = 4000) + public void test30() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNeutronNetworkId("hiSG;1>|vJ^&^D"); + String string0 = networkRollback0.getNeutronNetworkId(); + assertEquals("hiSG;1>|vJ^&^D", string0); + } + + @Test(timeout = 4000) + public void test31() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + boolean boolean0 = networkRollback0.isNetworkUpdated(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test32() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + String string0 = networkRollback0.getNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test33() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setTenantId(""); + assertFalse(networkRollback0.isNetworkCreated()); + } + + @Test(timeout = 4000) + public void test34() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + String string0 = networkRollback0.getPhysicalNetwork(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test35() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + String string0 = networkRollback0.getNeutronNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test36() throws Throwable { + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.setNetworkStackId("hiSG;1>|vJ^&^D"); + assertNull(networkRollback0.getNetworkType()); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/NetworkRollbackESTestscaffolding.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/NetworkRollbackESTestscaffolding.java new file mode 100644 index 0000000000..b493406634 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/NetworkRollbackESTestscaffolding.java @@ -0,0 +1,79 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:33:22 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class NetworkRollbackESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.network.async.client.NetworkRollback"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(NetworkRollbackESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.network.async.client.MsoRequest", + "org.openecomp.mso.adapters.network.async.client.NetworkRollback" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/NetworkStatusESTest.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/NetworkStatusESTest.java new file mode 100644 index 0000000000..ac2729ac9e --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/NetworkStatusESTest.java @@ -0,0 +1,91 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:37:01 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class NetworkStatusESTest extends NetworkStatusESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + NetworkStatus[] networkStatusArray0 = NetworkStatus.values(); + assertNotNull(networkStatusArray0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + // Undeclared exception! + try { + NetworkStatus.valueOf((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // Name is null + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + // Undeclared exception! + try { + NetworkStatus.valueOf("RjP-NHISY|sp*/M"); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // No enum constant org.openecomp.mso.adapters.network.async.client.NetworkStatus.RjP-NHISY|sp*_/M + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + // Undeclared exception! + try { + NetworkStatus.fromValue((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // Name is null + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + // Undeclared exception! + try { + NetworkStatus.fromValue(""); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // No enum constant org.openecomp.mso.adapters.network.async.client.NetworkStatus. + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + NetworkStatus networkStatus0 = NetworkStatus.ACTIVE; + String string0 = networkStatus0.value(); + assertEquals("ACTIVE", string0); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/NetworkStatusESTestscaffolding.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/NetworkStatusESTestscaffolding.java new file mode 100644 index 0000000000..0d9c2effd4 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/NetworkStatusESTestscaffolding.java @@ -0,0 +1,83 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:37:01 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class NetworkStatusESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.network.async.client.NetworkStatus"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(NetworkStatusESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.network.async.client.NetworkStatus" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(NetworkStatusESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.network.async.client.NetworkStatus" + ); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/ObjectFactoryESTest.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/ObjectFactoryESTest.java new file mode 100644 index 0000000000..d897ae678a --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/ObjectFactoryESTest.java @@ -0,0 +1,154 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:38:17 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import javax.xml.bind.JAXBElement; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class ObjectFactoryESTest extends ObjectFactoryESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + MsoRequest msoRequest0 = objectFactory0.createMsoRequest(); + assertNull(msoRequest0.getServiceInstanceId()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + NetworkRollback networkRollback0 = objectFactory0.createNetworkRollback(); + assertNull(networkRollback0.getPhysicalNetwork()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + CreateNetworkNotification.SubnetIdMap.Entry createNetworkNotification_SubnetIdMap_Entry0 = objectFactory0.createCreateNetworkNotificationSubnetIdMapEntry(); + assertNull(createNetworkNotification_SubnetIdMap_Entry0.getKey()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + CreateNetworkNotification.SubnetIdMap createNetworkNotification_SubnetIdMap0 = objectFactory0.createCreateNetworkNotificationSubnetIdMap(); + assertNotNull(createNetworkNotification_SubnetIdMap0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + UpdateNetworkNotification.SubnetIdMap.Entry updateNetworkNotification_SubnetIdMap_Entry0 = objectFactory0.createUpdateNetworkNotificationSubnetIdMapEntry(); + assertNull(updateNetworkNotification_SubnetIdMap_Entry0.getKey()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + UpdateNetworkNotification.SubnetIdMap updateNetworkNotification_SubnetIdMap0 = objectFactory0.createUpdateNetworkNotificationSubnetIdMap(); + assertNotNull(updateNetworkNotification_SubnetIdMap0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + QueryNetworkNotification.SubnetIdMap.Entry queryNetworkNotification_SubnetIdMap_Entry0 = objectFactory0.createQueryNetworkNotificationSubnetIdMapEntry(); + assertNull(queryNetworkNotification_SubnetIdMap_Entry0.getKey()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + DeleteNetworkNotification deleteNetworkNotification0 = objectFactory0.createDeleteNetworkNotification(); + JAXBElement<DeleteNetworkNotification> jAXBElement0 = objectFactory0.createDeleteNetworkNotification(deleteNetworkNotification0); + assertNotNull(jAXBElement0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + QueryNetworkNotification.SubnetIdMap queryNetworkNotification_SubnetIdMap0 = objectFactory0.createQueryNetworkNotificationSubnetIdMap(); + assertNotNull(queryNetworkNotification_SubnetIdMap0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + DeleteNetworkNotificationResponse deleteNetworkNotificationResponse0 = objectFactory0.createDeleteNetworkNotificationResponse(); + JAXBElement<DeleteNetworkNotificationResponse> jAXBElement0 = objectFactory0.createDeleteNetworkNotificationResponse(deleteNetworkNotificationResponse0); + assertNotNull(jAXBElement0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + RollbackNetworkNotificationResponse rollbackNetworkNotificationResponse0 = objectFactory0.createRollbackNetworkNotificationResponse(); + JAXBElement<RollbackNetworkNotificationResponse> jAXBElement0 = objectFactory0.createRollbackNetworkNotificationResponse(rollbackNetworkNotificationResponse0); + assertNotNull(jAXBElement0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + CreateNetworkNotificationResponse createNetworkNotificationResponse0 = objectFactory0.createCreateNetworkNotificationResponse(); + JAXBElement<CreateNetworkNotificationResponse> jAXBElement0 = objectFactory0.createCreateNetworkNotificationResponse(createNetworkNotificationResponse0); + assertNotNull(jAXBElement0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + RollbackNetworkNotification rollbackNetworkNotification0 = objectFactory0.createRollbackNetworkNotification(); + JAXBElement<RollbackNetworkNotification> jAXBElement0 = objectFactory0.createRollbackNetworkNotification(rollbackNetworkNotification0); + assertNotNull(jAXBElement0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + UpdateNetworkNotification updateNetworkNotification0 = objectFactory0.createUpdateNetworkNotification(); + JAXBElement<UpdateNetworkNotification> jAXBElement0 = objectFactory0.createUpdateNetworkNotification(updateNetworkNotification0); + assertNotNull(jAXBElement0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + QueryNetworkNotification queryNetworkNotification0 = objectFactory0.createQueryNetworkNotification(); + JAXBElement<QueryNetworkNotification> jAXBElement0 = objectFactory0.createQueryNetworkNotification(queryNetworkNotification0); + assertNotNull(jAXBElement0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + UpdateNetworkNotificationResponse updateNetworkNotificationResponse0 = objectFactory0.createUpdateNetworkNotificationResponse(); + JAXBElement<UpdateNetworkNotificationResponse> jAXBElement0 = objectFactory0.createUpdateNetworkNotificationResponse(updateNetworkNotificationResponse0); + assertNotNull(jAXBElement0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + QueryNetworkNotificationResponse queryNetworkNotificationResponse0 = objectFactory0.createQueryNetworkNotificationResponse(); + JAXBElement<QueryNetworkNotificationResponse> jAXBElement0 = objectFactory0.createQueryNetworkNotificationResponse(queryNetworkNotificationResponse0); + assertNotNull(jAXBElement0); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + CreateNetworkNotification createNetworkNotification0 = objectFactory0.createCreateNetworkNotification(); + JAXBElement<CreateNetworkNotification> jAXBElement0 = objectFactory0.createCreateNetworkNotification(createNetworkNotification0); + assertNotNull(jAXBElement0); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/ObjectFactoryESTestscaffolding.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/ObjectFactoryESTestscaffolding.java new file mode 100644 index 0000000000..1ac0a53880 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/ObjectFactoryESTestscaffolding.java @@ -0,0 +1,103 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:38:17 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class ObjectFactoryESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.network.async.client.ObjectFactory"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ObjectFactoryESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.network.async.client.MsoRequest", + "org.openecomp.mso.adapters.network.async.client.DeleteNetworkNotification", + "org.openecomp.mso.adapters.network.async.client.UpdateNetworkNotification", + "org.openecomp.mso.adapters.network.async.client.NetworkRollback", + "org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory", + "org.openecomp.mso.adapters.network.async.client.QueryNetworkNotification", + "org.openecomp.mso.adapters.network.async.client.QueryNetworkNotificationResponse", + "org.openecomp.mso.adapters.network.async.client.NetworkStatus", + "org.openecomp.mso.adapters.network.async.client.QueryNetworkNotification$SubnetIdMap$Entry", + "org.openecomp.mso.adapters.network.async.client.RollbackNetworkNotificationResponse", + "org.openecomp.mso.adapters.network.async.client.QueryNetworkNotification$SubnetIdMap", + "org.openecomp.mso.adapters.network.async.client.CreateNetworkNotification$SubnetIdMap", + "org.openecomp.mso.adapters.network.async.client.DeleteNetworkNotificationResponse", + "org.openecomp.mso.adapters.network.async.client.UpdateNetworkNotification$SubnetIdMap$Entry", + "org.openecomp.mso.adapters.network.async.client.UpdateNetworkNotification$SubnetIdMap", + "org.openecomp.mso.adapters.network.async.client.CreateNetworkNotificationResponse", + "org.openecomp.mso.adapters.network.async.client.CreateNetworkNotification$SubnetIdMap$Entry", + "org.openecomp.mso.adapters.network.async.client.RollbackNetworkNotification", + "org.openecomp.mso.adapters.network.async.client.ObjectFactory", + "org.openecomp.mso.adapters.network.async.client.CreateNetworkNotification", + "org.openecomp.mso.adapters.network.async.client.UpdateNetworkNotificationResponse" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ObjectFactoryESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.network.async.client.ObjectFactory" + ); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/QueryNetworkNotificationESTest.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/QueryNetworkNotificationESTest.java new file mode 100644 index 0000000000..f5e0f951bb --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/QueryNetworkNotificationESTest.java @@ -0,0 +1,266 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:33:21 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.LinkedList; +import java.util.List; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class QueryNetworkNotificationESTest extends QueryNetworkNotificationESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + Boolean boolean0 = new Boolean(true); + queryNetworkNotification0.networkExists = boolean0; + Boolean boolean1 = queryNetworkNotification0.isNetworkExists(); + assertTrue(boolean1); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + Boolean boolean0 = new Boolean("EY"); + queryNetworkNotification0.networkExists = boolean0; + Boolean boolean1 = queryNetworkNotification0.isNetworkExists(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + LinkedList<Integer> linkedList0 = new LinkedList<Integer>(); + queryNetworkNotification0.vlans = (List<Integer>) linkedList0; + Integer integer0 = new Integer((-1490)); + linkedList0.add(integer0); + List<Integer> list0 = queryNetworkNotification0.getVlans(); + assertEquals(1, list0.size()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + QueryNetworkNotification.SubnetIdMap queryNetworkNotification_SubnetIdMap0 = new QueryNetworkNotification.SubnetIdMap(); + queryNetworkNotification0.setSubnetIdMap(queryNetworkNotification_SubnetIdMap0); + QueryNetworkNotification.SubnetIdMap queryNetworkNotification_SubnetIdMap1 = queryNetworkNotification0.getSubnetIdMap(); + assertSame(queryNetworkNotification_SubnetIdMap1, queryNetworkNotification_SubnetIdMap0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + NetworkStatus networkStatus0 = NetworkStatus.ERROR; + queryNetworkNotification0.setStatus(networkStatus0); + NetworkStatus networkStatus1 = queryNetworkNotification0.getStatus(); + assertEquals(NetworkStatus.ERROR, networkStatus1); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + queryNetworkNotification0.setNeutronNetworkId("\"9\"@lJ*tfb"); + String string0 = queryNetworkNotification0.getNeutronNetworkId(); + assertEquals("\"9\"@lJ*tfb", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + queryNetworkNotification0.setNetworkId("uuPPD.~Xq(<)vCwo`"); + String string0 = queryNetworkNotification0.getNetworkId(); + assertEquals("uuPPD.~Xq(<)vCwo`", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + queryNetworkNotification0.messageId = "[P/"; + String string0 = queryNetworkNotification0.getMessageId(); + assertEquals("[P/", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + queryNetworkNotification0.messageId = ""; + String string0 = queryNetworkNotification0.getMessageId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + queryNetworkNotification0.setErrorMessage("Q39tT8q6(`"); + String string0 = queryNetworkNotification0.getErrorMessage(); + assertEquals("Q39tT8q6(`", string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + queryNetworkNotification0.setErrorMessage(""); + String string0 = queryNetworkNotification0.getErrorMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + List<Integer> list0 = queryNetworkNotification0.getVlans(); + assertEquals(0, list0.size()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + QueryNetworkNotification.SubnetIdMap queryNetworkNotification_SubnetIdMap0 = new QueryNetworkNotification.SubnetIdMap(); + queryNetworkNotification_SubnetIdMap0.getEntry(); + List<QueryNetworkNotification.SubnetIdMap.Entry> list0 = queryNetworkNotification_SubnetIdMap0.getEntry(); + assertEquals(0, list0.size()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + QueryNetworkNotification.SubnetIdMap.Entry queryNetworkNotification_SubnetIdMap_Entry0 = new QueryNetworkNotification.SubnetIdMap.Entry(); + String string0 = queryNetworkNotification_SubnetIdMap_Entry0.getKey(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + QueryNetworkNotification.SubnetIdMap.Entry queryNetworkNotification_SubnetIdMap_Entry0 = new QueryNetworkNotification.SubnetIdMap.Entry(); + queryNetworkNotification_SubnetIdMap_Entry0.setKey(""); + assertEquals("", queryNetworkNotification_SubnetIdMap_Entry0.getKey()); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + QueryNetworkNotification.SubnetIdMap.Entry queryNetworkNotification_SubnetIdMap_Entry0 = new QueryNetworkNotification.SubnetIdMap.Entry(); + String string0 = queryNetworkNotification_SubnetIdMap_Entry0.getValue(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + QueryNetworkNotification.SubnetIdMap.Entry queryNetworkNotification_SubnetIdMap_Entry0 = new QueryNetworkNotification.SubnetIdMap.Entry(); + queryNetworkNotification_SubnetIdMap_Entry0.setValue(""); + assertNull(queryNetworkNotification_SubnetIdMap_Entry0.getKey()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + queryNetworkNotification0.setCompleted(true); + boolean boolean0 = queryNetworkNotification0.isCompleted(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + QueryNetworkNotification.SubnetIdMap queryNetworkNotification_SubnetIdMap0 = queryNetworkNotification0.getSubnetIdMap(); + assertNull(queryNetworkNotification_SubnetIdMap0); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + String string0 = queryNetworkNotification0.getNeutronNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + queryNetworkNotification0.setMessageId("q;G$a9I6oMF_p-Zy4"); + assertNull(queryNetworkNotification0.getNetworkId()); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + String string0 = queryNetworkNotification0.getMessageId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + String string0 = queryNetworkNotification0.getErrorMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + queryNetworkNotification0.setException(msoExceptionCategory0); + MsoExceptionCategory msoExceptionCategory1 = queryNetworkNotification0.getException(); + assertSame(msoExceptionCategory1, msoExceptionCategory0); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + queryNetworkNotification0.getException(); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + Boolean boolean0 = Boolean.TRUE; + queryNetworkNotification0.setNetworkExists(boolean0); + assertFalse(queryNetworkNotification0.isCompleted()); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + String string0 = queryNetworkNotification0.getNetworkId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test27() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + queryNetworkNotification0.getStatus(); + } + + @Test(timeout = 4000) + public void test28() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + boolean boolean0 = queryNetworkNotification0.isCompleted(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test29() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + Boolean boolean0 = queryNetworkNotification0.isNetworkExists(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test30() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + queryNetworkNotification0.setNetworkId(""); + String string0 = queryNetworkNotification0.getNetworkId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test31() throws Throwable { + QueryNetworkNotification queryNetworkNotification0 = new QueryNetworkNotification(); + queryNetworkNotification0.setNeutronNetworkId(""); + String string0 = queryNetworkNotification0.getNeutronNetworkId(); + assertEquals("", string0); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/QueryNetworkNotificationESTestscaffolding.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/QueryNetworkNotificationESTestscaffolding.java new file mode 100644 index 0000000000..944237955c --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/QueryNetworkNotificationESTestscaffolding.java @@ -0,0 +1,82 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:33:21 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class QueryNetworkNotificationESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.network.async.client.QueryNetworkNotification"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(QueryNetworkNotificationESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory", + "org.openecomp.mso.adapters.network.async.client.QueryNetworkNotification", + "org.openecomp.mso.adapters.network.async.client.NetworkStatus", + "org.openecomp.mso.adapters.network.async.client.QueryNetworkNotification$SubnetIdMap$Entry", + "org.openecomp.mso.adapters.network.async.client.QueryNetworkNotification$SubnetIdMap" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/QueryNetworkNotificationResponseESTest.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/QueryNetworkNotificationResponseESTest.java new file mode 100644 index 0000000000..5ffce39508 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/QueryNetworkNotificationResponseESTest.java @@ -0,0 +1,20 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:36:18 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.junit.Test; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class QueryNetworkNotificationResponseESTest extends QueryNetworkNotificationResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + QueryNetworkNotificationResponse queryNetworkNotificationResponse0 = new QueryNetworkNotificationResponse(); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/QueryNetworkNotificationResponseESTestscaffolding.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/QueryNetworkNotificationResponseESTestscaffolding.java new file mode 100644 index 0000000000..cee34092f5 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/QueryNetworkNotificationResponseESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:36:18 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class QueryNetworkNotificationResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.network.async.client.QueryNetworkNotificationResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(QueryNetworkNotificationResponseESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.network.async.client.QueryNetworkNotificationResponse" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/RollbackNetworkNotificationESTest.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/RollbackNetworkNotificationESTest.java new file mode 100644 index 0000000000..2e1ec50642 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/RollbackNetworkNotificationESTest.java @@ -0,0 +1,116 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:37:41 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RollbackNetworkNotificationESTest extends RollbackNetworkNotificationESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + RollbackNetworkNotification rollbackNetworkNotification0 = new RollbackNetworkNotification(); + rollbackNetworkNotification0.completed = true; + boolean boolean0 = rollbackNetworkNotification0.isCompleted(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + RollbackNetworkNotification rollbackNetworkNotification0 = new RollbackNetworkNotification(); + rollbackNetworkNotification0.messageId = ""; + rollbackNetworkNotification0.messageId = "V^{b/%gy^"; + String string0 = rollbackNetworkNotification0.getMessageId(); + assertEquals("V^{b/%gy^", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + RollbackNetworkNotification rollbackNetworkNotification0 = new RollbackNetworkNotification(); + rollbackNetworkNotification0.messageId = ""; + String string0 = rollbackNetworkNotification0.getMessageId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + RollbackNetworkNotification rollbackNetworkNotification0 = new RollbackNetworkNotification(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.IO; + rollbackNetworkNotification0.exception = msoExceptionCategory0; + MsoExceptionCategory msoExceptionCategory1 = rollbackNetworkNotification0.getException(); + assertEquals(MsoExceptionCategory.IO, msoExceptionCategory1); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + RollbackNetworkNotification rollbackNetworkNotification0 = new RollbackNetworkNotification(); + rollbackNetworkNotification0.setErrorMessage("06SZ x\"@[d5*iJ"); + String string0 = rollbackNetworkNotification0.getErrorMessage(); + assertEquals("06SZ x\"@[d5*iJ", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + RollbackNetworkNotification rollbackNetworkNotification0 = new RollbackNetworkNotification(); + rollbackNetworkNotification0.errorMessage = ""; + String string0 = rollbackNetworkNotification0.getErrorMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + RollbackNetworkNotification rollbackNetworkNotification0 = new RollbackNetworkNotification(); + rollbackNetworkNotification0.setCompleted(false); + assertFalse(rollbackNetworkNotification0.isCompleted()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + RollbackNetworkNotification rollbackNetworkNotification0 = new RollbackNetworkNotification(); + boolean boolean0 = rollbackNetworkNotification0.isCompleted(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + RollbackNetworkNotification rollbackNetworkNotification0 = new RollbackNetworkNotification(); + String string0 = rollbackNetworkNotification0.getErrorMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + RollbackNetworkNotification rollbackNetworkNotification0 = new RollbackNetworkNotification(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.IO; + rollbackNetworkNotification0.setException(msoExceptionCategory0); + assertFalse(rollbackNetworkNotification0.isCompleted()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + RollbackNetworkNotification rollbackNetworkNotification0 = new RollbackNetworkNotification(); + String string0 = rollbackNetworkNotification0.getMessageId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + RollbackNetworkNotification rollbackNetworkNotification0 = new RollbackNetworkNotification(); + rollbackNetworkNotification0.getException(); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + RollbackNetworkNotification rollbackNetworkNotification0 = new RollbackNetworkNotification(); + rollbackNetworkNotification0.setMessageId("!!IDL8"); + assertNull(rollbackNetworkNotification0.getErrorMessage()); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/RollbackNetworkNotificationESTestscaffolding.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/RollbackNetworkNotificationESTestscaffolding.java new file mode 100644 index 0000000000..fc15f61b1f --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/RollbackNetworkNotificationESTestscaffolding.java @@ -0,0 +1,79 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:37:41 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RollbackNetworkNotificationESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.network.async.client.RollbackNetworkNotification"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RollbackNetworkNotificationESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory", + "org.openecomp.mso.adapters.network.async.client.RollbackNetworkNotification" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/RollbackNetworkNotificationResponseESTest.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/RollbackNetworkNotificationResponseESTest.java new file mode 100644 index 0000000000..1858a8eac7 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/RollbackNetworkNotificationResponseESTest.java @@ -0,0 +1,20 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:37:09 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.junit.Test; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RollbackNetworkNotificationResponseESTest extends RollbackNetworkNotificationResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + RollbackNetworkNotificationResponse rollbackNetworkNotificationResponse0 = new RollbackNetworkNotificationResponse(); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/RollbackNetworkNotificationResponseESTestscaffolding.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/RollbackNetworkNotificationResponseESTestscaffolding.java new file mode 100644 index 0000000000..15f739f8bf --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/RollbackNetworkNotificationResponseESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:37:09 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RollbackNetworkNotificationResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.network.async.client.RollbackNetworkNotificationResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RollbackNetworkNotificationResponseESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.network.async.client.RollbackNetworkNotificationResponse" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/UpdateNetworkNotificationESTest.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/UpdateNetworkNotificationESTest.java new file mode 100644 index 0000000000..eff07d3026 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/UpdateNetworkNotificationESTest.java @@ -0,0 +1,202 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:35:17 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.List; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class UpdateNetworkNotificationESTest extends UpdateNetworkNotificationESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + updateNetworkNotification0.setCompleted(true); + boolean boolean0 = updateNetworkNotification0.isCompleted(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + UpdateNetworkNotification.SubnetIdMap updateNetworkNotification_SubnetIdMap0 = new UpdateNetworkNotification.SubnetIdMap(); + updateNetworkNotification0.subnetIdMap = updateNetworkNotification_SubnetIdMap0; + UpdateNetworkNotification.SubnetIdMap updateNetworkNotification_SubnetIdMap1 = updateNetworkNotification0.getSubnetIdMap(); + assertSame(updateNetworkNotification_SubnetIdMap1, updateNetworkNotification_SubnetIdMap0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + NetworkRollback networkRollback0 = new NetworkRollback(); + networkRollback0.networkCreated = true; + updateNetworkNotification0.rollback = networkRollback0; + NetworkRollback networkRollback1 = updateNetworkNotification0.getRollback(); + assertNull(networkRollback1.getCloudId()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + NetworkRollback networkRollback0 = new NetworkRollback(); + updateNetworkNotification0.rollback = networkRollback0; + NetworkRollback networkRollback1 = updateNetworkNotification0.getRollback(); + assertSame(networkRollback1, networkRollback0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + updateNetworkNotification0.messageId = "Uc.S9x&9M[n"; + String string0 = updateNetworkNotification0.getMessageId(); + assertEquals("Uc.S9x&9M[n", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + updateNetworkNotification0.messageId = ""; + String string0 = updateNetworkNotification0.getMessageId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.IO; + updateNetworkNotification0.exception = msoExceptionCategory0; + MsoExceptionCategory msoExceptionCategory1 = updateNetworkNotification0.getException(); + assertEquals(MsoExceptionCategory.IO, msoExceptionCategory1); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + updateNetworkNotification0.setErrorMessage("org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory"); + String string0 = updateNetworkNotification0.getErrorMessage(); + assertEquals("org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + updateNetworkNotification0.errorMessage = ""; + String string0 = updateNetworkNotification0.getErrorMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + UpdateNetworkNotification.SubnetIdMap updateNetworkNotification_SubnetIdMap0 = new UpdateNetworkNotification.SubnetIdMap(); + updateNetworkNotification_SubnetIdMap0.getEntry(); + List<UpdateNetworkNotification.SubnetIdMap.Entry> list0 = updateNetworkNotification_SubnetIdMap0.getEntry(); + assertTrue(list0.isEmpty()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + UpdateNetworkNotification.SubnetIdMap.Entry updateNetworkNotification_SubnetIdMap_Entry0 = new UpdateNetworkNotification.SubnetIdMap.Entry(); + updateNetworkNotification_SubnetIdMap_Entry0.setValue(""); + assertEquals("", updateNetworkNotification_SubnetIdMap_Entry0.getValue()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + UpdateNetworkNotification.SubnetIdMap.Entry updateNetworkNotification_SubnetIdMap_Entry0 = new UpdateNetworkNotification.SubnetIdMap.Entry(); + String string0 = updateNetworkNotification_SubnetIdMap_Entry0.getValue(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + UpdateNetworkNotification.SubnetIdMap.Entry updateNetworkNotification_SubnetIdMap_Entry0 = new UpdateNetworkNotification.SubnetIdMap.Entry(); + String string0 = updateNetworkNotification_SubnetIdMap_Entry0.getKey(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + UpdateNetworkNotification.SubnetIdMap.Entry updateNetworkNotification_SubnetIdMap_Entry0 = new UpdateNetworkNotification.SubnetIdMap.Entry(); + updateNetworkNotification_SubnetIdMap_Entry0.setKey("F"); + assertEquals("F", updateNetworkNotification_SubnetIdMap_Entry0.getKey()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + UpdateNetworkNotification.SubnetIdMap updateNetworkNotification_SubnetIdMap0 = new UpdateNetworkNotification.SubnetIdMap(); + updateNetworkNotification0.setSubnetIdMap(updateNetworkNotification_SubnetIdMap0); + assertFalse(updateNetworkNotification0.isCompleted()); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + updateNetworkNotification0.getException(); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + updateNetworkNotification0.setMessageId(""); + assertEquals("", updateNetworkNotification0.getMessageId()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + updateNetworkNotification0.setRollback((NetworkRollback) null); + assertFalse(updateNetworkNotification0.isCompleted()); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + String string0 = updateNetworkNotification0.getErrorMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + boolean boolean0 = updateNetworkNotification0.isCompleted(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + NetworkRollback networkRollback0 = updateNetworkNotification0.getRollback(); + assertNull(networkRollback0); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + String string0 = updateNetworkNotification0.getMessageId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + UpdateNetworkNotification.SubnetIdMap updateNetworkNotification_SubnetIdMap0 = updateNetworkNotification0.getSubnetIdMap(); + assertNull(updateNetworkNotification_SubnetIdMap0); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + UpdateNetworkNotification updateNetworkNotification0 = new UpdateNetworkNotification(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + updateNetworkNotification0.setException(msoExceptionCategory0); + assertNull(updateNetworkNotification0.getMessageId()); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/UpdateNetworkNotificationESTestscaffolding.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/UpdateNetworkNotificationESTestscaffolding.java new file mode 100644 index 0000000000..8c4e0ed56f --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/UpdateNetworkNotificationESTestscaffolding.java @@ -0,0 +1,83 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:35:17 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class UpdateNetworkNotificationESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.network.async.client.UpdateNetworkNotification"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(UpdateNetworkNotificationESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.network.async.client.MsoRequest", + "org.openecomp.mso.adapters.network.async.client.UpdateNetworkNotification", + "org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory", + "org.openecomp.mso.adapters.network.async.client.NetworkRollback", + "org.openecomp.mso.adapters.network.async.client.UpdateNetworkNotification$SubnetIdMap$Entry", + "org.openecomp.mso.adapters.network.async.client.UpdateNetworkNotification$SubnetIdMap" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/UpdateNetworkNotificationResponseESTest.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/UpdateNetworkNotificationResponseESTest.java new file mode 100644 index 0000000000..a493ce1119 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/UpdateNetworkNotificationResponseESTest.java @@ -0,0 +1,20 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 09:38:03 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.junit.Test; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class UpdateNetworkNotificationResponseESTest extends UpdateNetworkNotificationResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + UpdateNetworkNotificationResponse updateNetworkNotificationResponse0 = new UpdateNetworkNotificationResponse(); + } +} diff --git a/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/UpdateNetworkNotificationResponseESTestscaffolding.java b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/UpdateNetworkNotificationResponseESTestscaffolding.java new file mode 100644 index 0000000000..f897b276a5 --- /dev/null +++ b/adapters/mso-network-adapter-async-client/src/test/java/org/openecomp/mso/adapters/network/async/client/UpdateNetworkNotificationResponseESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 09:38:03 GMT 2016 + */ + +package org.openecomp.mso.adapters.network.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class UpdateNetworkNotificationResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.network.async.client.UpdateNetworkNotificationResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(UpdateNetworkNotificationResponseESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.network.async.client.UpdateNetworkNotificationResponse" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-network-adapter/README b/adapters/mso-network-adapter/README new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/adapters/mso-network-adapter/README diff --git a/adapters/mso-network-adapter/WebContent/META-INF/MANIFEST.MF b/adapters/mso-network-adapter/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..5e9495128c --- /dev/null +++ b/adapters/mso-network-adapter/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0
+Class-Path:
+
diff --git a/adapters/mso-network-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector b/adapters/mso-network-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector new file mode 100644 index 0000000000..1281d32948 --- /dev/null +++ b/adapters/mso-network-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector @@ -0,0 +1 @@ +com.woorea.openstack.connector.HttpClientConnector
\ No newline at end of file diff --git a/adapters/mso-network-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml b/adapters/mso-network-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 0000000000..58ddb4a08f --- /dev/null +++ b/adapters/mso-network-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml @@ -0,0 +1,16 @@ +<jboss-deployment-structure>
+ <deployment>
+ <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
+ <exclusions>
+ <module name="org.apache.log4j" />
+ <module name="org.slf4j" />
+ <module name="org.slf4j.impl" />
+ </exclusions>
+ <dependencies>
+ <module name="org.jboss.jandex" slot="main" />
+ <module name="org.javassist" slot="main" />
+ <module name="org.antlr" slot="main" />
+ <module name="org.dom4j" slot="main" />
+ </dependencies>
+ </deployment>
+</jboss-deployment-structure>
\ No newline at end of file diff --git a/adapters/mso-network-adapter/WebContent/WEB-INF/jboss-web.xml b/adapters/mso-network-adapter/WebContent/WEB-INF/jboss-web.xml new file mode 100644 index 0000000000..251a78b850 --- /dev/null +++ b/adapters/mso-network-adapter/WebContent/WEB-INF/jboss-web.xml @@ -0,0 +1,3 @@ +<jboss-web>
+ <context-root>networks</context-root>
+</jboss-web>
\ No newline at end of file diff --git a/adapters/mso-network-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-network-adapter/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000000..a0c726a6f4 --- /dev/null +++ b/adapters/mso-network-adapter/WebContent/WEB-INF/web.xml @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> + <display-name>mso-network-adapter</display-name> + + <context-param> + <param-name>resteasy.jndi.resources</param-name> + <param-value>java:module/MsoPropertiesFactory,java:module/CloudConfigFactory</param-value> + </context-param> + + <context-param> + <param-name>log.configuration</param-name> + <param-value>logback.network.xml</param-value> + </context-param> + <context-param> + <param-name>mso.configuration</param-name> + <param-value>MSO_PROP_NETWORK_ADAPTER=mso.network.properties,MSO_PROP_TOPOLOGY=topology.properties</param-value> + </context-param> + <context-param> + <param-name>mso.cloud_config.configuration</param-name> + <param-value>cloud_config.json=2</param-value> + </context-param> + <context-param> + <param-name>resteasy.resources</param-name> + <param-value> + org.openecomp.mso.MsoStatusHandler, + org.openecomp.mso.logger.MsoLoggingServlet, + org.openecomp.mso.adapters.network.HealthCheckHandler, + org.openecomp.mso.adapters.network.NetworkAdapterRest + </param-value> + </context-param> + <context-param> + <param-name>resteasy.servlet.mapping.prefix</param-name> + <param-value>/rest</param-value> + </context-param> + <servlet> + <servlet-name>Resteasy</servlet-name> + <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>Resteasy</servlet-name> + <url-pattern>/rest/*</url-pattern> + </servlet-mapping> + <security-constraint> + <web-resource-collection> + <web-resource-name>SoapRequests</web-resource-name> + <description>Soap Ingress Requests</description> + <url-pattern>/NetworkAdapter</url-pattern> + <url-pattern>/NetworkAdapterAsync</url-pattern> + <http-method>POST</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>BPEL-Client</role-name> + </auth-constraint> + </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>SiteStatus</web-resource-name> + <description>SiteStatus APIs</description> + <url-pattern>/rest/setStatus/*</url-pattern> + <http-method>POST</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>SiteControl-Client</role-name> + </auth-constraint> + </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>RestRequests</web-resource-name> + <description>Rest Ingress Requests</description> + <url-pattern>/rest/v1/networks/*</url-pattern> + <http-method>DELETE</http-method> + <http-method>GET</http-method> + <http-method>POST</http-method> + <http-method>PUT</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>BPEL-Client</role-name> + </auth-constraint> + </security-constraint> + <login-config> + <auth-method>BASIC</auth-method> + <realm-name>ApplicationRealm</realm-name> + </login-config> + <security-role> + <role-name>BPEL-Client</role-name> + </security-role> + <security-role> + <role-name>SiteControl-Client</role-name> + </security-role> + <filter> + <filter-name>LogFilter</filter-name> + <filter-class>org.openecomp.mso.logger.LogFilter</filter-class> + </filter> + <filter-mapping> + <filter-name>LogFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + <welcome-file-list> + <welcome-file>check.html</welcome-file> + </welcome-file-list> +</web-app> + diff --git a/adapters/mso-network-adapter/WebContent/check.html b/adapters/mso-network-adapter/WebContent/check.html new file mode 100644 index 0000000000..00f37d60d1 --- /dev/null +++ b/adapters/mso-network-adapter/WebContent/check.html @@ -0,0 +1,10 @@ +<!DOCTYPE html>
+<html>
+<head>
+<meta charset="ISO-8859-1">
+<title>Health Check</title>
+</head>
+<body>
+Application ready
+</body>
+</html>
\ No newline at end of file diff --git a/adapters/mso-network-adapter/pom.xml b/adapters/mso-network-adapter/pom.xml new file mode 100644 index 0000000000..3991bf3118 --- /dev/null +++ b/adapters/mso-network-adapter/pom.xml @@ -0,0 +1,154 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp.mso</groupId> + <artifactId>adapters</artifactId> + <version>0.0.4-SNAPSHOT</version> + </parent> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-network-adapter</artifactId> + <packaging>war</packaging> + <name>mso-network-adapter</name> + <description>Web service endpoint for Network operations</description> + + <!-- <properties> --> + <!-- <project.build.sourceEncoding/> --> + <!-- <project.reporting.outputEncoding/> --> + <!-- </properties> --> + + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>2.4</version> + <configuration> + <warSourceDirectory>WebContent</warSourceDirectory> + <failOnMissingWebXml>false</failOnMissingWebXml> + <attachClasses>true</attachClasses> + </configuration> + </plugin> + <plugin> + <groupId>org.jvnet.jax-ws-commons</groupId> + <artifactId>jaxws-maven-plugin</artifactId> + <version>2.3</version> + <executions> + <execution> + <goals> + <goal>wsgen</goal> + </goals> + </execution> + </executions> + <configuration> + <verbose>true</verbose> + <sei>org.openecomp.mso.adapters.network.MsoNetworkAdapterImpl</sei> + <genWsdl>true</genWsdl> + <inlineSchemas>true</inlineSchemas> + </configuration> + <dependencies> + <dependency> + <groupId>com.sun.xml.ws</groupId> + <artifactId>jaxws-tools</artifactId> + <version>2.2.7</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <!--This plugin's configuration is used to store Eclipse m2e settings + only. It has no influence on the Maven build itself. --> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId> + org.jvnet.jax-ws-commons + </groupId> + <artifactId> + jaxws-maven-plugin + </artifactId> + <versionRange> + [2.3,) + </versionRange> + <goals> + <goal>wsgen</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore></ignore> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + + <dependencies> + <dependency> + <groupId>javax</groupId> + <artifactId>javaee-web-api</artifactId> + <version>6.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-network-adapter-async-client</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapters-rest-interface</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <version>1.10.19</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jboss.spec.javax.ejb</groupId> + <artifactId>jboss-ejb-api_3.2_spec</artifactId> + <version>1.0.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.ejb3</groupId> + <artifactId>jboss-ejb3-ext-api</artifactId> + <version>2.2.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>status-control</artifactId> + <version>${project.version}</version> + </dependency> + + </dependencies> +</project> diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java new file mode 100644 index 0000000000..dcd12d24e7 --- /dev/null +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java @@ -0,0 +1,304 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.network; + + +import java.io.IOException; +import java.util.Set; +import java.util.TreeSet; + +import javax.xml.bind.DatatypeConverter; + +import org.apache.http.HttpEntity; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; + +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +/** + * This is the class that is used to POST replies from the MSO adapters to the BPEL engine. + * It can be configured via property file, or modified using the member methods. + * The properties to use are: + * org.openecomp.mso.adapters.vnf.bpelauth encrypted authorization string to send to BEPL engine + * org.openecomp.mso.adapters.vnf.sockettimeout socket timeout value + * org.openecomp.mso.adapters.vnf.connecttimeout connect timeout value + * org.openecomp.mso.adapters.vnf.retrycount number of times to retry failed connections + * org.openecomp.mso.adapters.vnf.retryinterval interval (in seconds) between retries + * org.openecomp.mso.adapters.vnf.retrylist list of response codes that will trigger a retry (the special code + * 900 means "connection was not established") + */ +public class BpelRestClient { + public static final String MSO_PROP_NETWORK_ADAPTER = "MSO_PROP_NETWORK_ADAPTER"; + private static final String PROPERTY_DOMAIN = "org.openecomp.mso.adapters.network"; + private static final String BPEL_AUTH_PROPERTY = PROPERTY_DOMAIN+".bpelauth"; + private static final String SOCKET_TIMEOUT_PROPERTY = PROPERTY_DOMAIN+".sockettimeout"; + private static final String CONN_TIMEOUT_PROPERTY = PROPERTY_DOMAIN+".connecttimeout"; + private static final String RETRY_COUNT_PROPERTY = PROPERTY_DOMAIN+".retrycount"; + private static final String RETRY_INTERVAL_PROPERTY = PROPERTY_DOMAIN+".retryinterval"; + private static final String RETRY_LIST_PROPERTY = PROPERTY_DOMAIN+".retrylist"; + private static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + + /** Default socket timeout (in seconds) */ + public static final int DEFAULT_SOCKET_TIMEOUT = 5; + /** Default connect timeout (in seconds) */ + public static final int DEFAULT_CONNECT_TIMEOUT = 5; + /** By default, retry up to five times */ + public static final int DEFAULT_RETRY_COUNT = 5; + /** Default interval to wait between retries (in seconds), negative means use backoff algorithm */ + public static final int DEFAULT_RETRY_INTERVAL = -15; + /** Default list of response codes to trigger a retry */ + public static final String DEFAULT_RETRY_LIST = "408,429,500,502,503,504,900"; // 900 is "connection failed" + /** Default credentials */ + public static final String DEFAULT_CREDENTIALS = ""; + + // Properties of the BPEL client -- all are configurable + private int socketTimeout; + private int connectTimeout; + private int retryCount; + private int retryInterval; + private Set<Integer> retryList; + private String credentials; + + // last response from BPEL engine + private int lastResponseCode; + private String lastResponse; + + /** + * Create a client to send results to the BPEL engine, using configuration from the + * MSO_PROP_NETWORK_ADAPTER properties. + */ + public BpelRestClient() { + socketTimeout = DEFAULT_SOCKET_TIMEOUT; + connectTimeout = DEFAULT_CONNECT_TIMEOUT; + retryCount = DEFAULT_RETRY_COUNT; + retryInterval = DEFAULT_RETRY_INTERVAL; + setRetryList(DEFAULT_RETRY_LIST); + credentials = DEFAULT_CREDENTIALS; + lastResponseCode = 0; + lastResponse = ""; + + try { + MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + MsoJavaProperties jp = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_NETWORK_ADAPTER); + socketTimeout = jp.getIntProperty(SOCKET_TIMEOUT_PROPERTY, DEFAULT_SOCKET_TIMEOUT); + connectTimeout = jp.getIntProperty(CONN_TIMEOUT_PROPERTY, DEFAULT_CONNECT_TIMEOUT); + retryCount = jp.getIntProperty(RETRY_COUNT_PROPERTY, DEFAULT_RETRY_COUNT); + retryInterval = jp.getIntProperty(RETRY_INTERVAL_PROPERTY, DEFAULT_RETRY_INTERVAL); + setRetryList(jp.getProperty(RETRY_LIST_PROPERTY, DEFAULT_RETRY_LIST)); + credentials = jp.getEncryptedProperty(BPEL_AUTH_PROPERTY, DEFAULT_CREDENTIALS, ENCRYPTION_KEY); + } catch (MsoPropertiesException e) { + String error = "Unable to get properties:" + MSO_PROP_NETWORK_ADAPTER; + LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "", "", MsoLogger.ErrorCode.DataError, "Unable to get properties", e); + } + } + + public int getSocketTimeout() { + return socketTimeout; + } + + public void setSocketTimeout(int socketTimeout) { + this.socketTimeout = socketTimeout; + } + + public int getConnectTimeout() { + return connectTimeout; + } + + public void setConnectTimeout(int connectTimeout) { + this.connectTimeout = connectTimeout; + } + + public int getRetryCount() { + return retryCount; + } + + public void setRetryCount(int retryCount) { + if (retryCount < 0) + retryCount = DEFAULT_RETRY_COUNT; + this.retryCount = retryCount; + } + + public int getRetryInterval() { + return retryInterval; + } + + public void setRetryInterval(int retryInterval) { + this.retryInterval = retryInterval; + } + + public String getCredentials() { + return credentials; + } + + public void setCredentials(String credentials) { + this.credentials = credentials; + } + + public String getRetryList() { + if (retryList.size() == 0) + return ""; + String t = retryList.toString(); + return t.substring(1, t.length()-1); + } + + public void setRetryList(String retryList) { + Set<Integer> s = new TreeSet<Integer>(); + for (String t : retryList.split("[, ]")) { + try { + s.add(Integer.parseInt(t)); + } catch (NumberFormatException x) { + // ignore + } + } + this.retryList = s; + } + + public int getLastResponseCode() { + return lastResponseCode; + } + + public String getLastResponse() { + return lastResponse; + } + + /** + * Post a response to the URL of the BPEL engine. As long as the response code is one of those in + * the retryList, the post will be retried up to "retrycount" times with an interval (in seconds) + * of "retryInterval". If retryInterval is negative, then each successive retry interval will be + * double the previous one. + * @param toBpelStr the content (XML or JSON) to post + * @param bpelUrl the URL to post to + * @param isxml true if the content is XML, otherwise assumed to be JSON + * @return true if the post succeeded, false if all retries failed + */ + public boolean bpelPost(final String toBpelStr, final String bpelUrl, final boolean isxml) { + debug("Sending response to BPEL: " + toBpelStr); + int totalretries = 0; + int retryint = retryInterval; + while (true) { + sendOne(toBpelStr, bpelUrl, isxml); + // Note: really should handle response code 415 by switching between content types if needed + if (!retryList.contains(lastResponseCode)) { + debug("Got response code: " + lastResponseCode + ": returning."); + return true; + } + if (totalretries >= retryCount) { + debug("Retried " + totalretries + " times, giving up."); + LOGGER.error(MessageEnum.RA_SEND_VNF_NOTIF_ERR, "Could not deliver response to BPEL after "+totalretries+" tries: "+toBpelStr, "Camunda", "", MsoLogger.ErrorCode.DataError, "Could not deliver response to BPEL"); + return false; + } + totalretries++; + int sleepinterval = retryint; + if (retryint < 0) { + // if retry interval is negative double the retry on each pass + sleepinterval = -retryint; + retryint *= 2; + } + debug("Sleeping for " + sleepinterval + " seconds."); + try { + Thread.sleep(sleepinterval * 1000L); + } catch (InterruptedException e) { + // ignore + } + } + } + private void debug(String m) { + LOGGER.debug(m); +// System.err.println(m); + } + private void sendOne(final String toBpelStr, final String bpelUrl, final boolean isxml) { + LOGGER.debug("Sending to BPEL server: "+bpelUrl); + LOGGER.debug("Content is: "+toBpelStr); + + //POST + HttpPost post = new HttpPost(bpelUrl); + if (credentials != null && !credentials.isEmpty()) + post.addHeader("Authorization", "Basic " + DatatypeConverter.printBase64Binary(credentials.getBytes())); + + //ContentType + ContentType ctype = isxml ? ContentType.APPLICATION_XML : ContentType.APPLICATION_JSON; + post.setEntity(new StringEntity(toBpelStr, ctype)); + + //Timeouts + RequestConfig requestConfig = RequestConfig + .custom() + .setSocketTimeout(socketTimeout * 1000) + .setConnectTimeout(connectTimeout * 1000) + .build(); + post.setConfig(requestConfig); + + //Client 4.3+ + //Execute & GetResponse + try (CloseableHttpClient client = HttpClients.createDefault(); + CloseableHttpResponse response = client.execute(post)) { + if (response != null) { + lastResponseCode = response.getStatusLine().getStatusCode(); + HttpEntity entity = response.getEntity(); + lastResponse = (entity != null) ? EntityUtils.toString(entity) : ""; + } else { + lastResponseCode = 900; + lastResponse = ""; + } + } catch (Exception e) { + String error = "Error sending Bpel notification:" + toBpelStr; + LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, error, "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "Exception sending Bpel notification", e); + lastResponseCode = 900; + lastResponse = ""; + } + LOGGER.debug("Response code from BPEL server: "+lastResponseCode); + LOGGER.debug("Response body is: "+lastResponse); + } + + public static void main(String[] a) throws MsoPropertiesException { + final String bpelengine = "http://mtmac1.research.att.com:8080/catch.jsp"; + final String propfile = "/tmp/mso.vnf.properties"; + // "/Users/eby/src/mso.rest/mso/packages/mso-config-centralized/mso-po-adapter-config/mso.vnf.properties" + final String xml = + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + + "<updateVolumeGroupResponse><volumeGroupId>1464013300723</volumeGroupId><volumeGroupOutputs>" + + "<entry><key>clyde</key><value>10</value></entry>" + + "<entry><key>wayne</key><value>99</value></entry>" + + "<entry><key>mickey</key><value>7</value></entry>" + + "</volumeGroupOutputs></updateVolumeGroupResponse>"; + + MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + msoPropertiesFactory.initializeMsoProperties (MSO_PROP_NETWORK_ADAPTER, propfile); + + BpelRestClient bc = new BpelRestClient(); + System.out.println(bc.getRetryList()); + System.out.println(bc.getCredentials()); // poAvos:Domain2.0! + + bc.bpelPost(xml, bpelengine, true); + System.out.println("respcode = "+bc.getLastResponseCode()); + System.out.println("resp = "+bc.getLastResponse()); + } +} diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRef.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRef.java new file mode 100644 index 0000000000..6e2644db73 --- /dev/null +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRef.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.network; + + +import org.codehaus.jackson.JsonNode; +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; + +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.exceptions.MsoAdapterException; + +public class ContrailPolicyRef { + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + + @JsonProperty("network_policy_refs_data_sequence") + private ContrailPolicyRefSeq seq; + + public JsonNode toJsonNode() + { + JsonNode node = null; + try + { + ObjectMapper mapper = new ObjectMapper(); + node = mapper.convertValue(this, JsonNode.class); + } + catch (Exception e) + { + LOGGER.error (MessageEnum.RA_MARSHING_ERROR, "Error creating JsonString for Contrail Policy Ref", "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonString for Contrail Policy Ref", e); + } + + return node; + } + + public String toJsonString() + { + String jsonString = null; + try + { + ObjectMapper mapper = new ObjectMapper(); + jsonString = mapper.writeValueAsString(this); + } + catch (Exception e) + { + LOGGER.error (MessageEnum.RA_MARSHING_ERROR, "Error creating JsonString for Contrail Policy Ref", "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonString for Contrail Policy Ref", e); + } + + return jsonString; + } + + public void populate(String major, String minor) + { + seq = new ContrailPolicyRefSeq(major, minor); + return; + } + +} diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeq.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeq.java new file mode 100644 index 0000000000..b5d750288f --- /dev/null +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeq.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.network; + + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ContrailPolicyRefSeq { + + @JsonProperty("network_policy_refs_data_sequence_major") + private String major; + + @JsonProperty("network_policy_refs_data_sequence_minor") + private String minor; + + public ContrailPolicyRefSeq() { + } + + public ContrailPolicyRefSeq(String major, String minor) { + super(); + this.major = major; + this.minor = minor; + } + + public String getMajor() { + return major; + } + + public void setMajor(String major) { + this.major = major; + } + + public String getMinor() { + return minor; + } + + public void setMinor(String minor) { + this.minor = minor; + } + + @Override + public String toString() { + return "ContrailPolicyRefSeq [major=" + major + ", minor=" + minor + + "]"; + } + +} diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java new file mode 100644 index 0000000000..3df1014a90 --- /dev/null +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java @@ -0,0 +1,196 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.network; + +import java.util.ArrayList; +import java.util.List; + +import org.codehaus.jackson.JsonNode; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.ObjectMapper; + +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.beans.Pool; +import org.openecomp.mso.openstack.beans.Subnet; +import static org.openecomp.mso.openstack.utils.MsoCommonUtils.isNullOrEmpty; + +public class ContrailSubnet { + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + + @JsonProperty("network_ipam_refs_data_ipam_subnets_subnet") + private ContrailSubnetIp subnet = new ContrailSubnetIp(); + + @JsonProperty("network_ipam_refs_data_ipam_subnets_default_gateway") + private String default_gateway; + + @JsonProperty("network_ipam_refs_data_ipam_subnets_subnet_name") + private String subnet_name; + + @JsonProperty("network_ipam_refs_data_ipam_subnets_enable_dhcp") + private Boolean enable_dhcp; + + @JsonProperty("network_ipam_refs_data_ipam_subnets_addr_from_start") + private Boolean addr_from_start = true; + + /** future - leave this commented + private String subnet_uuid; + private String dns_server_address; + private List<String> dns_nameservers; + private String dhcp_option_list; + private String host_routes; + **/ + + @JsonProperty("network_ipam_refs_data_ipam_subnets_allocation_pools") + private List<ContrailSubnetPool> allocation_pools = new ArrayList <ContrailSubnetPool> (); + + public ContrailSubnet() { + super(); + } + + public String getDefault_gateway() { + return default_gateway; + } + + public void setDefault_gateway(String default_gateway) { + this.default_gateway = default_gateway; + } + + public ContrailSubnetIp getSubnet() { + return subnet; + } + + public void setSubnet(ContrailSubnetIp subnet) { + this.subnet = subnet; + } + + public Boolean isEnable_dhcp() { + return enable_dhcp; + } + + public void setEnable_dhcp(Boolean enable_dhcp) { + this.enable_dhcp = enable_dhcp; + } + + public String getSubnet_name() { + return subnet_name; + } + + public void setSubnet_name(String subnet_name) { + this.subnet_name = subnet_name; + } + + public List<ContrailSubnetPool> getAllocation_pools() { + return allocation_pools; + } + + public void setPools(List<ContrailSubnetPool> allocation_pools) { + this.allocation_pools = allocation_pools; + } + + public Boolean isAddr_from_start() { + return addr_from_start; + } + + public void setAddr_from_start(Boolean addr_from_start) { + this.addr_from_start = addr_from_start; + } + + public JsonNode toJsonNode() + { + JsonNode node = null; + try + { + ObjectMapper mapper = new ObjectMapper(); + node = mapper.convertValue(this, JsonNode.class); + } + catch (Exception e) + { + String error = "Error creating JsonNode for Contrail Subnet:" + subnet_name; + LOGGER.error (MessageEnum.RA_MARSHING_ERROR, error, "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonNode for Contrail Subnet", e); + } + + return node; + } + + public String toJsonString() + { + String jsonString = null; + try + { + ObjectMapper mapper = new ObjectMapper(); + jsonString = mapper.writeValueAsString(this); + } + catch (Exception e) + { + String error = "Error creating JsonString for Contrail Subnet:" + subnet_name; + LOGGER.error (MessageEnum.RA_MARSHING_ERROR, error, "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonString for Contrail Subnet", e); + } + + return jsonString; + } + //poulate contrail subnet with input(from bopel) subnet + public void populateWith(Subnet i_subnet) + { + if (i_subnet != null) + { + if (!isNullOrEmpty(i_subnet.getSubnetName())) + subnet_name = i_subnet.getSubnetName(); + else + subnet_name = i_subnet.getSubnetId(); + enable_dhcp = i_subnet.getEnableDHCP(); + default_gateway = i_subnet.getGatewayIp(); + if (!isNullOrEmpty(i_subnet.getCidr()) ) + { + int idx = i_subnet.getCidr().indexOf("/"); + if (idx != -1) + { + subnet.setIp_prefix(i_subnet.getCidr().substring(0, idx)); + subnet.setIp_prefix_len(i_subnet.getCidr().substring(idx+1)); + } + } + if (i_subnet.getAllocationPools() != null) + { + for (Pool pool : i_subnet.getAllocationPools()) + { + if ( !isNullOrEmpty(pool.getStart()) && !isNullOrEmpty(pool.getEnd()) ) + { + ContrailSubnetPool csp = new ContrailSubnetPool(); + csp.populateWith(pool); + allocation_pools.add (csp); + } + } + } + } + } + + @Override + public String toString() { + + StringBuilder buf = new StringBuilder (); + for (ContrailSubnetPool pool : allocation_pools) + { + buf.append(pool.toString()); + } + return "ContrailSubnet [subnet=" + subnet.toString() + " default_gateway=" + default_gateway + + " enable_dhcp=" + enable_dhcp + " addr_from_start=" + addr_from_start + " subnet_name=" + subnet_name + " allocation_pools=" + buf + " ]"; + } +} diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java new file mode 100644 index 0000000000..c0a5311fec --- /dev/null +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.network; + + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ContrailSubnetIp { + + @JsonProperty("network_ipam_refs_data_ipam_subnets_subnet_ip_prefix") + private String ip_prefix; + + @JsonProperty("network_ipam_refs_data_ipam_subnets_subnet_ip_prefix_len") + private String ip_prefix_len; + + public ContrailSubnetIp() { + } + + public String getIp_prefix() { + return ip_prefix; + } + + public void setIp_prefix(String ip_prefix) { + this.ip_prefix = ip_prefix; + } + + public String getIp_prefix_len() { + return ip_prefix_len; + } + + public void setIp_prefix_len(String ip_prefix_len) { + this.ip_prefix_len = ip_prefix_len; + } + + @Override + public String toString() { + return "ContrailSubnetIp [ip_prefix=" + ip_prefix + ", ip_prefix_len=" + ip_prefix_len + "]"; + } + +} diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java new file mode 100644 index 0000000000..5b40ba26a6 --- /dev/null +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.network; + + +import org.openecomp.mso.openstack.beans.Pool; +import org.codehaus.jackson.annotate.JsonProperty; +public class ContrailSubnetPool { + + @JsonProperty("network_ipam_refs_data_ipam_subnets_allocation_pools_start") + private String start; + + @JsonProperty("network_ipam_refs_data_ipam_subnets_allocation_pools_end") + private String end; + + public ContrailSubnetPool() { + } + + public String getStart() { + return start; + } + + public void setStart(String start) { + this.start = start; + } + + public String getEnd() { + return end; + } + + public void setEnd(String end) { + this.end = end; + } + + public void populateWith(Pool pool) + { + if (pool != null) + { + start = pool.getStart(); + end = pool.getEnd(); + } + } + + @Override + public String toString() { + return "ContrailSubnetPool [start=" + start + ", end=" + end + "]"; + } + +} diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/HealthCheckHandler.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/HealthCheckHandler.java new file mode 100644 index 0000000000..2767baffac --- /dev/null +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/HealthCheckHandler.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.network; + + +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.HealthCheckUtils; +import org.openecomp.mso.utils.UUIDChecker; + + +@Path("/") + public class HealthCheckHandler { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static final String MSO_PROP_NETWORK_ADAPTER = "MSO_PROP_NETWORK_ADAPTER"; + + @HEAD + @GET + @Path("/healthcheck") + @Produces("text/html") + public Response healthcheck (@QueryParam("requestId") String requestId) { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("Healthcheck"); + UUIDChecker.verifyOldUUID(requestId, msoLogger); + HealthCheckUtils healthCheck = new HealthCheckUtils (); + if (!healthCheck.siteStatusCheck(msoLogger, startTime)) { + return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; + } + + if (!healthCheck.configFileCheck(msoLogger, startTime, MSO_PROP_NETWORK_ADAPTER)) { + return HealthCheckUtils.NOT_STARTED_RESPONSE; + } + + if (!healthCheck.catalogDBCheck (msoLogger, startTime)) { + return HealthCheckUtils.NOT_STARTED_RESPONSE; + } + msoLogger.debug("healthcheck - Successful"); + return HealthCheckUtils.HEALTH_CHECK_RESPONSE; + } + + +} diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java new file mode 100644 index 0000000000..4960877b8a --- /dev/null +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java @@ -0,0 +1,216 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.network; + + +import java.util.List; +import java.util.Map; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebParam.Mode; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.ws.Holder; + +import org.openecomp.mso.adapters.network.exceptions.NetworkException; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.NetworkRollback; +import org.openecomp.mso.openstack.beans.NetworkStatus; +import org.openecomp.mso.openstack.beans.Subnet; + +@WebService (name="NetworkAdapter", targetNamespace="http://com.att.mso/network") +public interface MsoNetworkAdapter +{ + // TODO: Rename all of these to include Vlan in the service name? At least for the + // create and update calls, since they are specific to VLAN-based provider networks. + + /** + * This is the "Create Network" Web Service Endpoint definition. + */ + @WebMethod + public void createNetwork (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="networkName") @XmlElement(required=true) String networkName, + @WebParam(name="physicalNetworkName") String physicalNetworkName, + @WebParam(name="vlans") List<Integer> vlans, + @WebParam(name="failIfExists") Boolean failIfExists, + @WebParam(name="backout") Boolean backout, + @WebParam(name="subnets") List<Subnet> subnets, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="networkId", mode=Mode.OUT) Holder<String> networkId, + @WebParam(name="neutronNetworkId", mode=Mode.OUT) Holder<String> neutronNetworkId, + @WebParam(name="subnetIdMap", mode=Mode.OUT) Holder<Map<String, String>> subnetIdMap, + @WebParam(name="rollback", mode=Mode.OUT) Holder<NetworkRollback> rollback ) + throws NetworkException; + + @WebMethod + public void createNetworkContrail (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="networkName") @XmlElement(required=true) String networkName, + @WebParam(name="routeTargets") List<String> routeTargets, + @WebParam(name="shared") String shared, + @WebParam(name="external") String external, + @WebParam(name="failIfExists") Boolean failIfExists, + @WebParam(name="backout") Boolean backout, + @WebParam(name="subnets") List<Subnet> subnets, + @WebParam(name="policyFqdns") List<String> policyFqdns, + @WebParam(name="routeTableFqdns") List<String> routeTableFqdns, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="networkId", mode=Mode.OUT) Holder<String> networkId, + @WebParam(name="neutronNetworkId", mode=Mode.OUT) Holder<String> neutronNetworkId, + @WebParam(name="networkFqdn", mode=Mode.OUT) Holder<String> networkFqdn, + @WebParam(name="subnetIdMap", mode=Mode.OUT) Holder<Map<String, String>> subnetIdMap, + @WebParam(name="rollback", mode=Mode.OUT) Holder<NetworkRollback> rollback ) + throws NetworkException; + + /** + * This is the "Update VLANs" Web Service Endpoint definition. + * This webservice replaces the set of VLANs on a network. + */ + @WebMethod + public void updateNetwork (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="networkId") @XmlElement(required=true) String networkId, + @WebParam(name="networkName") @XmlElement(required=true) String networkName, + @WebParam(name="physicalNetworkName") @XmlElement(required=true) String physicalNetworkName, + @WebParam(name="vlans") @XmlElement(required=true) List<Integer> vlans, + @WebParam(name="subnets") List<Subnet> subnets, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="subnetIdMap", mode=Mode.OUT) Holder<Map<String, String>> subnetIdMap, + @WebParam(name="rollback", mode=Mode.OUT) Holder<NetworkRollback> rollback ) + throws NetworkException; + + @WebMethod + public void updateNetworkContrail (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="networkId") @XmlElement(required=true) String networkId, + @WebParam(name="networkName") @XmlElement(required=true) String networkName, + @WebParam(name="routeTargets") List<String> routeTargets, + @WebParam(name="shared") String shared, + @WebParam(name="external") String external, + @WebParam(name="subnets") List<Subnet> subnets, + @WebParam(name="policyFqdns") List<String> policyFqdns, + @WebParam(name="routeTableFqdns") List<String> routeTableFqdns, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="subnetIdMap", mode=Mode.OUT) Holder<Map<String, String>> subnetIdMap, + @WebParam(name="rollback", mode=Mode.OUT) Holder<NetworkRollback> rollback ) + throws NetworkException; + + /** + * TODO: + * This is the "Add VLAN" Web Service Endpoint definition. + * This webservice adds a VLAN to a network. + * This service assumes that PO supports querying the current vlans in real time. + * Otherwise, the caller must have the complete list and should use updateVlans instead. + @WebMethod + public void addVlan (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="networkId") @XmlElement(required=true) String networkId, + @WebParam(name="physicalNetworkName") @XmlElement(required=true) String physicalNetworkName, + @WebParam(name="vlan") @XmlElement(required=true) Integer vlan, + @WebParam(name="rollback", mode=Mode.OUT) Holder<NetworkRollback> rollback ) + throws NetworkException; + */ + + /** + * TODO: + * This is the "Remove VLAN" Web Service Endpoint definition. + * This webservice removes a VLAN from a network. + * This service assumes that PO supports querying the current vlans in real time. + * Otherwise, the caller must have the complete list and should use updateVlans instead. + * + * This service returns an indicator (noMoreVLans) if the VLAN that was removed was + * the last one on the network. + * + * It is not clear that Rollback will work for delete. The network can be + * recreated from the NetworkRollback object, but the network ID (and stack ID + * for Heat-based orchestration) will be different. The caller will need to know + * to update these identifiers in the inventory DB (A&AI). + @WebMethod + public void removeVlan (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="networkId") @XmlElement(required=true) String networkId, + @WebParam(name="physicalNetworkName") @XmlElement(required=true) String physicalNetworkName, + @WebParam(name="vlan") @XmlElement(required=true) Integer vlan, + @WebParam(name="noMoreVlans", mode=Mode.OUT) Holder<Boolean> noMoreVlans, + @WebParam(name="rollback", mode=Mode.OUT) Holder<NetworkRollback> rollback ) + throws NetworkException; + */ + + /** + * This is the "Query Network" Web Service Endpoint definition. + * TODO: Should this just return the NetworkInfo complete structure? + */ + @WebMethod + public void queryNetwork (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="networkNameOrId") @XmlElement(required=true) String networkNameOrId, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="networkExists", mode=Mode.OUT) Holder<Boolean> networkExists, + @WebParam(name="networkId", mode=Mode.OUT) Holder<String> networkId, + @WebParam(name="neutronNetworkId", mode=Mode.OUT) Holder<String> neutronNetworkId, + @WebParam(name="status", mode=Mode.OUT) Holder<NetworkStatus> status, + @WebParam(name="vlans", mode=Mode.OUT) Holder<List<Integer>> vlans, + @WebParam(name="subnetIdMap", mode=Mode.OUT) Holder<Map<String, String>> subnetIdMap) + throws NetworkException; + + @WebMethod + public void queryNetworkContrail (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="networkNameOrId") @XmlElement(required=true) String networkNameOrId, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="networkExists", mode=Mode.OUT) Holder<Boolean> networkExists, + @WebParam(name="networkId", mode=Mode.OUT) Holder<String> networkId, + @WebParam(name="neutronNetworkId", mode=Mode.OUT) Holder<String> neutronNetworkId, + @WebParam(name="status", mode=Mode.OUT) Holder<NetworkStatus> status, + @WebParam(name="routeTargets", mode=Mode.OUT) Holder<List<String>> routeTargets, + @WebParam(name="subnetIdMap", mode=Mode.OUT) Holder<Map<String, String>> subnetIdMap) + throws NetworkException; + + /** + * This is the "Delete Network" Web Service endpoint definition. + */ + @WebMethod + public void deleteNetwork (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="networkId") @XmlElement(required=true) String networkId, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="networkDeleted", mode=Mode.OUT) Holder<Boolean> networkDeleted) + throws NetworkException; + + /** + * This is the "Rollback Network" Web Service endpoint definition. + */ + @WebMethod + public void rollbackNetwork (@WebParam(name="rollback") @XmlElement(required=true) NetworkRollback rollback) + throws NetworkException; + + @WebMethod + public void healthCheck (); +} diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsync.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsync.java new file mode 100644 index 0000000000..e79ba125e2 --- /dev/null +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsync.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.network; + + +import javax.jws.Oneway; +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlElement; + +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.Subnet; +import org.openecomp.mso.openstack.beans.NetworkRollback; + +import java.util.List; +/** + * This webservice defines the Asynchronous versions of NETWORK adapter calls. + * The notification messages for final responses are documented elsewhere + * (by the client service WSDL). + * + */ +@WebService (name="NetworkAdapterAsync", targetNamespace="http://com.att.mso/networkA") +public interface MsoNetworkAdapterAsync +{ + /** + * This is the "Create NETWORK" Web Service Endpoint definition. + */ + @WebMethod + @Oneway + public void createNetworkA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="networkName") @XmlElement(required=true) String networkName, + @WebParam(name="physicalNetworkName") String physicalNetworkName, + @WebParam(name="vlans") List<Integer> vlans, + @WebParam(name="failIfExists") Boolean failIfExists, + @WebParam(name="backout") Boolean backout, + @WebParam(name="subnets") List<Subnet> subnets, + @WebParam(name="messageId") @XmlElement(required=true) String messageId, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl ); + + @WebMethod + @Oneway + public void updateNetworkA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="networkId") @XmlElement(required=true) String networkId, + @WebParam(name="networkName") @XmlElement(required=true) String networkName, + @WebParam(name="physicalNetworkName") @XmlElement(required=true) String physicalNetworkName, + @WebParam(name="vlans") @XmlElement(required=true) List<Integer> vlans, + @WebParam(name="subnets") List<Subnet> subnets, + @WebParam(name="messageId") @XmlElement(required=true) String messageId, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl ); + + @WebMethod + @Oneway + public void queryNetworkA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="networkNameOrId") @XmlElement(required=true) String networkNameOrId, + @WebParam(name="messageId") @XmlElement(required=true) String messageId, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl ); + + @WebMethod + @Oneway + public void deleteNetworkA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="networkId") @XmlElement(required=true) String networkId, + @WebParam(name="messageId") @XmlElement(required=true) String messageId, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl ); + + @WebMethod + @Oneway + public void rollbackNetworkA (@WebParam(name="rollback") @XmlElement(required=true) NetworkRollback rollback, + @WebParam(name="messageId") @XmlElement(required=true) String messageId, + @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl ); + + @WebMethod + public void healthCheckA (); +} diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java new file mode 100644 index 0000000000..75cbc636cc --- /dev/null +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java @@ -0,0 +1,679 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.network; + + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.jws.WebService; +import javax.xml.bind.DatatypeConverter; +import javax.xml.namespace.QName; +import javax.xml.ws.BindingProvider; +import javax.xml.ws.Holder; +import javax.xml.ws.handler.MessageContext; + +import org.openecomp.mso.adapters.network.async.client.CreateNetworkNotification; +import org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory; +import org.openecomp.mso.adapters.network.async.client.NetworkAdapterNotify; +import org.openecomp.mso.adapters.network.async.client.NetworkAdapterNotify_Service; +import org.openecomp.mso.adapters.network.async.client.QueryNetworkNotification; +import org.openecomp.mso.adapters.network.async.client.UpdateNetworkNotification; +import org.openecomp.mso.adapters.network.exceptions.NetworkException; +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.beans.NetworkRollback; +import org.openecomp.mso.openstack.beans.NetworkStatus; +import org.openecomp.mso.openstack.beans.Subnet; +import org.openecomp.mso.properties.MsoPropertiesFactory; + + +@WebService(serviceName = "NetworkAdapterAsync", endpointInterface = "org.openecomp.mso.adapters.network.MsoNetworkAdapterAsync", targetNamespace = "http://com.att.mso/networkA") +public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { + + MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory(); + + CloudConfigFactory cloudConfigFactory=new CloudConfigFactory(); + + public static final String MSO_PROP_NETWORK_ADAPTER="MSO_PROP_NETWORK_ADAPTER"; + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + private static final String BPEL_AUTH_PROP = "org.openecomp.mso.adapters.network.bpelauth"; + private static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; + /** + * Health Check web method. Does nothing but return to show the adapter is deployed. + */ + @Override + public void healthCheckA () { + LOGGER.debug ("Health check call in Network Adapter"); + } + + /** + * This is the "Create Network" web service implementation. + * It will create a new Network of the requested type in the specified cloud + * and tenant. The tenant must exist at the time this service is called. + * + * If a network with the same name already exists, this can be considered a + * success or failure, depending on the value of the 'failIfExists' parameter. + * + * There will be a pre-defined set of network types defined in the MSO Catalog. + * All such networks will have a similar configuration, based on the allowable + * Openstack networking definitions. This includes basic networks, provider + * networks (with a single VLAN), and multi-provider networks (one or more VLANs) + * + * Initially, all provider networks must be "vlan" type, and multiple segments in + * a multi-provider network must be multiple VLANs on the same physical network. + * + * This service supports two modes of Network creation/update: + * - via Heat Templates + * - via Neutron API + * The network orchestration mode for each network type is declared in its + * catalog definition. All Heat-based templates must support some subset of + * the same input parameters: network_name, physical_network, vlan(s). + * + * The method returns the network ID and a NetworkRollback object. This latter + * object can be passed as-is to the rollbackNetwork operation to undo everything + * that was created. This is useful if a network is successfully created but + * the orchestration fails on a subsequent operation. + */ + @Override + public void createNetworkA (String cloudSiteId, + String tenantId, + String networkType, + String networkName, + String physicalNetworkName, + List <Integer> vlans, + Boolean failIfExists, + Boolean backout, + List <Subnet> subnets, + String messageId, + MsoRequest msoRequest, + String notificationUrl) { + String error; + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + MsoLogger.setLogContext (msoRequest); + MsoLogger.setServiceName ("CreateNetworkA"); + LOGGER.debug ("Async Create Network: " + networkName + + " of type " + + networkType + + " in " + + cloudSiteId + + "/" + + tenantId); + + // Use the synchronous method to perform the actual Create + MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory); + + // Synchronous Web Service Outputs + Holder <String> networkId = new Holder <String> (); + Holder <String> neutronNetworkId = new Holder <String> (); + Holder <NetworkRollback> networkRollback = new Holder <NetworkRollback> (); + Holder <Map <String, String>> subnetIdMap = new Holder <Map <String, String>> (); + + try { + networkAdapter.createNetwork (cloudSiteId, + tenantId, + networkType, + networkName, + physicalNetworkName, + vlans, + failIfExists, + backout, + subnets, + msoRequest, + networkId, + neutronNetworkId, + subnetIdMap, + networkRollback); + } catch (NetworkException e) { + LOGGER.debug ("Got a NetworkException on createNetwork: ", e); + MsoExceptionCategory exCat = null; + String eMsg = null; + try { + eMsg = e.getFaultInfo ().getMessage (); + exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ()); + } catch (Exception e1) { + LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1); + } + // Build and send Asynchronous error response + try { + NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.createNetworkNotification (messageId, false, exCat, eMsg, null, null, null, null); + } catch (Exception e1) { + error = "Error sending createNetwork notification " + e1.getMessage (); + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + return; + } + LOGGER.debug ("Async Create Network:Name " + networkName + " physicalNetworkName:" + physicalNetworkName); + // Build and send Asynchronous response + try { + NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.createNetworkNotification (messageId, + true, + null, + null, + networkId.value, + neutronNetworkId.value, + copyCreateSubnetIdMap (subnetIdMap), + copyNrb (networkRollback)); + } catch (Exception e) { + error = "Error sending createNetwork notification " + e.getMessage (); + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + return; + } + + /** + * This is the "Update Network" web service implementation. + * It will update an existing Network of the requested type in the specified cloud + * and tenant. The typical use will be to replace the VLANs with the supplied + * list (to add or remove a VLAN), but other properties may be updated as well. + * + * There will be a pre-defined set of network types defined in the MSO Catalog. + * All such networks will have a similar configuration, based on the allowable + * Openstack networking definitions. This includes basic networks, provider + * networks (with a single VLAN), and multi-provider networks (one or more VLANs). + * + * Initially, all provider networks must currently be "vlan" type, and multi-provider + * networks must be multiple VLANs on the same physical network. + * + * This service supports two modes of Network update: + * - via Heat Templates + * - via Neutron API + * The network orchestration mode for each network type is declared in its + * catalog definition. All Heat-based templates must support some subset of + * the same input parameters: network_name, physical_network, vlan, segments. + * + * The method returns a NetworkRollback object. This object can be passed + * as-is to the rollbackNetwork operation to undo everything that was updated. + * This is useful if a network is successfully updated but orchestration + * fails on a subsequent operation. + */ + @Override + public void updateNetworkA (String cloudSiteId, + String tenantId, + String networkType, + String networkId, + String networkName, + String physicalNetworkName, + List <Integer> vlans, + List <Subnet> subnets, + String messageId, + MsoRequest msoRequest, + String notificationUrl) { + String error; + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + String serviceName = "UpdateNetworkA"; + MsoLogger.setServiceName (serviceName); + MsoLogger.setLogContext (msoRequest); + LOGGER.debug ("Async Update Network: " + networkId + + " of type " + + networkType + + "in " + + cloudSiteId + + "/" + + tenantId); + + // Use the synchronous method to perform the actual Create + MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory); + + // Synchronous Web Service Outputs + Holder <NetworkRollback> networkRollback = new Holder <NetworkRollback> (); + Holder <Map <String, String>> subnetIdMap = new Holder <Map <String, String>> (); + + try { + networkAdapter.updateNetwork (cloudSiteId, + tenantId, + networkType, + networkId, + networkName, + physicalNetworkName, + vlans, + subnets, + msoRequest, + subnetIdMap, + networkRollback); + MsoLogger.setServiceName (serviceName); + } catch (NetworkException e) { + MsoLogger.setServiceName (serviceName); + LOGGER.debug ("Got a NetworkException on updateNetwork: ", e); + MsoExceptionCategory exCat = null; + String eMsg = null; + try { + eMsg = e.getFaultInfo ().getMessage (); + exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ()); + } catch (Exception e1) { + LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1); + } + // Build and send Asynchronous error response + try { + NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.updateNetworkNotification (messageId, false, exCat, eMsg, null, copyNrb (networkRollback)); + } catch (Exception e1) { + error = "Error sending updateNetwork notification " + e1.getMessage (); + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending updateNetwork notification", e1); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + return; + } + LOGGER.debug ("Async Update Network:Name " + networkName + " NetworkId:" + networkId); + // Build and send Asynchronous response + try { + NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.updateNetworkNotification (messageId, + true, + null, + null, + copyUpdateSubnetIdMap (subnetIdMap), + copyNrb (networkRollback)); + } catch (Exception e) { + error = "Error sending updateNotification request" + e.getMessage (); + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending updateNotification request", e); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + return; + } + + /** + * This is the queryNetwork method. It returns the existence and status of + * the specified network, along with its Neutron UUID and list of VLANs. + * This method attempts to find the network using both Heat and Neutron. + * Heat stacks are first searched based on the provided network name/id. + * If none is found, the Neutron is directly queried. + */ + @Override + public void queryNetworkA (String cloudSiteId, + String tenantId, + String networkNameOrId, + String messageId, + MsoRequest msoRequest, + String notificationUrl) { + String error; + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + MsoLogger.setLogContext (msoRequest); + String serviceName = "QueryNetworkA"; + MsoLogger.setServiceName (serviceName); + LOGGER.debug ("Async Query Network " + networkNameOrId + " in " + cloudSiteId + "/" + tenantId); + + // Use the synchronous method to perform the actual Create + MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory); + + // Synchronous Web Service Outputs + Holder <Boolean> networkExists = new Holder <Boolean> (); + Holder <String> networkId = new Holder <String> (); + Holder <String> neutronNetworkId = new Holder <String> (); + Holder <NetworkStatus> status = new Holder <NetworkStatus> (); + Holder <List <Integer>> vlans = new Holder <List <Integer>> (); + Holder <Map <String, String>> subnetIdMap = new Holder <Map <String, String>> (); + + try { + networkAdapter.queryNetwork (cloudSiteId, + tenantId, + networkNameOrId, + msoRequest, + networkExists, + networkId, + neutronNetworkId, + status, + vlans, + subnetIdMap); + MsoLogger.setServiceName (serviceName); + } catch (NetworkException e) { + MsoLogger.setServiceName (serviceName); + LOGGER.debug ("Got a NetworkException on createNetwork: ", e); + MsoExceptionCategory exCat = null; + String eMsg = null; + try { + eMsg = e.getFaultInfo ().getMessage (); + exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ()); + } catch (Exception e1) { + LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1); + } + // Build and send Asynchronous error response + try { + NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.queryNetworkNotification (messageId, false, exCat, eMsg, null, null, null, null, null, null); + } catch (Exception e1) { + error = "Error sending createNetwork notification " + e1.getMessage (); + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + return; + } + LOGGER.debug ("Async Query Network:NameOrId " + networkNameOrId + " tenantId:" + tenantId); + // Build and send Asynchronous response + try { + NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); + org.openecomp.mso.adapters.network.async.client.NetworkStatus networkS = org.openecomp.mso.adapters.network.async.client.NetworkStatus.fromValue (status.value.name ()); + notifyPort.queryNetworkNotification (messageId, + true, + null, + null, + networkExists.value, + networkId.value, + neutronNetworkId.value, + networkS, + vlans.value, + copyQuerySubnetIdMap (subnetIdMap)); + } catch (Exception e) { + error = "Error sending createNetwork notification " + e.getMessage (); + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + return; + } + + /** + * This is the "Delete Network" web service implementation. + * It will delete a Network in the specified cloud and tenant. + * + * If the network is not found, it is treated as a success. + * + * This service supports two modes of Network creation/update/delete: + * - via Heat Templates + * - via Neutron API + * The network orchestration mode for each network type is declared in its + * catalog definition. + * + * For Heat-based orchestration, the networkId should be the stack ID. + * For Neutron-based orchestration, the networkId should be the Neutron network UUID. + * + * The method returns nothing on success. Rollback is not possible for delete + * commands, so any failure on delete will require manual fallout in the client. + */ + @Override + public void deleteNetworkA (String cloudSiteId, + String tenantId, + String networkType, + String networkId, + String messageId, + MsoRequest msoRequest, + String notificationUrl) { + String error; + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + MsoLogger.setLogContext (msoRequest); + String serviceName = "DeleteNetworkA"; + MsoLogger.setServiceName (serviceName); + LOGGER.debug ("Async Delete Network " + networkId + " in " + cloudSiteId + "/" + tenantId); + + // Use the synchronous method to perform the actual Create + MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory); + + // Synchronous Web Service Outputs + Holder <Boolean> networkDeleted = new Holder <Boolean> (); + + try { + networkAdapter.deleteNetwork (cloudSiteId, tenantId, networkType, networkId, msoRequest, networkDeleted); + MsoLogger.setServiceName (serviceName); + } catch (NetworkException e) { + MsoLogger.setServiceName (serviceName); + LOGGER.debug ("Got a NetworkException on createNetwork: ", e); + MsoExceptionCategory exCat = null; + String eMsg = null; + try { + eMsg = e.getFaultInfo ().getMessage (); + exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ()); + } catch (Exception e1) { + LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1); + } + // Build and send Asynchronous error response + try { + NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.deleteNetworkNotification (messageId, false, exCat, eMsg, null); + } catch (Exception e1) { + error = "Error sending createNetwork notification " + e1.getMessage (); + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + return; + } + LOGGER.debug ("Async Delete NetworkId: " + networkId + " tenantId:" + tenantId); + // Build and send Asynchronous response + try { + NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.deleteNetworkNotification (messageId, true, null, null, networkDeleted.value); + } catch (Exception e) { + error = "Error sending deleteNetwork notification " + e.getMessage (); + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending deleteNetwork notification", e); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + return; + } + + /** + * This web service endpoint will rollback a previous Create VNF operation. + * A rollback object is returned to the client in a successful creation + * response. The client can pass that object as-is back to the rollbackNetwork + * operation to undo the creation. + * + * The rollback includes removing the VNF and deleting the tenant if the + * tenant did not exist prior to the VNF creation. + */ + @Override + public void rollbackNetworkA (NetworkRollback rollback, String messageId, String notificationUrl) { + String error; + String serviceName = "RollbackNetworkA"; + MsoLogger.setServiceName (serviceName); + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + // rollback may be null (e.g. if network already existed when Create was called) + if (rollback == null) { + LOGGER.warn (MessageEnum.RA_ROLLBACK_NULL, "", "", MsoLogger.ErrorCode.SchemaError, "Rollback is null"); + return; + } + + MsoLogger.setLogContext (rollback.getMsoRequest ()); + LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK, rollback.getNetworkStackId (), "", ""); + // Use the synchronous method to perform the actual Create + MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory); + + try { + networkAdapter.rollbackNetwork (rollback); + MsoLogger.setServiceName (serviceName); + } catch (NetworkException e) { + MsoLogger.setServiceName (serviceName); + LOGGER.debug ("Got a NetworkException on rollbackNetwork: ", e); + // Build and send Asynchronous error response + MsoExceptionCategory exCat = null; + String eMsg = null; + try { + eMsg = e.getFaultInfo ().getMessage (); + exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ()); + } catch (Exception e1) { + LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in get fault info", e1); + } + // Build and send Asynchronous error response + try { + NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.rollbackNetworkNotification (rollback.getMsoRequest ().getRequestId (), false, exCat, eMsg); + } catch (Exception e1) { + error = "Error sending createNetwork notification " + e1.getMessage (); + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in sending createNetwork notification ", e1); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + return; + } + LOGGER.debug ("Async Rollback NetworkId: " + rollback.getNetworkStackId () + " tenantId:" + rollback.getTenantId ()); + // Build and send Asynchronous response + try { + NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.rollbackNetworkNotification (rollback.getMsoRequest ().getRequestId (), true, null, null); + } catch (Exception e) { + error = "Error sending rollbackNetwork notification " + e.getMessage (); + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in sending rollbackNetwork notification", e); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + return; + } + + private org.openecomp.mso.adapters.network.async.client.NetworkRollback copyNrb (Holder <NetworkRollback> hNrb) { + org.openecomp.mso.adapters.network.async.client.NetworkRollback cnrb = new org.openecomp.mso.adapters.network.async.client.NetworkRollback (); + + if (hNrb != null && hNrb.value != null) { + org.openecomp.mso.adapters.network.async.client.MsoRequest cmr = new org.openecomp.mso.adapters.network.async.client.MsoRequest (); + + cnrb.setCloudId (hNrb.value.getCloudId ()); + cmr.setRequestId (hNrb.value.getMsoRequest ().getRequestId ()); + cmr.setServiceInstanceId (hNrb.value.getMsoRequest ().getServiceInstanceId ()); + cnrb.setMsoRequest (cmr); + cnrb.setNetworkId (hNrb.value.getNetworkId ()); + cnrb.setNetworkStackId (hNrb.value.getNetworkStackId ()); + cnrb.setNeutronNetworkId (hNrb.value.getNeutronNetworkId ()); + cnrb.setTenantId (hNrb.value.getTenantId ()); + cnrb.setNetworkType (hNrb.value.getNetworkType ()); + cnrb.setNetworkCreated (hNrb.value.getNetworkCreated ()); + cnrb.setNetworkName (hNrb.value.getNetworkName ()); + cnrb.setPhysicalNetwork (hNrb.value.getPhysicalNetwork ()); + List <Integer> vlansc = cnrb.getVlans (); + List <Integer> vlansh = hNrb.value.getVlans (); + if (vlansh != null) { + vlansc.addAll (vlansh); + } + } + return cnrb; + } + + private NetworkAdapterNotify getNotifyEP (String notificationUrl) { + + URL warWsdlLoc = null; + try { + warWsdlLoc = Thread.currentThread ().getContextClassLoader ().getResource ("NetworkAdapterNotify.wsdl"); + } catch (Exception e) { + LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.DataError, "Exception - WSDL not found", e); + } + if (warWsdlLoc == null) { + LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.DataError, "WSDL not found"); + } else { + try { + LOGGER.debug ("NetworkAdpaterNotify.wsdl location:" + warWsdlLoc.toURI ().toString ()); + } catch (Exception e) { + LOGGER.error (MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.SchemaError, "Exception - WSDL URL convention", e); + } + } + + NetworkAdapterNotify_Service notifySvc = new NetworkAdapterNotify_Service (warWsdlLoc, + new QName ("http://com.att.mso/networkNotify", + "networkAdapterNotify")); + + NetworkAdapterNotify notifyPort = notifySvc.getMsoNetworkAdapterAsyncImplPort (); + + BindingProvider bp = (BindingProvider) notifyPort; + + URL epUrl = null; + try { + epUrl = new URL (notificationUrl); + } catch (MalformedURLException e1) { + LOGGER.error (MessageEnum.RA_INIT_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - init notification", e1); + } + + LOGGER.debug ("Notification Endpoint URL: " + epUrl.toExternalForm ()); + + bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ()); + + // authentication + try { + Map <String, Object> reqCtx = bp.getRequestContext (); + Map <String, List <String>> headers = new HashMap <String, List <String>> (); + + String userCredentials = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_NETWORK_ADAPTER).getEncryptedProperty (BPEL_AUTH_PROP, + "", + ENCRYPTION_KEY); + + String basicAuth = "Basic " + DatatypeConverter.printBase64Binary (userCredentials.getBytes ()); + reqCtx.put (MessageContext.HTTP_REQUEST_HEADERS, headers); + headers.put ("Authorization", Collections.singletonList (basicAuth)); + } catch (Exception e) { + String error1 = "Unable to set authorization in callback request" + e.getMessage (); + LOGGER.error (MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - Unable to set authorization in callback request", e); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error1); + } + + return notifyPort; + } + + private CreateNetworkNotification.SubnetIdMap copyCreateSubnetIdMap (Holder <Map <String, String>> hMap) { + + CreateNetworkNotification.SubnetIdMap subnetIdMap = new CreateNetworkNotification.SubnetIdMap (); + + if (hMap != null && hMap.value != null) { + Map <String, String> sMap = new HashMap <String, String> (); + sMap = hMap.value; + CreateNetworkNotification.SubnetIdMap.Entry entry = new CreateNetworkNotification.SubnetIdMap.Entry (); + + for (String key : sMap.keySet ()) { + entry.setKey (key); + entry.setValue (sMap.get (key)); + subnetIdMap.getEntry ().add (entry); + } + } + return subnetIdMap; + } + + private UpdateNetworkNotification.SubnetIdMap copyUpdateSubnetIdMap (Holder <Map <String, String>> hMap) { + + UpdateNetworkNotification.SubnetIdMap subnetIdMap = new UpdateNetworkNotification.SubnetIdMap (); + + if (hMap != null && hMap.value != null) { + Map <String, String> sMap = new HashMap <String, String> (); + sMap = hMap.value; + UpdateNetworkNotification.SubnetIdMap.Entry entry = new UpdateNetworkNotification.SubnetIdMap.Entry (); + + for (String key : sMap.keySet ()) { + entry.setKey (key); + entry.setValue (sMap.get (key)); + subnetIdMap.getEntry ().add (entry); + } + } + return subnetIdMap; + } + + private QueryNetworkNotification.SubnetIdMap copyQuerySubnetIdMap (Holder <Map <String, String>> hMap) { + + QueryNetworkNotification.SubnetIdMap subnetIdMap = new QueryNetworkNotification.SubnetIdMap (); + + if (hMap != null && hMap.value != null) { + Map <String, String> sMap = new HashMap <String, String> (); + sMap = hMap.value; + QueryNetworkNotification.SubnetIdMap.Entry entry = new QueryNetworkNotification.SubnetIdMap.Entry (); + + for (String key : sMap.keySet ()) { + entry.setKey (key); + entry.setValue (sMap.get (key)); + subnetIdMap.getEntry ().add (entry); + } + } + return subnetIdMap; + } +} diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java new file mode 100644 index 0000000000..97624dae30 --- /dev/null +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java @@ -0,0 +1,2052 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.network; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.xml.ws.Holder; + +import org.codehaus.jackson.JsonNode; +import org.codehaus.jackson.map.ObjectMapper; + +import org.openecomp.mso.adapters.network.exceptions.NetworkException; +import org.openecomp.mso.cloud.CloudConfig; +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.cloud.CloudSite; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.HeatTemplate; +import org.openecomp.mso.db.catalog.beans.NetworkResource; +import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.beans.HeatStatus; +import org.openecomp.mso.openstack.beans.NetworkInfo; +import org.openecomp.mso.openstack.beans.NetworkRollback; +import org.openecomp.mso.openstack.beans.NetworkStatus; +import org.openecomp.mso.openstack.beans.Pool; +import org.openecomp.mso.openstack.beans.StackInfo; +import org.openecomp.mso.openstack.beans.Subnet; +import org.openecomp.mso.openstack.exceptions.MsoAdapterException; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.openecomp.mso.openstack.utils.MsoCommonUtils; +import org.openecomp.mso.openstack.utils.MsoHeatUtils; +import org.openecomp.mso.openstack.utils.MsoHeatUtilsWithUpdate; +import org.openecomp.mso.openstack.utils.MsoNeutronUtils; +import org.openecomp.mso.openstack.utils.MsoNeutronUtils.NetworkType; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +import static org.openecomp.mso.openstack.utils.MsoCommonUtils.isNullOrEmpty; + +@WebService(serviceName = "NetworkAdapter", endpointInterface = "org.openecomp.mso.adapters.network.MsoNetworkAdapter", targetNamespace = "http://com.att.mso/network") +public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { + + MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory(); + + CloudConfigFactory cloudConfigFactory=new CloudConfigFactory(); + + private static final String AIC3_NW_PROPERTY= "org.openecomp.mso.adapters.network.aic3nw"; + private static final String AIC3_NW="OS::ContrailV2::VirtualNetwork"; + public static final String MSO_PROP_NETWORK_ADAPTER="MSO_PROP_NETWORK_ADAPTER"; + private static final String VLANS = "vlans"; + private static final String PHYSICAL_NETWORK = "physical_network"; + private static final String UPDATE_NETWORK_CONTEXT = "UpdateNetwork"; + private static final String NETWORK_ID = "network_id"; + private static final String NETWORK_FQDN = "network_fqdn"; + private static final String CREATE_NETWORK_CONTEXT = "CreateNetwork"; + private static final String MSO_CONFIGURATION_ERROR = "MsoConfigurationError"; + private static final String NEUTRON_MODE = "NEUTRON"; + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + protected CloudConfig cloudConfig; + + /** + * Health Check web method. Does nothing but return to show the adapter is deployed. + */ + @Override + public void healthCheck () { + LOGGER.debug ("Health check call in Network Adapter"); + } + + /** + * Do not use this constructor or the msoPropertiesFactory will be NULL. + * + * @see MsoNetworkAdapterImpl#MsoNetworkAdapterImpl(MsoPropertiesFactory) + */ + public MsoNetworkAdapterImpl() { + } + + /** + * This constructor MUST be used if this class if called with the new operator. + * @param msoPropFactory + + */ + public MsoNetworkAdapterImpl(MsoPropertiesFactory msoPropFactory,CloudConfigFactory cloudConfigFact) { + this.msoPropertiesFactory = msoPropFactory; + this.cloudConfigFactory=cloudConfigFact; + cloudConfig = cloudConfigFactory.getCloudConfig (); + } + + @Override + public void createNetwork (String cloudSiteId, + String tenantId, + String networkType, + String networkName, + String physicalNetworkName, + List <Integer> vlans, + Boolean failIfExists, + Boolean backout, + List <Subnet> subnets, + MsoRequest msoRequest, + Holder <String> networkId, + Holder <String> neutronNetworkId, + Holder <Map <String, String>> subnetIdMap, + Holder <NetworkRollback> rollback) throws NetworkException { + Holder <String> networkFqdn = new Holder <String> (); + createNetwork (cloudSiteId, + tenantId, + networkType, + networkName, + physicalNetworkName, + vlans, + null, + null, + null, + failIfExists, + backout, + subnets, + null, + null, + msoRequest, + networkId, + neutronNetworkId, + networkFqdn, + subnetIdMap, + rollback); + } + + @Override + public void createNetworkContrail (String cloudSiteId, + String tenantId, + String networkType, + String networkName, + List <String> routeTargets, + String shared, + String external, + Boolean failIfExists, + Boolean backout, + List <Subnet> subnets, + List <String> policyFqdns, + List<String> routeTableFqdns, + MsoRequest msoRequest, + Holder <String> networkId, + Holder <String> neutronNetworkId, + Holder <String> networkFqdn, + Holder <Map <String, String>> subnetIdMap, + Holder <NetworkRollback> rollback) throws NetworkException { + createNetwork (cloudSiteId, + tenantId, + networkType, + networkName, + null, + null, + routeTargets, + shared, + external, + failIfExists, + backout, + subnets, + policyFqdns, + routeTableFqdns, + msoRequest, + networkId, + neutronNetworkId, + networkFqdn, + subnetIdMap, + rollback); + } + + /** + * This is the "Create Network" web service implementation. + * It will create a new Network of the requested type in the specified cloud + * and tenant. The tenant must exist at the time this service is called. + * + * If a network with the same name already exists, this can be considered a + * success or failure, depending on the value of the 'failIfExists' parameter. + * + * There will be a pre-defined set of network types defined in the MSO Catalog. + * All such networks will have a similar configuration, based on the allowable + * Openstack networking definitions. This includes basic networks, provider + * networks (with a single VLAN), and multi-provider networks (one or more VLANs) + * + * Initially, all provider networks must be "vlan" type, and multiple segments in + * a multi-provider network must be multiple VLANs on the same physical network. + * + * This service supports two modes of Network creation/update: + * - via Heat Templates + * - via Neutron API + * The network orchestration mode for each network type is declared in its + * catalog definition. All Heat-based templates must support some subset of + * the same input parameters: network_name, physical_network, vlan(s). + * + * The method returns the network ID and a NetworkRollback object. This latter + * object can be passed as-is to the rollbackNetwork operation to undo everything + * that was created. This is useful if a network is successfully created but + * the orchestration fails on a subsequent operation. + */ + + private void createNetwork (String cloudSiteId, + String tenantId, + String networkType, + String networkName, + String physicalNetworkName, + List <Integer> vlans, + List <String> routeTargets, + String shared, + String external, + Boolean failIfExists, + Boolean backout, + List <Subnet> subnets, + List <String> policyFqdns, + List <String> routeTableFqdns, + MsoRequest msoRequest, + Holder <String> networkId, + Holder <String> neutronNetworkId, + Holder <String> networkFqdn, + Holder <Map <String, String>> subnetIdMap, + Holder <NetworkRollback> rollback) throws NetworkException { + MsoLogger.setLogContext (msoRequest); + MsoLogger.setServiceName ("CreateNetwork"); + + LOGGER.debug ("*** CREATE Network: " + networkName + + " of type " + + networkType + + " in " + + cloudSiteId + + "/" + + tenantId); + + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + + // Build a default rollback object (no actions performed) + NetworkRollback networkRollback = new NetworkRollback (); + networkRollback.setCloudId (cloudSiteId); + networkRollback.setTenantId (tenantId); + networkRollback.setMsoRequest (msoRequest); + + // tenant query is not required here. + // If the tenant doesn’t exist, the Heat calls will fail anyway (when the HeatUtils try to obtain a token). + // So this is just catching that error in a bit more obvious way up front. + + cloudConfig = cloudConfigFactory.getCloudConfig (); + CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + if (cloudSite == null) + { + String error = "Configuration Error. Stack " + networkName + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + " CloudSite does not exist in MSO Configuration"; + LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "", "", MsoLogger.ErrorCode.DataError, "Configuration Error"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); + // Set the detailed error as the Exception 'message' + throw new NetworkException (error, MsoExceptionCategory.USERDATA); + } + + try (CatalogDatabase db = getCatalogDb()) { + NetworkResource networkResource = networkCheck (db, + startTime, + networkType, + networkName, + physicalNetworkName, + vlans, + routeTargets, + cloudSite); + String mode = networkResource.getOrchestrationMode (); + NetworkType neutronNetworkType = NetworkType.valueOf (networkResource.getNeutronNetworkType ()); + + if (NEUTRON_MODE.equals (mode)) { + + // Use an MsoNeutronUtils for all neutron commands + MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory); + + // See if the Network already exists (by name) + NetworkInfo netInfo = null; + long queryNetworkStarttime = System.currentTimeMillis (); + try { + netInfo = neutron.queryNetwork (networkName, tenantId, cloudSiteId); + LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "QueryNetwork", null); + } catch (MsoException me) { + LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack", "OpenStack", "QueryNetwork", null); + String error = "Create Network (neutron): query network " + networkName + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while querying network from OpenStack", me); + me.addContext (CREATE_NETWORK_CONTEXT); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack"); + throw new NetworkException (me); + } + + if (netInfo != null) { + // Exists. If that's OK, return success with the network ID. + // Otherwise, return an exception. + if (failIfExists != null && failIfExists) { + String error = "Create Nework: Network " + networkName + + " already exists in " + + cloudSiteId + + "/" + + tenantId + + " with ID " + netInfo.getId(); + LOGGER.error (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Network already exists"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + throw new NetworkException(error, MsoExceptionCategory.USERDATA); + } else { + // Populate the outputs from the existing network. + networkId.value = netInfo.getId (); + neutronNetworkId.value = netInfo.getId (); + rollback.value = networkRollback; // Default rollback - no updates performed + String msg = "Found Existing network, status=" + netInfo.getStatus () + " for Neutron mode"; + LOGGER.warn (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", MsoLogger.ErrorCode.DataError, "Found Existing network, status=" + netInfo.getStatus ()); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, msg); + } + return; + } + + long createNetworkStarttime = System.currentTimeMillis (); + try { + netInfo = neutron.createNetwork (cloudSiteId, + tenantId, + neutronNetworkType, + networkName, + physicalNetworkName, + vlans); + LOGGER.recordMetricEvent (createNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "CreateNetwork", null); + } catch (MsoException me) { + me.addContext (CREATE_NETWORK_CONTEXT); + LOGGER.recordMetricEvent (createNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with OpenStack", "OpenStack", "CreateNetwork", null); + String error = "Create Network: type " + neutronNetworkType + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception while communicate with OpenStack", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + + throw new NetworkException (me); + } + + // Note: ignoring MsoNetworkAlreadyExists because we already checked. + + // If reach this point, network creation is successful. + // Since directly created via Neutron, networkId tracked by MSO is the same + // as the neutron network ID. + networkId.value = netInfo.getId (); + neutronNetworkId.value = netInfo.getId (); + + networkRollback.setNetworkCreated (true); + networkRollback.setNetworkId (netInfo.getId ()); + networkRollback.setNeutronNetworkId (netInfo.getId ()); + networkRollback.setNetworkType (networkType); + + LOGGER.debug ("Network " + networkName + " created, id = " + netInfo.getId ()); + } else if ("HEAT".equals (mode)) { + + // Use an MsoHeatUtils for all Heat commands + MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + + HeatTemplate heatTemplate = db.getHeatTemplate (networkResource.getTemplateId ()); + if (heatTemplate == null) { + String error = "Network error - undefined Heat Template. Network Type = " + networkType; + LOGGER.error (MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType, "Openstack", "", MsoLogger.ErrorCode.DataError, "Network error - undefined Heat Template. Network Type = " + networkType); + alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this + // error, + // configuration + // must be fixed + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + throw new NetworkException (error, MsoExceptionCategory.INTERNAL); + } + + LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ()); + + // "Fix" the template if it has CR/LF (getting this from Oracle) + String template = heatTemplate.getHeatTemplate (); + template = template.replaceAll ("\r\n", "\n"); + + boolean aic3template=false; + String aic3nw = AIC3_NW; + try { + aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER).getProperty(AIC3_NW_PROPERTY, AIC3_NW); + } catch (MsoPropertiesException e) { + String error = "Unable to get properties:" + MSO_PROP_NETWORK_ADAPTER; + LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "", "", MsoLogger.ErrorCode.DataError, "Exception - Unable to get properties", e); + } + + if (template.contains(aic3nw)) + aic3template = true; + + // First, look up to see if the Network already exists (by name). + // For HEAT orchestration of networks, the stack name will always match the network name + StackInfo heatStack = null; + long queryNetworkStarttime = System.currentTimeMillis (); + try { + heatStack = heat.queryStack (cloudSiteId, tenantId, networkName); + LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "QueryNetwork", null); + } catch (MsoException me) { + me.addContext (CREATE_NETWORK_CONTEXT); + LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying stack from OpenStack", "OpenStack", "QueryNetwork", null); + String error = "Create Network (heat): query network " + networkName + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception while querying stack from OpenStack", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException (me); + } + + if (heatStack != null && !(heatStack.getStatus () == HeatStatus.NOTFOUND)) { + // Stack exists. Return success or error depending on input directive + if (failIfExists != null && failIfExists) { + String error = "CreateNetwork: Stack " + networkName + + " already exists in " + + cloudSiteId + + "/" + + tenantId + + " as " + heatStack.getCanonicalName(); + LOGGER.error (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", MsoLogger.ErrorCode.DataError, "Network already exists"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + throw new NetworkException(error, MsoExceptionCategory.USERDATA); + } else { + // Populate the outputs from the existing stack. + networkId.value = heatStack.getCanonicalName (); + neutronNetworkId.value = (String) heatStack.getOutputs ().get (NETWORK_ID); + rollback.value = networkRollback; // Default rollback - no updates performed + if (aic3template) + { + networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN); + } + Map <String, Object> outputs = heatStack.getOutputs (); + Map <String, String> sMap = new HashMap <String, String> (); + if (outputs != null) { + for (String key : outputs.keySet ()) { + if (key != null && key.startsWith ("subnet")) { + if (aic3template) //one subnet_id output + { + Map <String, String> map = getSubnetUUId(key, outputs, subnets); + sMap.putAll(map); + } + else //multiples subnet_%aaid% outputs + { + String subnetUUId = (String) outputs.get(key); + sMap.put (key.substring("subnet_id_".length()), subnetUUId); + } + } + } + } + subnetIdMap.value = sMap; + String msg = "Found Existing network stack, status=" + heatStack.getStatus () + " for Heat mode"; + LOGGER.warn (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", MsoLogger.ErrorCode.DataError, "Found Existing network stack, status=" + heatStack.getStatus ()); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc, "Found Existing network stack"); + } + return; + } + + // Ready to deploy the new Network + // Build the common set of HEAT template parameters + Map <String, Object> stackParams = populateNetworkParams (neutronNetworkType, + networkName, + physicalNetworkName, + vlans, + routeTargets, + shared, + external, + aic3template); + + // Validate (and update) the input parameters against the DB definition + // Shouldn't happen unless DB config is wrong, since all networks use same inputs + // and inputs were already validated. + try { + stackParams = heat.validateStackParams (stackParams, heatTemplate); + } catch (IllegalArgumentException e) { + String error = "Create Network: Configuration Error: " + e.getMessage (); + LOGGER.error (MessageEnum.RA_CONFIG_EXC, e.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - Create Network, Configuration Error", e); + alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this + // error, + // configuration + // must be fixed + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); + // Input parameters were not valid + throw new NetworkException (error, MsoExceptionCategory.INTERNAL); + } + + if (subnets != null) { + try { + if (aic3template) + { + template = mergeSubnetsAIC3 (template, subnets, stackParams); + } + else + { + template = mergeSubnets (template, subnets); + } + } catch (MsoException me) { + me.addContext (CREATE_NETWORK_CONTEXT); + String error = "Create Network (heat): type " + neutronNetworkType + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception Create Network, merging subnets", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); + throw new NetworkException (me); + } + } + + if (policyFqdns != null && !policyFqdns.isEmpty() && aic3template) { + try { + mergePolicyRefs (policyFqdns, stackParams); + } catch (MsoException me) { + me.addContext (CREATE_NETWORK_CONTEXT); + String error = "Create Network (heat) mergePolicyRefs type " + neutronNetworkType + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception Create Network, merging policyRefs", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); + throw new NetworkException (me); + } + } + + if (routeTableFqdns != null && !routeTableFqdns.isEmpty() && aic3template) { + try { + mergeRouteTableRefs (routeTableFqdns, stackParams); + } catch (MsoException me) { + me.addContext (CREATE_NETWORK_CONTEXT); + String error = "Create Network (heat) mergeRouteTableRefs type " + neutronNetworkType + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception Create Network, merging routeTableRefs", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); + throw new NetworkException (me); + } + } + + // Deploy the network stack + // Ignore MsoStackAlreadyExists exception because we already checked. + long createStackStartTime = System.currentTimeMillis (); + try { + if (backout == null) + backout = true; + heatStack = heat.createStack (cloudSiteId, + tenantId, + networkName, + template, + stackParams, + true, + heatTemplate.getTimeoutMinutes (), + null, + null, + null, + backout.booleanValue()); + } catch (MsoException me) { + me.addContext (CREATE_NETWORK_CONTEXT); + String error = "Create Network (heat): type " + neutronNetworkType + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception creating network", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException (me); + } + + // Reach this point if createStack is successful. + + // For Heat-based orchestration, the MSO-tracked network ID is the heat stack, + // and the neutronNetworkId is the network UUID returned in stack outputs. + networkId.value = heatStack.getCanonicalName (); + neutronNetworkId.value = (String) heatStack.getOutputs ().get (NETWORK_ID); + if (aic3template) + { + networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN); + } + Map <String, Object> outputs = heatStack.getOutputs (); + Map <String, String> sMap = new HashMap <String, String> (); + if (outputs != null) { + for (String key : outputs.keySet ()) { + if (key != null && key.startsWith ("subnet")) { + if (aic3template) //one subnet output expected + { + Map <String, String> map = getSubnetUUId(key, outputs, subnets); + sMap.putAll(map); + } + else //multiples subnet_%aaid% outputs allowed + { + String subnetUUId = (String) outputs.get(key); + sMap.put (key.substring("subnet_id_".length()), subnetUUId); + } + } + } + } + subnetIdMap.value = sMap; + + rollback.value = networkRollback; + // Populate remaining rollback info and response parameters. + networkRollback.setNetworkStackId (heatStack.getCanonicalName ()); + networkRollback.setNeutronNetworkId ((String) heatStack.getOutputs ().get (NETWORK_ID)); + networkRollback.setNetworkCreated (true); + networkRollback.setNetworkType (networkType); + + LOGGER.debug ("Network " + networkName + " successfully created via HEAT"); + } + } + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc, "Successfully created network"); + return; + } + + @Override + public void updateNetwork (String cloudSiteId, + String tenantId, + String networkType, + String networkId, + String networkName, + String physicalNetworkName, + List <Integer> vlans, + List <Subnet> subnets, + MsoRequest msoRequest, + Holder <Map <String, String>> subnetIdMap, + Holder <NetworkRollback> rollback) throws NetworkException { + updateNetwork (cloudSiteId, + tenantId, + networkType, + networkId, + networkName, + physicalNetworkName, + vlans, + null, + null, + null, + subnets, + null, + null, + msoRequest, + subnetIdMap, + rollback); + + } + + @Override + public void updateNetworkContrail (String cloudSiteId, + String tenantId, + String networkType, + String networkId, + String networkName, + List <String> routeTargets, + String shared, + String external, + List <Subnet> subnets, + List <String> policyFqdns, + List<String> routeTableFqdns, + MsoRequest msoRequest, + Holder <Map <String, String>> subnetIdMap, + Holder <NetworkRollback> rollback) throws NetworkException { + updateNetwork (cloudSiteId, + tenantId, + networkType, + networkId, + networkName, + null, + null, + routeTargets, + shared, + external, + subnets, + policyFqdns, + routeTableFqdns, + msoRequest, + subnetIdMap, + rollback); + } + + /** + * This is the "Update Network" web service implementation. + * It will update an existing Network of the requested type in the specified cloud + * and tenant. The typical use will be to replace the VLANs with the supplied + * list (to add or remove a VLAN), but other properties may be updated as well. + * + * There will be a pre-defined set of network types defined in the MSO Catalog. + * All such networks will have a similar configuration, based on the allowable + * Openstack networking definitions. This includes basic networks, provider + * networks (with a single VLAN), and multi-provider networks (one or more VLANs). + * + * Initially, all provider networks must currently be "vlan" type, and multi-provider + * networks must be multiple VLANs on the same physical network. + * + * This service supports two modes of Network update: + * - via Heat Templates + * - via Neutron API + * The network orchestration mode for each network type is declared in its + * catalog definition. All Heat-based templates must support some subset of + * the same input parameters: network_name, physical_network, vlan, segments. + * + * The method returns a NetworkRollback object. This object can be passed + * as-is to the rollbackNetwork operation to undo everything that was updated. + * This is useful if a network is successfully updated but orchestration + * fails on a subsequent operation. + */ + private void updateNetwork (String cloudSiteId, + String tenantId, + String networkType, + String networkId, + String networkName, + String physicalNetworkName, + List <Integer> vlans, + List <String> routeTargets, + String shared, + String external, + List <Subnet> subnets, + List <String> policyFqdns, + List<String> routeTableFqdns, + MsoRequest msoRequest, + Holder <Map <String, String>> subnetIdMap, + Holder <NetworkRollback> rollback) throws NetworkException { + MsoLogger.setLogContext (msoRequest); + MsoLogger.setServiceName ("UpdateNetwork"); + LOGGER.debug ("***UPDATE Network adapter with Network: " + networkName + + " of type " + + networkType + + " in " + + cloudSiteId + + "/" + + tenantId); + + + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + + // Build a default rollback object (no actions performed) + NetworkRollback networkRollback = new NetworkRollback (); + networkRollback.setCloudId (cloudSiteId); + networkRollback.setTenantId (tenantId); + networkRollback.setMsoRequest (msoRequest); + + cloudConfig = cloudConfigFactory.getCloudConfig (); + CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + if (cloudSite == null) { + String error = "UpdateNetwork: Configuration Error. Stack " + networkName + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + " CloudSite does not exist in MSO Configuration"; + LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "Openstack", "", MsoLogger.ErrorCode.DataError, "CloudSite does not exist in MSO Configuration"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); + // Set the detailed error as the Exception 'message' + throw new NetworkException (error, MsoExceptionCategory.USERDATA); + } + + try(CatalogDatabase db = getCatalogDb()) { + NetworkResource networkResource = networkCheck (db, + startTime, + networkType, + networkName, + physicalNetworkName, + vlans, + routeTargets, + cloudSite); + String mode = networkResource.getOrchestrationMode (); + NetworkType neutronNetworkType = NetworkType.valueOf (networkResource.getNeutronNetworkType ()); + + // Use an MsoNeutronUtils for all Neutron commands + MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory); + + if (NEUTRON_MODE.equals (mode)) { + + // Verify that the Network exists + // For Neutron-based orchestration, the networkId is the Neutron Network UUID. + NetworkInfo netInfo = null; + long queryNetworkStarttime = System.currentTimeMillis (); + try { + netInfo = neutron.queryNetwork (networkId, tenantId, cloudSiteId); + LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryNetwork", null); + } catch (MsoException me) { + me.addContext (UPDATE_NETWORK_CONTEXT); + String error = "Update Network (neutron): query " + networkId + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryNetwork", null); + LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "QueryNetwork", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryNetwork", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException (me); + } + + if (netInfo == null) { + String error = "Update Nework: Network " + networkId + + " does not exist in " + + cloudSiteId + + "/" + + tenantId; + LOGGER.error (MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Network not found"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + // Does not exist. Throw an exception (can't update a non-existent network) + throw new NetworkException(error, MsoExceptionCategory.USERDATA); + } + long updateNetworkStarttime = System.currentTimeMillis (); + try { + netInfo = neutron.updateNetwork (cloudSiteId, + tenantId, + networkId, + neutronNetworkType, + physicalNetworkName, + vlans); + LOGGER.recordMetricEvent (updateNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "UpdateNetwork", null); + } catch (MsoException me) { + me.addContext (UPDATE_NETWORK_CONTEXT); + String error = "Update Network (neutron): " + networkId + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error (MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "Openstack", "updateNetwork", MsoLogger.ErrorCode.DataError, "Exception - updateNetwork", me); + LOGGER.recordMetricEvent (updateNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateNetwork", null); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException (me); + } + + // Add the network ID and previously queried vlans to the rollback object + networkRollback.setNetworkId (netInfo.getId ()); + networkRollback.setNeutronNetworkId (netInfo.getId ()); + networkRollback.setNetworkType (networkType); + // Save previous parameters + networkRollback.setNetworkName (netInfo.getName ()); + networkRollback.setPhysicalNetwork (netInfo.getProvider ()); + networkRollback.setVlans (netInfo.getVlans ()); + + LOGGER.debug ("Network " + networkId + " updated, id = " + netInfo.getId ()); + } else if ("HEAT".equals (mode)) { + + // Use an MsoHeatUtils for all Heat commands + MsoHeatUtilsWithUpdate heat = new MsoHeatUtilsWithUpdate (MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + + // First, look up to see that the Network already exists. + // For Heat-based orchestration, the networkId is the network Stack ID. + StackInfo heatStack = null; + long queryStackStarttime = System.currentTimeMillis (); + try { + heatStack = heat.queryStack (cloudSiteId, tenantId, networkName); + LOGGER.recordMetricEvent (queryStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", null); + } catch (MsoException me) { + me.addContext (UPDATE_NETWORK_CONTEXT); + String error = "UpdateNetwork (heat): query " + networkName + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.recordMetricEvent (queryStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null); + LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Exception - QueryStack", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException (me); + } + + if (heatStack == null || (heatStack.getStatus () == HeatStatus.NOTFOUND)) { + String error = "UpdateNetwork: Stack " + networkName + + " does not exist in " + + cloudSiteId + + "/" + + tenantId; + LOGGER.error (MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Network not found"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + // Network stack does not exist. Return an error + throw new NetworkException(error, MsoExceptionCategory.USERDATA); + } + + // Get the previous parameters for rollback + Map <String, Object> heatParams = heatStack.getParameters (); + + String previousNetworkName = (String) heatParams.get ("network_name"); + String previousPhysicalNetwork = (String) heatParams.get (PHYSICAL_NETWORK); + + List <Integer> previousVlans = new ArrayList <Integer> (); + String vlansParam = (String) heatParams.get (VLANS); + if (vlansParam != null) { + for (String vlan : vlansParam.split (",")) { + try { + previousVlans.add (Integer.parseInt (vlan)); + } catch (NumberFormatException e) { + LOGGER.warn (MessageEnum.RA_VLAN_PARSE, networkId, vlansParam, "", "", MsoLogger.ErrorCode.DataError, "Exception - VLAN parse", e); + } + } + } + LOGGER.debug ("Update Stack: Previous VLANS: " + previousVlans); + + // Ready to deploy the updated Network via Heat + + HeatTemplate heatTemplate = db.getHeatTemplate (networkResource.getTemplateId ()); + if (heatTemplate == null) { + String error = "Network error - undefined Heat Template. Network Type=" + networkType; + LOGGER.error (MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType, "OpenStack", "getHeatTemplate", MsoLogger.ErrorCode.DataError, "Network error - undefined Heat Template. Network Type=" + networkType); + alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + throw new NetworkException (error, MsoExceptionCategory.INTERNAL); + } + + LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ()); + + // "Fix" the template if it has CR/LF (getting this from Oracle) + String template = heatTemplate.getHeatTemplate (); + template = template.replaceAll ("\r\n", "\n"); + + boolean aic3template=false; + String aic3nw = AIC3_NW; + try { + aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER).getProperty(AIC3_NW_PROPERTY, AIC3_NW); + } catch (MsoPropertiesException e) { + String error = "Unable to get properties:" + MSO_PROP_NETWORK_ADAPTER; + LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - Unable to get properties", e); + } + if (template.contains(aic3nw)) + aic3template = true; + + // Build the common set of HEAT template parameters + Map <String, Object> stackParams = populateNetworkParams (neutronNetworkType, + networkName, + physicalNetworkName, + vlans, + routeTargets, + shared, + external, + aic3template); + + // Validate (and update) the input parameters against the DB definition + // Shouldn't happen unless DB config is wrong, since all networks use same inputs + try { + stackParams = heat.validateStackParams (stackParams, heatTemplate); + } catch (IllegalArgumentException e) { + String error = "UpdateNetwork: Configuration Error: Network Type=" + networkType; + LOGGER.error (MessageEnum.RA_CONFIG_EXC, "Network Type=" + networkType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork: Configuration Error"); + alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, error); + throw new NetworkException (error, MsoExceptionCategory.INTERNAL, e); + } + + if (subnets != null) { + try { + if (aic3template) + { + template = mergeSubnetsAIC3 (template, subnets, stackParams); + } + else + { + template = mergeSubnets (template, subnets); + } + } catch (MsoException me) { + me.addContext (UPDATE_NETWORK_CONTEXT); + String error = "Update Network (heat): type " + neutronNetworkType + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error (MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork mergeSubnets ", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); + throw new NetworkException (me); + } + } + + if (policyFqdns != null && aic3template) { + try { + mergePolicyRefs (policyFqdns, stackParams); + } catch (MsoException me) { + me.addContext (UPDATE_NETWORK_CONTEXT); + String error = "UpdateNetwork (heat) mergePolicyRefs type " + neutronNetworkType + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error (MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork mergePolicyRefs", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); + throw new NetworkException (me); + } + } + + if (routeTableFqdns != null && !routeTableFqdns.isEmpty() && aic3template) { + try { + mergeRouteTableRefs (routeTableFqdns, stackParams); + } catch (MsoException me) { + me.addContext (UPDATE_NETWORK_CONTEXT); + String error = "UpdateNetwork (heat) mergeRouteTableRefs type " + neutronNetworkType + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error (MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork mergeRouteTableRefs", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); + throw new NetworkException (me); + } + } + + // Update the network stack + // Ignore MsoStackNotFound exception because we already checked. + long updateStackStarttime = System.currentTimeMillis (); + try { + heatStack = heat.updateStack (cloudSiteId, + tenantId, + networkId, + template, + stackParams, + true, + heatTemplate.getTimeoutMinutes ()); + LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "UpdateStack", null); + } catch (MsoException me) { + me.addContext (UPDATE_NETWORK_CONTEXT); + String error = "Update Network: " + networkId + " in " + cloudSiteId + "/" + tenantId + ": " + me; + LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null); + LOGGER.error (MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - update network", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException (me); + } + + Map <String, Object> outputs = heatStack.getOutputs (); + Map <String, String> sMap = new HashMap <String, String> (); + if (outputs != null) { + for (String key : outputs.keySet ()) { + if (key != null && key.startsWith ("subnet")) { + if (aic3template) //one subnet output expected + { + Map <String, String> map = getSubnetUUId(key, outputs, subnets); + sMap.putAll(map); + } + else //multiples subnet_%aaid% outputs allowed + { + String subnetUUId = (String) outputs.get(key); + sMap.put (key.substring("subnet_id_".length()), subnetUUId); + } + } + } + } + subnetIdMap.value = sMap; + + // Reach this point if createStack is successful. + // Populate remaining rollback info and response parameters. + networkRollback.setNetworkStackId (heatStack.getCanonicalName ()); + networkRollback.setNeutronNetworkId ((String) outputs.get (NETWORK_ID)); + networkRollback.setNetworkType (networkType); + // Save previous parameters + networkRollback.setNetworkName (previousNetworkName); + networkRollback.setPhysicalNetwork (previousPhysicalNetwork); + networkRollback.setVlans (previousVlans); + + rollback.value = networkRollback; + + LOGGER.debug ("Network " + networkId + " successfully updated via HEAT"); + } + } + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully updated network"); + return; + } + + private NetworkResource networkCheck (CatalogDatabase db, + long startTime, + String networkType, + String networkName, + String physicalNetworkName, + List <Integer> vlans, + List <String> routeTargets, + CloudSite cloudSite) throws NetworkException { + // Retrieve the Network Resource definition + NetworkResource networkResource = db.getNetworkResource (networkType); + if (networkResource == null) { + String error = "CreateNetwork: Unknown Network Type: " + networkType; + LOGGER.error (MessageEnum.RA_UNKOWN_PARAM, "Network Type", networkType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "CreateNetwork: Unknown Network Type"); + + throw new NetworkException (error, MsoExceptionCategory.USERDATA); + } + LOGGER.debug ("Got Network definition from Catalog: " + networkResource.toString ()); + + String mode = networkResource.getOrchestrationMode (); + NetworkType neutronNetworkType = NetworkType.valueOf (networkResource.getNeutronNetworkType ()); + + // All Networks are orchestrated via HEAT or Neutron + if (!("HEAT".equals (mode) || NEUTRON_MODE.equals (mode))) { + String error = "CreateNetwork: Configuration Error: Network Type = " + networkType; + LOGGER.error (MessageEnum.RA_NETWORK_ORCHE_MODE_NOT_SUPPORT, mode, "OpenStack", "", MsoLogger.ErrorCode.DataError, "CreateNetwork: Configuration Error"); + // Alarm on this error, configuration must be fixed + alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + + throw new NetworkException (error, MsoExceptionCategory.INTERNAL); + } + + MavenLikeVersioning aicV = new MavenLikeVersioning(); + aicV.setVersion(cloudSite.getAic_version()); + if ((aicV.isMoreRecentThan(networkResource.getAicVersionMin()) || aicV.isTheSameVersion(networkResource.getAicVersionMin())) // aic >= min + && (aicV.isTheSameVersion(networkResource.getAicVersionMax()) || !(aicV.isMoreRecentThan(networkResource.getAicVersionMax())))) //aic <= max + { + LOGGER.debug ("Network Type:" + networkType + + " VersionMin:" + networkResource.getAicVersionMin() + + " VersionMax:" + networkResource.getAicVersionMax() + + " supported on Cloud:" + cloudSite.getId() + + " with AIC_Version:" + cloudSite.getAic_version()); + } + else + { + String error = "Network Type:" + networkType + + " Version_Min:" + networkResource.getAicVersionMin() + + " Version_Max:" + networkResource.getAicVersionMax() + + " not supported on Cloud:" + cloudSite.getId() + + " with AIC_Version:" + cloudSite.getAic_version(); + LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Network Type not supported on Cloud"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); + throw new NetworkException (error, MsoExceptionCategory.USERDATA); + } + + + // Validate the Network parameters. + String missing = validateNetworkParams (neutronNetworkType, + networkName, + physicalNetworkName, + vlans, + routeTargets); + if (!missing.isEmpty ()) { + String error = "Create Network: Missing parameters: " + missing; + LOGGER.error (MessageEnum.RA_MISSING_PARAM, missing, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create Network: Missing parameters"); + + throw new NetworkException (error, MsoExceptionCategory.USERDATA); + } + return networkResource; + } + + @Override + public void queryNetwork (String cloudSiteId, + String tenantId, + String networkNameOrId, + MsoRequest msoRequest, + Holder <Boolean> networkExists, + Holder <String> networkId, + Holder <String> neutronNetworkId, + Holder <NetworkStatus> status, + Holder <List <Integer>> vlans, + Holder <Map <String, String>> subnetIdMap) throws NetworkException { + queryNetwork (cloudSiteId, + tenantId, + networkNameOrId, + msoRequest, + networkExists, + networkId, + neutronNetworkId, + status, + vlans, + null, + subnetIdMap); + } + + @Override + public void queryNetworkContrail (String cloudSiteId, + String tenantId, + String networkNameOrId, + MsoRequest msoRequest, + Holder <Boolean> networkExists, + Holder <String> networkId, + Holder <String> neutronNetworkId, + Holder <NetworkStatus> status, + Holder <List <String>> routeTargets, + Holder <Map <String, String>> subnetIdMap) throws NetworkException { + queryNetwork (cloudSiteId, + tenantId, + networkNameOrId, + msoRequest, + networkExists, + networkId, + neutronNetworkId, + status, + null, + routeTargets, + subnetIdMap); + } + + /** + * This is the queryNetwork method. It returns the existence and status of + * the specified network, along with its Neutron UUID and list of VLANs. + * This method attempts to find the network using both Heat and Neutron. + * Heat stacks are first searched based on the provided network name/id. + * If none is found, the Neutron is directly queried. + */ + private void queryNetwork (String cloudSiteId, + String tenantId, + String networkNameOrId, + MsoRequest msoRequest, + Holder <Boolean> networkExists, + Holder <String> networkId, + Holder <String> neutronNetworkId, + Holder <NetworkStatus> status, + Holder <List <Integer>> vlans, + Holder <List <String>> routeTargets, + Holder <Map <String, String>> subnetIdMap) throws NetworkException { + MsoLogger.setLogContext (msoRequest); + MsoLogger.setServiceName ("QueryNetwork"); + LOGGER.debug ("*** QUERY Network with Network: " + networkNameOrId + + " in " + + cloudSiteId + + "/" + + tenantId); + + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + + if (isNullOrEmpty (cloudSiteId) + || isNullOrEmpty(tenantId) + || isNullOrEmpty(networkNameOrId)) { + + String error = "Missing mandatory parameter cloudSiteId, tenantId or networkId"; + LOGGER.error (MessageEnum.RA_MISSING_PARAM, "cloudSiteId or tenantId or networkNameOrId", "OpenStack", "", MsoLogger.ErrorCode.DataError, "Missing mandatory parameter cloudSiteId, tenantId or networkId"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + throw new NetworkException (error, MsoExceptionCategory.USERDATA); + } + + cloudConfig = cloudConfigFactory.getCloudConfig (); + CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + if (cloudSite == null) + { + String error = "Configuration Error. Stack " + networkNameOrId + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + " CloudSite does not exist in MSO Configuration"; + LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Configuration Error"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); + // Set the detailed error as the Exception 'message' + throw new NetworkException (error, MsoExceptionCategory.USERDATA); + } + + // Use MsoNeutronUtils for all NEUTRON commands + MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER,msoPropertiesFactory,cloudConfigFactory); + MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory); + + String mode = null; + String neutronId = null; + // Try Heat first, since networks may be named the same as the Heat stack + StackInfo heatStack = null; + long queryStackStarttime = System.currentTimeMillis (); + try { + heatStack = heat.queryStack (cloudSiteId, tenantId, networkNameOrId); + LOGGER.recordMetricEvent (queryStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", null); + } catch (MsoException me) { + me.addContext ("QueryNetwork"); + String error = "Query Network (heat): " + networkNameOrId + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.recordMetricEvent (queryStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "BPMN", "QueryStack", null); + LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkNameOrId, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Exception - Query Network (heat)", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException (me); + } + + // Populate the outputs based on the returned Stack information + if (heatStack != null && heatStack.getStatus () != HeatStatus.NOTFOUND) { + // Found it. Get the neutronNetworkId for further query + Map <String, Object> outputs = heatStack.getOutputs (); + neutronId = (String) outputs.get (NETWORK_ID); + mode = "HEAT"; + + Map <String, String> sMap = new HashMap <String, String> (); + if (outputs != null) { + for (String key : outputs.keySet ()) { + if (key != null && key.startsWith ("subnet_id_")) //multiples subnet_%aaid% outputs + { + String subnetUUId = (String) outputs.get(key); + sMap.put (key.substring("subnet_id_".length()), subnetUUId); + } + else if (key != null && key.startsWith ("subnet")) //one subnet output expected + { + Map <String, String> map = getSubnetUUId(key, outputs, null); + sMap.putAll(map); + } + + } + } + subnetIdMap.value = sMap; + } else { + // Input ID was not a Heat stack ID. Try it directly in Neutron + neutronId = networkNameOrId; + mode = NEUTRON_MODE; + } + + // Query directly against the Neutron Network for the details + // no RouteTargets available for ContrailV2 in neutron net-show + // networkId is heatStackId + long queryNetworkStarttime = System.currentTimeMillis (); + try { + NetworkInfo netInfo = neutron.queryNetwork (neutronId, tenantId, cloudSiteId); + LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryNetwork", null); + if (netInfo != null) { + // Found. Populate the output elements + networkExists.value = Boolean.TRUE; + if ("HEAT".equals (mode)) { + networkId.value = heatStack.getCanonicalName (); + } else { + networkId.value = netInfo.getId (); + } + neutronNetworkId.value = netInfo.getId (); + status.value = netInfo.getStatus (); + if (vlans != null) + vlans.value = netInfo.getVlans (); + + LOGGER.debug ("Network " + networkNameOrId + + " found (" + + mode + + "), ID = " + + networkId.value + + ("HEAT".equals (mode) ? ",NeutronId = " + neutronNetworkId.value : "")); + } else { + // Not found. Populate the status fields, leave the rest null + networkExists.value = Boolean.FALSE; + status.value = NetworkStatus.NOTFOUND; + neutronNetworkId.value = null; + if (vlans != null) + vlans.value = new ArrayList <Integer> (); + + LOGGER.debug ("Network " + networkNameOrId + " not found"); + } + } catch (MsoException me) { + me.addContext ("QueryNetwork"); + String error = "Query Network (neutron): " + networkNameOrId + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryNetwork", null); + LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkNameOrId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - Query Network (neutron)", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException (me); + } + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully queried network"); + return; + } + + /** + * This is the "Delete Network" web service implementation. + * It will delete a Network in the specified cloud and tenant. + * + * If the network is not found, it is treated as a success. + * + * This service supports two modes of Network creation/update/delete: + * - via Heat Templates + * - via Neutron API + * The network orchestration mode for each network type is declared in its + * catalog definition. + * + * For Heat-based orchestration, the networkId should be the stack ID. + * For Neutron-based orchestration, the networkId should be the Neutron network UUID. + * + * The method returns nothing on success. Rollback is not possible for delete + * commands, so any failure on delete will require manual fallout in the client. + */ + @Override + public void deleteNetwork (String cloudSiteId, + String tenantId, + String networkType, + String networkId, + MsoRequest msoRequest, + Holder <Boolean> networkDeleted) throws NetworkException { + MsoLogger.setLogContext (msoRequest); + MsoLogger.setServiceName ("DeleteNetwork"); + LOGGER.debug ("*** DELETE Network adapter with Network: " + networkId + + " in " + + cloudSiteId + + "/" + + tenantId); + + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + + try (CatalogDatabase db = getCatalogDb()) { + if (isNullOrEmpty (cloudSiteId) + || isNullOrEmpty(tenantId) + || isNullOrEmpty(networkId)) { + String error = "Missing mandatory parameter cloudSiteId, tenantId or networkId"; + LOGGER.error (MessageEnum.RA_MISSING_PARAM, "cloudSiteId or tenantId or networkId", "Openstack", "", MsoLogger.ErrorCode.DataError, "Missing mandatory parameter cloudSiteId, tenantId or networkId"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + throw new NetworkException (error, MsoExceptionCategory.USERDATA); + } + + // Retrieve the Network Resource definition + NetworkResource networkResource = db.getNetworkResource (networkType); + if (networkResource == null) { + String error = "Unknown Network Type: " + networkType; + LOGGER.error (MessageEnum.RA_UNKOWN_PARAM, "Network Type", networkType, "Openstack", "", MsoLogger.ErrorCode.DataError, "Unknown Network Type"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + throw new NetworkException (error, MsoExceptionCategory.USERDATA); + } + LOGGER.debug ("Got Network definition from Catalog: " + networkResource.toString ()); + + String mode = networkResource.getOrchestrationMode (); + + if (NEUTRON_MODE.equals (mode)) { + + // Use MsoNeutronUtils for all NEUTRON commands + MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory); + long deleteNetworkStarttime = System.currentTimeMillis (); + try { + // The deleteNetwork function in MsoNeutronUtils returns success if the network + // was not found. So don't bother to query first. + boolean deleted = neutron.deleteNetwork (networkId, tenantId, cloudSiteId); + LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteNetwork", null); + networkDeleted.value = deleted; + } catch (MsoException me) { + me.addContext ("DeleteNetwork"); + String error = "Delete Network (neutron): " + networkId + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null); + LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Delete Network (neutron)", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException (me); + } + } else if ("HEAT".equals (mode)) { + long deleteStackStarttime = System.currentTimeMillis (); + // Use MsoHeatUtils for all HEAT commands + MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + + try { + // The deleteStack function in MsoHeatUtils returns NOTFOUND if the stack was not found or if the stack was deleted. + // So query first to report back if stack WAS deleted or just NOTOFUND + StackInfo heatStack = null; + heatStack = heat.queryStack(cloudSiteId, tenantId, networkId); + if (heatStack != null && heatStack.getStatus() != HeatStatus.NOTFOUND) + { + heat.deleteStack (tenantId, cloudSiteId, networkId, true); + LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", null); + networkDeleted.value = true; + } + else + { + networkDeleted.value = false; + } + } catch (MsoException me) { + me.addContext ("DeleteNetwork"); + String error = "Delete Network (heat): " + networkId + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null); + LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Delete Network (heat)", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException (me); + } + } + } + + // On success, nothing is returned. + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully deleted network"); + return; + } + + public CatalogDatabase getCatalogDb() { + return new CatalogDatabase(); + } + + /** + * This web service endpoint will rollback a previous Create VNF operation. + * A rollback object is returned to the client in a successful creation + * response. The client can pass that object as-is back to the rollbackVnf + * operation to undo the creation. + * + * The rollback includes removing the VNF and deleting the tenant if the + * tenant did not exist prior to the VNF creation. + */ + @Override + public void rollbackNetwork (NetworkRollback rollback) throws NetworkException { + MsoLogger.setServiceName ("RollbackNetwork"); + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + + if (rollback == null) { + LOGGER.error (MessageEnum.RA_ROLLBACK_NULL, "Openstack", "", MsoLogger.ErrorCode.DataError, "rollback is null"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "No action to perform"); + return; + } + + MsoLogger.setLogContext (rollback.getMsoRequest()); + + // Get the elements of the VnfRollback object for easier access + String cloudSiteId = rollback.getCloudId (); + String tenantId = rollback.getTenantId (); + String networkId = rollback.getNetworkStackId (); + String networkType = rollback.getNetworkType (); + + LOGGER.debug ("*** ROLLBACK Network " + networkId + " in " + cloudSiteId + "/" + tenantId); + + // rollback may be null (e.g. if network already existed when Create was called) + // Get a handle to the Catalog Database + + try (CatalogDatabase db = getCatalogDb()){ + + // Retrieve the Network Resource definition + NetworkResource networkResource = db.getNetworkResource (networkType); + if (networkResource == null) { + String error = "Rollback Network: Unknown Network Type: " + networkType; + LOGGER.error (MessageEnum.RA_UNKOWN_PARAM, "Network Type", networkType, "Openstack", "", MsoLogger.ErrorCode.DataError, "Rollback Network: Unknown Network Type"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + throw new NetworkException (error, MsoExceptionCategory.USERDATA); + } + LOGGER.debug ("Got Network definition from Catalog: " + networkResource.toString ()); + + String mode = networkResource.getOrchestrationMode (); + + if (rollback.getNetworkCreated ()) { + // Rolling back a newly created network, so delete it. + if (NEUTRON_MODE.equals (mode)) { + // Use MsoNeutronUtils for all NEUTRON commands + MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory); + long deleteNetworkStarttime = System.currentTimeMillis (); + try { + // The deleteNetwork function in MsoNeutronUtils returns success if the network + // was not found. So don't bother to query first. + neutron.deleteNetwork (networkId, tenantId, cloudSiteId); + LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteNetwork", null); + } catch (MsoException me) { + me.addContext ("RollbackNetwork"); + String error = "Rollback Network (neutron): " + networkId + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null); + LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (neutron)", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException (me); + } + } else if ("HEAT".equals (mode)) { + // Use MsoHeatUtils for all HEAT commands + MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + long deleteStackStarttime = System.currentTimeMillis (); + try { + // The deleteStack function in MsoHeatUtils returns success if the stack + // was not found. So don't bother to query first. + heat.deleteStack (tenantId, cloudSiteId, networkId, true); + LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", null); + } catch (MsoException me) { + me.addContext ("RollbackNetwork"); + String error = "Rollback Network (heat): " + networkId + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null); + LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (heat)", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException (me); + } + } + } + } + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully rolled back network"); + return; + } + + private String validateNetworkParams (NetworkType neutronNetworkType, + String networkName, + String physicalNetwork, + List <Integer> vlans, + List <String> routeTargets) { + String sep = ""; + StringBuilder missing = new StringBuilder (); + if (isNullOrEmpty(networkName)) { + missing.append ("networkName"); + sep = ","; + } + + if (neutronNetworkType == NetworkType.PROVIDER || neutronNetworkType == NetworkType.MULTI_PROVIDER) { + if (isNullOrEmpty(physicalNetwork)) { + missing.append (sep).append ("physicalNetworkName"); + sep = ","; + } + if (vlans == null || vlans.isEmpty ()) { + missing.append (sep).append (VLANS); + } + } + + return missing.toString (); + } + + private Map <String, Object> populateNetworkParams (NetworkType neutronNetworkType, + String networkName, + String physicalNetwork, + List <Integer> vlans, + List <String> routeTargets, + String shared, + String external, + boolean aic3template) { + // Build the common set of HEAT template parameters + Map <String, Object> stackParams = new HashMap <String, Object> (); + stackParams.put ("network_name", networkName); + + if (neutronNetworkType == NetworkType.PROVIDER) { + // For Provider type + stackParams.put (PHYSICAL_NETWORK, physicalNetwork); + stackParams.put ("vlan", vlans.get (0).toString ()); + } else if (neutronNetworkType == NetworkType.MULTI_PROVIDER) { + // For Multi-provider, PO supports a custom resource extension of ProviderNet. + // It supports all ProviderNet properties except segmentation_id, and adds a + // comma-separated-list of VLANs as a "segments" property. + // Note that this does not match the Neutron definition of Multi-Provider network, + // which contains a list of 'segments', each having physical_network, network_type, + // and segmentation_id. + StringBuilder buf = new StringBuilder (); + String sep = ""; + for (Integer vlan : vlans) { + buf.append (sep).append (vlan.toString ()); + sep = ","; + } + String csl = buf.toString (); + + stackParams.put (PHYSICAL_NETWORK, physicalNetwork); + stackParams.put (VLANS, csl); + } + if (routeTargets != null && !routeTargets.isEmpty()) { + StringBuilder buf = new StringBuilder (); + String sep = ""; + for (String rt : routeTargets) { + if (!isNullOrEmpty(rt)) + { + if (aic3template) + buf.append (sep).append ("target:" + rt.toString ()); + else + buf.append (sep).append (rt.toString ()); + + sep = ","; + } + } + String csl = buf.toString (); + + stackParams.put ("route_targets", csl); + } + if (isNullOrEmpty(shared)) { + stackParams.put ("shared", "False"); + } else { + stackParams.put ("shared", shared); + } + if (isNullOrEmpty(external)) { + stackParams.put ("external", "False"); + } else { + stackParams.put ("external", external); + } + return stackParams; + } + + + + /** policyRef_list structure in stackParams + [ + { + "network_policy_refs_data_sequence": { + "network_policy_refs_data_sequence_major": "1", + "network_policy_refs_data_sequence_minor": "0" + } + }, + { + "network_policy_refs_data_sequence": { + "network_policy_refs_data_sequence_major": "2", + "network_policy_refs_data_sequence_minor": "0" + } + } + ] + **/ + private void mergePolicyRefs(List <String> pFqdns, Map <String, Object> stackParams) throws MsoException { + //Resource Property + List<ContrailPolicyRef> prlist = new ArrayList <ContrailPolicyRef> (); + int index = 1; + for (String pf : pFqdns) { + if (!isNullOrEmpty(pf)) + { + ContrailPolicyRef pr = new ContrailPolicyRef(); + pr.populate(String.valueOf(index), "0"); + index++; + LOGGER.debug("Contrail PolicyRefs Data:" + pr.toString()); + prlist.add(pr); + } + } + + JsonNode node = null; + try + { + ObjectMapper mapper = new ObjectMapper(); + node = mapper.convertValue(prlist, JsonNode.class); + String jsonString = mapper.writeValueAsString(prlist); + LOGGER.debug("Json PolicyRefs Data:" + jsonString); + } + catch (Exception e) + { + String error = "Error creating JsonNode for policyRefs Data"; + LOGGER.error (MessageEnum.RA_MARSHING_ERROR, error, "Openstack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception creating JsonNode for policyRefs Data", e); + throw new MsoAdapterException (error); + } + //update parameters + if (pFqdns != null && node != null) + { + StringBuilder buf = new StringBuilder (); + String sep = ""; + for (String pf : pFqdns) { + if (!isNullOrEmpty(pf)) + { + buf.append (sep).append (pf.toString ()); + sep = ","; + } + } + String csl = buf.toString (); + stackParams.put ("policy_refs", csl); + stackParams.put ("policy_refsdata", node); + } + + LOGGER.debug ("StackParams updated with policy refs"); + return; + } + + private void mergeRouteTableRefs(List <String> rtFqdns, Map <String, Object> stackParams) throws MsoException { + + //update parameters + if (rtFqdns != null) + { + StringBuilder buf = new StringBuilder (); + String sep = ""; + for (String rtf : rtFqdns) { + if (!isNullOrEmpty(rtf)) + { + buf.append (sep).append (rtf.toString ()); + sep = ","; + } + } + String csl = buf.toString (); + stackParams.put ("route_table_refs", csl); + } + + LOGGER.debug ("StackParams updated with route_table refs"); + return; + } + + + /*** Subnet Output structure from Juniper + { + "ipam_subnets": [ + { + "subnet": { + "ip_prefix": "10.100.1.0", + "ip_prefix_len": 28 + }, + "addr_from_start": null, + "enable_dhcp": false, + "default_gateway": "10.100.1.1", + "dns_nameservers": [], + "dhcp_option_list": null, + "subnet_uuid": "10391fbf-6b9c-4160-825d-2d018b7649cf", + "allocation_pools": [ + { + "start": "10.100.1.3", + "end": "10.100.1.5" + }, + { + "start": "10.100.1.6", + "end": "10.100.1.9" + } + ], + "host_routes": null, + "dns_server_address": "10.100.1.13", + "subnet_name": "subnet_MsoNW1_692c9032-e1a2-4d64-828c-7b9a4fcc05b0" + }, + { + "subnet": { + "ip_prefix": "10.100.2.16", + "ip_prefix_len": 28 + }, + "addr_from_start": null, + "enable_dhcp": true, + "default_gateway": "10.100.2.17", + "dns_nameservers": [], + "dhcp_option_list": null, + "subnet_uuid": "c7aac5ea-66fe-443a-85f9-9c38a608c0f6", + "allocation_pools": [ + { + "start": "10.100.2.18", + "end": "10.100.2.20" + } + ], + "host_routes": null, + "dns_server_address": "10.100.2.29", + "subnet_name": "subnet_MsoNW1_692c9032-e1a2-4d64-828c-7b9a4fcc05b1" + } + ], + "host_routes": null + } + ***/ + private String mergeSubnetsAIC3 (String heatTemplate, List <Subnet> subnets, Map <String, Object> stackParams) throws MsoException { + + //Resource Property + List<ContrailSubnet> cslist = new ArrayList <ContrailSubnet> (); + for (Subnet subnet : subnets) { + ContrailSubnet cs = new ContrailSubnet(); + LOGGER.debug("Input Subnet:" + subnet.toString()); + cs.populateWith(subnet); + LOGGER.debug("Contrail Subnet:" + cs.toString()); + cslist.add(cs); + } + + JsonNode node = null; + try + { + ObjectMapper mapper = new ObjectMapper(); + node = mapper.convertValue(cslist, JsonNode.class); + String jsonString = mapper.writeValueAsString(cslist); + LOGGER.debug("Json Subnet List:" + jsonString); + } + catch (Exception e) + { + String error = "Error creating JsonNode from input subnets"; + LOGGER.error (MessageEnum.RA_MARSHING_ERROR, error, "", "", MsoLogger.ErrorCode.DataError, "Exception creating JsonNode from input subnets", e); + throw new MsoAdapterException (error); + } + //update parameters + if (node != null) + { + stackParams.put ("subnet_list", node); + } + //Outputs - All subnets are in one ipam_subnets structure + String outputTempl = " subnet:\n" + " description: Openstack subnet identifier\n" + + " value: { get_attr: [network, network_ipam_refs, 0, attr]}\n"; + + // append outputs in heatTemplate + int outputsIdx = heatTemplate.indexOf ("outputs:"); + heatTemplate = insertStr (heatTemplate, outputTempl, outputsIdx + 8); + LOGGER.debug ("Template updated with all AIC3.0 subnets:" + heatTemplate); + return heatTemplate; + } + + + private String mergeSubnets (String heatTemplate, List <Subnet> subnets) throws MsoException { + + String resourceTempl = " subnet_%subnetId%:\n" + " type: OS::Neutron::Subnet\n" + + " properties:\n" + + " name: %name%\n" + + " network_id: { get_resource: network }\n" + + " cidr: %cidr%\n"; + + /* make these optional + + " ip_version: %ipversion%\n" + + " enable_dhcp: %enabledhcp%\n" + + " gateway_ip: %gatewayip%\n" + + " allocation_pools:\n" + + " - start: %poolstart%\n" + + " end: %poolend%\n"; + + */ + + String outputTempl = " subnet_id_%subnetId%:\n" + " description: Openstack subnet identifier\n" + + " value: {get_resource: subnet_%subnetId%}\n"; + + String curR = ""; + String curO = ""; + StringBuilder resourcesBuf = new StringBuilder (); + StringBuilder outputsBuf = new StringBuilder (); + for (Subnet subnet : subnets) { + + // build template for each subnet + curR = resourceTempl; + if (subnet.getSubnetId () != null) { + curR = curR.replace ("%subnetId%", subnet.getSubnetId ()); + } else { + String error = "Missing Required AAI SubnetId for subnet in HEAT Template"; + LOGGER.error (MessageEnum.RA_MISSING_PARAM, error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Missing Required AAI ID for subnet in HEAT Template"); + throw new MsoAdapterException (error); + } + + if (subnet.getSubnetName () != null) { + curR = curR.replace ("%name%", subnet.getSubnetName ()); + } else { + curR = curR.replace ("%name%", subnet.getSubnetId ()); + } + + if (subnet.getCidr () != null) { + curR = curR.replace ("%cidr%", subnet.getCidr ()); + } else { + String error = "Missing Required cidr for subnet in HEAT Template"; + LOGGER.error (MessageEnum.RA_MISSING_PARAM, error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Missing Required cidr for subnet in HEAT Template"); + throw new MsoAdapterException (error); + } + + if (subnet.getIpVersion () != null) { + curR = curR + " ip_version: " + subnet.getIpVersion () + "\n"; + } + if (subnet.getEnableDHCP () != null) { + curR = curR + " enable_dhcp: " + Boolean.toString (subnet.getEnableDHCP ()) + "\n"; + } + if (subnet.getGatewayIp () != null && !subnet.getGatewayIp ().isEmpty() ) { + curR = curR + " gateway_ip: " + subnet.getGatewayIp () + "\n"; + } + + if (subnet.getAllocationPools() != null) { + curR = curR + " allocation_pools:\n"; + for (Pool pool : subnet.getAllocationPools()) + { + if (!isNullOrEmpty(pool.getStart()) && !isNullOrEmpty(pool.getEnd())) + { + curR = curR + " - start: " + pool.getStart () + "\n"; + curR = curR + " end: " + pool.getEnd () + "\n"; + } + } + } + + resourcesBuf.append (curR); + + curO = outputTempl; + curO = curO.replace ("%subnetId%", subnet.getSubnetId ()); + + outputsBuf.append (curO); + + } + // append resources and outputs in heatTemplate + LOGGER.debug ("Tempate initial:" + heatTemplate); + int outputsIdx = heatTemplate.indexOf ("outputs:"); + heatTemplate = insertStr (heatTemplate, outputsBuf.toString (), outputsIdx + 8); + int resourcesIdx = heatTemplate.indexOf ("resources:"); + heatTemplate = insertStr (heatTemplate, resourcesBuf.toString (), resourcesIdx + 10); + + LOGGER.debug ("Template updated with all subnets:" + heatTemplate); + return heatTemplate; + } + + private Map <String, String> getSubnetUUId(String key, Map <String, Object> outputs, List <Subnet> subnets) { + + Map <String, String> sMap = new HashMap <String, String> (); + + try{ + Object obj = outputs.get(key); + ObjectMapper mapper = new ObjectMapper(); + String jStr = mapper.writeValueAsString(obj); + LOGGER.debug ("Subnet_Ipam Output JSON String:" + obj.getClass() + " " + jStr); + + JsonNode rootNode = mapper.readTree(jStr); + for (JsonNode sNode : rootNode.path("ipam_subnets")) + { + LOGGER.debug("Output Subnet Node" + sNode.toString()); + String name = sNode.path("subnet_name").getTextValue(); + String uuid = sNode.path("subnet_uuid").getTextValue(); + String aaiId = name; // default + // try to find aaiId for name in input subnetList + if (subnets != null) + { + for (Subnet subnet : subnets) + { + if ( subnet != null && !isNullOrEmpty(subnet.getSubnetName())) + { + if (subnet.getSubnetName().equals(name)) + { + aaiId = subnet.getSubnetId(); + break; + } + } + } + } + sMap.put(aaiId, uuid); //bpmn needs aaid to uuid map + } + } + catch (Exception e) + { + LOGGER.error (MessageEnum.RA_MARSHING_ERROR, "error getting subnet-uuids", "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception getting subnet-uuids", e); + } + + LOGGER.debug ("Return sMap" + sMap.toString()); + return sMap; + } + + private static String insertStr (String template, String snippet, int index) { + + String updatedTemplate = ""; + + LOGGER.debug ("Index:" + index + " Snippet:" + snippet); + + String templateBeg = template.substring (0, index); + String templateEnd = template.substring (index); + + updatedTemplate = templateBeg + "\n" + snippet + templateEnd; + + LOGGER.debug ("Template updated with a subnet:" + updatedTemplate); + return updatedTemplate; + } + +} diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java new file mode 100644 index 0000000000..c813534212 --- /dev/null +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java @@ -0,0 +1,595 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.network; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.GenericEntity; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.xml.ws.Holder; + +import org.apache.http.HttpStatus; + +import org.openecomp.mso.adapters.network.exceptions.NetworkException; +import org.openecomp.mso.adapters.nwrest.ContrailNetwork; +import org.openecomp.mso.adapters.nwrest.CreateNetworkError; +import org.openecomp.mso.adapters.nwrest.CreateNetworkRequest; +import org.openecomp.mso.adapters.nwrest.CreateNetworkResponse; +import org.openecomp.mso.adapters.nwrest.DeleteNetworkError; +import org.openecomp.mso.adapters.nwrest.DeleteNetworkRequest; +import org.openecomp.mso.adapters.nwrest.DeleteNetworkResponse; +import org.openecomp.mso.adapters.nwrest.ProviderVlanNetwork; +import org.openecomp.mso.adapters.nwrest.QueryNetworkError; +import org.openecomp.mso.adapters.nwrest.QueryNetworkResponse; +import org.openecomp.mso.adapters.nwrest.RollbackNetworkError; +import org.openecomp.mso.adapters.nwrest.RollbackNetworkRequest; +import org.openecomp.mso.adapters.nwrest.RollbackNetworkResponse; +import org.openecomp.mso.adapters.nwrest.UpdateNetworkError; +import org.openecomp.mso.adapters.nwrest.UpdateNetworkRequest; +import org.openecomp.mso.adapters.nwrest.UpdateNetworkResponse; +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.beans.NetworkRollback; +import org.openecomp.mso.openstack.beans.NetworkStatus; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +@Path("/v1/networks") +public class NetworkAdapterRest { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static final String TESTING_KEYWORD = "___TESTING___"; + private final CloudConfigFactory cloudConfigFactory = new CloudConfigFactory(); + private final MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + private final MsoNetworkAdapterImpl adapter = new MsoNetworkAdapterImpl(msoPropertiesFactory, cloudConfigFactory); + + @POST + @Path("") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response createNetwork(CreateNetworkRequest req) { + LOGGER.debug("createNetwork enter: " + req.toJsonString()); + CreateNetworkTask task = new CreateNetworkTask(req); + if (req.isSynchronous()) { + // This is a synchronous request + task.run(); + return Response + .status(task.getStatusCode()) + .entity(task.getGenericEntityResponse()) + .build(); + } else { + // This is an asynchronous request + try { + Thread t1 = new Thread(task); + t1.start(); + } catch (Exception e) { + // problem handling create, send generic failure as sync resp to caller + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while create network", e); + return Response.serverError().build(); + } + // send sync response (ACK) to caller + LOGGER.debug ("createNetwork exit"); + return Response.status(HttpStatus.SC_ACCEPTED).build(); + } + } + + public class CreateNetworkTask implements Runnable { + private final CreateNetworkRequest req; + private CreateNetworkResponse response = null; + private CreateNetworkError eresp = null; + private boolean sendxml; + + public CreateNetworkTask(CreateNetworkRequest req) { + this.req = req; + this.sendxml = true; // can be set with a field or header later + } + public int getStatusCode() { + return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; + } + public Object getGenericEntityResponse() { + return (response != null) + ? new GenericEntity<CreateNetworkResponse>(response) {} + : new GenericEntity<CreateNetworkError>(eresp) {}; + } + private String getResponse() { + if (response != null) { + return sendxml ? response.toXmlString() : response.toJsonString(); + } else { + return sendxml ? eresp.toXmlString() : eresp.toJsonString(); + } + } + @Override + public void run() { + LOGGER.debug ("CreateNetworkTask start"); + try { + // Synchronous Web Service Outputs + Holder<String> networkId = new Holder<String>(); + Holder<String> neutronNetworkId = new Holder<String>(); + Holder<String> networkFqdn = new Holder<String>(); + Holder<Map<String, String>> subnetIdMap = new Holder<Map<String, String>>(); + Holder<NetworkRollback> rollback = new Holder<NetworkRollback>(); + + String cloudsite = req.getCloudSiteId(); + if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) { + String tenant = req.getTenantId(); + if (tenant != null && tenant.equals(TESTING_KEYWORD)) { + throw new NetworkException("testing."); + } + networkId.value = "479D3D8B-6360-47BC-AB75-21CC91981484"; + neutronNetworkId.value = "55e55884-28fa-11e6-8971-0017f20fe1b8"; + networkFqdn.value = "086f70b6-28fb-11e6-8260-0017f20fe1b8"; + subnetIdMap.value = testMap(); + rollback.value = new NetworkRollback(); + } else if (req.isContrailRequest()) { + ContrailNetwork ctn = req.getContrailNetwork(); + if (ctn == null) { + ctn = new ContrailNetwork(); + req.setContrailNetwork(ctn); + } + adapter.createNetworkContrail( + req.getCloudSiteId(), + req.getTenantId(), + req.getNetworkType(), + req.getNetworkName(), + req.getContrailNetwork().getRouteTargets(), + req.getContrailNetwork().getShared(), + req.getContrailNetwork().getExternal(), + req.getFailIfExists(), + req.getBackout(), + req.getSubnets(), + req.getContrailNetwork().getPolicyFqdns(), + req.getContrailNetwork().getRouteTableFqdns(), + req.getMsoRequest(), + networkId, + neutronNetworkId, + networkFqdn, + subnetIdMap, + rollback); + } else { + ProviderVlanNetwork pvn = req.getProviderVlanNetwork(); + if (pvn == null) { + pvn = new ProviderVlanNetwork(); + req.setProviderVlanNetwork(pvn); + } + adapter.createNetwork( + req.getCloudSiteId(), + req.getTenantId(), + req.getNetworkType(), + req.getNetworkName(), + req.getProviderVlanNetwork().getPhysicalNetworkName(), + req.getProviderVlanNetwork().getVlans(), + req.getFailIfExists(), + req.getBackout(), + req.getSubnets(), + req.getMsoRequest(), + networkId, + neutronNetworkId, + subnetIdMap, + rollback); + } + response = new CreateNetworkResponse( + req.getNetworkId(), + neutronNetworkId.value, + rollback.value.getNetworkStackId(), + networkFqdn.value, + rollback.value.getNetworkCreated(), + subnetIdMap.value, + rollback.value, + req.getMessageId()); + } catch (NetworkException e) { + eresp = new CreateNetworkError( + e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); + } + if (!req.isSynchronous()) { + // This is asynch, so POST response back to caller + BpelRestClient bpelClient = new BpelRestClient(); + bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); + } + LOGGER.debug ("CreateNetworkTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); + } + } + + @DELETE + @Path("{aaiNetworkId}") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response deleteNetwork( + @PathParam("aaiNetworkId") String aaiNetworkId, + DeleteNetworkRequest req) + { + LOGGER.debug("deleteNetwork enter: " + req.toJsonString()); + if (aaiNetworkId == null || !aaiNetworkId.equals(req.getNetworkId())) { + return Response + .status(HttpStatus.SC_BAD_REQUEST) + .type(MediaType.TEXT_PLAIN) + .entity("A&AI NetworkId in URL ("+aaiNetworkId+") does not match content ("+req.getNetworkId()+")") + .build(); + } + DeleteNetworkTask task = new DeleteNetworkTask(req); + if (req.isSynchronous()) { + // This is a synchronous request + task.run(); + return Response + .status(task.getStatusCode()) + .entity(task.getGenericEntityResponse()) + .build(); + } else { + // This is an asynchronous request + try { + Thread t1 = new Thread(task); + t1.start(); + } catch (Exception e) { + // problem handling create, send generic failure as sync resp to caller + LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while delete network", e); + return Response.serverError().build(); + } + // send sync response (ACK) to caller + LOGGER.debug ("deleteNetwork exit"); + return Response.status(HttpStatus.SC_ACCEPTED).build(); + } + } + + public class DeleteNetworkTask implements Runnable { + private final DeleteNetworkRequest req; + private DeleteNetworkResponse response = null; + private DeleteNetworkError eresp = null; + private boolean sendxml; + + public DeleteNetworkTask(DeleteNetworkRequest req) { + this.req = req; + this.sendxml = true; // can be set with a field or header later + } + public int getStatusCode() { + return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; + } + public Object getGenericEntityResponse() { + return (response != null) + ? new GenericEntity<DeleteNetworkResponse>(response) {} + : new GenericEntity<DeleteNetworkError>(eresp) {}; + } + private String getResponse() { + if (response != null) { + return sendxml ? response.toXmlString() : response.toJsonString(); + } else { + return sendxml ? eresp.toXmlString() : eresp.toJsonString(); + } + } + @Override + public void run() { + LOGGER.debug("DeleteNetworkTask start"); + try { + Holder<Boolean> networkDeleted = new Holder<Boolean>(); + if (req.getCloudSiteId().equals(TESTING_KEYWORD)) { + networkDeleted.value = true; + } else { + adapter.deleteNetwork( + req.getCloudSiteId(), + req.getTenantId(), + req.getNetworkType(), + req.getNetworkStackId(), + req.getMsoRequest(), + networkDeleted); + } + response = new DeleteNetworkResponse(req.getNetworkId(), networkDeleted.value, req.getMessageId()); + } catch (NetworkException e) { + eresp = new DeleteNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); + } + if (!req.isSynchronous()) { + // This is asynch, so POST response back to caller + BpelRestClient bpelClient = new BpelRestClient(); + bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); + } + LOGGER.debug("DeleteNetworkTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); + } + } + + @GET + @Path("{aaiNetworkId}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response queryNetwork( + @QueryParam("cloudSiteId") String cloudSiteId, + @QueryParam("tenantId") String tenantId, + @QueryParam("networkStackId") String networkStackId, + @QueryParam("skipAAI") String skipAAI, + @QueryParam("msoRequest.requestId") String requestId, + @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId, + @PathParam("aaiNetworkId") String aaiNetworkId) + { + //This request responds synchronously only + LOGGER.debug ("Query network enter:" + aaiNetworkId); + MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId); + + try { + int respStatus = HttpStatus.SC_OK; + QueryNetworkResponse resp = new QueryNetworkResponse(networkStackId, null, networkStackId, null, null); + Holder<Boolean> networkExists = new Holder<Boolean>(); + Holder<String> networkId = new Holder<String>(); + Holder<String> neutronNetworkId = new Holder<String>(); + Holder<NetworkStatus> status = new Holder<NetworkStatus>(); + Holder<List<String>> routeTargets = new Holder<List<String>>(); + Holder<Map<String, String>> subnetIdMap = new Holder<Map<String, String>>(); + + adapter.queryNetworkContrail(cloudSiteId, tenantId, aaiNetworkId, msoRequest, + networkExists, networkId, neutronNetworkId, status, routeTargets, subnetIdMap); + + if (!networkExists.value) { + LOGGER.debug ("network not found"); + respStatus = HttpStatus.SC_NOT_FOUND; + } else { + LOGGER.debug ("network found" + networkId.value + ", status=" + status.value); + resp.setNetworkExists(networkExists.value); + resp.setNetworkId(networkId.value); + resp.setNeutronNetworkId(neutronNetworkId.value); + resp.setNetworkStatus(status.value); + resp.setRouteTargets(routeTargets.value); + resp.setSubnetIdMap(subnetIdMap.value); + } + LOGGER.debug ("Query network exit"); + return Response + .status(respStatus) + .entity(new GenericEntity<QueryNetworkResponse>(resp) {}) + .build(); + } catch (NetworkException e) { + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, aaiNetworkId, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception when query VNF", e); + QueryNetworkError err = new QueryNetworkError(); + err.setMessage(e.getMessage()); + err.setCategory(MsoExceptionCategory.INTERNAL); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<QueryNetworkError>(err) {}) + .build(); + } + } + + @DELETE + @Path("{aaiNetworkId}/rollback") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response rollbackNetwork( + RollbackNetworkRequest req) + { + LOGGER.debug("rollbackNetwork enter: " + req.toJsonString()); + RollbackNetworkTask task = new RollbackNetworkTask(req); + if (req.isSynchronous()) { + // This is a synchronous request + task.run(); + return Response + .status(task.getStatusCode()) + .entity(task.getGenericEntityResponse()) + .build(); + } else { + // This is an asynchronous request + try { + Thread t1 = new Thread(task); + t1.start(); + } catch (Exception e) { + // problem handling create, send generic failure as sync resp to caller + LOGGER.error (MessageEnum.RA_ROLLBACK_NULL, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in rollbackNetwork", e); + return Response.serverError().build(); + } + // send sync response (ACK) to caller + LOGGER.debug("rollbackNetwork exit"); + return Response.status(HttpStatus.SC_ACCEPTED).build(); + } + } + + public class RollbackNetworkTask implements Runnable { + private final RollbackNetworkRequest req; + private RollbackNetworkResponse response = null; + private RollbackNetworkError eresp = null; + private boolean sendxml; + + public RollbackNetworkTask(RollbackNetworkRequest req) { + this.req = req; + this.sendxml = true; // can be set with a field or header later + } + public int getStatusCode() { + return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; + } + public Object getGenericEntityResponse() { + return (response != null) + ? new GenericEntity<RollbackNetworkResponse>(response) {} + : new GenericEntity<RollbackNetworkError>(eresp) {}; + } + private String getResponse() { + if (response != null) { + return sendxml ? response.toXmlString() : response.toJsonString(); + } else { + return sendxml ? eresp.toXmlString() : eresp.toJsonString(); + } + } + @Override + public void run() { + LOGGER.debug("RollbackNetworkTask start"); + try { + NetworkRollback nwr = req.getNetworkRollback(); + adapter.rollbackNetwork(nwr); + response = new RollbackNetworkResponse(true, req.getMessageId()); + } catch (NetworkException e) { + eresp = new RollbackNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); + } + if (!req.isSynchronous()) { + // This is asynch, so POST response back to caller + BpelRestClient bpelClient = new BpelRestClient(); + bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); + } + LOGGER.debug("RollbackNetworkTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); + } + } + + @PUT + @Path("{aaiNetworkId}") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response updateNetwork( + @PathParam("aaiNetworkId") String aaiNetworkId, + UpdateNetworkRequest req) + { + LOGGER.debug("updateNetwork enter: " + req.toJsonString()); + if (aaiNetworkId == null || !aaiNetworkId.equals(req.getNetworkId())) { + return Response + .status(HttpStatus.SC_BAD_REQUEST) + .type(MediaType.TEXT_PLAIN) + .entity("A&AI NetworkId in URL ("+aaiNetworkId+") does not match content ("+req.getNetworkId()+")") + .build(); + } + UpdateNetworkTask task = new UpdateNetworkTask(req); + if (req.isSynchronous()) { + // This is a synchronous request + task.run(); + return Response + .status(task.getStatusCode()) + .entity(task.getGenericEntityResponse()) + .build(); + } else { + // This is an asynchronous request + try { + Thread t1 = new Thread(task); + t1.start(); + } catch (Exception e) { + // problem handling create, send generic failure as sync resp to caller + LOGGER.error (MessageEnum.RA_UPDATE_NETWORK_ERR, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in updateNetwork", e); + return Response.serverError().build(); + } + // send sync response (ACK) to caller + LOGGER.debug ("updateNetwork exit"); + return Response.status(HttpStatus.SC_ACCEPTED).build(); + } + } + + public class UpdateNetworkTask implements Runnable { + private final UpdateNetworkRequest req; + private UpdateNetworkResponse response = null; + private UpdateNetworkError eresp = null; + private boolean sendxml; + + public UpdateNetworkTask(UpdateNetworkRequest req) { + this.req = req; + this.sendxml = true; // can be set with a field or header later + } + public int getStatusCode() { + return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; + } + public Object getGenericEntityResponse() { + return (response != null) + ? new GenericEntity<UpdateNetworkResponse>(response) {} + : new GenericEntity<UpdateNetworkError>(eresp) {}; + } + private String getResponse() { + if (response != null) { + return sendxml ? response.toXmlString() : response.toJsonString(); + } else { + return sendxml ? eresp.toXmlString() : eresp.toJsonString(); + } + } + @Override + public void run() { + LOGGER.debug("UpdateNetworkTask start"); + try { + Holder<Map<String, String>> subnetIdMap = new Holder<Map<String, String>>(); + Holder<NetworkRollback> rollback = new Holder<NetworkRollback> (); + + if (req.getCloudSiteId().equals(TESTING_KEYWORD)) { + subnetIdMap.value = testMap(); + NetworkRollback rb = new NetworkRollback (); + rb.setCloudId(req.getCloudSiteId()); + rb.setTenantId(req.getTenantId()); + rb.setMsoRequest(req.getMsoRequest()); + rollback.value = rb; + } else if (req.isContrailRequest()) { + ContrailNetwork ctn = req.getContrailNetwork(); + if (ctn == null) { + ctn = new ContrailNetwork(); + req.setContrailNetwork(ctn); + } + adapter.updateNetworkContrail( + req.getCloudSiteId(), + req.getTenantId(), + req.getNetworkType(), + req.getNetworkStackId(), + req.getNetworkName(), + req.getContrailNetwork().getRouteTargets(), + req.getContrailNetwork().getShared(), + req.getContrailNetwork().getExternal(), + req.getSubnets(), + req.getContrailNetwork().getPolicyFqdns(), + req.getContrailNetwork().getRouteTableFqdns(), + req.getMsoRequest(), + subnetIdMap, + rollback); + } else { + ProviderVlanNetwork pvn = req.getProviderVlanNetwork(); + if (pvn == null) { + pvn = new ProviderVlanNetwork(); + req.setProviderVlanNetwork(pvn); + } + adapter.updateNetwork( + req.getCloudSiteId(), + req.getTenantId(), + req.getNetworkType(), + req.getNetworkStackId(), + req.getNetworkName(), + req.getProviderVlanNetwork().getPhysicalNetworkName(), + req.getProviderVlanNetwork().getVlans(), + req.getSubnets(), + req.getMsoRequest(), + subnetIdMap, + rollback); + } + response = new UpdateNetworkResponse( + req.getNetworkId(), + null, // NeutronNetworkId is not available from an update + subnetIdMap.value, + req.getMessageId()); + } catch (NetworkException e) { + eresp = new UpdateNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); + } + if (!req.isSynchronous()) { + // This is asynch, so POST response back to caller + BpelRestClient bpelClient = new BpelRestClient(); + bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); + } + LOGGER.debug("UpdateNetworkTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); + } + } + + public static Map<String, String> testMap() { + Map<String, String> m = new HashMap<String, String>(); + m.put("mickey", "7"); + m.put("clyde", "10"); + m.put("wayne", "99"); + return m; + } +} diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/exceptions/NetworkException.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/exceptions/NetworkException.java new file mode 100644 index 0000000000..0fd4d02933 --- /dev/null +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/exceptions/NetworkException.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.network.exceptions; + + + +import javax.xml.ws.WebFault; + +import org.openecomp.mso.adapters.network.exceptions.NetworkExceptionBean; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +/** + * This class simply extends Exception (without addition additional functionality) + * to provide an identifier for Network related exceptions on create, delete, query. + * + * + */ +@WebFault (name="NetworkException", faultBean="org.openecomp.mso.adapters.network.exceptions.NetworkExceptionBean", targetNamespace="http://com.att.mso/network") +public class NetworkException extends Exception { + + private static final long serialVersionUID = 1L; + + private NetworkExceptionBean faultInfo; + + public NetworkException (String msg) { + super(msg); + faultInfo = new NetworkExceptionBean (msg); + } + + public NetworkException (Throwable e) { + super(e); + faultInfo = new NetworkExceptionBean (e.getMessage()); + } + + public NetworkException (String msg, Throwable e) { + super (msg, e); + faultInfo = new NetworkExceptionBean (msg); + } + + public NetworkException (String msg, MsoExceptionCategory category) { + super(msg); + faultInfo = new NetworkExceptionBean (msg, category); + } + + public NetworkException (String msg, MsoExceptionCategory category, Throwable e) { + super (msg, e); + faultInfo = new NetworkExceptionBean (msg, category); + } + + public NetworkException (MsoException e) { + super (e); + faultInfo = new NetworkExceptionBean (e.getContextMessage(), e.getCategory()); + } + + public NetworkExceptionBean getFaultInfo() { + return faultInfo; + } + + public void setFaultInfo(NetworkExceptionBean faultInfo) { + this.faultInfo = faultInfo; + } +} diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionBean.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionBean.java new file mode 100644 index 0000000000..af4e0e386e --- /dev/null +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionBean.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.network.exceptions; + + +import java.io.Serializable; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +/** + * Jax-WS Fault Bean for Network Exceptions + */ +public class NetworkExceptionBean implements Serializable { + + private static final long serialVersionUID = 1655343530371342871L; + + private String message; + private MsoExceptionCategory category; + private Boolean rolledBack; + + public NetworkExceptionBean () {} + + public NetworkExceptionBean (String message) { + this.message = message; + } + + public NetworkExceptionBean (String message, MsoExceptionCategory category) { + this.message = message; + this.category = category; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public MsoExceptionCategory getCategory () { + return category; + } + + public void setCategory (MsoExceptionCategory category) { + this.category = category; + } + + public Boolean isRolledBack() { + return rolledBack; + } + + public void setRolledBack(Boolean rolledBack) { + this.rolledBack = rolledBack; + } +} diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java new file mode 100644 index 0000000000..41cc3f5533 --- /dev/null +++ b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java @@ -0,0 +1,266 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.network; + + +import static org.junit.Assert.assertTrue; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import javax.xml.ws.Holder; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; + +import org.openecomp.mso.adapters.network.exceptions.NetworkException; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.NetworkResource; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.NetworkStatus; +import org.openecomp.mso.openstack.beans.Subnet; +import org.openecomp.mso.openstack.beans.NetworkRollback; + +public class NetworkAdapterTest { + + @Mock + private static MsoNetworkAdapterImpl adapter; + + @Mock + private static CatalogDatabase db; + + @BeforeClass + public static final void prepare () { + adapter = Mockito.spy (new MsoNetworkAdapterImpl ()); + db = Mockito.mock (CatalogDatabase.class); + NetworkResource networkResource = new NetworkResource (); + networkResource.setNetworkType ("PROVIDER"); + networkResource.setNeutronNetworkType ("PROVIDER"); + networkResource.setId (1); + networkResource.setOrchestrationMode ("toto"); + Mockito.when (db.getNetworkResource ("PROVIDER")).thenReturn (networkResource); + Mockito.when (adapter.getCatalogDb()).thenReturn (db); + } + + @Test + public void createTest () { + + List <Integer> vlans = new LinkedList <> (); + vlans.add (1); + vlans.add (2); + List <Subnet> subnets = new LinkedList <> (); + subnets.add (new Subnet ()); + MsoRequest msoRequest = new MsoRequest (); + Holder <String> networkId = new Holder <> (); + Holder <String> neutronNetworkId = new Holder <> (); + Holder <Map <String, String>> subnetIdMap = new Holder <> (); + Holder <NetworkRollback> rollback = new Holder <> (); + try { + adapter.createNetwork ("toto", + "tenant", + "PROVIDER", + "networkName", + "physicalNetworkName", + vlans, + Boolean.TRUE, + Boolean.TRUE, + subnets, + msoRequest, + networkId, + neutronNetworkId, + subnetIdMap, + rollback); + } catch (NetworkException e) { + assertTrue (e.getMessage ().contains ("Configuration Error")); + } + } + + @Test + public void createTest2 () { + List <Integer> vlans = new LinkedList <> (); + vlans.add (1); + vlans.add (2); + List <Subnet> subnets = new LinkedList <> (); + List <String> routeTargets = new LinkedList <> (); + subnets.add (new Subnet ()); + List <String> policyFqdns = new LinkedList <> (); + policyFqdns.add("pfqdn1"); + policyFqdns.add("pfqdn2"); + List <String> routeTableFqdns = new LinkedList <> (); + routeTableFqdns.add("rtfqdn1"); + routeTableFqdns.add("rtfqdn2"); + MsoRequest msoRequest = new MsoRequest (); + Holder <String> networkId = new Holder <> (); + Holder <String> neutronNetworkId = new Holder <> (); + Holder <Map <String, String>> subnetIdMap = new Holder <> (); + Holder <NetworkRollback> rollback = new Holder <> (); + Holder <String> networkFqdn= new Holder <> (); + try { + adapter.createNetworkContrail ("toto", + "tenant", + "PROVIDER", + "networkName", + routeTargets, + "shared", + "external", + Boolean.TRUE, + Boolean.TRUE, + subnets, + policyFqdns, + routeTableFqdns, + msoRequest, + networkId, + neutronNetworkId, + networkFqdn, + subnetIdMap, + rollback); + } catch (NetworkException e) { + assertTrue (e.getMessage ().contains ("Configuration Error")); + } + } + + @Test + public void updateTest () { + List <Integer> vlans = new LinkedList <> (); + vlans.add (1); + vlans.add (2); + List <Subnet> subnets = new LinkedList <> (); + subnets.add (new Subnet ()); + MsoRequest msoRequest = new MsoRequest (); + Holder <Map <String, String>> subnetIdMap = new Holder <> (); + Holder <NetworkRollback> rollback = new Holder <> (); + try { + adapter.updateNetwork ("toto", + "tenant", + "PROVIDER", + "networkId", + "networkName", + "physicalNetworkName", + vlans, + subnets, + msoRequest, + subnetIdMap, + rollback); + } catch (NetworkException e) { + assertTrue (e.getMessage ().contains ("Configuration Error")); + } + } + + @Test + public void updateTest2 () { + List <Integer> vlans = new LinkedList <> (); + vlans.add (1); + vlans.add (2); + List <Subnet> subnets = new LinkedList <> (); + List <String> routeTargets = new LinkedList <> (); + subnets.add (new Subnet ()); + List <String> policyFqdns = new LinkedList <> (); + policyFqdns.add("pfqdn1"); + List <String> routeTableFqdns = new LinkedList <> (); + routeTableFqdns.add("rtfqdn1"); + routeTableFqdns.add("rtfqdn2"); + MsoRequest msoRequest = new MsoRequest (); + Holder <Map <String, String>> subnetIdMap = new Holder <> (); + Holder <NetworkRollback> rollback = new Holder <> (); + try { + adapter.updateNetworkContrail ("toto", + "tenant", + "PROVIDER", + "networkId", + "networkName", + routeTargets, + "shared", + "external", + subnets, + policyFqdns, + routeTableFqdns, + msoRequest, + subnetIdMap, + rollback); + } catch (NetworkException e) { + assertTrue (e.getMessage ().contains ("Configuration Error")); + } + } + + @Test + public void queryTest () { + Holder <List <Integer>> vlans = new Holder <> (); + Holder <NetworkStatus> status = new Holder <> (); + MsoRequest msoRequest = new MsoRequest (); + Holder <String> networkId = new Holder <> (); + Holder <Boolean> result = new Holder <> (); + Holder <String> neutronNetworkId = new Holder <> (); + Holder <Map <String, String>> subnetIdMap = new Holder <> (); + try { + adapter.queryNetwork (null, + "tenant", + "networkName", + msoRequest, + result, + networkId, + neutronNetworkId, + status, + vlans, + subnetIdMap); + } catch (NetworkException e) { + assertTrue (e.getMessage ().contains ("Missing mandatory parameter")); + } + } + + @Test + public void queryTest2 () { + Holder <List <String>> routeTargets = new Holder <> (); + Holder <NetworkStatus> status = new Holder <> (); + MsoRequest msoRequest = new MsoRequest (); + Holder <String> networkId = new Holder <> (); + Holder <Boolean> result = new Holder <> (); + Holder <String> neutronNetworkId = new Holder <> (); + Holder <Map <String, String>> subnetIdMap = new Holder <> (); + try { + adapter.queryNetworkContrail (null, + "tenant", + "networkName", + msoRequest, + result, + networkId, + neutronNetworkId, + status, + routeTargets, + subnetIdMap); + } catch (NetworkException e) { + assertTrue (e.getMessage ().contains ("Missing mandatory parameter")); + } + } + + @Test + public void deleteTest () { + Holder <Boolean> networkDeleted = new Holder<> (); + MsoRequest msoRequest = new MsoRequest (); + try { + adapter.deleteNetwork ("toto", "tenant", "PROVIDER", "networkId", msoRequest, networkDeleted); + } catch (NetworkException e) { + assertTrue (e.getMessage ().contains ("Configuration Error")); + } + } +} diff --git a/adapters/mso-network-adapter/src/test/resources/logback-test.xml b/adapters/mso-network-adapter/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..d2c17192ea --- /dev/null +++ b/adapters/mso-network-adapter/src/test/resources/logback-test.xml @@ -0,0 +1,48 @@ +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + 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. + ============LICENSE_END========================================================= + --> + +<configuration > + + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern> + </encoder> + </appender> + + + <logger name="com.att.eelf.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="trace" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <root level="info"> + <appender-ref ref="STDOUT" /> + </root> + + +</configuration> diff --git a/adapters/mso-requests-db-adapter/WebContent/META-INF/MANIFEST.MF b/adapters/mso-requests-db-adapter/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..5e9495128c --- /dev/null +++ b/adapters/mso-requests-db-adapter/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0
+Class-Path:
+
diff --git a/adapters/mso-requests-db-adapter/WebContent/WEB-INF/beans.xml b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/beans.xml new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/beans.xml diff --git a/adapters/mso-requests-db-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 0000000000..88d5024f0d --- /dev/null +++ b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml @@ -0,0 +1,17 @@ +<jboss-deployment-structure>
+ <deployment>
+ <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
+ <exclusions>
+ <module name="org.apache.log4j" />
+ <module name="org.slf4j" />
+ <module name="org.slf4j.impl" />
+ </exclusions>
+ <dependencies>
+ <module name="org.jboss.jandex" slot="main" />
+ <module name="org.javassist" slot="main" />
+ <module name="org.antlr" slot="main" />
+ <module name="org.dom4j" slot="main" />
+ </dependencies>
+ </deployment>
+</jboss-deployment-structure>
+
diff --git a/adapters/mso-requests-db-adapter/WebContent/WEB-INF/jboss-web.xml b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/jboss-web.xml new file mode 100644 index 0000000000..a39d506225 --- /dev/null +++ b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/jboss-web.xml @@ -0,0 +1,3 @@ +<jboss-web>
+ <context-root>dbadapters</context-root>
+</jboss-web>
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000000..7fa3f2a24c --- /dev/null +++ b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/web.xml @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ id="WebApp_ID" version="3.0">
+ <display-name>mso-requests-db-adapter</display-name>
+ <context-param>
+ <param-name>resteasy.scan</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>resteasy.scan.providers</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>resteasy.scan.resources</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>mso.configuration</param-name>
+ <param-value>MSO_PROP_TOPOLOGY=topology.properties</param-value>
+ </context-param>
+
+ <servlet>
+ <servlet-name>Resteasy</servlet-name>
+ <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Resteasy</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+ <filter>
+ <filter-name>LogFilter</filter-name>
+ <filter-class>org.openecomp.mso.logger.LogFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>LogFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <context-param>
+ <param-name>log.configuration</param-name>
+ <param-value>logback.msorequestsdbadapter.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>resteasy.scan</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>resteasy.scan.providers</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>resteasy.scan.resources</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>SiteStatus</web-resource-name>
+ <description>SiteStatus APIs</description>
+ <url-pattern>/setStatus/*</url-pattern>
+ <http-method>POST</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>SiteControl-Client</role-name>
+ </auth-constraint>
+ </security-constraint>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>ApplicationRealm</realm-name>
+ </login-config>
+ <security-role>
+ <role-name>SiteControl-Client</role-name>
+ </security-role>
+</web-app>
diff --git a/adapters/mso-requests-db-adapter/WebContent/index.xhtml b/adapters/mso-requests-db-adapter/WebContent/index.xhtml new file mode 100644 index 0000000000..f902af8cc0 --- /dev/null +++ b/adapters/mso-requests-db-adapter/WebContent/index.xhtml @@ -0,0 +1,19 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+<f:loadBundle basename="resources.application" var="msg"/>
+
+<head>
+ <title><h:outputText value="#{msg.welcomeTitle}" /></title>
+</head>
+
+<body>
+<h3><h:outputText value="#{msg.welcomeHeading}" /></h3>
+<p><h:outputText value="#{msg.welcomeMessage}" /></p>
+</body>
+</html>
diff --git a/adapters/mso-requests-db-adapter/pom.xml b/adapters/mso-requests-db-adapter/pom.xml new file mode 100644 index 0000000000..b14cde1657 --- /dev/null +++ b/adapters/mso-requests-db-adapter/pom.xml @@ -0,0 +1,96 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp.mso</groupId> + <artifactId>adapters</artifactId> + <version>0.0.4-SNAPSHOT</version> + </parent> + + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-requests-db-adapter</artifactId> + <packaging>war</packaging> + + + <dependencies> + + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>mso-requests-db</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.jboss.resteasy</groupId> + <artifactId>resteasy-jaxrs</artifactId> + <version>3.0.19.Final</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </exclusion> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>status-control</artifactId> + <version>${project.version}</version> + </dependency> + + </dependencies> + + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>2.4</version> + <configuration> + <warSourceDirectory>WebContent</warSourceDirectory> + <failOnMissingWebXml>false</failOnMissingWebXml> + <attachClasses>true</attachClasses> + </configuration> + </plugin> + + <plugin> + <groupId>org.jvnet.jax-ws-commons</groupId> + <artifactId>jaxws-maven-plugin</artifactId> + <version>2.3</version> + <executions> + <execution> + <goals> + <goal>wsgen</goal> + </goals> + </execution> + </executions> + <configuration> + <verbose>true</verbose> + <sei>org.openecomp.mso.adapters.requestsdb.MsoRequestsDbAdapterImpl</sei> + <genWsdl>true</genWsdl> + <inlineSchemas>true</inlineSchemas> + </configuration> + <dependencies> + <dependency> + <groupId>com.sun.xml.ws</groupId> + <artifactId>jaxws-tools</artifactId> + <version>2.2.7</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </build> +</project>
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandler.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandler.java new file mode 100644 index 0000000000..22fcdda416 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandler.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.requestsdb; + + +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.HealthCheckUtils; +import org.openecomp.mso.utils.UUIDChecker; + + +@Path("/") + public class HealthCheckHandler { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + + @HEAD + @GET + @Path("/healthcheck") + @Produces("text/html") + public Response healthcheck (@QueryParam("requestId") String requestId) { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("Healthcheck"); + UUIDChecker.verifyOldUUID(requestId, msoLogger); + HealthCheckUtils healthCheck = new HealthCheckUtils (); + if (!healthCheck.siteStatusCheck(msoLogger, startTime)) { + return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; + } + + if (!healthCheck.requestDBCheck (msoLogger, startTime)) { + return HealthCheckUtils.NOT_STARTED_RESPONSE; + } + msoLogger.debug("healthcheck - Successful"); + return HealthCheckUtils.HEALTH_CHECK_RESPONSE; + } + +} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java new file mode 100644 index 0000000000..5b4009fb77 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.requestsdb; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlElement; + +import org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbException; +import org.openecomp.mso.requestsdb.InfraActiveRequests; +import org.openecomp.mso.requestsdb.SiteStatus; + +/** + * MSO Request DB Adapter Web Service + */ +@WebService(name = "RequestsDbAdapter", targetNamespace = "http://com.att.mso/requestsdb") +public interface MsoRequestsDbAdapter { + + @WebMethod + public void updateInfraRequest (@WebParam(name = "requestId") @XmlElement(required = true) String requestId, + @WebParam(name = "lastModifiedBy") @XmlElement(required = true) String lastModifiedBy, + @WebParam(name = "statusMessage") @XmlElement(required = false) String statusMessage, + @WebParam(name = "responseBody") @XmlElement(required = false) String responseBody, + @WebParam(name = "requestStatus") @XmlElement(required = false) RequestStatusType requestStatus, + @WebParam(name = "progress") @XmlElement(required = false) String progress, + @WebParam(name = "vnfOutputs") @XmlElement(required = false) String vnfOutputs, + @WebParam(name = "serviceInstanceId") @XmlElement(required = false) String serviceInstanceId, + @WebParam(name = "networkId") @XmlElement(required = false) String networkId, + @WebParam(name = "vnfId") @XmlElement(required = false) String vnfId, + @WebParam(name = "vfModuleId") @XmlElement(required = false) String vfModuleId, + @WebParam(name = "volumeGroupId") @XmlElement(required = false) String volumeGroupId) throws MsoRequestsDbException; + + @WebMethod + public InfraActiveRequests getInfraRequest (@WebParam(name="requestId") @XmlElement(required = true) String requestId) throws MsoRequestsDbException; + + @WebMethod + public boolean getSiteStatus (@WebParam(name="siteName") @XmlElement(required = true) String siteName); + +} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java new file mode 100644 index 0000000000..e1b752af24 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java @@ -0,0 +1,246 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.requestsdb; + +import java.sql.Timestamp; +import java.util.List; + +import javax.jws.WebService; + +import org.openecomp.mso.requestsdb.SiteStatus; +import org.openecomp.mso.utils.UUIDChecker; +import org.hibernate.HibernateException; +import org.hibernate.Query; +import org.hibernate.Session; + +import org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbException; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.requestsdb.HibernateUtil; +import org.openecomp.mso.requestsdb.InfraActiveRequests; + +@WebService(serviceName = "RequestsDbAdapter", endpointInterface = "org.openecomp.mso.adapters.requestsdb.MsoRequestsDbAdapter", targetNamespace = "http://com.att.mso/requestsdb") +public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { + + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + + @Override + public void updateInfraRequest (String requestId, + String lastModifiedBy, + String statusMessage, + String responseBody, + RequestStatusType requestStatus, + String progress, + String vnfOutputs, + String serviceInstanceId, + String networkId, + String vnfId, + String vfModuleId, + String volumeGroupId) throws MsoRequestsDbException { + MsoLogger.setLogContext (requestId, null); + Session session = HibernateUtil.getSessionFactory ().openSession (); + int result = 0; + long startTime = System.currentTimeMillis (); + try { + session.beginTransaction (); + String queryString = "update InfraActiveRequests set "; + if (statusMessage != null) { + queryString += "statusMessage = :statusMessage, "; + } + if (responseBody != null) { + queryString += "responseBody = :responseBody, "; + } + if (requestStatus != null) { + queryString += "requestStatus = :requestStatus, "; + } + if (progress != null) { + queryString += "progress = :progress, "; + } + if (vnfOutputs != null) { + queryString += "vnfOutputs = :vnfOutputs, "; + } + if (serviceInstanceId != null) { + queryString += "serviceInstanceId = :serviceInstanceId, "; + } + if (networkId != null) { + queryString += "networkId = :networkId, "; + } + if (vnfId != null) { + queryString += "vnfId = :vnfId, "; + } + if (vfModuleId != null) { + queryString += "vfModuleId = :vfModuleId, "; + } + if (volumeGroupId != null) { + queryString += "volumeGroupId = :volumeGroupId, "; + } + if (requestStatus == RequestStatusType.COMPLETE || requestStatus == RequestStatusType.FAILED) { + queryString += "endTime = :endTime, "; + } else { + queryString += "modifyTime = :modifyTime, "; + } + queryString += "lastModifiedBy = :lastModifiedBy where requestId = :requestId OR clientRequestId = :requestId"; + + LOGGER.debug("Executing update: " + queryString); + + Query query = session.createQuery (queryString); + query.setParameter ("requestId", requestId); + if (statusMessage != null) { + query.setParameter ("statusMessage", statusMessage); + LOGGER.debug ("StatusMessage in updateInfraRequest is set to: " + statusMessage); + } + if (responseBody != null) { + query.setParameter ("responseBody", responseBody); + LOGGER.debug ("ResponseBody in updateInfraRequest is set to: " + responseBody); + } + if (requestStatus != null) { + query.setParameter ("requestStatus", requestStatus.toString ()); + LOGGER.debug ("RequestStatus in updateInfraRequest is set to: " + requestStatus.toString()); + } + + if (progress != null) { + query.setParameter ("progress", Long.parseLong (progress)); + LOGGER.debug ("Progress in updateInfraRequest is set to: " + progress); + } + if (vnfOutputs != null) { + query.setParameter ("vnfOutputs", vnfOutputs); + LOGGER.debug ("VnfOutputs in updateInfraRequest is set to: " + vnfOutputs); + } + if (serviceInstanceId != null) { + query.setParameter ("serviceInstanceId", serviceInstanceId); + LOGGER.debug ("ServiceInstanceId in updateInfraRequest is set to: " + serviceInstanceId); + } + if (networkId != null) { + query.setParameter ("networkId", networkId); + LOGGER.debug ("NetworkId in updateInfraRequest is set to: " + networkId); + } + if (vnfId != null) { + query.setParameter ("vnfId", vnfId); + LOGGER.debug ("VnfId in updateInfraRequest is set to: " + vnfId); + } + if (vfModuleId != null) { + query.setParameter ("vfModuleId", vfModuleId); + LOGGER.debug ("vfModuleId in updateInfraRequest is set to: " + vfModuleId); + } + if (volumeGroupId != null) { + query.setParameter ("volumeGroupId", volumeGroupId); + LOGGER.debug ("VolumeGroupId in updateInfraRequest is set to: " + volumeGroupId); + } + Timestamp nowTimeStamp = new Timestamp (System.currentTimeMillis ()); + if (requestStatus == RequestStatusType.COMPLETE || requestStatus == RequestStatusType.FAILED) { + query.setParameter ("endTime", nowTimeStamp); + LOGGER.debug ("EndTime in updateInfraRequest is set to: " + nowTimeStamp); + } else { + query.setParameter ("modifyTime", nowTimeStamp); + LOGGER.debug ("ModifyTime in updateInfraRequest is set to: " + nowTimeStamp); + } + query.setParameter ("lastModifiedBy", lastModifiedBy); + LOGGER.debug ("LastModifiedBy in updateInfraRequest is set to: " + lastModifiedBy); + result = query.executeUpdate (); + checkIfExists (result, requestId, startTime); + session.getTransaction ().commit (); + } catch (HibernateException e) { + String error = "Unable to update MSO Requests DB: " + e.getMessage (); + LOGGER.error (MessageEnum.RA_CANT_UPDATE_REQUEST, "infra request parameters", requestId, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "HibernateException - " + error, e); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error); + throw new MsoRequestsDbException (error, e); + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + } + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + } + + + private void checkIfExists (int result, String requestId, long startTime) throws MsoRequestsDbException { + if (result == 0) { + String error = "Request ID does not exist in MSO Requests DB: " + requestId; + LOGGER.error (MessageEnum.RA_DB_REQUEST_NOT_EXIST, requestId, "", "", MsoLogger.ErrorCode.DataError, error); + throw new MsoRequestsDbException (error); + } + } + + + @Override + public InfraActiveRequests getInfraRequest (String requestId) throws MsoRequestsDbException { + long startTime = System.currentTimeMillis (); + MsoLogger.setLogContext (requestId, null); + Session session = HibernateUtil.getSessionFactory ().openSession (); + + LOGGER.debug ("Call to MSO Infra RequestsDb adapter get method with request Id: " + requestId); + + InfraActiveRequests request = null; + try { + session.beginTransaction (); + Query query = session.createQuery ("FROM InfraActiveRequests where requestId = :requestId OR clientRequestId = :requestId"); + query.setParameter ("requestId", requestId); + request = (InfraActiveRequests) query.uniqueResult(); + } catch (HibernateException e) { + String error = "Unable to retrieve MSO Infra Requests DB for Request ID " + + requestId; + LOGGER.error (MessageEnum.RA_DB_REQUEST_NOT_EXIST, "Get Infra request", requestId, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "HibernateException - " + error, e); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error); + throw new MsoRequestsDbException (error, e); + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + } + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + return request; + } + + + /** + * Get SiteStatus by SiteName. + * + * @param siteName The unique name of the site + * @return Status of that site + */ + public boolean getSiteStatus (String siteName) { + UUIDChecker.generateUUID (LOGGER); + Session session = HibernateUtil.getSessionFactory ().openSession (); + + long startTime = System.currentTimeMillis (); + SiteStatus siteStatus = null; + LOGGER.debug ("Request database - get Site Status with Site name:" + siteName); + try { + String hql = "FROM SiteStatus WHERE siteName = :site_name"; + Query query = session.createQuery (hql); + query.setParameter ("site_name", siteName); + + siteStatus = (SiteStatus) query.uniqueResult (); + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + } + if (siteStatus == null) { + // if not exist in DB, it means the site is not disabled, thus return true + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + return true; + } else { + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + return siteStatus.getStatus(); + } + } +} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/RequestStatusType.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/RequestStatusType.java new file mode 100644 index 0000000000..706142f366 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/RequestStatusType.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.07.24 at 11:49:17 AM EDT +// + + +package org.openecomp.mso.adapters.requestsdb; + + + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for request-status-type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * <pre> + * <simpleType name="request-status-type"> + * <restriction base="{http://www.w3.org/2001/XMLSchema}string"> + * <enumeration value="COMPLETE"/> + * <enumeration value="FAILED"/> + * <enumeration value="IN_PROGRESS"/> + * </restriction> + * </simpleType> + * </pre> + * + */ +@XmlType(name = "request-status-type") +@XmlEnum +public enum RequestStatusType { + + COMPLETE, + FAILED, + IN_PROGRESS; + + public String value() { + return name(); + } + + public static RequestStatusType fromValue(String v) { + return valueOf(v); + } + +} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/ResponseStatus.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/ResponseStatus.java new file mode 100644 index 0000000000..5b943e2aec --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/ResponseStatus.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.requestsdb; + + + +/* + * Enum for Status values returned by API Handler to Tail-F +*/ +public enum ResponseStatus { + SENDING_FINAL_NOTIFY, + SUCCESS, + FAILED, + TIMEOUT +} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/Status.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/Status.java new file mode 100644 index 0000000000..0b4db4bbc3 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/Status.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.requestsdb; + + +/* + * Enum for Status values returned by API Handler to Tail-F +*/ +public enum Status { + PENDING, INPROGRESS, COMPLETED, FAILED, TIMEOUT; + + public boolean isFinished () { + switch (this) { + case COMPLETED: + case FAILED: + case TIMEOUT: + return true; + default: + return false; + } + } +} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbException.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbException.java new file mode 100644 index 0000000000..8e4fcf4083 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbException.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.requestsdb.exceptions; + + + +import javax.xml.ws.WebFault; + +/** + * This class simply extends Exception (without addition additional functionality) + * to provide an identifier for RequestsDB related exceptions on create, delete, query. + * + * + */ +@WebFault (name="MsoRequestsDbException", faultBean="org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbExceptionBean", targetNamespace="http://com.att.mso/requestsdb") +public class MsoRequestsDbException extends Exception { + + private static final long serialVersionUID = 1L; + + private MsoRequestsDbExceptionBean faultInfo; + + public MsoRequestsDbException (String msg) { + super(msg); + faultInfo = new MsoRequestsDbExceptionBean (msg); + } + + public MsoRequestsDbException (Throwable e) { + super(e); + faultInfo = new MsoRequestsDbExceptionBean (e.getMessage()); + } + + public MsoRequestsDbException (String msg, Throwable e) { + super (msg, e); + faultInfo = new MsoRequestsDbExceptionBean (msg); + } + + public MsoRequestsDbExceptionBean getFaultInfo() { + return faultInfo; + } + + public void setFaultInfo(MsoRequestsDbExceptionBean faultInfo) { + this.faultInfo = faultInfo; + } +} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java new file mode 100644 index 0000000000..8701e5b06e --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.requestsdb.exceptions; + + +import java.io.Serializable; + +/** + * Jax-WS Fault Bean for MsoRequestsDB Exception + */ +public class MsoRequestsDbExceptionBean implements Serializable { + + private static final long serialVersionUID = 1360000062602372639L; + + private String message; + + public MsoRequestsDbExceptionBean () {} + + public MsoRequestsDbExceptionBean (String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/adapters/mso-requests-db-adapter/src/main/java/resources/application.properties b/adapters/mso-requests-db-adapter/src/main/java/resources/application.properties new file mode 100644 index 0000000000..c9345389c9 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/resources/application.properties @@ -0,0 +1,28 @@ +### +# ============LICENSE_START======================================================= +# ECOMP MSO +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# 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. +# ============LICENSE_END========================================================= +### + + +# -- welcome -- +welcomeTitle=JSF Blank Application + +welcomeHeading=Welcome! + +welcomeMessage=This is a JSF blank application. \ + You can find the application.properties file with this message in the src/resources folder. diff --git a/adapters/mso-sdnc-adapter/WebContent/META-INF/MANIFEST.MF b/adapters/mso-sdnc-adapter/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..bbf7aa0cf9 --- /dev/null +++ b/adapters/mso-sdnc-adapter/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,4 @@ +Manifest-Version: 1.0 +Dependencies: org.jboss.logging +Class-Path: + diff --git a/adapters/mso-sdnc-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml b/adapters/mso-sdnc-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 0000000000..88d5024f0d --- /dev/null +++ b/adapters/mso-sdnc-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml @@ -0,0 +1,17 @@ +<jboss-deployment-structure>
+ <deployment>
+ <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
+ <exclusions>
+ <module name="org.apache.log4j" />
+ <module name="org.slf4j" />
+ <module name="org.slf4j.impl" />
+ </exclusions>
+ <dependencies>
+ <module name="org.jboss.jandex" slot="main" />
+ <module name="org.javassist" slot="main" />
+ <module name="org.antlr" slot="main" />
+ <module name="org.dom4j" slot="main" />
+ </dependencies>
+ </deployment>
+</jboss-deployment-structure>
+
diff --git a/adapters/mso-sdnc-adapter/WebContent/WEB-INF/jboss-web.xml b/adapters/mso-sdnc-adapter/WebContent/WEB-INF/jboss-web.xml new file mode 100644 index 0000000000..fa0fe9bab6 --- /dev/null +++ b/adapters/mso-sdnc-adapter/WebContent/WEB-INF/jboss-web.xml @@ -0,0 +1,4 @@ +<jboss-web> + <context-root>adapters</context-root> + <security-domain>other</security-domain> +</jboss-web>
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-sdnc-adapter/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000000..bb58197bf1 --- /dev/null +++ b/adapters/mso-sdnc-adapter/WebContent/WEB-INF/web.xml @@ -0,0 +1,126 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> + <display-name>mso-sdnc-adapter</display-name> + <welcome-file-list> + <welcome-file>check.html</welcome-file> + </welcome-file-list> + + <context-param> + <param-name>resteasy.jndi.resources</param-name> + <param-value>java:module/MsoPropertiesFactory,java:module/CloudConfigFactory</param-value> + </context-param> + <context-param> + <param-name>log.configuration</param-name> + <param-value>logback.sdnc.xml</param-value> + </context-param> + <context-param> + <param-name>mso.configuration</param-name> + <param-value>MSO_PROP_SDNC_ADAPTER=mso.sdnc.properties,MSO_PROP_TOPOLOGY=topology.properties</param-value> + </context-param> + <context-param> + <param-name>mso.cloud_config.configuration</param-name> + <param-value>cloud_config.json=2</param-value> + </context-param> + <context-param> + <param-name>resteasy.resources</param-name> + <param-value>org.openecomp.mso.logger.MsoLoggingServlet,org.openecomp.mso.adapters.sdnc.notify.SDNCNotifyResource,org.openecomp.mso.adapters.sdnc.impl.SDNCAdapterRestImpl,org.openecomp.mso.MsoStatusHandler</param-value> + </context-param> + <context-param> + <param-name>resteasy.servlet.mapping.prefix</param-name> + <param-value>/rest</param-value> + </context-param> + <servlet> + <display-name>SDNCAdapter</display-name> + <servlet-name>SDNCAdapter</servlet-name> + <servlet-class>org.openecomp.mso.adapters.sdnc.impl.SDNCAdapterPortTypeImpl</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>SDNCAdapter</servlet-name> + <url-pattern>/SDNCAdapter</url-pattern> + </servlet-mapping> + <servlet> + <servlet-name>Resteasy</servlet-name> + <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>Resteasy</servlet-name> + <url-pattern>/rest/*</url-pattern> + </servlet-mapping> + + <filter> + <filter-name>LogFilter</filter-name> + <filter-class>org.openecomp.mso.logger.LogFilter</filter-class> + </filter> + <filter-mapping> + <filter-name>LogFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + <listener> + <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class> + </listener> + + <security-constraint> + <web-resource-collection> + <web-resource-name>RestRequests</web-resource-name> + <description>Rest Ingress Requests</description> + <url-pattern>/rest/logging/*</url-pattern> + <url-pattern>/rest/properties/*</url-pattern> + <url-pattern>/rest/MSORequest</url-pattern> + <http-method>POST</http-method> + <http-method>GET</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>MSO-Client</role-name> + </auth-constraint> + </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>SDNCNotification</web-resource-name> + <description>Rest Async Notification from SDNC</description> + <url-pattern>/rest/SDNCNotify</url-pattern> + <http-method>POST</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>SDNC-Client</role-name> + </auth-constraint> + </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>SoapRequests</web-resource-name> + <description>Soap Ingress Requests</description> + <url-pattern>/SDNCAdapter</url-pattern> + <http-method>POST</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>BPEL-Client</role-name> + </auth-constraint> + </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>SiteStatus</web-resource-name> + <description>SiteStatus APIs</description> + <url-pattern>/rest/setStatus/*</url-pattern> + <http-method>POST</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>SiteControl-Client</role-name> + </auth-constraint> + </security-constraint> + + <login-config> + <auth-method>BASIC</auth-method> + <realm-name>ApplicationRealm</realm-name> + </login-config> + <security-role> + <role-name>SDNC-Client</role-name> + </security-role> + <security-role> + <role-name>MSO-Client</role-name> + </security-role> + <security-role> + <role-name>BPEL-Client</role-name> + </security-role> + <security-role> + <role-name>SiteControl-Client</role-name> + </security-role> +</web-app> diff --git a/adapters/mso-sdnc-adapter/WebContent/check.html b/adapters/mso-sdnc-adapter/WebContent/check.html new file mode 100644 index 0000000000..454997901e --- /dev/null +++ b/adapters/mso-sdnc-adapter/WebContent/check.html @@ -0,0 +1,10 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="ISO-8859-1"> +<title>Health Check</title> +</head> +<body> +Application ready +</body> +</html>
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/null/mso-config/uuid/uuid_null b/adapters/mso-sdnc-adapter/null/mso-config/uuid/uuid_null new file mode 100644 index 0000000000..1e111235e7 --- /dev/null +++ b/adapters/mso-sdnc-adapter/null/mso-config/uuid/uuid_null @@ -0,0 +1 @@ +57df7036-93ea-48bb-9667-f97098b99742
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/pom.xml b/adapters/mso-sdnc-adapter/pom.xml new file mode 100644 index 0000000000..11648aa4dc --- /dev/null +++ b/adapters/mso-sdnc-adapter/pom.xml @@ -0,0 +1,104 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp.mso</groupId> + <artifactId>adapters</artifactId> + <version>0.0.4-SNAPSHOT</version> + </parent> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-sdnc-adapter</artifactId> + <packaging>war</packaging> + <name>mso-sdnc-adapter</name> + <description>mso sdnc adapter</description> + + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>2.4</version> + <configuration> + <warSourceDirectory>${basedir}/WebContent</warSourceDirectory> + <failOnMissingWebXml>false</failOnMissingWebXml> + <attachClasses>true</attachClasses> + </configuration> + </plugin> +<!-- <plugin> --> +<!-- <groupId>org.jboss.as.plugins</groupId> --> +<!-- <artifactId>jboss-as-maven-plugin</artifactId> --> +<!-- <version>7.6.Final</version> --> +<!-- <configuration> --> +<!-- <force>true</force> --> +<!-- <port>${jboss.port}</port> --> +<!-- <hostname>${jboss.hostname}</hostname> --> +<!-- <username>${jboss.username}</username> --> +<!-- <password>${jboss.password}</password> --> +<!-- <ignoreMissingDeployment>true</ignoreMissingDeployment> --> +<!-- <domain> --> +<!-- <server-groups> --> +<!-- <server-group>server-group-one</server-group> --> +<!-- <server-group>server-group-two</server-group> --> +<!-- </server-groups> --> +<!-- </domain> --> +<!-- <fileNames> --> +<!-- <fileName>target/${project.build.finalName}.${project.packaging}</fileName> --> +<!-- </fileNames> --> +<!-- </configuration> --> +<!-- <executions> --> +<!-- <execution> --> +<!-- <id>undeploy</id> --> +<!-- <phase>clean</phase> --> +<!-- <goals> --> +<!-- <goal>undeploy</goal> --> +<!-- </goals> --> +<!-- </execution> --> +<!-- <execution> --> +<!-- <id>deploy</id> --> +<!-- <phase>install</phase> --> +<!-- <goals> --> +<!-- <goal>deploy</goal> --> +<!-- </goals> --> +<!-- </execution> --> +<!-- </executions> --> +<!-- </plugin> --> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <version>${project.version}</version> + + </dependency> + <dependency> + <groupId>javax</groupId> + <artifactId>javaee-web-api</artifactId> + <version>6.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.spec.javax.ejb</groupId> + <artifactId>jboss-ejb-api_3.2_spec</artifactId> + <version>1.0.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.ejb3</groupId> + <artifactId>jboss-ejb3-ext-api</artifactId> + <version>2.2.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>status-control</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapters-rest-interface</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project>
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/readme b/adapters/mso-sdnc-adapter/readme new file mode 100644 index 0000000000..34c09fdf7c --- /dev/null +++ b/adapters/mso-sdnc-adapter/readme @@ -0,0 +1,67 @@ +SDNC Adapter is a conduit between MSO BPEL and SDNC +SOAP requests from BPEL are sent as REST requests to SDNC +BPEL get a SYNC response (with no data) right away +On SDNC SYNC response, BPEL is sent an ASYNC (callback) response +On SDNC ASYNC responses/notifications, BPEL is sent ASYNC responses +Failure to send request to SDNC results in header to BPEL with respCode(4xx,5xx) and msg +Success in sending requests to SDNC results in header to BPEL with 2xx respCode to BPEL and data received from SDNC +SDNC data might have failures or success + +SDNCAdapter behaviour on being deployed in JBOSS +------------------------------------------------- +http://host:port/ - JBOSS Default Msg (Welcome to JBoss EAP 6) + +http://host:port/adapters/[check.html] - Application Ready + +http://host:port/adapters/rest/[anything] - SDNC Adapter Rest Services [: Anything] + +http://host:port/adapters/rest/properties/show - Lists all the properties loaded + org.openecomp.mso.adapters.sdnc.bpelcauth=avosAdmin:jboss123 + org.openecomp.mso.adapters.sdnc.sdncconnecttime=2000 + org.openecomp.mso.adapters.sdnc.myurl=http://192.20.205.182:8380/adapters/rest/SDNCNotify + org.openecomp.mso.adapters.sdnc.sdncurl=https://odl.node01.it.app.sdn.labs.att.com:8443/restconf/operations/L3SDN-API: + org.openecomp.mso.adapters.sdnc.sdncauth=admin:admin + org.openecomp.mso.adapters.sdnc.bpelurl=http://NJCDTL21RA1926.ITServices.sbc.com:8088/mockSDNCCallbackAdapterSoapHttpBinding?wsdl + org.openecomp.mso.adapters.sdnc.sdncreadtime=5000 + +http://host:port/adapters/rest/properties/reload - Reloads all the properties + from $configDir/$configFile : /etc/ecomp/mso/config/mso.sdnc.properties + +http://host:port/adapters/rest/logging/setLevel//{logContext}/{level}") - changes application loglevel + where level is one of (ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF) + e.g + http://192.20.205.182:8380/adapters/rest/logging/setLevel/ROOT/INFO + log Level set to: INFO for + http://192.20.205.182:8380/adapters/rest/logging/setLevel/ROOT/INFO + log Level set to: DEBUG for com.att + http://192.20.205.182:8380/adapters/rest/logging/setLevel/garbage/DEBUG + Unknown logger: garbage + +http://host:port/adapters/rest/logging/loggers - shows all the loggers + :DEBUG (DEBUG) + com.att:INFO (INFO) + org.openecomp.mso:DEBUG (DEBUG) + org.openecomp.mso.adapters.sdnc.impl.SDNCAdapterPortTypeImpl:null (DEBUG) + org.openecomp.mso.adapters.sdnc.impl.SDNCRestClient:null (DEBUG) + org.openecomp.mso.adapters.sdnc.client.SDNCCallbackAdapterService:null (DEBUG) + org.openecomp.mso.adapters.sdnc.client.SDNCAdapterCallbackRequest:null (DEBUG) + org.openecomp.mso.adapters.sdnc.SDNCAdapterRequest:null (DEBUG) + org.openecomp.mso.adapters.sdnc.notify.SDNCNotifyResource:null (DEBUG) + org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl:null (DEBUG) + org.openecomp.mso.adapters.network.MsoNetworkAdapterImpl:null (DEBUG) + org.openecomp.mso.logger.MsoLoggingServlet:null (DEBUG) + org.openecomp.mso.logger.MsoLogger:null (DEBUG) + org.openecomp.mso.properties.MsoProperties:null (DEBUG) + org.openecomp.mso.properties.MsoPropertyInitializer:null (DEBUG) + org.jboss.resteasy.plugins.providers.YamlProvider:null (DEBUG) + org.jboss.resteasy.plugins.providers.RegisterBuiltin:null (DEBUG) + org.jboss.resteasy.plugins.providers.DocumentProvider:null (DEBUG) + org.jboss.resteasy.plugins.providers.IIOImageProvider:null (DEBUG) + org.jboss.resteasy.plugins.server.servlet.ConfigurationBootstrap:null (DEBUG) + org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher:null (DEBUG) + org.jboss.resteasy.spi.ResteasyDeployment:null (DEBUG) + org.jboss.resteasy.core.SynchronousDispatcher:null (DEBUG) + org.jboss.resteasy.core.ResourceMethodRegistry:null (DEBUG) + org.jboss.resteasy.util.PickConstructor:null (DEBUG) + +SDNC Adapter will use ActiveRequests DB to track SDNC_CALLBACK_BPEL_URL
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/ObjectFactory.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/ObjectFactory.java new file mode 100644 index 0000000000..1f63eb8a61 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/ObjectFactory.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc; + + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the org.openecomp.mso.adapters.sdnc package. + * <p>An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.openecomp.mso.adapters.sdnc + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link RequestHeader } + * + */ + public RequestHeader createRequestHeader() { + return new RequestHeader(); + } + + /** + * Create an instance of {@link SDNCAdapterResponse } + * + */ + public SDNCAdapterResponse createSDNCAdapterResponse() { + return new SDNCAdapterResponse(); + } + + /** + * Create an instance of {@link SDNCAdapterRequest } + * + */ + public SDNCAdapterRequest createSDNCAdapterRequest() { + return new SDNCAdapterRequest(); + } + +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/RequestHeader.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/RequestHeader.java new file mode 100644 index 0000000000..c26d48b4a2 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/RequestHeader.java @@ -0,0 +1,219 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="RequestId" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="SvcInstanceId" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="SvcAction" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="SvcOperation" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="CallbackUrl" type="{http://www.w3.org/2001/XMLSchema}string"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +//BPEL to SDNCAdapter request header +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "requestId", + "svcInstanceId", + "svcAction", + "svcOperation", + "callbackUrl", + "msoAction" +}) +@XmlRootElement(name = "RequestHeader") +public class RequestHeader { + + @XmlElement(name = "RequestId", required = true) + protected String requestId; + @XmlElement(name = "SvcInstanceId") + protected String svcInstanceId; + @XmlElement(name = "SvcAction", required = true) + protected String svcAction; + @XmlElement(name = "SvcOperation", required = true) + protected String svcOperation; + @XmlElement(name = "CallbackUrl", required = true) + protected String callbackUrl; + @XmlElement(name = "MsoAction") + protected String msoAction; + + /** + * Gets the value of the requestId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRequestId() { + return requestId; + } + + /** + * Sets the value of the requestId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRequestId(String value) { + this.requestId = value; + } + + public String getSvcInstanceId() { + return svcInstanceId; + } + + public void setSvcInstanceId(String svcInstanceId) { + this.svcInstanceId = svcInstanceId; + } + + /** + * Gets the value of the svcAction property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSvcAction() { + return svcAction; + } + + /** + * Sets the value of the svcAction property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSvcAction(String value) { + this.svcAction = value; + } + + /** + * Gets the value of the svcOperation property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSvcOperation() { + return svcOperation; + } + + /** + * Sets the value of the svcOperation property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSvcOperation(String value) { + this.svcOperation = value; + } + + /** + * Gets the value of the callbackUrl property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCallbackUrl() { + return callbackUrl; + } + + /** + * Sets the value of the callbackUrl property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCallbackUrl(String value) { + this.callbackUrl = value; + } + + /** + * Gets the value of the callbackUrl property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMsoAction() { + return msoAction; + } + + /** + * Sets the value of the callbackUrl property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMsoAction(String value) { + this.msoAction = value; + } + + + @Override + public String toString() { + return "RequestHeader [requestId=" + requestId + + ", svcInstanceId=" + svcInstanceId + + ", svcAction=" + svcAction + + ", svcOperation=" + svcOperation + + ", callbackUrl=" + callbackUrl + + ", msoAction=" + msoAction + "]"; + } + +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterPortType.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterPortType.java new file mode 100644 index 0000000000..254fea0ba3 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterPortType.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc; + + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; +import javax.xml.bind.annotation.XmlSeeAlso; + + +/** + * This class was generated by Apache CXF 2.7.11.redhat-3 + * 2015-01-27T18:25:50.914-05:00 + * Generated source version: 2.7.11.redhat-3 + * + */ +//BPEL SDNCAdapter SOAP WebService - impl class in impl pkg +@WebService(targetNamespace = "http://domain2.att.com/workflow/sdnc/adapter/wsdl/v1", name = "SDNCAdapterPortType") +@XmlSeeAlso({ObjectFactory.class}) +@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) +public interface SDNCAdapterPortType { + + @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://domain2.att.com/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterResponse") + @WebMethod(operationName = "SDNCAdapter") + public SDNCAdapterResponse sdncAdapter( + @WebParam(partName = "SDNCAdapterRequest", name = "SDNCAdapterRequest", targetNamespace = "http://domain2.att.com/workflow/sdnc/adapter/schema/v1") + SDNCAdapterRequest sdncAdapterRequest + ); + + @WebMethod + public void healthCheck(); +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequest.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequest.java new file mode 100644 index 0000000000..6b75949453 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequest.java @@ -0,0 +1,129 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; + +import org.openecomp.mso.adapters.sdnc.impl.Utils; +/** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element ref="{http://domain2.att.com/workflow/sdnc/adapter/schema/v1}RequestHeader"/> + * <element name="RequestData" type="{http://www.w3.org/2001/XMLSchema}anyType"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +//BPEL to SDNCAdapter request +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "requestHeader", + "requestData" +}) +@XmlRootElement(name = "SDNCAdapterRequest") +public class SDNCAdapterRequest { + + @XmlElement(name = "RequestHeader", required = true) + protected RequestHeader requestHeader; + @XmlElement(name = "RequestData", required = true) + protected Object requestData; + + /** + * Gets the value of the requestHeader property. + * + * @return + * possible object is + * {@link RequestHeader } + * + */ + public RequestHeader getRequestHeader() { + return requestHeader; + } + + /** + * Sets the value of the requestHeader property. + * + * @param value + * allowed object is + * {@link RequestHeader } + * + */ + public void setRequestHeader(RequestHeader value) { + this.requestHeader = value; + } + + /** + * Gets the value of the requestData property. + * + * @return + * possible object is + * {@link Object } + * + */ + public Object getRequestData() { + return requestData; + } + + /** + * Sets the value of the requestData property. + * + * @param value + * allowed object is + * {@link Object } + * + */ + public void setRequestData(Object value) { + this.requestData = value; + } + + @Override + public String toString() { + + String rd = ""; + if (requestData != null) + { + Node node = (Node) requestData; + Document doc = node.getOwnerDocument(); + rd = Utils.domToStr(doc); + } + return "SDNCAdapterRequest [requestHeader=" + requestHeader.toString() + + ", requestData=" + rd + "]"; + } +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterResponse.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterResponse.java new file mode 100644 index 0000000000..edbd3297c0 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterResponse.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +//SDNCAdapter to BPEL Sync Response(ACK) - async response(s) follow +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +@XmlRootElement(name = "SDNCAdapterResponse") +public class SDNCAdapterResponse { + + +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterService.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterService.java new file mode 100644 index 0000000000..0b63ad6dea --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterService.java @@ -0,0 +1,128 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc; + + +import java.net.URL; + +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import javax.xml.ws.WebEndpoint; +import javax.xml.ws.WebServiceClient; +import javax.xml.ws.WebServiceFeature; + +//import org.openecomp.mso.adapters.sdnc.impl.MsoLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.logger.MessageEnum; + +/** + * This class was generated by Apache CXF 2.7.11.redhat-3 + * 2015-01-27T18:25:50.994-05:00 + * Generated source version: 2.7.11.redhat-3 + * + */ +//BPEL SDNCAdapter SOAP WebService +@WebServiceClient(name = "SDNCAdapterService", + wsdlLocation = "main/resources/SDNCAdapter.wsdl", + targetNamespace = "http://domain2.att.com/workflow/sdnc/adapter/wsdl/v1") +public class SDNCAdapterService extends Service { + + private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + + public final static URL WSDL_LOCATION; + + public final static QName SERVICE = new QName("http://domain2.att.com/workflow/sdnc/adapter/wsdl/v1", "SDNCAdapterService"); + public final static QName SDNCAdapterSoapHttpPort = new QName("http://domain2.att.com/workflow/sdnc/adapter/wsdl/v1", "SDNCAdapterSoapHttpPort"); + static { + URL wsdlUrl = null; + try { + wsdlUrl = Thread.currentThread().getContextClassLoader().getResource("main/resources/SDNCAdapter.wsdl"); + //wsdlUrl = SDNCAdapterService.class.getClassLoader().getResource("SDNCAdapter.wsdl"); + } catch (Exception e) { + logger.error(MessageEnum.RA_WSDL_NOT_FOUND, "SDNCAdapter.wsdl", "", "", MsoLogger.ErrorCode.DataError, "Exception - WSDL not found", e); + } + if(wsdlUrl == null) { + logger.error(MessageEnum.RA_WSDL_NOT_FOUND, "SDNCAdapter.wsdl", "", "", MsoLogger.ErrorCode.DataError, "WSDL not found"); + } else { + try { + logger.info(MessageEnum.RA_PRINT_URL, "SDNCAdpater.wsdl", wsdlUrl.toURI().toString(), "", ""); + } catch (Exception e) { + logger.error(MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "SDNCAdapter.wsdl", "", "", MsoLogger.ErrorCode.DataError, "Exception - print URL", e); + } + } + WSDL_LOCATION = wsdlUrl; + } + + public SDNCAdapterService(URL wsdlLocation) { + super(wsdlLocation, SERVICE); + } + + public SDNCAdapterService(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + + public SDNCAdapterService() { + super(WSDL_LOCATION, SERVICE); + } + + //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 + //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 + //compliant code instead. + public SDNCAdapterService(WebServiceFeature ... features) { + super(WSDL_LOCATION, SERVICE, features); + } + + //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 + //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 + //compliant code instead. + public SDNCAdapterService(URL wsdlLocation, WebServiceFeature ... features) { + super(wsdlLocation, SERVICE, features); + } + + //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 + //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 + //compliant code instead. + public SDNCAdapterService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) { + super(wsdlLocation, serviceName, features); + } + + /** + * + * @return + * returns SDNCAdapterPortType + */ + @WebEndpoint(name = "SDNCAdapterSoapHttpPort") + public SDNCAdapterPortType getSDNCAdapterSoapHttpPort() { + return super.getPort(SDNCAdapterSoapHttpPort, SDNCAdapterPortType.class); + } + + /** + * + * @param features + * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. + * @return + * returns SDNCAdapterPortType + */ + @WebEndpoint(name = "SDNCAdapterSoapHttpPort") + public SDNCAdapterPortType getSDNCAdapterSoapHttpPort(WebServiceFeature... features) { + return super.getPort(SDNCAdapterSoapHttpPort, SDNCAdapterPortType.class, features); + } +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeader.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeader.java new file mode 100644 index 0000000000..a49f55b596 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeader.java @@ -0,0 +1,154 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.client; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +/** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="RequestId" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="ResponseCode" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="ResponseMessage" type="{http://www.w3.org/2001/XMLSchema}string"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +//SDNCAdapter to BPEL Async response header +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "requestId", + "responseCode", + "responseMessage" +}) +@XmlRootElement(name = "CallbackHeader") +public class CallbackHeader { + + @XmlElement(name = "RequestId", required = true) + protected String requestId; + @XmlElement(name = "ResponseCode", required = true) + protected String responseCode; + @XmlElement(name = "ResponseMessage", required = true) + protected String responseMessage; + + public CallbackHeader() { + } + + public CallbackHeader(String reqId, String respCode, String respMsg) { + this.requestId = reqId; + this.responseCode = respCode; + this.responseMessage = respMsg; + } + + /** + * Gets the value of the requestId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRequestId() { + return requestId; + } + + /** + * Sets the value of the requestId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRequestId(String value) { + this.requestId = value; + } + + /** + * Gets the value of the responseCode property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getResponseCode() { + return responseCode; + } + + /** + * Sets the value of the responseCode property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setResponseCode(String value) { + this.responseCode = value; + } + + /** + * Gets the value of the responseMessage property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getResponseMessage() { + return responseMessage; + } + + /** + * Sets the value of the responseMessage property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setResponseMessage(String value) { + this.responseMessage = value; + } + + @Override + public String toString() { + return "CallbackHeader [requestId=" + requestId + ", responseCode=" + + responseCode + ", responseMessage=" + responseMessage + "]"; + } +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/ObjectFactory.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/ObjectFactory.java new file mode 100644 index 0000000000..6e7e599c7d --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/ObjectFactory.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.client; + + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the org.openecomp.mso.adapters.sdnc.client package. + * <p>An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.openecomp.mso.adapters.sdnc.client + * + */ + public ObjectFactory() { + } + + + /** + * Create an instance of {@link SDNCAdapterCallbackRequest } + * + */ + public SDNCAdapterCallbackRequest createSDNCAdapterCallbackRequest() { + return new SDNCAdapterCallbackRequest(); + } + + /** + * Create an instance of {@link CallbackHeader } + * + */ + public CallbackHeader createCallbackHeader() { + return new CallbackHeader(); + } +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequest.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequest.java new file mode 100644 index 0000000000..fd16e4754c --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequest.java @@ -0,0 +1,136 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.client; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; +import java.io.StringWriter; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.logger.MessageEnum; +/** + * <p>Java class for anonymous complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element ref="{http://domain2.att.com/workflow/sdnc/adapter/schema/v1}CallbackHeader"/> + * <element name="RequestData" type="{http://www.w3.org/2001/XMLSchema}anyType"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +//SDNCAdapter to BPEL Async response +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "callbackHeader", + "requestData" +}) +@XmlRootElement(name = "SDNCAdapterCallbackRequest") +public class SDNCAdapterCallbackRequest { + + @XmlElement(name = "CallbackHeader", required = true) + protected CallbackHeader callbackHeader; + @XmlElement(name = "RequestData") + protected Object requestData; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + + /** + * Gets the value of the callbackHeader property. + * + * @return + * possible object is + * {@link CallbackHeader } + * + */ + public CallbackHeader getCallbackHeader() { + return callbackHeader; + } + + /** + * Sets the value of the callbackHeader property. + * + * @param value + * allowed object is + * {@link CallbackHeader } + * + */ + public void setCallbackHeader(CallbackHeader value) { + this.callbackHeader = value; + } + + /** + * Gets the value of the requestData property. + * + * @return + * possible object is + * {@link Object } + * + */ + public Object getRequestData() { + return requestData; + } + + /** + * Sets the value of the requestData property. + * + * @param value + * allowed object is + * {@link Object } + * + */ + public void setRequestData(Object value) { + this.requestData = value; + } + + @Override + public String toString() { + try { + JAXBContext ctx = JAXBContext.newInstance("org.openecomp.mso.adapters.sdnc.client"); + Marshaller m = ctx.createMarshaller(); + m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); + StringWriter w = new StringWriter(); + m.marshal(this, w); + return (w.toString()); + } + catch (Exception e) + { + msoLogger.error(MessageEnum.RA_MARSHING_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception - MARSHING_ERROR", e); + } + return(""); + } +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCCallbackAdapterPortType.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCCallbackAdapterPortType.java new file mode 100644 index 0000000000..6818e67e75 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCCallbackAdapterPortType.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.client; + + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; +import javax.xml.bind.annotation.XmlSeeAlso; +import org.openecomp.mso.adapters.sdnc.SDNCAdapterResponse; + + +/** + * This class was generated by Apache CXF 2.7.11.redhat-3 + * 2015-01-28T11:07:01.997-05:00 + * Generated source version: 2.7.11.redhat-3 + * + */ +//SDNCAdapter to BPEL Async response WEB Service +@WebService(targetNamespace = "http://domain2.att.com/workflow/sdnc/adapter/callback/wsdl/v1", name = "SDNCCallbackAdapterPortType") +@XmlSeeAlso({ObjectFactory.class}) +@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) +public interface SDNCCallbackAdapterPortType { + + @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://domain2.att.com/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackResponse") + @WebMethod(operationName = "SDNCAdapterCallback") + public SDNCAdapterResponse sdncAdapterCallback( + @WebParam(partName = "SDNCAdapterCallbackRequest", name = "SDNCAdapterCallbackRequest", targetNamespace = "http://domain2.att.com/workflow/sdnc/adapter/schema/v1") + SDNCAdapterCallbackRequest sdncAdapterCallbackRequest + ); +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCCallbackAdapterService.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCCallbackAdapterService.java new file mode 100644 index 0000000000..6fa8e035a5 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/SDNCCallbackAdapterService.java @@ -0,0 +1,126 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.client; + + +import java.net.URL; + +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import javax.xml.ws.WebEndpoint; +import javax.xml.ws.WebServiceClient; +import javax.xml.ws.WebServiceFeature; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; + +/** + * This class was generated by Apache CXF 2.7.11.redhat-3 + * 2015-01-28T11:07:02.074-05:00 + * Generated source version: 2.7.11.redhat-3 + * + */ +//SDNCAdapter to BPEL Async response WEB Service +@WebServiceClient(name = "SDNCCallbackAdapterService", + wsdlLocation = "main/resources/SDNCCallbackAdapter.wsdl", + targetNamespace = "http://domain2.att.com/workflow/sdnc/adapter/callback/wsdl/v1") +public class SDNCCallbackAdapterService extends Service { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + + public final static URL WSDL_LOCATION; + public final static QName SERVICE = new QName("http://domain2.att.com/workflow/sdnc/adapter/callback/wsdl/v1", "SDNCCallbackAdapterService"); + public final static QName SDNCCallbackAdapterSoapHttpPort = new QName("http://domain2.att.com/workflow/sdnc/adapter/callback/wsdl/v1", "SDNCCallbackAdapterSoapHttpPort"); + static { + URL wsdlUrl = null; + try { + wsdlUrl = Thread.currentThread().getContextClassLoader().getResource("main/resources/SDNCCallbackAdapter.wsdl"); + //wsdlUrl = SDNCCallbackAdapterService.class.getClassLoader().getResource("SDNCCallbackAdapter.wsdl"); + } catch (Exception e) { + msoLogger.error(MessageEnum.RA_WSDL_NOT_FOUND, "SDNCCallbackAdapter.wsdl", "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - WSDL not found", e); + } + if(wsdlUrl == null) { + msoLogger.error(MessageEnum.RA_WSDL_NOT_FOUND, "SDNCCallbackAdapter.wsdl", "SDNC", "", MsoLogger.ErrorCode.DataError, "WSDL not found"); + } else { + try { + msoLogger.info(MessageEnum.RA_PRINT_URL, "SDNCCallbackAdapter.wsdl", wsdlUrl.toURI().toString(), "SDNC", ""); + } catch (Exception e) { + msoLogger.error(MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "SDNCCallbackAdapter.wsdl", "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - URL convention problem", e); + } + } + WSDL_LOCATION = wsdlUrl; + } + + public SDNCCallbackAdapterService(URL wsdlLocation) { + super(wsdlLocation, SERVICE); + } + + public SDNCCallbackAdapterService(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + + public SDNCCallbackAdapterService() { + super(WSDL_LOCATION, SERVICE); + } + + //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 + //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 + //compliant code instead. + public SDNCCallbackAdapterService(WebServiceFeature ... features) { + super(WSDL_LOCATION, SERVICE, features); + } + + //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 + //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 + //compliant code instead. + public SDNCCallbackAdapterService(URL wsdlLocation, WebServiceFeature ... features) { + super(wsdlLocation, SERVICE, features); + } + + //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 + //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 + //compliant code instead. + public SDNCCallbackAdapterService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) { + super(wsdlLocation, serviceName, features); + } + + /** + * + * @return + * returns SDNCCallbackAdapterPortType + */ + @WebEndpoint(name = "SDNCCallbackAdapterSoapHttpPort") + public SDNCCallbackAdapterPortType getSDNCCallbackAdapterSoapHttpPort() { + return super.getPort(SDNCCallbackAdapterSoapHttpPort, SDNCCallbackAdapterPortType.class); + } + + /** + * + * @param features + * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. + * @return + * returns SDNCCallbackAdapterPortType + */ + @WebEndpoint(name = "SDNCCallbackAdapterSoapHttpPort") + public SDNCCallbackAdapterPortType getSDNCCallbackAdapterSoapHttpPort(WebServiceFeature... features) { + return super.getPort(SDNCCallbackAdapterSoapHttpPort, SDNCCallbackAdapterPortType.class, features); + } + +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/package-info.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/package-info.java new file mode 100644 index 0000000000..0d6f900f47 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/client/package-info.java @@ -0,0 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://domain2.att.com/workflow/sdnc/adapter/schema/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package org.openecomp.mso.adapters.sdnc.client; + diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/Constants.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/Constants.java new file mode 100644 index 0000000000..6cc0ecbd92 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/Constants.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.impl; + + +public interface Constants { + + public static final String BPEL_URL_PROP = "org.openecomp.mso.adapters.sdnc.bpelurl"; + public static final String DEFAULT_BPEL_URL = "http://msobpel.mtcnj.aic.cip.att.com:8080//active-bpel/services/SDNCAdapterCallbackV1"; + + public static final String MY_URL_PROP = "org.openecomp.mso.adapters.sdnc.myurl"; + public static final String DEFAULT_MY_URL = "https://msojra.mtcnj.aic.cip.att.com:8443/adapters/rest/SDNCNotify"; + + public static final String SDNC_AUTH_PROP = "org.openecomp.mso.adapters.sdnc.sdncauth"; + public static final String DEFAULT_SDNC_AUTH = "406B2AE613211B6FB52466DE6E1769AC"; + + public static final String DEFAULT_BPEL_AUTH = "05FDA034C27D1CA51AAB8FAE512EDE45241E16FC8C137D292AA3A964431C82DB"; + public static final String BPEL_AUTH_PROP = "org.openecomp.mso.adapters.sdnc.bpelauth"; + + + public static final String SDNC_SVCCFGRESP_ROOT = "input"; + public static final String SDNC_REQ_ID = "/svc-request-id"; + public static final String SDNC_RESP_CODE = "/response-code"; + public static final String SDNC_RESP_MSG = "/response-message"; + public static final String SDNC_CONNECTTIME_PROP = "org.openecomp.mso.adapters.sdnc.sdncconnecttime"; + public static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; + + public static final String REQUEST_TUNABLES = "org.openecomp.mso.adapters.sdnc"; +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/RequestTunables.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/RequestTunables.java new file mode 100644 index 0000000000..6c8c8819ed --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/RequestTunables.java @@ -0,0 +1,223 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.impl; + + +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +import org.openecomp.mso.logger.MessageEnum; +public class RequestTunables { + + private MsoPropertiesFactory msoPropertiesFactory; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); + public static final String MSO_PROP_SDNC_ADAPTER="MSO_PROP_SDNC_ADAPTER"; + + //criteria + private String reqId = ""; + private String msoAction = ""; + private String operation = ""; + private String action = ""; + + //tunables + private String reqMethod = "POST"; + private String sdncUrl = null; + private String timeout = "60000"; + private String headerName = "sdnc-request-header"; + private String namespace = ""; + private String asyncInd = "N"; //future use + + private String sdncaNotificationUrl = null; + + public RequestTunables(String reqId, String msoAction, String operation, String action, MsoPropertiesFactory msoPropFactory) { + super(); + msoPropertiesFactory = msoPropFactory; + if (reqId != null) { + this.reqId = reqId; + } + if (msoAction != null) { + this.msoAction = msoAction; + } + if (operation != null) { + this.operation = operation; + } + if (action != null) { + this.action = action; + } + } + + public String getReqId() { + return reqId; + } + public void setReqId(String reqId) { + this.reqId = reqId; + } + public String getReqMethod() { + return reqMethod; + } + public void setReqMethod(String reqMethod) { + this.reqMethod = reqMethod; + } + public String getMsoAction() { + return msoAction; + } + public void setMsoAction(String msoAction) { + this.msoAction = msoAction; + } + public String getAction() { + return action; + } + public void setAction(String action) { + this.action = action; + } + public String getOperation() { + return operation; + } + public void setOperation(String operation) { + this.operation = operation; + } + public String getSdncUrl() { + return sdncUrl; + } + public void setSdncUrl(String sdncUrl) { + this.sdncUrl = sdncUrl; + } + public String getTimeout() { + return timeout; + } + public void setTimeout(String timeout) { + this.timeout = timeout; + } + public String getAsyncInd() { + return asyncInd; + } + public void setAsyncInd(String asyncInd) { + this.asyncInd = asyncInd; + } + public String getHeaderName() { + return headerName; + } + public void setHeaderName(String headerName) { + this.headerName = headerName; + } + + + public String getSdncaNotificationUrl() { + return sdncaNotificationUrl; + } + + public void setSdncaNotificationUrl(String sdncaNotificationUrl) { + this.sdncaNotificationUrl = sdncaNotificationUrl; + } + + public String getNamespace() { + return namespace; + } + + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + @Override + public String toString() { + return "RequestTunables [reqId=" + reqId + ", msoAction=" + msoAction + + ", operation=" + operation + ", action=" + action + + ", reqMethod=" + reqMethod + ", sdncUrl=" + sdncUrl + + ", timeout=" + timeout + ", headerName=" + headerName + + ", sdncaNotificationUrl=" + sdncaNotificationUrl + + ", namespace=" + namespace + "]"; + } + + public void setTunables() + { + String error = null; + String key = null; + if ("query".equals(action)) { //due to variable format for operation eg services/layer3-service-list/8fe4ba4f-35cf-4d9b-a04a-fd3f5d4c5cc9 + key = Constants.REQUEST_TUNABLES + "." + msoAction + ".." + action; + msoLogger.debug("Generated key: " + key); + } + else if ("put".equals(action) || "restdelete".equals(action)) { //due to variable format for operation eg services/layer3-service-list/8fe4ba4f-35cf-4d9b-a04a-fd3f5d4c5cc9 + key = Constants.REQUEST_TUNABLES + "..." + action; + msoLogger.debug("Generated key: " + key); + } else { + key = Constants.REQUEST_TUNABLES + "." + msoAction + "." + operation +"." + action; + msoLogger.debug("Generated key: " + key); + } + + String value; + try { + value = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_SDNC_ADAPTER).getProperty(key, ""); + } catch (MsoPropertiesException e) { + msoLogger.error (MessageEnum.LOAD_PROPERTIES_FAIL, "Unknown. Mso Properties ID not found in cache: " + MSO_PROP_SDNC_ADAPTER, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - Mso Properties ID not found in cache", e); + value=""; + } + + if (value != null && value.length() > 0) { + + String[] parts = value.split("\\|"); //escape pipe + if (parts.length < 3) { + msoLogger.warn(MessageEnum.RA_SDNC_INVALID_CONFIG, key, value, "SDNC", "", MsoLogger.ErrorCode.DataError, "Invalid config"); + } + + for (int i = 0; i < parts.length; i++) { + if (i == 0) { + reqMethod = parts[i]; + msoLogger.debug("Request Method is set to: " + reqMethod); + } else if (i == 1) { + timeout = parts[i]; + msoLogger.debug("Timeout is set to: " + timeout); + } else if (i == 2) { + sdncUrl = SDNCAdapterPortTypeImpl.getProperty(Constants.REQUEST_TUNABLES + "." + parts[i], "",msoPropertiesFactory); + if (operation != null && sdncUrl != null) { + sdncUrl = sdncUrl + operation; + } + msoLogger.debug("SDNC Url is set to: " + sdncUrl); + } else if (i == 3) { + headerName = parts[i]; + msoLogger.debug("HeaderName is set to: " + headerName); + } else if (i == 4) { + namespace = parts[i]; + msoLogger.debug("NameSpace is set to: " + namespace); + } else if (i == 5) { + asyncInd = parts[i]; + msoLogger.debug("AsyncInd is set to: " + asyncInd); + } + } + + if (sdncUrl == null) { + error = "Invalid configuration, sdncUrl required for:" + key + " value:" + value; + } + } else { + error = "Missing configuration for:" + key; + } + if (error != null) { + msoLogger.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, key, "SDNC", "", MsoLogger.ErrorCode.DataError, "Missing config param"); + alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + msoLogger.debug ("RequestTunables Key:" + key + " Value:" + value + " Tunables:" + this.toString()); + return; + } +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterPortTypeImpl.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterPortTypeImpl.java new file mode 100644 index 0000000000..887c0a9990 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterPortTypeImpl.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.impl; + +import javax.annotation.PostConstruct; +import javax.jws.WebService; +import javax.servlet.http.HttpServletResponse; + +import org.openecomp.mso.adapters.sdnc.SDNCAdapterPortType; +import org.openecomp.mso.adapters.sdnc.SDNCAdapterRequest; +import org.openecomp.mso.adapters.sdnc.SDNCAdapterResponse; +import org.openecomp.mso.adapters.sdnc.util.SDNCRequestIdUtil; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +//BPEL SDNCAdapter SOAP Web Service implementation +@WebService(serviceName = "SDNCAdapterService", endpointInterface = "org.openecomp.mso.adapters.sdnc.SDNCAdapterPortType", targetNamespace = "http://domain2.att.com/workflow/sdnc/adapter/wsdl/v1") +public class SDNCAdapterPortTypeImpl implements SDNCAdapterPortType { + + private MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory(); + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); + private static final String LOG_SERVICE_NAME = "MSO-BPMN:MSO-SDNCAdapter."; + private static final String LOG_REPLY_NAME = "MSO-SDNCAdapter:MSO-BPMN."; + public static final String MSO_PROP_SDNC_ADAPTER="MSO_PROP_SDNC_ADAPTER"; + + @PostConstruct + public void init () { + msoLogger.info(MessageEnum.RA_INIT_SDNC_ADAPTER, "SDNC", "SDNCAdapterPortType"); + } + + /** + * Health Check web method. Does nothing but return to show the adapter is deployed. + */ + @Override + public void healthCheck () + { + msoLogger.debug("Health check call in SDNC Adapter"); + } + + public static String getProperty(String key, String defaultValue, MsoPropertiesFactory msoPropertiesFactoryp) { + String value; + try { + value = msoPropertiesFactoryp.getMsoJavaProperties(MSO_PROP_SDNC_ADAPTER).getProperty(key, defaultValue); + } catch (MsoPropertiesException e) { + msoLogger.error (MessageEnum.NO_PROPERTIES, "Unknown. Mso Properties ID not found in cache: " + MSO_PROP_SDNC_ADAPTER, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - Mso Properties ID not found in cache", e); + return null; + } + msoLogger.debug("Config read for " + MSO_PROP_SDNC_ADAPTER + " - key:" + key + " value:" + value); + return value; + } + + @Override + public SDNCAdapterResponse sdncAdapter(SDNCAdapterRequest bpelRequest) { + String bpelReqId = bpelRequest.getRequestHeader().getRequestId(); + String callbackUrl = bpelRequest.getRequestHeader().getCallbackUrl(); + long startTime = System.currentTimeMillis (); + MsoLogger.setLogContext(SDNCRequestIdUtil.getSDNCOriginalRequestId (bpelReqId), bpelRequest.getRequestHeader().getSvcInstanceId()); + MsoLogger.setServiceName (bpelRequest.getRequestHeader().getSvcAction()); + msoLogger.info(MessageEnum.RA_RECEIVE_BPEL_REQUEST, bpelReqId, callbackUrl, "SDNC", ""); + + SDNCRestClient sdncClient = new SDNCRestClient(bpelRequest,msoPropertiesFactory); + long subStartTime = System.currentTimeMillis (); + try { + Thread sdncClientThread = new Thread(sdncClient); + sdncClientThread.start(); + } + catch (Exception e){ + String respMsg = "Error sending request to SDNC. Failed to start SDNC Client thread " + e.getMessage(); + msoLogger.error(MessageEnum.RA_SEND_REQUEST_SDNC_ERR, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception sending request to SDNC. Failed to start SDNC Client thread", e); + alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, respMsg); + SDNCResponse sdncResp = new SDNCResponse(bpelReqId); + sdncResp.setRespCode(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + sdncResp.setRespMsg(respMsg); + SDNCRestClient.sendRespToBpel(callbackUrl, sdncResp, msoPropertiesFactory); + } + + msoLogger.debug("Sending synchronous response to BPEL"); + SDNCAdapterResponse wsResp = new SDNCAdapterResponse(); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + return (wsResp); + } +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImpl.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImpl.java new file mode 100644 index 0000000000..c873c9215e --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImpl.java @@ -0,0 +1,191 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.impl; + + +import java.io.StringReader; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.POST; +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.Response; +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.openecomp.mso.HealthCheckUtils; +import org.openecomp.mso.utils.UUIDChecker; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; + +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoPropertiesFactory; +import org.openecomp.mso.logger.MessageEnum; +@Path("/") +public class SDNCAdapterRestImpl { + + private MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + public final static String MSO_PROP_ADAPTER="MSO_PROP_SDNC_ADAPTER"; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + + @Context + private HttpHeaders headers; + @Context HttpServletRequest request; + + @POST + @Path("/MSORequest") + @Consumes("application/xml") + @Produces("application/xml") + public Response MSORequest(String reqXML) { + msoLogger.debug("***Received MSO Rest Request. XML:" + reqXML); + + Document reqDoc = null; + SDNCResponse sdncResp = null; + RequestTunables rt = null; + String reqId = ""; + long startTime = System.currentTimeMillis(); + MsoLogger.setServiceName("UNKNOWN"); + String action = ""; + String operation = ""; + try { + + reqId = headers.getRequestHeader("att-mso-request-id").get(0); + action = headers.getRequestHeader("att-mso-request-action").get(0); + operation = headers.getRequestHeader("att-mso-request-operation").get(0); + + MsoLogger.setLogContext(reqId, ""); + + msoLogger.debug ("Received MSO Rest Request XML: " + reqXML); + rt = new RequestTunables(reqId, "", operation, action, msoPropertiesFactory); + rt.setTunables(); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setFeature (XMLConstants.FEATURE_SECURE_PROCESSING, true); + DocumentBuilder db = dbf.newDocumentBuilder(); + + InputSource source = new InputSource(new StringReader(reqXML)); + + reqDoc = db.parse(source); + + } catch (Exception e) { + msoLogger.error(MessageEnum.RA_PARSING_REQUEST_ERROR, reqXML, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - Invalid XML request format", e); + sdncResp = new SDNCResponse(reqId, HttpServletResponse.SC_BAD_REQUEST, "Invalid XML request format"); + } + + if (reqDoc != null) { + msoLogger.debug("***Getting response from sdnc***"); + long subStartTime = System.currentTimeMillis (); + sdncResp = SDNCRestClient.getSdncResp(Utils.genSdncReq(reqDoc, rt), rt,msoPropertiesFactory); + msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from SDNC", "SDNC", action + "." + operation, null); + } + + if (sdncResp == null) { + msoLogger.debug("An Internal Server error has occurred in SDNC Adapter"); + sdncResp = new SDNCResponse(reqId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "MSO - SDNCA Internal Error"); + } + + if (sdncResp.getSdncRespXml() == null) { + sdncResp.setSdncRespXml(Utils.genMsoFailResp(sdncResp)); + } + + msoLogger.debug("***Completed MSO Rest Request." + sdncResp.toString()); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + return Response.status(sdncResp.getRespCode()).entity(sdncResp.getSdncRespXml()).build(); + } + + @HEAD + @GET + @Path("/healthcheck") + @Produces("text/html") + public Response healthcheck (@QueryParam("requestId") String requestId) { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("Healthcheck"); + UUIDChecker.verifyOldUUID(requestId, msoLogger); + HealthCheckUtils healthCheck = new HealthCheckUtils (); + if (!healthCheck.siteStatusCheck(msoLogger, startTime)) { + return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; + } + + if (!healthCheck.configFileCheck(msoLogger, startTime, MSO_PROP_ADAPTER)) { + return HealthCheckUtils.NOT_STARTED_RESPONSE; + } + msoLogger.debug("healthcheck - Successful"); + return HealthCheckUtils.HEALTH_CHECK_RESPONSE; + } + + @HEAD + @GET + @Path("/globalhealthcheck") + @Produces("text/html") + public Response globalHealthcheck (@DefaultValue("true") @QueryParam("enableBpmn") boolean enableBpmn) { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("GlobalHealthcheck"); + // Generate a Request Id + String requestId = UUIDChecker.generateUUID(msoLogger); + HealthCheckUtils healthCheck = new HealthCheckUtils (); + if (!healthCheck.siteStatusCheck (msoLogger, startTime)) { + return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; + } + + if (healthCheck.verifyGlobalHealthCheck(enableBpmn, requestId)) { + msoLogger.debug("globalHealthcheck - Successful"); + return HealthCheckUtils.HEALTH_CHECK_RESPONSE; + } else { + msoLogger.debug("globalHealthcheck - At leaset one of the sub-modules is not available."); + return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; + } + } + + @HEAD + @GET + @Path("/nodehealthcheck") + @Produces("text/html") + public Response nodeHealthcheck () { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("NodeHealthcheck"); + // Generate a Request Id + String requestId = UUIDChecker.generateUUID(msoLogger); + HealthCheckUtils healthCheck = new HealthCheckUtils (); + if (!healthCheck.siteStatusCheck (msoLogger, startTime)) { + return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; + } + + if (healthCheck.verifyNodeHealthCheck(HealthCheckUtils.NodeType.RA, requestId)) { + msoLogger.debug("nodeHealthcheck - Successful"); + return HealthCheckUtils.HEALTH_CHECK_RESPONSE; + } else { + msoLogger.debug("nodeHealthcheck - At leaset one of the sub-modules is not available."); + return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; + } + } + +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCResponse.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCResponse.java new file mode 100644 index 0000000000..b6178596f6 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCResponse.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.impl; + + +import java.io.Serializable; + +public class SDNCResponse implements Serializable { + + private static final long serialVersionUID = 1L; + private String reqId = null; + private int respCode = 0; + private String respMsg = null; + private String sdncRespXml = null; + + public SDNCResponse(String reqId) { + this.reqId = reqId; + } + public SDNCResponse(String reqId, int respCode, String respMsg) { + this.reqId = reqId; + this.respCode = respCode; + this.respMsg = respMsg; + } + + public String getReqId() { + return reqId; + } + public void setReqId(String reqId) { + this.reqId = reqId; + } + public int getRespCode() { + return respCode; + } + public void setRespCode(int respCode) { + this.respCode = respCode; + } + public String getRespMsg() { + return respMsg; + } + public void setRespMsg(String respMsg) { + this.respMsg = respMsg; + } + public String getSdncRespXml() { + return sdncRespXml; + } + public void setSdncRespXml(String sdncRespXml) { + this.sdncRespXml = sdncRespXml; + } + + @Override + public String toString() { + return "SDNCResponse [reqId=" + reqId + ", respCode=" + respCode + + ", respMsg=" + respMsg + ", sdncRespXml=" + sdncRespXml + "]"; + } +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java new file mode 100644 index 0000000000..00d7c5a144 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java @@ -0,0 +1,345 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.impl; + + +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.ejb.EJB; +import javax.xml.XMLConstants; +import javax.xml.bind.DatatypeConverter; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.ws.BindingProvider; +import javax.xml.ws.handler.MessageContext; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathFactory; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import org.openecomp.mso.adapters.sdnc.SDNCAdapterRequest; +import org.openecomp.mso.adapters.sdnc.client.CallbackHeader; +import org.openecomp.mso.adapters.sdnc.client.SDNCAdapterCallbackRequest; +import org.openecomp.mso.adapters.sdnc.client.SDNCCallbackAdapterPortType; +import org.openecomp.mso.adapters.sdnc.client.SDNCCallbackAdapterService; +import org.openecomp.mso.adapters.sdnc.util.SDNCRequestIdUtil; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +//SDNCAdapter to SDNC Rest Client +public class SDNCRestClient implements Runnable { + + private MsoPropertiesFactory msoPropertiesFactory; + + private SDNCAdapterRequest bpelRequest; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); + public static final String MSO_PROP_SDNC_ADAPTER="MSO_PROP_SDNC_ADAPTER"; + + + public SDNCRestClient(SDNCAdapterRequest bpelRequest,MsoPropertiesFactory msoPropFactory) { + this.bpelRequest = bpelRequest; + msoPropertiesFactory = msoPropFactory; + } + + @Override + public void run() + { + + String action = bpelRequest.getRequestHeader().getSvcAction(); + String operation = bpelRequest.getRequestHeader().getSvcOperation(); + String bpelReqId = bpelRequest.getRequestHeader().getRequestId(); + String callbackUrl = bpelRequest.getRequestHeader().getCallbackUrl(); + MsoLogger.setLogContext(SDNCRequestIdUtil.getSDNCOriginalRequestId (bpelReqId), bpelRequest.getRequestHeader().getSvcInstanceId()); + MsoLogger.setServiceName("SDNCRestClient"); + + String sdncReqBody = null; + + msoLogger.debug("BPEL Request:" + bpelRequest.toString()); + + RequestTunables rt = new RequestTunables(bpelReqId, + bpelRequest.getRequestHeader().getMsoAction(), + bpelRequest.getRequestHeader().getSvcOperation(), + bpelRequest.getRequestHeader().getSvcAction(),msoPropertiesFactory); + rt.setTunables(); + rt.setSdncaNotificationUrl(SDNCAdapterPortTypeImpl.getProperty(Constants.MY_URL_PROP, Constants.DEFAULT_MY_URL,msoPropertiesFactory)); + + + if ("POST".equals(rt.getReqMethod())) + { + /* TODO Hibernate + try { + RequestsDatabase.updateBpelUrl(bpelReqId, callbackUrl); + } + catch (Exception e1) + { + logger.error("Failed to update DB ActiveRequests with SDNC_CALLBACK_BPEL_URL. Default CallbackUrl will be used for SDNC async notifications", e1); + } + */ + + Node node = (Node) bpelRequest.getRequestData(); + Document reqDoc = node.getOwnerDocument(); + sdncReqBody = Utils.genSdncReq(reqDoc, rt); + + } + //should be more generic if we do RPC then we add the input tags etc, if it is pure REST this is not needed + else if("PUT".equals(rt.getReqMethod())){ + Node node = (Node) bpelRequest.getRequestData(); + Document reqDoc = node.getOwnerDocument(); + sdncReqBody = Utils.genSdncPutReq(reqDoc, rt); + } + long sdncStartTime = System.currentTimeMillis(); + SDNCResponse sdncResp = getSdncResp(sdncReqBody, rt, msoPropertiesFactory); + msoLogger.recordMetricEvent (sdncStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from SDNC", "SDNC", action + "." + operation, null); + + msoLogger.debug ("Got the SDNC Response: " + sdncResp.getSdncRespXml()); + msoLogger.debug("Sending reponse to bpel from SDNC rest client"); + long bpelStartTime = System.currentTimeMillis(); + sendRespToBpel(callbackUrl, sdncResp,msoPropertiesFactory); + msoLogger.recordMetricEvent (bpelStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully send reauest to BPEL", "BPMN", callbackUrl, null); + return; + } + + public static SDNCResponse getSdncResp(String sdncReqBody, RequestTunables rt, MsoPropertiesFactory msoPropertiesFactoryp) + { + + URL url; + HttpURLConnection con = null; + DataOutputStream out = null; + BufferedReader in = null; + SDNCResponse sdncResp = new SDNCResponse(rt.getReqId()); + StringBuffer response = new StringBuffer(); + + msoLogger.info(MessageEnum.RA_SEND_REQUEST_SDNC, rt.toString(), "SDNC", ""); + msoLogger.debug("SDNC Request Body:\n" + sdncReqBody); + + try { + + url = new URL(rt.getSdncUrl()); + + con = (HttpURLConnection) url.openConnection(); + con.setConnectTimeout(Integer.parseInt(SDNCAdapterPortTypeImpl.getProperty(Constants.SDNC_CONNECTTIME_PROP, "2000",msoPropertiesFactoryp))); + con.setReadTimeout(Integer.parseInt(rt.getTimeout())); + con.setRequestProperty("Accept", "application/yang.data+xml"); //for response in xml + String userCredentials = msoPropertiesFactoryp.getMsoJavaProperties(MSO_PROP_SDNC_ADAPTER).getEncryptedProperty(Constants.SDNC_AUTH_PROP, Constants.DEFAULT_SDNC_AUTH, Constants.ENCRYPTION_KEY); + + String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); + con.setRequestProperty ("Authorization", basicAuth); + con.setRequestMethod(rt.getReqMethod()); + + // Add request headers + if ("POST".equals(rt.getReqMethod()) || "PUT".equals(rt.getReqMethod())) + { + con.setRequestProperty("Content-type", "application/xml"); + con.setRequestProperty("Content-length",String.valueOf(sdncReqBody.length())); + con.setDoOutput(true); + out = new DataOutputStream(con.getOutputStream()); + out.writeBytes(sdncReqBody); + out.flush(); + out.close(); + } + + //Get response + sdncResp.setRespCode(con.getResponseCode()); + sdncResp.setRespMsg(con.getResponseMessage()); + + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + + String inputLine; + //Not parsing the response -it contains a responseHdr section and data section + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + + sdncResp.setSdncRespXml(response.toString()); + msoLogger.info(MessageEnum.RA_RESPONSE_FROM_SDNC, sdncResp.toString(), "SDNC", ""); + return(sdncResp); + } + catch (Exception e) + { + msoLogger.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception processing request to SDNC", e); + //default + sdncResp.setRespCode(HttpURLConnection.HTTP_INTERNAL_ERROR); + String respMsg = "Error processing request to SDNC. "; + String sdncErrMsg = null; + + if (e instanceof java.net.SocketTimeoutException ) + { + sdncResp.setRespCode(HttpURLConnection.HTTP_CLIENT_TIMEOUT); + respMsg = "Request to SDNC timed out. "; + } + if (con != null) + { + try { //e1 + if (con.getResponseCode() != HttpURLConnection.HTTP_OK) //seen in SocketException connection reset + sdncResp.setRespCode(con.getResponseCode()); + respMsg = respMsg + con.getResponseMessage() + ". "; + InputStream is = con.getErrorStream(); + if (is != null) + { + XPathFactory xpathFactory = XPathFactory.newInstance(); + XPath xpath = xpathFactory.newXPath(); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setFeature (XMLConstants.FEATURE_SECURE_PROCESSING, true); + DocumentBuilder db; + Document doc = null; + try { //e2 + db = dbf.newDocumentBuilder(); + doc = db.parse(is); + NodeList errors = (NodeList)xpath.evaluate("errors/error", doc, XPathConstants.NODESET); + for (int i = 0; i < errors.getLength(); i++) + { + Element error = (Element) errors.item(i); + String eType = null; + try { + eType = xpath.evaluate("error-type", error); + sdncErrMsg = ". SDNC Returned-[error-type:" + eType; + } catch (Exception e3) { + msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-type", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3); + } + + String eTag = null; + try { + eTag = xpath.evaluate( "error-tag", error); + sdncErrMsg = sdncErrMsg + ", error-tag:" + eTag; + } catch (Exception e3) { + msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-tag", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3); + } + + String eMsg = null; + try { + eMsg = xpath.evaluate("error-message", error); + sdncErrMsg = sdncErrMsg + ", error-message:" + eMsg + "]"; + } catch (Exception e3) { + msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-message", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3); + } + } + } catch (Exception e2) { + msoLogger.error (MessageEnum.RA_ANALYZE_ERROR_EXC, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while analyse error", e2); + } + } //is != null + } catch (Exception e1) { + msoLogger.error (MessageEnum.RA_ERROR_GET_RESPONSE_SDNC, "SDNC", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while get SDNC response", e1); + } + } //con != null + + if (e.getMessage() != null) { + respMsg = respMsg + e.getMessage(); + } + if (sdncErrMsg != null) { + respMsg = respMsg + sdncErrMsg; + } + + sdncResp.setRespMsg(respMsg); + + msoLogger.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with SDNC", e); + alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, respMsg); + return(sdncResp); + } + finally + { + if (con != null) { + con.disconnect(); + } + } + } + + public static void sendRespToBpel(String bpelUrl, SDNCResponse sdncResp,MsoPropertiesFactory msoPropertiesFactoryp) + { + String error; + try + { + SDNCAdapterCallbackRequest cbReq = new SDNCAdapterCallbackRequest(); + cbReq.setCallbackHeader(new CallbackHeader(sdncResp.getReqId(), Integer.toString(sdncResp.getRespCode()), sdncResp.getRespMsg())); + if (sdncResp.getSdncRespXml() != null) + { + cbReq.setRequestData(sdncResp.getSdncRespXml()); + } + msoLogger.info(MessageEnum.RA_CALLBACK_BPEL, cbReq.toString(), "Camunda", ""); + + URL wsdlUrl = null; + try { + wsdlUrl = new URL (bpelUrl); + } catch (MalformedURLException e1) { + error = "Caught exception initializing Callback wsdl " + e1.getMessage(); + msoLogger.error(MessageEnum.RA_INIT_CALLBACK_WSDL_ERR, "Camunda", "", MsoLogger.ErrorCode.DataError, "Exception initializing Callback wsdl", e1); + alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + + SDNCCallbackAdapterService cbSvc = new SDNCCallbackAdapterService(); + + SDNCCallbackAdapterPortType cbPort = cbSvc.getSDNCCallbackAdapterSoapHttpPort(); + + BindingProvider bp = (BindingProvider)cbPort; + + bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsdlUrl.toExternalForm()); + + //authentication + try + { + Map<String, Object> req_ctx = bp.getRequestContext(); + Map<String, List<String>> headers = new HashMap<String, List<String>>(); + String userCredentials = msoPropertiesFactoryp.getMsoJavaProperties(MSO_PROP_SDNC_ADAPTER).getEncryptedProperty(Constants.BPEL_AUTH_PROP, Constants.DEFAULT_BPEL_AUTH, Constants.ENCRYPTION_KEY); + + String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); + req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers); + headers.put ("Authorization", Collections.singletonList(basicAuth)); + } + catch (Exception e2) { + error = "Unable to set authorization in callback request " + e2.getMessage(); + msoLogger.error(MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Unable to set authorization in callback request", e2); + alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + + msoLogger.debug("Invoking Bpel Callback. BpelCallbackUrl:" + bpelUrl); + cbPort.sdncAdapterCallback(cbReq); + + } + catch (Exception e) + { + error = "Error sending BpelCallback request" + e.getMessage(); + msoLogger.error(MessageEnum.RA_CALLBACK_BPEL_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending BpelCallback request", e); + alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + msoLogger.info(MessageEnum.RA_CALLBACK_BPEL_COMPLETE, "Camunda", ""); + return; + } + +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/Utils.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/Utils.java new file mode 100644 index 0000000000..345d0a015c --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/Utils.java @@ -0,0 +1,195 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.impl; + + +import java.io.StringWriter; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.logger.MessageEnum; +public class Utils { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + + public static String genSdncReq(Document reqDoc, RequestTunables rt) { + try { + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + + //NewDoc for output + //Root + Document newdoc = db.newDocument(); + Element root = newdoc.createElementNS(rt.getNamespace(), "input"); + newdoc.appendChild(root); + + //Header + Element hdr = newdoc.createElement(rt.getHeaderName()); + root.appendChild(hdr); + + String elemData = rt.getReqId(); + Element hdrChild; + if (elemData != null && elemData.length() > 0) + { + hdrChild = newdoc.createElement("svc-request-id"); + hdrChild.appendChild(newdoc.createTextNode(elemData)); + hdr.appendChild(hdrChild); + } + + elemData = rt.getAction(); + if (elemData != null && elemData.length() > 0) + { + hdrChild = newdoc.createElement("svc-action"); + hdrChild.appendChild(newdoc.createTextNode(elemData)); + hdr.appendChild(hdrChild); + } + + elemData = rt.getSdncaNotificationUrl(); + if (elemData != null && elemData.length() > 0) + { + hdrChild = newdoc.createElement("svc-notification-url"); + hdrChild.appendChild(newdoc.createTextNode(elemData)); + hdr.appendChild(hdrChild); + } + + //RequestData + NodeList nodes = reqDoc.getDocumentElement().getChildNodes(); + for (int i = 0; i < nodes.getLength(); i++) { + Node n = nodes.item(i); + Node newNode = newdoc.importNode(n, true); + root.appendChild(newNode); + } + + String s = domToStr(newdoc); + msoLogger.debug("Formatted SdncReq:\n" + s); + return (s); + + } catch (Exception e) { + msoLogger.error(MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST, "SDNC", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in genSdncReq", e); + } + return(null); + } + + public static String genSdncPutReq(Document reqDoc, RequestTunables rt) { + try { + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + + //NewDoc for output + //Root + Document newdoc = db.newDocument(); + + //RequestData + NodeList nodes = reqDoc.getDocumentElement().getChildNodes(); + + + Element root = newdoc.createElement(nodes.item(0).getNodeName()); + newdoc.appendChild(root); + + NodeList childNodes = nodes.item(0).getChildNodes(); + for (int i = 0; i < childNodes.getLength(); i++) { + Node n = childNodes.item(i); + Node newNode = newdoc.importNode(n, true); + root.appendChild(newNode); + } + + String s = domToStr(newdoc); + msoLogger.debug("Formatted SdncPutReq:\n" + s); + return (s); + + } catch (Exception e) { + msoLogger.error(MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception in genSdncPutReq", e); + } + return(null); + } + + public static String genMsoFailResp(SDNCResponse resp) { + try { + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + + //NewDoc for output + //Root + Document newdoc = db.newDocument(); + Element root = newdoc.createElement("output"); + newdoc.appendChild(root); + + Element elem1 = newdoc.createElement("svc-request-id"); + elem1.appendChild(newdoc.createTextNode(resp.getReqId())); + root.appendChild(elem1); + + Element elem2 = newdoc.createElement("response-code"); + elem2.appendChild(newdoc.createTextNode(String.valueOf(resp.getRespCode()))); + root.appendChild(elem2); + + Element elem3 = newdoc.createElement("response-message"); + elem3.appendChild(newdoc.createTextNode(String.valueOf(resp.getRespMsg()))); + root.appendChild(elem3); + + String s = domToStr(newdoc); + msoLogger.debug("Formatted SdncReq:" + s); + return (s); + + } catch (Exception e) { + msoLogger.error(MessageEnum.RA_ERROR_CREATE_SDNC_RESPONSE, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception in genMsoFailResp", e); + } + return(null); + } + + + public static String domToStr(Document doc) + { + if (doc != null) + { + try { + DOMSource ds = new DOMSource(doc); + StringWriter sw = new StringWriter(); + StreamResult sr = new StreamResult(sw); + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer t = tf.newTransformer(); + //t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");//<?xml version="1.0" encoding="UTF-8"?> + t.transform(ds, sr); + String s = sw.toString(); + + // This is an awful fix for now but we don't want that xmlns="" to be generated + s = s.replaceAll("xmlns=\"\"", ""); + return(s); + } catch (Exception e) { + msoLogger.error(MessageEnum.RA_ERROR_CONVERT_XML2STR, "", "", MsoLogger.ErrorCode.DataError, "Exception - domToStr", e); + } + } + return(null); + } +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java new file mode 100644 index 0000000000..68f31f103f --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java @@ -0,0 +1,200 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.notify; + + +import java.io.StringReader; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathFactory; +import javax.ejb.EJB; + +import org.openecomp.mso.utils.UUIDChecker; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; + +import org.openecomp.mso.adapters.sdnc.impl.Constants; +import org.openecomp.mso.adapters.sdnc.impl.SDNCAdapterPortTypeImpl; +import org.openecomp.mso.adapters.sdnc.impl.SDNCResponse; +import org.openecomp.mso.adapters.sdnc.impl.SDNCRestClient; +import org.openecomp.mso.adapters.sdnc.util.SDNCRequestIdUtil; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoPropertiesFactory; +import org.openecomp.mso.logger.MessageEnum; + +//SDNC to SDNC Async Notifcations +@Path("/") +public class SDNCNotifyResource { + + private MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory(); + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + + @GET() + public Response printMessage () { + long startTime = System.currentTimeMillis (); + UUIDChecker.generateUUID (msoLogger); + String result = "SDNCAdapter Rest services"; + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + return Response.status (HttpServletResponse.SC_OK).entity (result).build (); + + } + + @GET() + @Path("/{param}") + public Response printMessageParam (@PathParam("param") String msg) { + long startTime = System.currentTimeMillis (); + UUIDChecker.generateUUID (msoLogger); + String result = "SDNCAdapter Rest services : " + msg; + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + return Response.status (HttpServletResponse.SC_OK).entity (result).build (); + + } + + @POST + @Path("/SDNCNotify") + @Consumes("application/xml") + @Produces("application/xml") + public Response SDNCNotify (String reqXML, @Context HttpServletRequest request) { + + XPathFactory xpathFactory = XPathFactory.newInstance (); + XPath xpath = xpathFactory.newXPath (); + long startTime = System.currentTimeMillis (); + + msoLogger.info (MessageEnum.RA_RECEIVE_SDNC_NOTIF, reqXML, "SDNC", "SDNCNotify"); + + InputSource source = new InputSource (new StringReader (reqXML)); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance (); + + DocumentBuilder db; + + try { + dbf.setFeature (XMLConstants.FEATURE_SECURE_PROCESSING, true); + db = dbf.newDocumentBuilder (); + } catch (ParserConfigurationException e) { + msoLogger.error (MessageEnum.RA_PARSING_REQUEST_ERROR, "SDNC", "SDNCNotify", MsoLogger.ErrorCode.SchemaError, "Exception - Invalid XML request format", e); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Invalid XML request format"); + return Response.status (HttpServletResponse.SC_BAD_REQUEST).entity ("Invalid XML request format").build (); + } + + Document doc = null; + try { + doc = db.parse (source); + } catch (Exception e) { + msoLogger.error (MessageEnum.RA_PARSING_REQUEST_ERROR, "SDNC", "SDNCNotify", MsoLogger.ErrorCode.SchemaError, "Exception - Invalid XML request format", e); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Invalid XML request format"); + return Response.status (HttpServletResponse.SC_BAD_REQUEST).entity ("Invalid XML request format").build (); + } + + try { + NodeList nl = (NodeList) xpath.evaluate (Constants.SDNC_SVCCFGRESP_ROOT, doc, XPathConstants.NODESET); + if (nl.getLength () <= 0) { + msoLogger.error (MessageEnum.RA_MISSING_PARAM, Constants.SDNC_SVCCFGRESP_ROOT, "SDNC", "SDNCNotify", MsoLogger.ErrorCode.DataError, "Missing param"); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "Missing" + Constants.SDNC_SVCCFGRESP_ROOT); + return Response.status (HttpServletResponse.SC_BAD_REQUEST) + .entity ("Missing " + Constants.SDNC_SVCCFGRESP_ROOT) + .build (); + } + } catch (Exception e) { + msoLogger.error (MessageEnum.RA_MISSING_PARAM, Constants.SDNC_SVCCFGRESP_ROOT, "SDNC", "SDNCNotify", MsoLogger.ErrorCode.DataError, "Exception - Missing param", e); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "Missing" + Constants.SDNC_SVCCFGRESP_ROOT); + return Response.status (HttpServletResponse.SC_BAD_REQUEST) + .entity ("Missing " + Constants.SDNC_SVCCFGRESP_ROOT) + .build (); + } + + String reqId; + try { + reqId = xpath.evaluate (Constants.SDNC_SVCCFGRESP_ROOT + Constants.SDNC_REQ_ID, doc); + } catch (Exception e) { + msoLogger.error (MessageEnum.RA_MISSING_PARAM, Constants.SDNC_SVCCFGRESP_ROOT + Constants.SDNC_REQ_ID, "SDNC", "SDNCNotify", MsoLogger.ErrorCode.DataError, "Exception - Missing param", e); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "Missing" + Constants.SDNC_SVCCFGRESP_ROOT + Constants.SDNC_REQ_ID); + return Response.status (HttpServletResponse.SC_BAD_REQUEST) + .entity ("Missing " + Constants.SDNC_SVCCFGRESP_ROOT + Constants.SDNC_REQ_ID) + .build (); + } + + MsoLogger.setLogContext (SDNCRequestIdUtil.getSDNCOriginalRequestId (reqId), ""); + + String respCode; + try { + respCode = xpath.evaluate (Constants.SDNC_SVCCFGRESP_ROOT + Constants.SDNC_RESP_CODE, doc); + } catch (Exception e) { + msoLogger.error (MessageEnum.RA_MISSING_PARAM, + Constants.SDNC_SVCCFGRESP_ROOT + Constants.SDNC_RESP_CODE, "SDNC", "SDNCNotify", MsoLogger.ErrorCode.DataError, "Exception - Missing param", + e); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "Missing" + Constants.SDNC_SVCCFGRESP_ROOT + Constants.SDNC_RESP_CODE); + return Response.status (HttpServletResponse.SC_BAD_REQUEST) + .entity ("Missing" + Constants.SDNC_SVCCFGRESP_ROOT + Constants.SDNC_RESP_CODE) + .build (); + } + + String respMsg = ""; + try { + respMsg = xpath.evaluate (Constants.SDNC_SVCCFGRESP_ROOT + Constants.SDNC_RESP_MSG, doc); + } catch (Exception e) { + msoLogger.error (MessageEnum.RA_MISSING_PARAM, Constants.SDNC_SVCCFGRESP_ROOT + Constants.SDNC_RESP_MSG, "SDNC", "SDNCNotify", MsoLogger.ErrorCode.DataError, "Exception - Missing param", e); + } + + String bpelUrl = null; + /* + * TODO Hibernate + * try { + * bpelUrl = RequestsDatabase.getBpelUrl(reqId); + * } + * catch (Exception e) + * { + * logger.error("Unable to get SDNC_CALLBACK_URL from ActiveRequests, using default for reqid:" + reqId, e); + * } + */ + if (bpelUrl == null) { + bpelUrl = SDNCAdapterPortTypeImpl.getProperty (Constants.BPEL_URL_PROP, Constants.DEFAULT_BPEL_URL,msoPropertiesFactory); + } + + SDNCResponse sdncResp = new SDNCResponse (reqId); + sdncResp.setRespCode (Integer.parseInt (respCode)); + sdncResp.setRespMsg (respMsg); + sdncResp.setSdncRespXml (reqXML); + long subStartTime = System.currentTimeMillis (); + SDNCRestClient.sendRespToBpel (bpelUrl, sdncResp,msoPropertiesFactory); + msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully send request to BPMN", "BPMN", bpelUrl, null); + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + return Response.ok ().build (); + } +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/package-info.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/package-info.java new file mode 100644 index 0000000000..58359c69b0 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/package-info.java @@ -0,0 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://domain2.att.com/workflow/sdnc/adapter/schema/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package org.openecomp.mso.adapters.sdnc; + diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/util/SDNCRequestIdUtil.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/util/SDNCRequestIdUtil.java new file mode 100644 index 0000000000..733cb69bd8 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/util/SDNCRequestIdUtil.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.util; + + +public class SDNCRequestIdUtil { + // Add private constructor to prevent instance creation. + private SDNCRequestIdUtil () {} + + public static String getSDNCOriginalRequestId (String newRequestId) { + + // Camunda scripts will add postfix, such as -1, -2, on the original requestID, to make sure requestID is unique while sending request to SDNC + // In order to use the unique requestID in logging, need to remove the postfix added by the Camunda scripts + // Verify whether the requestId is a valid UUID with postfix (-1, -2). If yes, it should contain 5 times char '-', since valid UUID contains 4 times '-' + // If the requestId is not a valid UUID with postfix, we do nothing + if (newRequestId.split("-").length == 6) { + return newRequestId.substring(0, newRequestId.lastIndexOf('-')); + } + return newRequestId; + } +} diff --git a/adapters/mso-sdnc-adapter/src/main/resources/SDNCAdapter.wsdl b/adapters/mso-sdnc-adapter/src/main/resources/SDNCAdapter.wsdl new file mode 100644 index 0000000000..2f4c5ad5eb --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/resources/SDNCAdapter.wsdl @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:sdncadaptersc="http://domain2.att.com/workflow/sdnc/adapter/schema/v1" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:tns="http://domain2.att.com/workflow/sdnc/adapter/wsdl/v1" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://domain2.att.com/workflow/sdnc/adapter/wsdl/v1"> + <types> + <schema xmlns="http://www.w3.org/2001/XMLSchema" + elementFormDefault="qualified" + targetNamespace="http://domain2.att.com/workflow/sdnc/adapter/wsdl/v1"> + <import namespace="http://domain2.att.com/workflow/sdnc/adapter/schema/v1" + schemaLocation="SDNCAdapterSchema.xsd" /> + </schema> + </types> + + <message name="SDNCAdapterRequest"> + <part element="sdncadaptersc:SDNCAdapterRequest" name="SDNCAdapterRequest"> + </part> + </message> + <message name="SDNCAdapterResponse"> + <part element="sdncadaptersc:SDNCAdapterResponse" name="SDNCAdapterResponse"> + </part> + </message> + + <portType name="SDNCAdapterPortType"> + <operation name="SDNCAdapter"> + <input message="tns:SDNCAdapterRequest" name="SDNCAdapterRequest"> + </input> + <output message="tns:SDNCAdapterResponse" name="SDNCAdapterResponse"> + </output> + </operation> + </portType> + + <binding name="SDNCAdapterSoapHttpBinding" type="tns:SDNCAdapterPortType"> + <soap:binding style="document" + transport="http://schemas.xmlsoap.org/soap/http" /> + <operation name="SDNCAdapter"> + <soap:operation soapAction="" style="document" /> + <input> + <soap:body use="literal" /> + </input> + <output> + <soap:body use="literal" /> + </output> + </operation> + </binding> + + <service name="SDNCAdapterService"> + <port binding="tns:SDNCAdapterSoapHttpBinding" name="SDNCAdapterSoapHttpPort"> + <soap:address location="SDNCAdapterService" /> + </port> + </service> +</definitions> diff --git a/adapters/mso-sdnc-adapter/src/main/resources/SDNCAdapterSchema.xsd b/adapters/mso-sdnc-adapter/src/main/resources/SDNCAdapterSchema.xsd new file mode 100644 index 0000000000..f0e4435771 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/resources/SDNCAdapterSchema.xsd @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8"?> +<schema targetNamespace="http://domain2.att.com/workflow/sdnc/adapter/schema/v1" +xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:tns="http://domain2.att.com/workflow/sdnc/adapter/schema/v1" + xmlns:sdncadaptersc="http://domain2.att.com/workflow/sdnc/adapter/schema/v1" + elementFormDefault="qualified"> + + + <!-- ========================= --> + <!-- Complex Types --> + <!-- ========================= --> + + + <!-- ========================= --> + <!-- Elements --> + <!-- ========================= --> + + <element name="RequestHeader"> + <complexType> + <sequence> + <element name="RequestId" type="string" minOccurs="1" maxOccurs="1"/> + <element name="SvcInstanceId" type="string" minOccurs="0" maxOccurs="1"/> + <element name="SvcAction" type="string" minOccurs="1" maxOccurs="1"/> + <element name="SvcOperation" type="string" minOccurs="1" maxOccurs="1"/> + <element name="CallbackUrl" type="string" minOccurs="1" maxOccurs="1"/> + <element name="MsoAction" type="string" minOccurs="0" maxOccurs="1"/> + </sequence> + </complexType> + </element> + + <element name="CallbackHeader"> + <complexType> + <sequence> + <element name="RequestId" type="string" minOccurs="1" maxOccurs="1"/> + <element name="ResponseCode" type="string" minOccurs="1" maxOccurs="1"/> + <element name="ResponseMessage" type="string" minOccurs="1" maxOccurs="1"/> + </sequence> + </complexType> + </element> + + <!-- ========================= --> + <!-- Requests/Responses --> + <!-- ========================= --> + + <element name="SDNCAdapterRequest"> + <complexType> + <sequence> + <element ref="tns:RequestHeader" minOccurs="1" maxOccurs="1" /> + <element name="RequestData" type="anyType" minOccurs="1" maxOccurs="1" /> + </sequence> + </complexType> + </element> + + <!-- Empty Ack --> + <element name="SDNCAdapterResponse"> + <complexType> + + </complexType> + </element> + + <!--Used to post Async Status back to workflow, Status Message would be used for any fallouts from SDNC --> + <element name="SDNCAdapterCallbackRequest"> + <complexType> + <sequence> + <element ref="tns:CallbackHeader" minOccurs="1" maxOccurs="1" /> + <element name="RequestData" type="anyType" minOccurs="0" maxOccurs="1" /> + </sequence> + </complexType> + </element> + + +</schema> diff --git a/adapters/mso-sdnc-adapter/src/main/resources/SDNCCallbackAdapter.wsdl b/adapters/mso-sdnc-adapter/src/main/resources/SDNCCallbackAdapter.wsdl new file mode 100644 index 0000000000..1429b5f1c7 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/resources/SDNCCallbackAdapter.wsdl @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:sdncadaptersc="http://domain2.att.com/workflow/sdnc/adapter/schema/v1" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:tns="http://domain2.att.com/workflow/sdnc/adapter/callback/wsdl/v1" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://domain2.att.com/workflow/sdnc/adapter/callback/wsdl/v1"> + <types> + <schema xmlns="http://www.w3.org/2001/XMLSchema" + elementFormDefault="qualified" + targetNamespace="http://domain2.att.com/workflow/sdnc/adapter/wsdl/v1"> + <import namespace="http://domain2.att.com/workflow/sdnc/adapter/schema/v1" + schemaLocation="SDNCAdapterSchema.xsd" /> + </schema> + </types> + + <message name="SDNCAdapterCallbackRequest"> + <part element="sdncadaptersc:SDNCAdapterCallbackRequest" name="SDNCAdapterCallbackRequest"> + </part> + </message> + + <message name="SDNCAdapterCallbackResponse"> + <part element="sdncadaptersc:SDNCAdapterResponse" name="SDNCAdapterCallbackResponse"> + </part> + </message> + + <portType name="SDNCCallbackAdapterPortType"> + <operation name="SDNCAdapterCallback"> + <input message="tns:SDNCAdapterCallbackRequest" name="SDNCAdapterCallbackRequest"> + </input> + <output message="tns:SDNCAdapterCallbackResponse" name="SDNCAdapterCallbackResponse"> + </output> + </operation> + </portType> + + <binding name="SDNCCallbackAdapterSoapHttpBinding" type="tns:SDNCCallbackAdapterPortType"> + <soap:binding style="document" + transport="http://schemas.xmlsoap.org/soap/http" /> + <operation name="SDNCAdapterCallback"> + <soap:operation soapAction="" style="document" /> + <input> + <soap:body use="literal" /> + </input> + <output> + <soap:body use="literal" /> + </output> + </operation> + </binding> + + <service name="SDNCCallbackAdapterService"> + <port binding="tns:SDNCCallbackAdapterSoapHttpBinding" name="SDNCCallbackAdapterSoapHttpPort"> + <soap:address location="SDNCCallbackAdapterService" /> + </port> + </service> +</definitions> diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/ObjectFactoryTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/ObjectFactoryTest.java new file mode 100644 index 0000000000..ed3c780522 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/ObjectFactoryTest.java @@ -0,0 +1,100 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc; + +import static org.junit.Assert.fail; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.StringWriter; +import java.nio.charset.Charset; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; + +import org.junit.Test; + +public class ObjectFactoryTest { + + private Marshaller jaxbMarshaller; + private Unmarshaller jaxbUnmarshaller; + + /** + * Test method for {@link org.openecomp.mso.adapters.sdnc.ObjectFactory#createRequestHeader()}. + */ + @Test + public final void testCreateRequestHeader () { + ObjectFactory of = new ObjectFactory (); + RequestHeader rh = of.createRequestHeader (); + rh.setCallbackUrl ("callback"); + rh.setMsoAction ("action"); + rh.setRequestId ("reqid"); + rh.setSvcAction ("svcAction"); + rh.setSvcInstanceId ("svcId"); + rh.setSvcOperation ("op"); + + try { + JAXBContext jaxbContext = JAXBContext.newInstance(RequestHeader.class); + jaxbMarshaller = jaxbContext.createMarshaller(); + + JAXBContext jaxbContext2 = JAXBContext.newInstance(RequestHeader.class); + jaxbUnmarshaller = jaxbContext2.createUnmarshaller(); + } + catch (JAXBException e) { + e.printStackTrace (); + fail(); + return; + } + + StringWriter writer = new StringWriter(); + try { + jaxbMarshaller.marshal (rh, writer); + } catch (JAXBException e) { + e.printStackTrace(); + fail (); + } + String marshalled = writer.toString (); + assert(marshalled.contains ("<RequestId>reqid</RequestId>")); + + InputStream inputStream = new ByteArrayInputStream(marshalled.getBytes(Charset.forName("UTF-8"))); + try { + RequestHeader res2 = (RequestHeader) jaxbUnmarshaller.unmarshal (inputStream); + assert(res2.getCallbackUrl ().equals ("callback")); + assert(res2.getMsoAction ().equals ("action")); + assert(res2.getSvcOperation ().equals ("op")); + } catch (JAXBException e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Test method for {@link org.openecomp.mso.adapters.sdnc.ObjectFactory#createSDNCAdapterResponse()}. + */ + @Test + public final void testCreateSDNCAdapterResponse () { + ObjectFactory of = new ObjectFactory (); + SDNCAdapterResponse ar = of.createSDNCAdapterResponse (); + assert (ar != null); + } +} diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/RequestTunablesTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/RequestTunablesTest.java new file mode 100644 index 0000000000..59e561a0a8 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/RequestTunablesTest.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.impl; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.junit.BeforeClass; +import org.junit.Test; + +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +public class RequestTunablesTest { + + public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + + /** + * This method is called before any test occurs. + * It creates a fake tree from scratch + * @throws MsoPropertiesException + */ + @BeforeClass + public static final void prepare () throws MsoPropertiesException { + ClassLoader classLoader = RequestTunablesTest.class.getClassLoader (); + String path = classLoader.getResource ("mso.properties").toString ().substring (5); + + msoPropertiesFactory.initializeMsoProperties(RequestTunables.MSO_PROP_SDNC_ADAPTER, path); + + } + + /** + * Test method for + * {@link org.openecomp.mso.adapters.sdnc.impl.RequestTunables#RequestTunables(java.lang.String, java.lang.String, java.lang.String, java.lang.String)} + * . + */ + @Test + public final void testRequestTunables () { + RequestTunables rt = new RequestTunables (null, null, "op", null,msoPropertiesFactory); + assert(rt.getReqId ().length ()==0); + rt = new RequestTunables ("reqId", "msoAction", null, "query",msoPropertiesFactory); + rt.setTunables (); + System.out.println(rt.toString ()); + // assert (rt.getReqMethod ().equals ("toto")); + assert (rt.getTimeout () != null); + assert (rt.getAction ().equals ("query")); + assert (rt.getMsoAction ().equals ("msoAction")); + assert (rt.getHeaderName ().equals ("sdnc-request-header")); + assert (rt.getOperation ().length () == 0); + assert (rt.getAsyncInd ().equals ("N")); + assert (rt.getReqId ().equals ("reqId")); + } + +} diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/util/SDNCRequestIdUtilTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/util/SDNCRequestIdUtilTest.java new file mode 100644 index 0000000000..d296d8d347 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/util/SDNCRequestIdUtilTest.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.sdnc.util; + +import java.util.UUID; +import org.junit.Test; + + +public class SDNCRequestIdUtilTest { + + /** + * Test method for {@link org.openecomp.mso.adapters.sdnc.SDNCRequestIdUtil#getSDNCOriginalRequestId()}. + */ + @Test + public final void testGetSDNCOriginalRequestId () { + String originalRequestId = UUID.randomUUID().toString(); + String postfixedRequestId = originalRequestId + "-1466203712068"; + String postfixedRequestId2 = originalRequestId + "-1466203712068-2"; + + assert(SDNCRequestIdUtil.getSDNCOriginalRequestId(postfixedRequestId).equals(originalRequestId)); + assert(SDNCRequestIdUtil.getSDNCOriginalRequestId(postfixedRequestId2).equals(postfixedRequestId2)); + + } + +} diff --git a/adapters/mso-sdnc-adapter/src/test/resources/logback-test.xml b/adapters/mso-sdnc-adapter/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..a66a1e8cd3 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/test/resources/logback-test.xml @@ -0,0 +1,47 @@ +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + 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. + ============LICENSE_END========================================================= + --> + +<configuration > + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern> + </encoder> + </appender> + + + <logger name="com.att.eelf.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="trace" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <root level="info"> + <appender-ref ref="STDOUT" /> + </root> + + +</configuration> diff --git a/adapters/mso-sdnc-adapter/src/test/resources/mso.properties b/adapters/mso-sdnc-adapter/src/test/resources/mso.properties new file mode 100644 index 0000000000..5384285306 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/test/resources/mso.properties @@ -0,0 +1,52 @@ +### +# ============LICENSE_START======================================================= +# ECOMP MSO +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# 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. +# ============LICENSE_END========================================================= +### + +### SDNCURL +### +#EE# +org.openecomp.mso.adapters.sdnc.sdncgeturl=https://localhost:8443/restconf/config/L3SDN-API: +org.openecomp.mso.adapters.sdnc.sdncposturl=https://localhost:8443/restconf/operations/L3SDN-API: +#ST#org.openecomp.mso.adapters.sdnc.sdncgeturl=https://sdncodl.mtsnjdcp1.aic.cip.att.com:8443/restconf/config/L3SDN-API: +#ST#org.openecomp.mso.adapters.sdnc.sdncposturl=https://sdncodl.mtsnjdcp1.aic.cip.att.com:8443/restconf/operations/L3SDN-API: +#IT#org.openecomp.mso.adapters.sdnc.sdncgeturl=https://odl.node01.it.app.sdn.labs.att.com:8443/restconf/config/L3SDN-API: +#IT#org.openecomp.mso.adapters.sdnc.sdncposturl=https://odl.node01.it.app.sdn.labs.att.com:8443/restconf/operations/L3SDN-API: +### +### BPEL ASYNC CALLLBACK/NOTIFICATION URL +### +#EE# +org.openecomp.mso.adapters.sdnc.bpelurl=http://localhost:8080/active-bpel/services/SDNCAdapterCallbackV1 +#ST#org.openecomp.mso.adapters.sdnc.bpelurl=http://mtsnjv9mobp01.aic.cip.att.com:8080/active-bpel/services/SDNCAdapterCallbackV1 +#IT#org.openecomp.mso.adapters.sdnc.bpelurl=http://mtanjv9mobp01.aic.cip.att.com:8080/active-bpel/services/SDNCAdapterCallbackV1 +#DV#org.openecomp.mso.adapters.sdnc.bpelurl=http://NJCDTL21RA1926.ITServices.sbc.com:8088/mockSDNCCallbackAdapterSoapHttpBinding?wsdl +### +### SDNC ASYNC NOTIFICATION/RESPONSE URL +### +#EE# +org.openecomp.mso.adapters.sdnc.myurl=https://localhost:8443/adapters/rest/SDNCNotify +#ST#org.openecomp.mso.adapters.sdnc.myurl=https://msojra.mtsnjdcp1.aic.cip.att.com:8443/adapters/rest/SDNCNotify +#IT#org.openecomp.mso.adapters.sdnc.myurl=http://mtanjv9moja01.aic.cip.att.com:8080/adapters/rest/SDNCNotify +#DV#org.openecomp.mso.adapters.sdnc.myurl=http://NJCDTL21RA1926.ITServices.sbc.com:8080/adapters/rest/SDNCNotify +### +org.openecomp.mso.adapters.sdnc.sdncauth=admin:admin +org.openecomp.mso.adapters.sdnc.bpelauth=avosAdmin:jboss123 +org.openecomp.mso.adapters.sdnc.sdncconnecttime=2000 +org.openecomp.mso.adapters.sdnc.sdncreadtime=5000 + +org.openecomp.mso.adapters.sdnc...query=toto diff --git a/adapters/mso-tenant-adapter/README.md b/adapters/mso-tenant-adapter/README.md new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/adapters/mso-tenant-adapter/README.md diff --git a/adapters/mso-tenant-adapter/WebContent/META-INF/MANIFEST.MF b/adapters/mso-tenant-adapter/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..5e9495128c --- /dev/null +++ b/adapters/mso-tenant-adapter/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0
+Class-Path:
+
diff --git a/adapters/mso-tenant-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector b/adapters/mso-tenant-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector new file mode 100644 index 0000000000..1281d32948 --- /dev/null +++ b/adapters/mso-tenant-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector @@ -0,0 +1 @@ +com.woorea.openstack.connector.HttpClientConnector
\ No newline at end of file diff --git a/adapters/mso-tenant-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml b/adapters/mso-tenant-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 0000000000..58ddb4a08f --- /dev/null +++ b/adapters/mso-tenant-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml @@ -0,0 +1,16 @@ +<jboss-deployment-structure>
+ <deployment>
+ <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
+ <exclusions>
+ <module name="org.apache.log4j" />
+ <module name="org.slf4j" />
+ <module name="org.slf4j.impl" />
+ </exclusions>
+ <dependencies>
+ <module name="org.jboss.jandex" slot="main" />
+ <module name="org.javassist" slot="main" />
+ <module name="org.antlr" slot="main" />
+ <module name="org.dom4j" slot="main" />
+ </dependencies>
+ </deployment>
+</jboss-deployment-structure>
\ No newline at end of file diff --git a/adapters/mso-tenant-adapter/WebContent/WEB-INF/jboss-web.xml b/adapters/mso-tenant-adapter/WebContent/WEB-INF/jboss-web.xml new file mode 100644 index 0000000000..5583b34d6e --- /dev/null +++ b/adapters/mso-tenant-adapter/WebContent/WEB-INF/jboss-web.xml @@ -0,0 +1,3 @@ +<jboss-web>
+ <context-root>tenants</context-root>
+</jboss-web>
\ No newline at end of file diff --git a/adapters/mso-tenant-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-tenant-adapter/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000000..9118bba5a8 --- /dev/null +++ b/adapters/mso-tenant-adapter/WebContent/WEB-INF/web.xml @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> + <display-name>mso-tenant-adapter</display-name> + + <context-param> + <param-name>resteasy.jndi.resources</param-name> + <param-value>java:module/MsoPropertiesFactory,java:module/CloudConfigFactory</param-value> + </context-param> + + <context-param> + <param-name>log.configuration</param-name> + <param-value>logback.tenant.xml</param-value> + </context-param> + <context-param> + <param-name>mso.configuration</param-name> + <param-value>MSO_PROP_TENANT_ADAPTER=mso.tenant.properties,MSO_PROP_TOPOLOGY=topology.properties</param-value> + </context-param> + <context-param> + <param-name>mso.cloud_config.configuration</param-name> + <param-value>cloud_config.json=2</param-value> + </context-param> + <context-param> + <param-name>resteasy.resources</param-name> + <param-value> + org.openecomp.mso.logger.MsoLoggingServlet, + org.openecomp.mso.MsoStatusHandler, + org.openecomp.mso.adapters.tenant.HealthCheckHandler, + org.openecomp.mso.adapters.tenant.TenantAdapterRest + </param-value> + </context-param> + <context-param> + <param-name>resteasy.servlet.mapping.prefix</param-name> + <param-value>/rest</param-value> + </context-param> + <servlet> + <servlet-name>Resteasy</servlet-name> + <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>Resteasy</servlet-name> +<!-- <url-pattern>/admin/*</url-pattern> --> + <url-pattern>/rest/*</url-pattern> + </servlet-mapping> + + <filter> + <filter-name>LogFilter</filter-name> + <filter-class>org.openecomp.mso.logger.LogFilter</filter-class> + </filter> + <filter-mapping> + <filter-name>LogFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + <welcome-file-list> + <welcome-file>/check.html</welcome-file> + </welcome-file-list> + <security-constraint> + <web-resource-collection> + <web-resource-name>SoapRequests</web-resource-name> + <description>Soap Ingress Requests</description> + <url-pattern>/TenantAdapter</url-pattern> + <http-method>POST</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>BPEL-Client</role-name> + </auth-constraint> + </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>SiteStatus</web-resource-name> + <description>SiteStatus APIs</description> + <url-pattern>/rest/setStatus/*</url-pattern> + <http-method>POST</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>SiteControl-Client</role-name> + </auth-constraint> + </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>RestRequests</web-resource-name> + <description>Rest Ingress Requests</description> + <url-pattern>/rest/v1/tenants/*</url-pattern> + <http-method>DELETE</http-method> + <http-method>GET</http-method> + <http-method>POST</http-method> + <http-method>PUT</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>BPEL-Client</role-name> + </auth-constraint> + </security-constraint> + <login-config> + <auth-method>BASIC</auth-method> + <realm-name>ApplicationRealm</realm-name> + </login-config> + <security-role> + <role-name>BPEL-Client</role-name> + </security-role> + <security-role> + <role-name>SiteControl-Client</role-name> + </security-role> +</web-app> + diff --git a/adapters/mso-tenant-adapter/WebContent/check.html b/adapters/mso-tenant-adapter/WebContent/check.html new file mode 100644 index 0000000000..00f37d60d1 --- /dev/null +++ b/adapters/mso-tenant-adapter/WebContent/check.html @@ -0,0 +1,10 @@ +<!DOCTYPE html>
+<html>
+<head>
+<meta charset="ISO-8859-1">
+<title>Health Check</title>
+</head>
+<body>
+Application ready
+</body>
+</html>
\ No newline at end of file diff --git a/adapters/mso-tenant-adapter/pom.xml b/adapters/mso-tenant-adapter/pom.xml new file mode 100644 index 0000000000..c649e9eb69 --- /dev/null +++ b/adapters/mso-tenant-adapter/pom.xml @@ -0,0 +1,155 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp.mso</groupId> + <artifactId>adapters</artifactId> + <version>0.0.4-SNAPSHOT</version> + </parent> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-tenant-adapter</artifactId> + <packaging>war</packaging> + <name>mso-tenant-adapter</name> + <description>Web Service endpoint for Tenant operations</description> + + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <version>2.6</version> + <executions> + <execution> + <id>copy-resources</id> + <phase>validate</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <resources> + <resource> + <directory>./src/main/resources/META-INF</directory> + <filtering>false</filtering> + </resource> + </resources> + <outputDirectory>${project.build.directory}/${project.build.finalName}/META-INF/</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>2.4</version> + <configuration> + <warSourceDirectory>WebContent</warSourceDirectory> + <failOnMissingWebXml>false</failOnMissingWebXml> + <attachClasses>true</attachClasses> + </configuration> + </plugin> + <plugin> + <groupId>org.jvnet.jax-ws-commons</groupId> + <artifactId>jaxws-maven-plugin</artifactId> + <version>2.3</version> + <executions> + <execution> + <goals> + <goal>wsgen</goal> + </goals> + </execution> + </executions> + <configuration> + <verbose>true</verbose> + <sei>org.openecomp.mso.adapters.tenant.MsoTenantAdapterImpl</sei> + <genWsdl>true</genWsdl> + <inlineSchemas>true</inlineSchemas> + </configuration> + <dependencies> + <dependency> + <groupId>com.sun.xml.ws</groupId> + <artifactId>jaxws-tools</artifactId> + <version>2.2.7</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + </plugin> + + </plugins> + <pluginManagement> + <plugins> + <!--This plugin's configuration is used to store Eclipse m2e settings + only. It has no influence on the Maven build itself. --> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId> + org.jvnet.jax-ws-commons + </groupId> + <artifactId> + jaxws-maven-plugin + </artifactId> + <versionRange> + [2.3,) + </versionRange> + <goals> + <goal>wsgen</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore></ignore> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + <dependencies> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapters-rest-interface</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>javax</groupId> + <artifactId>javaee-web-api</artifactId> + <version>6.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.spec.javax.ejb</groupId> + <artifactId>jboss-ejb-api_3.2_spec</artifactId> + <version>1.0.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.ejb3</groupId> + <artifactId>jboss-ejb3-ext-api</artifactId> + <version>2.2.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>status-control</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project> diff --git a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/HealthCheckHandler.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/HealthCheckHandler.java new file mode 100644 index 0000000000..7916be2aa9 --- /dev/null +++ b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/HealthCheckHandler.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenant; + + +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.HealthCheckUtils; +import org.openecomp.mso.utils.UUIDChecker; + +@Path("/") + public class HealthCheckHandler { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + @HEAD + @GET + @Path("/healthcheck") + @Produces("text/html") + public Response healthcheck (@QueryParam("requestId") String requestId) { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("Healthcheck"); + UUIDChecker.verifyOldUUID(requestId, msoLogger); + HealthCheckUtils healthCheck = new HealthCheckUtils (); + if (!healthCheck.siteStatusCheck(msoLogger, startTime)) { + return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; + } + + if (!healthCheck.catalogDBCheck (msoLogger, startTime)) { + return HealthCheckUtils.NOT_STARTED_RESPONSE; + } + msoLogger.debug("healthcheck - Successful"); + return HealthCheckUtils.HEALTH_CHECK_RESPONSE; + } + +} diff --git a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapter.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapter.java new file mode 100644 index 0000000000..a86c93828f --- /dev/null +++ b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapter.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenant; + + +import java.util.Map; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebParam.Mode; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.ws.Holder; + +import org.openecomp.mso.adapters.tenant.exceptions.TenantAlreadyExists; +import org.openecomp.mso.adapters.tenant.exceptions.TenantException; +import org.openecomp.mso.adapters.tenantrest.TenantRollback; +import org.openecomp.mso.entity.MsoRequest; + +@WebService (name="TenantAdapter", targetNamespace="http://com.att.mso/tenant") +public interface MsoTenantAdapter +{ + /** + * This is the "Create Tenant" Web Service Endpoint definition. + */ + @WebMethod + public void createTenant (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantName") @XmlElement(required=true) String tenantName, + @WebParam(name="metadata") Map<String,String> metadata, + @WebParam(name="failIfExists") Boolean failIfExists, + @WebParam(name="backout") Boolean backout, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="tenantId", mode=Mode.OUT) Holder<String> tenantId, + @WebParam(name="rollback", mode=Mode.OUT) Holder<TenantRollback> rollback ) + throws TenantException, TenantAlreadyExists; + + @WebMethod + public void queryTenant (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantNameOrId") @XmlElement(required=true) String tenantNameOrId, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="tenantId", mode=Mode.OUT) Holder<String> tenantId, + @WebParam(name="tenantName", mode=Mode.OUT) Holder<String> tenantName, + @WebParam(name="metadata", mode=Mode.OUT) Holder<Map<String,String>> metadata ) + throws TenantException; + + @WebMethod + public void deleteTenant (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="tenantDeleted", mode=Mode.OUT) Holder<Boolean> tenantDeleted) + throws TenantException; + + @WebMethod + public void rollbackTenant (@WebParam(name="rollback") @XmlElement(required=true) TenantRollback rollback) + throws TenantException; + + @WebMethod + public void healthCheck (); +} diff --git a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImpl.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImpl.java new file mode 100644 index 0000000000..040c682b3d --- /dev/null +++ b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImpl.java @@ -0,0 +1,279 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenant; + + +import java.util.Map; + +import javax.annotation.Resource; +import javax.jws.WebService; +import javax.xml.ws.Holder; +import javax.xml.ws.WebServiceContext; + +import org.openecomp.mso.properties.MsoPropertiesFactory; +import org.openecomp.mso.adapters.tenant.exceptions.TenantAlreadyExists; +import org.openecomp.mso.adapters.tenant.exceptions.TenantException; +import org.openecomp.mso.adapters.tenantrest.TenantRollback; +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.beans.MsoTenant; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.utils.MsoTenantUtils; +import org.openecomp.mso.openstack.utils.MsoTenantUtilsFactory; + +@WebService(serviceName = "TenantAdapter", endpointInterface = "org.openecomp.mso.adapters.tenant.MsoTenantAdapter", targetNamespace = "http://com.att.mso/tenant") +public class MsoTenantAdapterImpl implements MsoTenantAdapter { + + MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + MsoTenantUtilsFactory tFactory = new MsoTenantUtilsFactory(MSO_PROP_TENANT_ADAPTER); + + public static final String MSO_PROP_TENANT_ADAPTER="MSO_PROP_TENANT_ADAPTER"; + + @Resource + WebServiceContext wsContext; + + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + /** + * Health Check web method. Does nothing but return to show the adapter is deployed. + */ + @Override + public void healthCheck () { + LOGGER.debug ("Health check call in Tenant Adapter"); + } + + /** + * This is the "Create Tenant" web service implementation. It will create + * a new Tenant in the specified cloud. If the tenant already exists, this + * can be considered a success or failure, depending on the value of the + * 'failIfExists' parameter. + * + * The method returns the tenantId (the Openstack ID), and a TenantRollback + * object. This last object can be passed as-is to the rollbackTenant method + * to undo what (if anything) was created. This is useful if a Tenant is + * successfully created but the orchestrator fails on a subsequent operation. + */ + @Override + public void createTenant (String cloudSiteId, + String tenantName, + Map <String, String> metadata, + Boolean failIfExists, + Boolean backout, + MsoRequest msoRequest, + Holder <String> tenantId, + Holder <TenantRollback> rollback) throws TenantException, TenantAlreadyExists { + MsoLogger.setLogContext (msoRequest); + MsoLogger.setServiceName ("CreateTenant"); + + LOGGER.debug ("Call to MSO createTenant adapter. Creating Tenant: " + tenantName + + "in " + + cloudSiteId); + + // Will capture total time for metrics + long startTime = System.currentTimeMillis (); + + // Start building up rollback object + TenantRollback tenantRollback = new TenantRollback (); + tenantRollback.setCloudId (cloudSiteId); + tenantRollback.setMsoRequest (msoRequest); + + MsoTenantUtils tUtils = tFactory.getTenantUtils (cloudSiteId); + + MsoTenant newTenant = null; + String newTenantId = null; + long queryTenantStartTime = System.currentTimeMillis (); + try { + newTenant = tUtils.queryTenantByName (tenantName, cloudSiteId); + LOGGER.recordMetricEvent (queryTenantStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryTenant", null); + } catch (MsoException me) { + LOGGER.recordMetricEvent (queryTenantStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with Open Stack", "OpenStack", "QueryTenant", null); + String error = "Create Tenant " + tenantName + ": " + me; + LOGGER.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), "OpenStack", "createTenant", MsoLogger.ErrorCode.DataError, "Exception while communicate with Open Stack", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new TenantException (me); + } + if (newTenant == null) { + if (backout == null) + backout = true; + long createTenantStartTime = System.currentTimeMillis (); + try { + newTenantId = tUtils.createTenant (tenantName, cloudSiteId, metadata, backout.booleanValue ()); + LOGGER.recordMetricEvent (createTenantStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "CreateTenant", null); + } catch (MsoException me) { + LOGGER.recordMetricEvent (createTenantStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with Open Stack", "OpenStack", "CreateTenant", null); + String error = "Create Tenant " + tenantName + ": " + me; + LOGGER.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), "OpenStack", "createTenant", MsoLogger.ErrorCode.DataError, "Exception while communicate with Open Stack", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new TenantException (me); + } + tenantRollback.setTenantId (newTenantId); + tenantRollback.setTenantCreated (true); + LOGGER.debug ("Tenant " + tenantName + " successfully created with ID " + newTenantId); + } else { + if (failIfExists != null && failIfExists) { + String error = "CreateTenant: Tenant " + tenantName + " already exists in " + cloudSiteId; + LOGGER.error (MessageEnum.RA_TENANT_ALREADY_EXIST, tenantName, cloudSiteId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "CreateTenant, Tenant already exists"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); + throw new TenantAlreadyExists (tenantName, cloudSiteId, newTenant.getTenantId ()); + } + + newTenantId = newTenant.getTenantId (); + tenantRollback.setTenantCreated (false); + LOGGER.debug ("Tenant " + tenantName + " already exists with ID " + newTenantId); + } + + + tenantId.value = newTenantId; + rollback.value = tenantRollback; + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create tenant"); + return; + } + + @Override + public void queryTenant (String cloudSiteId, + String tenantNameOrId, + MsoRequest msoRequest, + Holder <String> tenantId, + Holder <String> tenantName, + Holder <Map <String, String>> metadata) throws TenantException { + MsoLogger.setLogContext (msoRequest); + MsoLogger.setServiceName ("QueryTenant"); + LOGGER.debug ("Querying Tenant " + tenantNameOrId + " in " + cloudSiteId); + + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + + MsoTenantUtils tUtils = tFactory.getTenantUtils (cloudSiteId); + + MsoTenant qTenant = null; + long subStartTime = System.currentTimeMillis (); + try { + qTenant = tUtils.queryTenant (tenantNameOrId, cloudSiteId); + LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryTenant", null); + if (qTenant == null) { + // Not found by ID, Try by name. + qTenant = tUtils.queryTenantByName (tenantNameOrId, cloudSiteId); + } + + if (qTenant == null) { + LOGGER.debug ("QueryTenant: Tenant " + tenantNameOrId + " not found"); + tenantId.value = null; + tenantName.value = null; + metadata.value = null; + } else { + LOGGER.debug ("QueryTenant: Tenant " + tenantNameOrId + " found with ID " + qTenant.getTenantId ()); + tenantId.value = qTenant.getTenantId (); + tenantName.value = qTenant.getTenantName (); + metadata.value = qTenant.getMetadata (); + } + } catch (MsoException me) { + String error = "Query Tenant " + tenantNameOrId + ": " + me; + LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryTenant", null); + LOGGER.error (MessageEnum.RA_GENERAL_EXCEPTION, me.getMessage(), "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception in queryTenant", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new TenantException (me); + } + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully query tenant"); + return; + } + + @Override + public void deleteTenant (String cloudSiteId, + String tenantId, + MsoRequest msoRequest, + Holder <Boolean> tenantDeleted) throws TenantException { + MsoLogger.setLogContext (msoRequest); + MsoLogger.setServiceName ("DeleteTenant"); + + LOGGER.debug ("Deleting Tenant " + tenantId + " in " + cloudSiteId); + + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + + // Delete the Tenant. + long subStartTime = System.currentTimeMillis (); + try { + + MsoTenantUtils tUtils = tFactory.getTenantUtils (cloudSiteId); + boolean deleted = tUtils.deleteTenant (tenantId, cloudSiteId); + tenantDeleted.value = deleted; + LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully communicate with Open Stack", "OpenStack", "DeleteTenant", null); + } catch (MsoException me) { + String error = "Delete Tenant " + tenantId + ": " + me; + LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteTenant", null); + LOGGER.error (MessageEnum.RA_DELETE_TEMAMT_ERR, me.getMessage(), "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - DeleteTenant", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new TenantException (me); + } + + // On success, nothing is returned. + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete tenant"); + return; + } + + /** + * This web service endpoint will rollback a previous Create VNF operation. + * A rollback object is returned to the client in a successful creation + * response. The client can pass that object as-is back to the rollbackVnf + * operation to undo the creation. + * + * The rollback includes removing the VNF and deleting the tenant if the + * tenant did not exist prior to the VNF creation. + */ + @Override + public void rollbackTenant (TenantRollback rollback) throws TenantException { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("RollbackTenant"); + // rollback may be null (e.g. if stack already existed when Create was called) + if (rollback == null) { + LOGGER.warn (MessageEnum.RA_ROLLBACK_NULL, "OpenStack", "rollbackTenant", MsoLogger.ErrorCode.DataError, "rollbackTenant, rollback is null"); + return; + } + + // Get the elements of the VnfRollback object for easier access + String cloudSiteId = rollback.getCloudId (); + String tenantId = rollback.getTenantId (); + + MsoLogger.setLogContext (rollback.getMsoRequest ()); + LOGGER.debug ("Rolling Back Tenant " + rollback.getTenantId () + " in " + cloudSiteId); + + long subStartTime = System.currentTimeMillis (); + if (rollback.getTenantCreated ()) { + try { + + MsoTenantUtils tUtils = tFactory.getTenantUtils (cloudSiteId); + tUtils.deleteTenant (tenantId, cloudSiteId); + LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully communicate with Open Stack", "OpenStack", "RollbackTenant", null); + } catch (MsoException me) { + me.addContext ("RollbackTenant"); + // Failed to delete the tenant. + String error = "Rollback Tenant " + tenantId + ": " + me; + LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "RollbackTenant", null); + LOGGER.error (MessageEnum.RA_ROLLBACK_TENANT_ERR, me.getMessage(), "OpenStack", "rollbackTenant", MsoLogger.ErrorCode.DataError, "Exception - rollbackTenant", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new TenantException (me); + } + } + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully roll back tenant"); + return; + } +} diff --git a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/TenantAdapterRest.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/TenantAdapterRest.java new file mode 100644 index 0000000000..0c9993cd20 --- /dev/null +++ b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/TenantAdapterRest.java @@ -0,0 +1,297 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenant; + + +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.xml.ws.Holder; + +import org.openecomp.mso.adapters.tenant.exceptions.TenantAlreadyExists; +import org.openecomp.mso.adapters.tenant.exceptions.TenantException; +import org.openecomp.mso.adapters.tenantrest.CreateTenantError; +import org.openecomp.mso.adapters.tenantrest.CreateTenantRequest; +import org.openecomp.mso.adapters.tenantrest.CreateTenantResponse; +import org.openecomp.mso.adapters.tenantrest.DeleteTenantError; +import org.openecomp.mso.adapters.tenantrest.DeleteTenantRequest; +import org.openecomp.mso.adapters.tenantrest.DeleteTenantResponse; +import org.openecomp.mso.adapters.tenantrest.QueryTenantError; +import org.openecomp.mso.adapters.tenantrest.QueryTenantResponse; +import org.openecomp.mso.adapters.tenantrest.RollbackTenantError; +import org.openecomp.mso.adapters.tenantrest.RollbackTenantRequest; +import org.openecomp.mso.adapters.tenantrest.RollbackTenantResponse; +import org.openecomp.mso.adapters.tenantrest.TenantRollback; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.beans.MsoTenant; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +/** + * This class services calls to the REST interface for Tenants (http://host:port/vnfs/rest/v1/tenants) + * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. + */ +@Path("/v1/tenants") +public class TenantAdapterRest { + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + + //RAA? No logging in wrappers + + @HEAD + @GET + @Path("/healthcheck") + @Produces(MediaType.TEXT_HTML) + public Response healthcheck () { + String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>"; + return Response.status (HttpServletResponse.SC_OK).entity (CHECK_HTML).build (); + } + + /* + URL: + EP: http://host:8080/tenants/rest + Resource: v1/tenants + REQ - metadata? + { + "cloudSiteId": "DAN", + "tenantName": "RAA_1", + "failIfExists": true, + "msoRequest": { + "requestId": "ra1", + "serviceInstanceId": "sa1" + }} + RESP- + { + "cloudSiteId": "DAN", + "tenantId": "128e10b9996d43a7874f19bbc4eb6749", + "tenantCreated": true, + "tenantRollback": { + "tenantId": "128e10b9996d43a7874f19bbc4eb6749", + "cloudId": "DAN", // RAA? cloudId instead of cloudSiteId + "tenantCreated": true, + "msoRequest": { + "requestId": "ra1", + "serviceInstanceId": "sa1" + } + } + } + */ + @POST + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response createTenant(CreateTenantRequest req) { + LOGGER.debug("createTenant enter: " + req.toJsonString()); + + String newTenantId = null; + TenantRollback tenantRollback = new TenantRollback (); + + try { + Holder<String> htenant = new Holder<String>(); + Holder<TenantRollback> hrollback = new Holder<TenantRollback>(); + MsoTenantAdapter impl = new MsoTenantAdapterImpl(); + impl.createTenant( + req.getCloudSiteId(), + req.getTenantName(), + req.getMetadata(), + req.getFailIfExists(), + req.getBackout(), + req.getMsoRequest(), + htenant, + hrollback); + newTenantId = htenant.value; + tenantRollback = hrollback.value; +// TenantAdapterCore TAImpl = new TenantAdapterCore(); +// newTenantId = TAImpl.createTenant (req.getCloudSiteId(), +// req.getTenantName(), +// req.getFailIfExists(), +// req.getBackout(), +// req.getMetadata(), +// req.getMsoRequest(), +// tenantRollback); + } + catch (TenantAlreadyExists tae) { + CreateTenantError exc = new CreateTenantError(tae.getMessage(), tae.getFaultInfo().getCategory(), Boolean.TRUE); + return Response.status(HttpServletResponse.SC_NOT_IMPLEMENTED).entity(exc).build(); + } + catch (TenantException te) { + CreateTenantError exc = new CreateTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory(), Boolean.TRUE); + return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); + } + catch (Exception e) { + CreateTenantError exc = new CreateTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE); + return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); + } + + CreateTenantResponse resp = new CreateTenantResponse (req.getCloudSiteId(), newTenantId, tenantRollback.getTenantCreated(), tenantRollback); + return Response.status(HttpServletResponse.SC_OK).entity(resp).build(); + } + + /* + URL: + http://host:8080/tenants/rest + Resource: v1/tenant/tennatId + REQ: + {"cloudSiteId": "DAN", + "tenantId": "ca84cd3d3df44272845da554656b3ace", + "msoRequest": { + "requestId": "ra1", + "serviceInstanceId": "sa1" + } + } + RESP: + {"tenantDeleted": true} + */ + @DELETE + @Path("{tenantId}") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response deleteTenant( + @PathParam("tenantId") String tenantId, + DeleteTenantRequest req) + { + boolean tenantDeleted = false; + + try { + Holder<Boolean> deleted = new Holder<Boolean>(); + MsoTenantAdapter impl = new MsoTenantAdapterImpl(); + impl.deleteTenant( + req.getCloudSiteId(), + req.getTenantId(), + req.getMsoRequest(), + deleted); + tenantDeleted = deleted.value; + } + catch (TenantException te) { + DeleteTenantError exc = new DeleteTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory(), Boolean.TRUE); + return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); + } + catch (Exception e) { + DeleteTenantError exc = new DeleteTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE); + return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); + } + DeleteTenantResponse resp = new DeleteTenantResponse(); + resp.setTenantDeleted(tenantDeleted); + return Response.status(HttpServletResponse.SC_OK).entity(resp).build(); + } + + /* + URL + EP://http://host:8080/tenants/rest + Resource: /v1/tenants + Params:?tenantNameOrId=RAA_1&cloudSiteId=DAN + RESP + { + "tenantId": "214b428a1f554c02935e66330f6a5409", + "tenantName": "RAA_1", + "metadata": {} + } + */ + @GET + @Path("{tenantId}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response queryTenant( + @PathParam("tenantId") String tenantId, +// @QueryParam("tenantNameOrId") String tenantNameOrId, //RAA? diff from doc + @QueryParam("cloudSiteId") String cloudSiteId, + @QueryParam("msoRequest.requestId") String requestId, + @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId) + { + MsoTenant tenant = null; + try { + Holder<String> htenant = new Holder<String>(); + Holder<String> tenantName = new Holder<String>(); + Holder<Map<String,String>> metadata = new Holder<Map<String,String>>(); + MsoTenantAdapter impl = new MsoTenantAdapterImpl(); + impl.queryTenant( + cloudSiteId, + tenantId, + null, + htenant, + tenantName, + metadata + ); + tenant = new MsoTenant(htenant.value, tenantName.value, metadata.value); +// TenantAdapterCore TAImpl = new TenantAdapterCore(); +// MsoRequest msoReq = new MsoRequest(); +// tenant = TAImpl.queryTenant (cloudSiteId, tenantId, msoReq); + } + catch (TenantException te) { + QueryTenantError exc = new QueryTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory()); + return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); + } + catch (Exception e) { + QueryTenantError exc = new QueryTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL); + return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); + } + QueryTenantResponse resp = new QueryTenantResponse(tenant.getTenantId(), tenant.getTenantName(), tenant.getMetadata()); + return Response.status(HttpServletResponse.SC_OK).entity(resp).build(); + } + + /* + URL + EP: //http://host:8080/tenants/rest + Resource: /v1/tenants/rollback + REQ + {"cloudSiteId": "DAN", + "tenantId": "f58abb05041d4ff384d4d22d1ccd2a6c", + "msoRequest": { + "requestId": "ra1", + "serviceInstanceId": "sa1" + } + } + RESP: + {"tenantDeleted": true} + */ + @DELETE + @Path("") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response rollbackTenant( + @QueryParam("rollback") String action, // WTF? + RollbackTenantRequest req) + { + try { + MsoTenantAdapter impl = new MsoTenantAdapterImpl(); + impl.rollbackTenant(req.getTenantRollback()); + } + catch (TenantException te) { + RollbackTenantError exc = new RollbackTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory(), Boolean.TRUE); + return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); + } + catch (Exception e) { + RollbackTenantError exc = new RollbackTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE); + return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); + } + + RollbackTenantResponse resp = new RollbackTenantResponse (); + resp.setTenantRolledback(req != null); + return Response.status(HttpServletResponse.SC_OK).entity(resp).build(); + } +} diff --git a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantAlreadyExists.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantAlreadyExists.java new file mode 100644 index 0000000000..cc80b949dd --- /dev/null +++ b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantAlreadyExists.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenant.exceptions; + + + +import javax.xml.ws.WebFault; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + + +/** + * This class reports an exception when trying to create a VNF when another + * VNF of the same name already exists in the target cloud/tenant. Note that + * the createVnf method suppresses this exception by default. + * + * + */ +@WebFault (name="TenantAlreadyExists", faultBean="org.openecomp.mso.adapters.tenant.exceptions.TenantExceptionBean", targetNamespace="http://com.att.mso/tenant") +public class TenantAlreadyExists extends TenantException { + + private static final long serialVersionUID = 1L; + + public TenantAlreadyExists (String name, String cloudId, String tenantId) { + super("Tenant " + name + " already exists in " + cloudId + " with ID " + tenantId, MsoExceptionCategory.USERDATA); + } +} diff --git a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantException.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantException.java new file mode 100644 index 0000000000..f68b0fa65b --- /dev/null +++ b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantException.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenant.exceptions; + + + +import javax.xml.ws.WebFault; + +import org.openecomp.mso.adapters.tenant.exceptions.TenantExceptionBean; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +/** + * This class simply extends Exception (without addition additional functionality) + * to provide an identifier for Tenant related exceptions on create, delete, query. + * + * + */ +@WebFault (name="TenantException", faultBean="org.openecomp.mso.adapters.tenant.exceptions.TenantExceptionBean", targetNamespace="http://com.att.mso/tenant") +public class TenantException extends Exception { + + private static final long serialVersionUID = 1L; + + private TenantExceptionBean faultInfo; + + public TenantException (String msg) { + super(msg); + faultInfo = new TenantExceptionBean (msg); + } + + public TenantException (String msg, Throwable e) { + super (msg, e); + faultInfo = new TenantExceptionBean (msg); + } + + public TenantException (String msg, MsoExceptionCategory category) { + super(msg); + faultInfo = new TenantExceptionBean (msg, category); + } + + public TenantException (String msg, MsoExceptionCategory category, Throwable e) { + super (msg, e); + faultInfo = new TenantExceptionBean (msg, category); + } + + public TenantException (MsoException e) { + super (e); + faultInfo = new TenantExceptionBean (e.getContextMessage(), e.getCategory()); + } + + public TenantExceptionBean getFaultInfo() { + return faultInfo; + } + + public void setFaultInfo(TenantExceptionBean faultInfo) { + this.faultInfo = faultInfo; + } +} diff --git a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantExceptionBean.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantExceptionBean.java new file mode 100644 index 0000000000..61c8f331df --- /dev/null +++ b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantExceptionBean.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenant.exceptions; + + +import java.io.Serializable; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +/** + * Jax-WS Fault Bean for Network Exceptions + */ +public class TenantExceptionBean implements Serializable { + + private static final long serialVersionUID = -9062290006520066109L; + + private String message; + private MsoExceptionCategory category; + + public TenantExceptionBean () {} + + public TenantExceptionBean (String message) { + this.message = message; + } + + public TenantExceptionBean (String message, MsoExceptionCategory category) { + this.message = message; + this.category = category; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public MsoExceptionCategory getCategory () { + return category; + } + + public void setCategory (MsoExceptionCategory category) { + this.category = category; + } +} diff --git a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java b/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java new file mode 100644 index 0000000000..dac0e6ebab --- /dev/null +++ b/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java @@ -0,0 +1,132 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenant.test; + + + +import java.util.Map; + +import javax.xml.ws.Holder; + +import org.openecomp.mso.adapters.tenant.MsoTenantAdapter; +import org.openecomp.mso.adapters.tenant.MsoTenantAdapterImpl; +import org.openecomp.mso.adapters.tenant.exceptions.TenantException; +import org.openecomp.mso.adapters.tenantrest.TenantRollback; + +public class TenantTest { + public static final void main (String args[]) + { + String cloudId = "MT"; + cloudId = "AIC_GAMMALAB"; + + MsoTenantAdapter tenantAdapter = new MsoTenantAdapterImpl(); + + Holder<String> tenantId = new Holder<String>(); + Holder<String> tenantName = new Holder<String>(); + Holder<Map<String,String>> tenantMetadata = new Holder<Map<String,String>>(); + Holder<Boolean> tenantDeleted = new Holder<Boolean>(); + Holder<TenantRollback> rollback = new Holder<TenantRollback>(); + + try { + tenantAdapter.queryTenant (cloudId, "934a4ac9c4bd4b8d9d8ab3ef900281b0", null, tenantId, tenantName, tenantMetadata); + System.out.println ("Got Tenant ID=" + tenantId.value + ", name=" + tenantName.value + ", metadata = " + tenantMetadata.value); + } + catch (TenantException e) { + System.out.println ("Got Tenant Exception: " + e); + System.exit(1); + } +/* + Map<String,String> metadata = new HashMap<String,String>(); + metadata.put("sdn-global-id", "abc"); + metadata.put("service-type", "gamma"); + + // Create a new tenant + try { + tenantAdapter.createTenant(cloudId, "TEST_META6", metadata, true, tenantId, rollback); + System.out.println ("Created Tenant ID " + tenantId.value); + } + catch (TenantAlreadyExists e) { + System.out.println ("Create: Tenant already exists: " + "TEST_META6"); + } + catch (TenantException e) { + System.out.println ("Got Tenant Exception on Create: " + e); + System.exit(1); + } + + // Query the new tenant + try { + tenantAdapter.queryTenant (cloudId, "TEST_META6", tenantId, tenantName, tenantMetadata); + System.out.println ("Queried Tenant ID=" + tenantId.value + ", name=" + tenantName.value + ", metadata = " + tenantMetadata.value); + } + catch (TenantException e) { + System.out.println ("Got Tenant Exception on Query: " + e); + System.exit(1); + } + + try { + Thread.sleep(10000); + } catch (InterruptedException e1) {} + + // Delete the new tenant + try { + tenantAdapter.deleteTenant (cloudId, tenantId.value, tenantDeleted); + if (tenantDeleted.value) + System.out.println ("Deleted Tenant " + tenantId.value); + else + System.out.println ("Delete: Tenant " + tenantId.value + " does not exist"); + } + catch (TenantException e) { + System.out.println ("Got Tenant Exception on Delete: " + e); + } +/* + // Create another new tenant + try { + tenantAdapter.createTenant(cloudId, "TEST_MSO2", null, false, tenantId, rollback); + System.out.println ("Created Tenant ID " + tenantId.value); + } + catch (TenantException e) { + System.out.println ("Got Tenant Exception on Create: " + e); + } + + // Query the new tenant + try { + tenantAdapter.queryTenant (cloudId, "TEST_MSO2", tenantId, tenantName); + System.out.println ("Queried Tenant ID=" + tenantId.value + ", name=" + tenantName.value); + } + catch (TenantException e) { + System.out.println ("Got Tenant Exception on Query: " + e); + } + + try { + Thread.sleep(10000); + } catch (InterruptedException e1) {} + + // Rollback the new tenant + try { + tenantAdapter.rollbackTenant(rollback.value); + System.out.println ("Rolled Back Tenant ID " + tenantId.value); + } + catch (TenantException e) { + System.out.println ("Got Tenant Exception on Rollback: " + e); + } +*/ + } +} diff --git a/adapters/mso-tenant-adapter/src/test/resources/logback-test.xml b/adapters/mso-tenant-adapter/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..a23395fe1b --- /dev/null +++ b/adapters/mso-tenant-adapter/src/test/resources/logback-test.xml @@ -0,0 +1,47 @@ +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + 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. + ============LICENSE_END========================================================= + --> + +<configuration > + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern> + </encoder> + </appender> + + + <logger name="com.att.eelf.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="trace" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <root level="info"> + <appender-ref ref="STDOUT" /> + </root> + + +</configuration> diff --git a/adapters/mso-vnf-adapter-async-client/README.md b/adapters/mso-vnf-adapter-async-client/README.md new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/README.md diff --git a/adapters/mso-vnf-adapter-async-client/WebContent/META-INF/MANIFEST.MF b/adapters/mso-vnf-adapter-async-client/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..254272e1c0 --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/adapters/mso-vnf-adapter-async-client/pom.xml b/adapters/mso-vnf-adapter-async-client/pom.xml new file mode 100644 index 0000000000..fc10f1c492 --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/pom.xml @@ -0,0 +1,90 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp.mso</groupId> + <artifactId>adapters</artifactId> + <version>0.0.4-SNAPSHOT</version> + </parent> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-vnf-adapter-async-client</artifactId> + <packaging>jar</packaging> + <name>mso-vnf-adapter-async-client</name> + <description>MSO VNF Adapter Async Client</description> + + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <version>2.6</version> + <configuration> + <classesDirectory>target/classes</classesDirectory> + </configuration> + </plugin> + <plugin> + <groupId>org.jvnet.jax-ws-commons</groupId> + <artifactId>jaxws-maven-plugin</artifactId> + <version>2.3</version> + <executions> + <execution> + <id>generate-stubs</id> + <phase>process-classes</phase> + <goals> + <goal>wsimport</goal> + </goals> + <configuration> + <vmArgs> + <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> + </vmArgs> + <wsdlDirectory>src/main/resources</wsdlDirectory> + <wsdlFiles> + <wsdlFile>VnfAdapterNotify.wsdl</wsdlFile> + </wsdlFiles> + <wsdlLocation>/VnfAdapterNotify.wsdl</wsdlLocation> + <packageName>org.openecomp.mso.adapters.vnf.async.client</packageName> + <xnocompile>false</xnocompile> + <keep>true</keep> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <!--This plugin's configuration is used to store Eclipse m2e settings + only. It has no influence on the Maven build itself. --> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId> + org.jvnet.jax-ws-commons + </groupId> + <artifactId> + jaxws-maven-plugin + </artifactId> + <versionRange> + [2.3,) + </versionRange> + <goals> + <goal>wsimport</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore></ignore> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> +</project> diff --git a/adapters/mso-vnf-adapter-async-client/src/main/resources/VnfAdapterNotify.wsdl b/adapters/mso-vnf-adapter-async-client/src/main/resources/VnfAdapterNotify.wsdl new file mode 100644 index 0000000000..aecef0dd03 --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/main/resources/VnfAdapterNotify.wsdl @@ -0,0 +1,218 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.7-b01 svn-revision#13316. --> +<definitions targetNamespace="http://com.att.mso/vnfNotify" name="vnfAdapterNotify" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:tns="http://com.att.mso/vnfNotify" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> + <types> + <xs:schema version="1.0" targetNamespace="http://com.att.mso/vnfNotify" xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:element name="createVnfNotification" type="tns:createVnfNotification"/> + + <xs:element name="updateVnfNotification" type="tns:updateVnfNotification"/> + + <xs:element name="deleteVnfNotification" type="tns:deleteVnfNotification"/> + + <xs:element name="queryVnfNotification" type="tns:queryVnfNotification"/> + + <xs:element name="rollbackVnfNotification" type="tns:rollbackVnfNotification"/> + + <xs:complexType name="queryVnfNotification"> + <xs:sequence> + <xs:element name="messageId" type="xs:string"/> + <xs:element name="completed" type="xs:boolean"/> + <xs:element name="exception" type="tns:msoExceptionCategory" minOccurs="0"/> + <xs:element name="errorMessage" type="xs:string" minOccurs="0"/> + <xs:element name="vnfExists" type="xs:boolean" minOccurs="0"/> + <xs:element name="vnfId" type="xs:string" minOccurs="0"/> + <xs:element name="status" type="tns:vnfStatus" minOccurs="0"/> + <xs:element name="outputs" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="entry" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="key" minOccurs="0" type="xs:string"/> + <xs:element name="value" minOccurs="0" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="deleteVnfNotification"> + <xs:sequence> + <xs:element name="messageId" type="xs:string"/> + <xs:element name="completed" type="xs:boolean"/> + <xs:element name="exception" type="tns:msoExceptionCategory" minOccurs="0"/> + <xs:element name="errorMessage" type="xs:string" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="rollbackVnfNotification"> + <xs:sequence> + <xs:element name="messageId" type="xs:string"/> + <xs:element name="completed" type="xs:boolean"/> + <xs:element name="exception" type="tns:msoExceptionCategory" minOccurs="0"/> + <xs:element name="errorMessage" type="xs:string" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="createVnfNotification"> + <xs:sequence> + <xs:element name="messageId" type="xs:string"/> + <xs:element name="completed" type="xs:boolean"/> + <xs:element name="exception" type="tns:msoExceptionCategory" minOccurs="0"/> + <xs:element name="errorMessage" type="xs:string" minOccurs="0"/> + <xs:element name="vnfId" type="xs:string" minOccurs="0"/> + <xs:element name="outputs" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="entry" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="key" minOccurs="0" type="xs:string"/> + <xs:element name="value" minOccurs="0" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="rollback" type="tns:vnfRollback" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="updateVnfNotification"> + <xs:sequence> + <xs:element name="messageId" type="xs:string"/> + <xs:element name="completed" type="xs:boolean"/> + <xs:element name="exception" type="tns:msoExceptionCategory" minOccurs="0"/> + <xs:element name="errorMessage" type="xs:string" minOccurs="0"/> + <xs:element name="outputs" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="entry" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="key" minOccurs="0" type="xs:string"/> + <xs:element name="value" minOccurs="0" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="rollback" type="tns:vnfRollback" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="vnfRollback"> + <xs:sequence> + <xs:element name="cloudSiteId" type="xs:string" minOccurs="0"/> + <xs:element name="msoRequest" type="tns:msoRequest" minOccurs="0"/> + <xs:element name="tenantCreated" type="xs:boolean"/> + <xs:element name="tenantId" type="xs:string" minOccurs="0"/> + <xs:element name="vnfCreated" type="xs:boolean"/> + <xs:element name="vnfId" type="xs:string" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="msoRequest"> + <xs:sequence> + <xs:element name="requestId" type="xs:string" minOccurs="0"/> + <xs:element name="serviceInstanceId" type="xs:string" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + + <xs:simpleType name="msoExceptionCategory"> + <xs:restriction base="xs:string"> + <xs:enumeration value="OPENSTACK"/> + <xs:enumeration value="IO"/> + <xs:enumeration value="INTERNAL"/> + <xs:enumeration value="USERDATA"/> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="vnfStatus"> + <xs:restriction base="xs:string"> + <xs:enumeration value="ACTIVE"/> + <xs:enumeration value="FAILED"/> + <xs:enumeration value="NOTFOUND"/> + <xs:enumeration value="UNKNOWN"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> + </types> + <message name="rollbackVnfNotification"> + <part name="parameters" element="tns:rollbackVnfNotification"/> + </message> + <message name="queryVnfNotification"> + <part name="parameters" element="tns:queryVnfNotification"/> + </message> + <message name="createVnfNotification"> + <part name="parameters" element="tns:createVnfNotification"/> + </message> + <message name="updateVnfNotification"> + <part name="parameters" element="tns:updateVnfNotification"/> + </message> + <message name="deleteVnfNotification"> + <part name="parameters" element="tns:deleteVnfNotification"/> + </message> + <portType name="vnfAdapterNotify"> + <operation name="rollbackVnfNotification"> + <input wsam:Action="http://com.att.mso/notify/adapterNotify/rollbackVnfNotificationRequest" message="tns:rollbackVnfNotification"/> + </operation> + <operation name="queryVnfNotification"> + <input wsam:Action="http://com.att.mso/notify/adapterNotify/queryVnfNotificationRequest" message="tns:queryVnfNotification"/> + </operation> + <operation name="createVnfNotification"> + <input wsam:Action="http://com.att.mso/notify/adapterNotify/createVnfNotificationRequest" message="tns:createVnfNotification"/> + </operation> + <operation name="updateVnfNotification"> + <input wsam:Action="http://com.att.mso/notify/adapterNotify/updateVnfNotificationRequest" message="tns:updateVnfNotification"/> + </operation> + <operation name="deleteVnfNotification"> + <input wsam:Action="http://com.att.mso/notify/adapterNotify/deleteVnfNotificationRequest" message="tns:deleteVnfNotification"/> + </operation> + </portType> + <binding name="MsoVnfAdapterAsyncImplPortBinding" type="tns:vnfAdapterNotify"> + <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> + <operation name="rollbackVnfNotification"> + <soap:operation soapAction=""/> + <input> + <soap:body use="literal"/> + </input> + </operation> + <operation name="queryVnfNotification"> + <soap:operation soapAction=""/> + <input> + <soap:body use="literal"/> + </input> + </operation> + <operation name="createVnfNotification"> + <soap:operation soapAction=""/> + <input> + <soap:body use="literal"/> + </input> + </operation> + <operation name="updateVnfNotification"> + <soap:operation soapAction=""/> + <input> + <soap:body use="literal"/> + </input> + </operation> + <operation name="deleteVnfNotification"> + <soap:operation soapAction=""/> + <input> + <soap:body use="literal"/> + </input> + </operation> + </binding> + <service name="vnfAdapterNotify"> + <port name="MsoVnfAdapterAsyncImplPort" binding="tns:MsoVnfAdapterAsyncImplPortBinding"> + <soap:address location="REPLACE_WITH_ACTUAL_URL"/> + </port> + </service> +</definitions> + diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/CreateVnfNotificationESTest.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/CreateVnfNotificationESTest.java new file mode 100644 index 0000000000..bd72cac98d --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/CreateVnfNotificationESTest.java @@ -0,0 +1,225 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 10:47:44 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.List; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class CreateVnfNotificationESTest extends CreateVnfNotificationESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + createVnfNotification0.completed = true; + boolean boolean0 = createVnfNotification0.isCompleted(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + createVnfNotification0.vnfId = "hxb7d^"; + String string0 = createVnfNotification0.getVnfId(); + assertEquals("hxb7d^", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + createVnfNotification0.vnfId = ""; + String string0 = createVnfNotification0.getVnfId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVnfCreated(true); + createVnfNotification0.setRollback(vnfRollback0); + VnfRollback vnfRollback1 = createVnfNotification0.getRollback(); + assertSame(vnfRollback1, vnfRollback0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + VnfRollback vnfRollback0 = new VnfRollback(); + createVnfNotification0.rollback = vnfRollback0; + VnfRollback vnfRollback1 = createVnfNotification0.getRollback(); + assertFalse(vnfRollback1.isVnfCreated()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + CreateVnfNotification.Outputs createVnfNotification_Outputs0 = new CreateVnfNotification.Outputs(); + createVnfNotification0.outputs = createVnfNotification_Outputs0; + CreateVnfNotification.Outputs createVnfNotification_Outputs1 = createVnfNotification0.getOutputs(); + assertSame(createVnfNotification_Outputs1, createVnfNotification_Outputs0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + createVnfNotification0.messageId = "org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory"; + String string0 = createVnfNotification0.getMessageId(); + assertEquals("org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + createVnfNotification0.exception = msoExceptionCategory0; + MsoExceptionCategory msoExceptionCategory1 = createVnfNotification0.getException(); + assertEquals(MsoExceptionCategory.OPENSTACK, msoExceptionCategory1); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + createVnfNotification0.errorMessage = "=(,wm"; + String string0 = createVnfNotification0.getErrorMessage(); + assertEquals("=(,wm", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + CreateVnfNotification.Outputs createVnfNotification_Outputs0 = new CreateVnfNotification.Outputs(); + createVnfNotification_Outputs0.getEntry(); + List<CreateVnfNotification.Outputs.Entry> list0 = createVnfNotification_Outputs0.getEntry(); + assertTrue(list0.isEmpty()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + CreateVnfNotification.Outputs createVnfNotification_Outputs0 = new CreateVnfNotification.Outputs(); + createVnfNotification0.setOutputs(createVnfNotification_Outputs0); + assertNull(createVnfNotification0.getErrorMessage()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + VnfRollback vnfRollback0 = createVnfNotification0.getRollback(); + assertNull(vnfRollback0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.OPENSTACK; + createVnfNotification0.setException(msoExceptionCategory0); + assertFalse(createVnfNotification0.isCompleted()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + String string0 = createVnfNotification0.getErrorMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + CreateVnfNotification.Outputs createVnfNotification_Outputs0 = createVnfNotification0.getOutputs(); + assertNull(createVnfNotification_Outputs0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + createVnfNotification0.getException(); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + createVnfNotification0.setCompleted(false); + assertFalse(createVnfNotification0.isCompleted()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + String string0 = createVnfNotification0.getMessageId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + createVnfNotification0.setVnfId("N"); + assertNull(createVnfNotification0.getException()); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + createVnfNotification0.setErrorMessage(""); + String string0 = createVnfNotification0.getErrorMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + String string0 = createVnfNotification0.getVnfId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + createVnfNotification0.setMessageId(""); + String string0 = createVnfNotification0.getMessageId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + boolean boolean0 = createVnfNotification0.isCompleted(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + CreateVnfNotification.Outputs.Entry createVnfNotification_Outputs_Entry0 = new CreateVnfNotification.Outputs.Entry(); + createVnfNotification_Outputs_Entry0.setValue("`)_fe1"); + assertNull(createVnfNotification_Outputs_Entry0.getKey()); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + CreateVnfNotification.Outputs.Entry createVnfNotification_Outputs_Entry0 = new CreateVnfNotification.Outputs.Entry(); + createVnfNotification_Outputs_Entry0.setKey(""); + assertEquals("", createVnfNotification_Outputs_Entry0.getKey()); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + CreateVnfNotification.Outputs.Entry createVnfNotification_Outputs_Entry0 = new CreateVnfNotification.Outputs.Entry(); + String string0 = createVnfNotification_Outputs_Entry0.getValue(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + CreateVnfNotification.Outputs.Entry createVnfNotification_Outputs_Entry0 = new CreateVnfNotification.Outputs.Entry(); + String string0 = createVnfNotification_Outputs_Entry0.getKey(); + assertNull(string0); + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/CreateVnfNotificationESTestscaffolding.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/CreateVnfNotificationESTestscaffolding.java new file mode 100644 index 0000000000..ff2e368ba6 --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/CreateVnfNotificationESTestscaffolding.java @@ -0,0 +1,83 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 10:47:44 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class CreateVnfNotificationESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnf.async.client.CreateVnfNotification"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(CreateVnfNotificationESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnf.async.client.CreateVnfNotification$Outputs$Entry", + "org.openecomp.mso.adapters.vnf.async.client.MsoRequest", + "org.openecomp.mso.adapters.vnf.async.client.CreateVnfNotification", + "org.openecomp.mso.adapters.vnf.async.client.CreateVnfNotification$Outputs", + "org.openecomp.mso.adapters.vnf.async.client.VnfRollback", + "org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/DeleteVnfNotificationESTest.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/DeleteVnfNotificationESTest.java new file mode 100644 index 0000000000..0d42b35541 --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/DeleteVnfNotificationESTest.java @@ -0,0 +1,109 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 10:48:02 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class DeleteVnfNotificationESTest extends DeleteVnfNotificationESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + DeleteVnfNotification deleteVnfNotification0 = new DeleteVnfNotification(); + deleteVnfNotification0.setCompleted(true); + boolean boolean0 = deleteVnfNotification0.isCompleted(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + DeleteVnfNotification deleteVnfNotification0 = new DeleteVnfNotification(); + deleteVnfNotification0.messageId = "H\"7~I/-7S["; + String string0 = deleteVnfNotification0.getMessageId(); + assertEquals("H\"7~I/-7S[", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + DeleteVnfNotification deleteVnfNotification0 = new DeleteVnfNotification(); + deleteVnfNotification0.messageId = ""; + String string0 = deleteVnfNotification0.getMessageId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + DeleteVnfNotification deleteVnfNotification0 = new DeleteVnfNotification(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.USERDATA; + deleteVnfNotification0.exception = msoExceptionCategory0; + MsoExceptionCategory msoExceptionCategory1 = deleteVnfNotification0.getException(); + assertEquals(MsoExceptionCategory.USERDATA, msoExceptionCategory1); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + DeleteVnfNotification deleteVnfNotification0 = new DeleteVnfNotification(); + deleteVnfNotification0.errorMessage = ""; + deleteVnfNotification0.errorMessage = "H\"7~I/-7S["; + String string0 = deleteVnfNotification0.getErrorMessage(); + assertEquals("H\"7~I/-7S[", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + DeleteVnfNotification deleteVnfNotification0 = new DeleteVnfNotification(); + deleteVnfNotification0.setErrorMessage(""); + String string0 = deleteVnfNotification0.getErrorMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + DeleteVnfNotification deleteVnfNotification0 = new DeleteVnfNotification(); + boolean boolean0 = deleteVnfNotification0.isCompleted(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + DeleteVnfNotification deleteVnfNotification0 = new DeleteVnfNotification(); + deleteVnfNotification0.getException(); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + DeleteVnfNotification deleteVnfNotification0 = new DeleteVnfNotification(); + String string0 = deleteVnfNotification0.getErrorMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + DeleteVnfNotification deleteVnfNotification0 = new DeleteVnfNotification(); + String string0 = deleteVnfNotification0.getMessageId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + DeleteVnfNotification deleteVnfNotification0 = new DeleteVnfNotification(); + deleteVnfNotification0.setMessageId("Jl^?zBSSPj<c<rl"); + assertEquals("Jl^?zBSSPj<c<rl", deleteVnfNotification0.getMessageId()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + DeleteVnfNotification deleteVnfNotification0 = new DeleteVnfNotification(); + MsoExceptionCategory msoExceptionCategory0 = deleteVnfNotification0.exception; + deleteVnfNotification0.setException(msoExceptionCategory0); + assertNull(deleteVnfNotification0.getErrorMessage()); + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/DeleteVnfNotificationESTestscaffolding.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/DeleteVnfNotificationESTestscaffolding.java new file mode 100644 index 0000000000..ea624cf05c --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/DeleteVnfNotificationESTestscaffolding.java @@ -0,0 +1,79 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 10:48:02 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class DeleteVnfNotificationESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnf.async.client.DeleteVnfNotification"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DeleteVnfNotificationESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnf.async.client.DeleteVnfNotification", + "org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/MsoExceptionCategoryESTest.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/MsoExceptionCategoryESTest.java new file mode 100644 index 0000000000..74b074c68c --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/MsoExceptionCategoryESTest.java @@ -0,0 +1,97 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 10:52:03 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoExceptionCategoryESTest extends MsoExceptionCategoryESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoExceptionCategory[] msoExceptionCategoryArray0 = MsoExceptionCategory.values(); + assertNotNull(msoExceptionCategoryArray0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.valueOf("INTERNAL"); + assertEquals(MsoExceptionCategory.INTERNAL, msoExceptionCategory0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + // Undeclared exception! + try { + MsoExceptionCategory.valueOf((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // Name is null + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + // Undeclared exception! + try { + MsoExceptionCategory.valueOf("sm%"); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // No enum constant org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory.sm% + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + // Undeclared exception! + try { + MsoExceptionCategory.fromValue((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // Name is null + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + // Undeclared exception! + try { + MsoExceptionCategory.fromValue("'E'J4$ovJ-=|?p<o5"); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // No enum constant org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory.'E'J4$ovJ-=|?p<o5 + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.IO; + String string0 = msoExceptionCategory0.value(); + assertEquals("IO", string0); + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/MsoExceptionCategoryESTestscaffolding.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/MsoExceptionCategoryESTestscaffolding.java new file mode 100644 index 0000000000..8b4298b929 --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/MsoExceptionCategoryESTestscaffolding.java @@ -0,0 +1,83 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 10:52:03 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoExceptionCategoryESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoExceptionCategoryESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(MsoExceptionCategoryESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory" + ); + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/MsoRequestESTest.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/MsoRequestESTest.java new file mode 100644 index 0000000000..7a1583ebb4 --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/MsoRequestESTest.java @@ -0,0 +1,70 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 10:46:30 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MsoRequestESTest extends MsoRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + msoRequest0.setServiceInstanceId("1lbEy=v({)?8!~ gb2"); + String string0 = msoRequest0.getServiceInstanceId(); + assertEquals("1lbEy=v({)?8!~ gb2", string0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + msoRequest0.setServiceInstanceId(""); + String string0 = msoRequest0.getServiceInstanceId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + msoRequest0.requestId = "<;cSWuoV*]74"; + String string0 = msoRequest0.getRequestId(); + assertEquals("<;cSWuoV*]74", string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + msoRequest0.requestId = ""; + String string0 = msoRequest0.getRequestId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + msoRequest0.setRequestId((String) null); + assertNull(msoRequest0.getServiceInstanceId()); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + String string0 = msoRequest0.getServiceInstanceId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + MsoRequest msoRequest0 = new MsoRequest(); + String string0 = msoRequest0.getRequestId(); + assertNull(string0); + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/MsoRequestESTestscaffolding.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/MsoRequestESTestscaffolding.java new file mode 100644 index 0000000000..c758057cdd --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/MsoRequestESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 10:46:30 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MsoRequestESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnf.async.client.MsoRequest"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MsoRequestESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnf.async.client.MsoRequest" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/ObjectFactoryESTest.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/ObjectFactoryESTest.java new file mode 100644 index 0000000000..ecfd66d0f9 --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/ObjectFactoryESTest.java @@ -0,0 +1,142 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 10:50:08 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import javax.xml.bind.JAXBElement; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class ObjectFactoryESTest extends ObjectFactoryESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + CreateVnfNotification createVnfNotification0 = objectFactory0.createCreateVnfNotification(); + assertNull(createVnfNotification0.getErrorMessage()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + JAXBElement<UpdateVnfNotification> jAXBElement0 = objectFactory0.createUpdateVnfNotification(updateVnfNotification0); + assertNotNull(jAXBElement0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + QueryVnfNotification queryVnfNotification0 = objectFactory0.createQueryVnfNotification(); + assertNull(queryVnfNotification0.getException()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + MsoRequest msoRequest0 = objectFactory0.createMsoRequest(); + assertNull(msoRequest0.getServiceInstanceId()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + CreateVnfNotification createVnfNotification0 = new CreateVnfNotification(); + JAXBElement<CreateVnfNotification> jAXBElement0 = objectFactory0.createCreateVnfNotification(createVnfNotification0); + assertNotNull(jAXBElement0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + VnfRollback vnfRollback0 = objectFactory0.createVnfRollback(); + assertNull(vnfRollback0.getTenantId()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + DeleteVnfNotification deleteVnfNotification0 = new DeleteVnfNotification(); + JAXBElement<DeleteVnfNotification> jAXBElement0 = objectFactory0.createDeleteVnfNotification(deleteVnfNotification0); + assertNotNull(jAXBElement0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + UpdateVnfNotification.Outputs.Entry updateVnfNotification_Outputs_Entry0 = objectFactory0.createUpdateVnfNotificationOutputsEntry(); + assertNull(updateVnfNotification_Outputs_Entry0.getValue()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + CreateVnfNotification.Outputs createVnfNotification_Outputs0 = objectFactory0.createCreateVnfNotificationOutputs(); + assertNotNull(createVnfNotification_Outputs0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + UpdateVnfNotification updateVnfNotification0 = objectFactory0.createUpdateVnfNotification(); + assertNull(updateVnfNotification0.getMessageId()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + UpdateVnfNotification.Outputs updateVnfNotification_Outputs0 = objectFactory0.createUpdateVnfNotificationOutputs(); + assertNotNull(updateVnfNotification_Outputs0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + CreateVnfNotification.Outputs.Entry createVnfNotification_Outputs_Entry0 = objectFactory0.createCreateVnfNotificationOutputsEntry(); + assertNull(createVnfNotification_Outputs_Entry0.getKey()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + DeleteVnfNotification deleteVnfNotification0 = objectFactory0.createDeleteVnfNotification(); + assertNull(deleteVnfNotification0.getErrorMessage()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + QueryVnfNotification.Outputs queryVnfNotification_Outputs0 = objectFactory0.createQueryVnfNotificationOutputs(); + assertNotNull(queryVnfNotification_Outputs0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + RollbackVnfNotification rollbackVnfNotification0 = objectFactory0.createRollbackVnfNotification(); + JAXBElement<RollbackVnfNotification> jAXBElement0 = objectFactory0.createRollbackVnfNotification(rollbackVnfNotification0); + assertNotNull(jAXBElement0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + JAXBElement<QueryVnfNotification> jAXBElement0 = objectFactory0.createQueryVnfNotification(queryVnfNotification0); + assertNotNull(jAXBElement0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + ObjectFactory objectFactory0 = new ObjectFactory(); + QueryVnfNotification.Outputs.Entry queryVnfNotification_Outputs_Entry0 = objectFactory0.createQueryVnfNotificationOutputsEntry(); + assertNull(queryVnfNotification_Outputs_Entry0.getValue()); + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/ObjectFactoryESTestscaffolding.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/ObjectFactoryESTestscaffolding.java new file mode 100644 index 0000000000..4482069c7a --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/ObjectFactoryESTestscaffolding.java @@ -0,0 +1,98 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 10:50:08 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class ObjectFactoryESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnf.async.client.ObjectFactory"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ObjectFactoryESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnf.async.client.MsoRequest", + "org.openecomp.mso.adapters.vnf.async.client.RollbackVnfNotification", + "org.openecomp.mso.adapters.vnf.async.client.QueryVnfNotification$Outputs$Entry", + "org.openecomp.mso.adapters.vnf.async.client.UpdateVnfNotification$Outputs$Entry", + "org.openecomp.mso.adapters.vnf.async.client.CreateVnfNotification", + "org.openecomp.mso.adapters.vnf.async.client.DeleteVnfNotification", + "org.openecomp.mso.adapters.vnf.async.client.VnfStatus", + "org.openecomp.mso.adapters.vnf.async.client.CreateVnfNotification$Outputs", + "org.openecomp.mso.adapters.vnf.async.client.UpdateVnfNotification$Outputs", + "org.openecomp.mso.adapters.vnf.async.client.QueryVnfNotification", + "org.openecomp.mso.adapters.vnf.async.client.CreateVnfNotification$Outputs$Entry", + "org.openecomp.mso.adapters.vnf.async.client.QueryVnfNotification$Outputs", + "org.openecomp.mso.adapters.vnf.async.client.ObjectFactory", + "org.openecomp.mso.adapters.vnf.async.client.VnfRollback", + "org.openecomp.mso.adapters.vnf.async.client.UpdateVnfNotification", + "org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ObjectFactoryESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.vnf.async.client.ObjectFactory" + ); + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/QueryVnfNotificationESTest.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/QueryVnfNotificationESTest.java new file mode 100644 index 0000000000..f65825108f --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/QueryVnfNotificationESTest.java @@ -0,0 +1,224 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 10:49:18 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.List; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class QueryVnfNotificationESTest extends QueryVnfNotificationESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + Boolean boolean0 = Boolean.valueOf("`97"); + queryVnfNotification0.setVnfExists(boolean0); + Boolean boolean1 = queryVnfNotification0.isVnfExists(); + assertFalse(boolean1); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + queryVnfNotification0.completed = true; + boolean boolean0 = queryVnfNotification0.isCompleted(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + queryVnfNotification0.setVnfId(""); + String string0 = queryVnfNotification0.getVnfId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + VnfStatus vnfStatus0 = VnfStatus.FAILED; + queryVnfNotification0.status = vnfStatus0; + VnfStatus vnfStatus1 = queryVnfNotification0.getStatus(); + assertSame(vnfStatus1, vnfStatus0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + QueryVnfNotification.Outputs queryVnfNotification_Outputs0 = new QueryVnfNotification.Outputs(); + queryVnfNotification0.setOutputs(queryVnfNotification_Outputs0); + QueryVnfNotification.Outputs queryVnfNotification_Outputs1 = queryVnfNotification0.getOutputs(); + assertSame(queryVnfNotification_Outputs1, queryVnfNotification_Outputs0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + queryVnfNotification0.messageId = "FAILED"; + String string0 = queryVnfNotification0.getMessageId(); + assertEquals("FAILED", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.INTERNAL; + queryVnfNotification0.setException(msoExceptionCategory0); + MsoExceptionCategory msoExceptionCategory1 = queryVnfNotification0.getException(); + assertEquals(MsoExceptionCategory.INTERNAL, msoExceptionCategory1); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + queryVnfNotification0.errorMessage = "Jk{*#{!k"; + String string0 = queryVnfNotification0.getErrorMessage(); + assertEquals("Jk{*#{!k", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + String string0 = queryVnfNotification0.getMessageId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + queryVnfNotification0.setMessageId(""); + String string0 = queryVnfNotification0.getMessageId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + queryVnfNotification0.setCompleted(true); + assertTrue(queryVnfNotification0.isCompleted()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + queryVnfNotification0.setVnfId("M:E`?t"); + String string0 = queryVnfNotification0.getVnfId(); + assertEquals("M:E`?t", string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + String string0 = queryVnfNotification0.getVnfId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + boolean boolean0 = queryVnfNotification0.isCompleted(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + queryVnfNotification0.getStatus(); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + queryVnfNotification0.setErrorMessage(""); + String string0 = queryVnfNotification0.getErrorMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + VnfStatus vnfStatus0 = VnfStatus.NOTFOUND; + queryVnfNotification0.setStatus(vnfStatus0); + assertFalse(queryVnfNotification0.isCompleted()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + Boolean boolean0 = queryVnfNotification0.isVnfExists(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + queryVnfNotification0.getException(); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + QueryVnfNotification.Outputs queryVnfNotification_Outputs0 = queryVnfNotification0.getOutputs(); + assertNull(queryVnfNotification_Outputs0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + String string0 = queryVnfNotification0.getErrorMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + QueryVnfNotification queryVnfNotification0 = new QueryVnfNotification(); + Boolean boolean0 = new Boolean(true); + queryVnfNotification0.setVnfExists(boolean0); + Boolean boolean1 = queryVnfNotification0.isVnfExists(); + assertTrue(boolean1); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + QueryVnfNotification.Outputs queryVnfNotification_Outputs0 = new QueryVnfNotification.Outputs(); + List<QueryVnfNotification.Outputs.Entry> list0 = queryVnfNotification_Outputs0.getEntry(); + List<QueryVnfNotification.Outputs.Entry> list1 = queryVnfNotification_Outputs0.getEntry(); + assertSame(list1, list0); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + QueryVnfNotification.Outputs.Entry queryVnfNotification_Outputs_Entry0 = new QueryVnfNotification.Outputs.Entry(); + String string0 = queryVnfNotification_Outputs_Entry0.getKey(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + QueryVnfNotification.Outputs.Entry queryVnfNotification_Outputs_Entry0 = new QueryVnfNotification.Outputs.Entry(); + queryVnfNotification_Outputs_Entry0.setValue("{[VrUC"); + assertNull(queryVnfNotification_Outputs_Entry0.getKey()); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + QueryVnfNotification.Outputs.Entry queryVnfNotification_Outputs_Entry0 = new QueryVnfNotification.Outputs.Entry(); + String string0 = queryVnfNotification_Outputs_Entry0.getValue(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + QueryVnfNotification.Outputs.Entry queryVnfNotification_Outputs_Entry0 = new QueryVnfNotification.Outputs.Entry(); + queryVnfNotification_Outputs_Entry0.setKey(""); + assertNull(queryVnfNotification_Outputs_Entry0.getValue()); + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/QueryVnfNotificationESTestscaffolding.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/QueryVnfNotificationESTestscaffolding.java new file mode 100644 index 0000000000..1c1a77429e --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/QueryVnfNotificationESTestscaffolding.java @@ -0,0 +1,82 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 10:49:18 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class QueryVnfNotificationESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnf.async.client.QueryVnfNotification"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(QueryVnfNotificationESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnf.async.client.QueryVnfNotification$Outputs$Entry", + "org.openecomp.mso.adapters.vnf.async.client.VnfStatus", + "org.openecomp.mso.adapters.vnf.async.client.QueryVnfNotification$Outputs", + "org.openecomp.mso.adapters.vnf.async.client.QueryVnfNotification", + "org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/RollbackVnfNotificationESTest.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/RollbackVnfNotificationESTest.java new file mode 100644 index 0000000000..02203acd27 --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/RollbackVnfNotificationESTest.java @@ -0,0 +1,100 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 10:46:51 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RollbackVnfNotificationESTest extends RollbackVnfNotificationESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + RollbackVnfNotification rollbackVnfNotification0 = new RollbackVnfNotification(); + rollbackVnfNotification0.setMessageId(":HW@8Kxo`M[S:7>"); + String string0 = rollbackVnfNotification0.getMessageId(); + assertNotNull(string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + RollbackVnfNotification rollbackVnfNotification0 = new RollbackVnfNotification(); + rollbackVnfNotification0.errorMessage = "INTERNAL"; + String string0 = rollbackVnfNotification0.getErrorMessage(); + assertEquals("INTERNAL", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + RollbackVnfNotification rollbackVnfNotification0 = new RollbackVnfNotification(); + rollbackVnfNotification0.errorMessage = ""; + String string0 = rollbackVnfNotification0.getErrorMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + RollbackVnfNotification rollbackVnfNotification0 = new RollbackVnfNotification(); + rollbackVnfNotification0.getException(); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + RollbackVnfNotification rollbackVnfNotification0 = new RollbackVnfNotification(); + rollbackVnfNotification0.setMessageId(""); + String string0 = rollbackVnfNotification0.getMessageId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + RollbackVnfNotification rollbackVnfNotification0 = new RollbackVnfNotification(); + String string0 = rollbackVnfNotification0.getErrorMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + RollbackVnfNotification rollbackVnfNotification0 = new RollbackVnfNotification(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.INTERNAL; + rollbackVnfNotification0.setException(msoExceptionCategory0); + MsoExceptionCategory msoExceptionCategory1 = rollbackVnfNotification0.getException(); + assertSame(msoExceptionCategory1, msoExceptionCategory0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + RollbackVnfNotification rollbackVnfNotification0 = new RollbackVnfNotification(); + rollbackVnfNotification0.setErrorMessage(""); + assertEquals("", rollbackVnfNotification0.getErrorMessage()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + RollbackVnfNotification rollbackVnfNotification0 = new RollbackVnfNotification(); + String string0 = rollbackVnfNotification0.getMessageId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + RollbackVnfNotification rollbackVnfNotification0 = new RollbackVnfNotification(); + boolean boolean0 = rollbackVnfNotification0.isCompleted(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + RollbackVnfNotification rollbackVnfNotification0 = new RollbackVnfNotification(); + rollbackVnfNotification0.setCompleted(true); + boolean boolean0 = rollbackVnfNotification0.isCompleted(); + assertTrue(boolean0); + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/RollbackVnfNotificationESTestscaffolding.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/RollbackVnfNotificationESTestscaffolding.java new file mode 100644 index 0000000000..8d91d5c730 --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/RollbackVnfNotificationESTestscaffolding.java @@ -0,0 +1,79 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 10:46:51 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RollbackVnfNotificationESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnf.async.client.RollbackVnfNotification"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RollbackVnfNotificationESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnf.async.client.RollbackVnfNotification", + "org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/UpdateVnfNotificationESTest.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/UpdateVnfNotificationESTest.java new file mode 100644 index 0000000000..e71d416bdc --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/UpdateVnfNotificationESTest.java @@ -0,0 +1,181 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 10:51:15 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.List; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class UpdateVnfNotificationESTest extends UpdateVnfNotificationESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.tenantCreated = true; + updateVnfNotification0.setRollback(vnfRollback0); + VnfRollback vnfRollback1 = updateVnfNotification0.getRollback(); + assertNull(vnfRollback1.getTenantId()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + VnfRollback vnfRollback0 = new VnfRollback(); + updateVnfNotification0.rollback = vnfRollback0; + VnfRollback vnfRollback1 = updateVnfNotification0.getRollback(); + assertFalse(vnfRollback1.isTenantCreated()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + UpdateVnfNotification.Outputs updateVnfNotification_Outputs0 = new UpdateVnfNotification.Outputs(); + updateVnfNotification0.setOutputs(updateVnfNotification_Outputs0); + UpdateVnfNotification.Outputs updateVnfNotification_Outputs1 = updateVnfNotification0.getOutputs(); + assertSame(updateVnfNotification_Outputs1, updateVnfNotification_Outputs0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + updateVnfNotification0.messageId = ":_rGAeg9'Jf17.p+,m"; + String string0 = updateVnfNotification0.getMessageId(); + assertEquals(":_rGAeg9'Jf17.p+,m", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + updateVnfNotification0.setMessageId(""); + String string0 = updateVnfNotification0.getMessageId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.IO; + updateVnfNotification0.exception = msoExceptionCategory0; + MsoExceptionCategory msoExceptionCategory1 = updateVnfNotification0.getException(); + assertEquals(MsoExceptionCategory.IO, msoExceptionCategory1); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + updateVnfNotification0.errorMessage = null; + updateVnfNotification0.errorMessage = ""; + String string0 = updateVnfNotification0.getErrorMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + VnfRollback vnfRollback0 = updateVnfNotification0.getRollback(); + assertNull(vnfRollback0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + boolean boolean0 = updateVnfNotification0.isCompleted(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + updateVnfNotification0.getException(); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + String string0 = updateVnfNotification0.getMessageId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + MsoExceptionCategory msoExceptionCategory0 = MsoExceptionCategory.IO; + updateVnfNotification0.setException(msoExceptionCategory0); + assertEquals(MsoExceptionCategory.IO, updateVnfNotification0.getException()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + updateVnfNotification0.setCompleted(true); + boolean boolean0 = updateVnfNotification0.isCompleted(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + UpdateVnfNotification.Outputs updateVnfNotification_Outputs0 = updateVnfNotification0.getOutputs(); + assertNull(updateVnfNotification_Outputs0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + updateVnfNotification0.setErrorMessage("m.m)#ZJF);)x*\"HQ8WB"); + String string0 = updateVnfNotification0.getErrorMessage(); + assertEquals("m.m)#ZJF);)x*\"HQ8WB", string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + UpdateVnfNotification updateVnfNotification0 = new UpdateVnfNotification(); + String string0 = updateVnfNotification0.getErrorMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + UpdateVnfNotification.Outputs updateVnfNotification_Outputs0 = new UpdateVnfNotification.Outputs(); + List<UpdateVnfNotification.Outputs.Entry> list0 = updateVnfNotification_Outputs0.getEntry(); + List<UpdateVnfNotification.Outputs.Entry> list1 = updateVnfNotification_Outputs0.getEntry(); + assertSame(list1, list0); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + UpdateVnfNotification.Outputs.Entry updateVnfNotification_Outputs_Entry0 = new UpdateVnfNotification.Outputs.Entry(); + updateVnfNotification_Outputs_Entry0.setKey(","); + assertEquals(",", updateVnfNotification_Outputs_Entry0.getKey()); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + UpdateVnfNotification.Outputs.Entry updateVnfNotification_Outputs_Entry0 = new UpdateVnfNotification.Outputs.Entry(); + String string0 = updateVnfNotification_Outputs_Entry0.getValue(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + UpdateVnfNotification.Outputs.Entry updateVnfNotification_Outputs_Entry0 = new UpdateVnfNotification.Outputs.Entry(); + updateVnfNotification_Outputs_Entry0.setValue("IO"); + assertNull(updateVnfNotification_Outputs_Entry0.getKey()); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + UpdateVnfNotification.Outputs.Entry updateVnfNotification_Outputs_Entry0 = new UpdateVnfNotification.Outputs.Entry(); + String string0 = updateVnfNotification_Outputs_Entry0.getKey(); + assertNull(string0); + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/UpdateVnfNotificationESTestscaffolding.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/UpdateVnfNotificationESTestscaffolding.java new file mode 100644 index 0000000000..65171632a6 --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/UpdateVnfNotificationESTestscaffolding.java @@ -0,0 +1,83 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 10:51:15 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class UpdateVnfNotificationESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnf.async.client.UpdateVnfNotification"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(UpdateVnfNotificationESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnf.async.client.MsoRequest", + "org.openecomp.mso.adapters.vnf.async.client.UpdateVnfNotification$Outputs$Entry", + "org.openecomp.mso.adapters.vnf.async.client.UpdateVnfNotification$Outputs", + "org.openecomp.mso.adapters.vnf.async.client.VnfRollback", + "org.openecomp.mso.adapters.vnf.async.client.UpdateVnfNotification", + "org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/VnfRollbackESTest.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/VnfRollbackESTest.java new file mode 100644 index 0000000000..7ac55f041a --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/VnfRollbackESTest.java @@ -0,0 +1,132 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 10:50:26 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class VnfRollbackESTest extends VnfRollbackESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVnfId("12&$HOD'rH:!tJy"); + String string0 = vnfRollback0.getVnfId(); + assertEquals("12&$HOD'rH:!tJy", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.vnfId = ""; + String string0 = vnfRollback0.getVnfId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.tenantId = "=x@lXzB:nqB-5F9"; + String string0 = vnfRollback0.getTenantId(); + assertEquals("=x@lXzB:nqB-5F9", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + MsoRequest msoRequest0 = new MsoRequest(); + vnfRollback0.setMsoRequest(msoRequest0); + MsoRequest msoRequest1 = vnfRollback0.getMsoRequest(); + assertNull(msoRequest1.getServiceInstanceId()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setCloudSiteId("/8Qc+9]"); + String string0 = vnfRollback0.getCloudSiteId(); + assertEquals("/8Qc+9]", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setTenantCreated(true); + boolean boolean0 = vnfRollback0.isTenantCreated(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + boolean boolean0 = vnfRollback0.isTenantCreated(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + String string0 = vnfRollback0.getVnfId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + MsoRequest msoRequest0 = vnfRollback0.getMsoRequest(); + assertNull(msoRequest0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVnfCreated(true); + boolean boolean0 = vnfRollback0.isVnfCreated(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + boolean boolean0 = vnfRollback0.isVnfCreated(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setCloudSiteId(""); + String string0 = vnfRollback0.getCloudSiteId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setTenantId(""); + String string0 = vnfRollback0.getTenantId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + String string0 = vnfRollback0.getCloudSiteId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + String string0 = vnfRollback0.getTenantId(); + assertNull(string0); + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/VnfRollbackESTestscaffolding.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/VnfRollbackESTestscaffolding.java new file mode 100644 index 0000000000..10defa429a --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/VnfRollbackESTestscaffolding.java @@ -0,0 +1,79 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 10:50:26 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class VnfRollbackESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnf.async.client.VnfRollback"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(VnfRollbackESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnf.async.client.MsoRequest", + "org.openecomp.mso.adapters.vnf.async.client.VnfRollback" + ); + } + + private static void resetClasses() { + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/VnfStatusESTest.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/VnfStatusESTest.java new file mode 100644 index 0000000000..2f40d5e4c8 --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/VnfStatusESTest.java @@ -0,0 +1,91 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 10:48:53 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class VnfStatusESTest extends VnfStatusESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + VnfStatus[] vnfStatusArray0 = VnfStatus.values(); + assertNotNull(vnfStatusArray0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + // Undeclared exception! + try { + VnfStatus.valueOf((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // Name is null + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + // Undeclared exception! + try { + VnfStatus.valueOf(""); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // No enum constant org.openecomp.mso.adapters.vnf.async.client.VnfStatus. + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + // Undeclared exception! + try { + VnfStatus.fromValue((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // Name is null + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + // Undeclared exception! + try { + VnfStatus.fromValue(""); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // No enum constant org.openecomp.mso.adapters.vnf.async.client.VnfStatus. + // + verifyException("java.lang.Enum", e); + } + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + VnfStatus vnfStatus0 = VnfStatus.NOTFOUND; + String string0 = vnfStatus0.value(); + assertEquals("NOTFOUND", string0); + } +} diff --git a/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/VnfStatusESTestscaffolding.java b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/VnfStatusESTestscaffolding.java new file mode 100644 index 0000000000..7875037332 --- /dev/null +++ b/adapters/mso-vnf-adapter-async-client/src/test/java/org/openecomp/mso/adapters/vnf/async/client/VnfStatusESTestscaffolding.java @@ -0,0 +1,83 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 10:48:53 GMT 2016 + */ + +package org.openecomp.mso.adapters.vnf.async.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class VnfStatusESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.adapters.vnf.async.client.VnfStatus"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(VnfStatusESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.vnf.async.client.VnfStatus" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(VnfStatusESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.vnf.async.client.VnfStatus" + ); + } +} diff --git a/adapters/mso-vnf-adapter/README.md b/adapters/mso-vnf-adapter/README.md new file mode 100644 index 0000000000..2085fc90b6 --- /dev/null +++ b/adapters/mso-vnf-adapter/README.md @@ -0,0 +1,11 @@ +This artifact is the MSO VNF adapter. It serves both SOAP and REST requests to the following URLs: + + * http://host:port/vnfs/VnfAdapter?wsdl + * http://host:port/vnfs/VnfAdapterAsync?wsdl + * http://host:port/vnfs/rest/v1/vnfs/healthcheck + * http://host:port/vnfs/rest/v1/vnfs/{aaiVnfId}/vf-modules + * http://host:port/vnfs/rest/v1/vnfs/{aaiVnfId}/vf-modules/{aaiVfModuleId} + * http://host:port/vnfs/rest/v1/vnfs/{aaiVnfId}/vf-modules/{aaiVfModuleId}/rollback + * http://host:port/vnfs/rest/v1/volume-groups + * http://host:port/vnfs/rest/v1/volume-groups/{aaiVolumeGroupId} + * http://host:port/vnfs/rest/v1/volume-groups/{aaiVolumeGroupId}/rollback diff --git a/adapters/mso-vnf-adapter/WebContent/META-INF/MANIFEST.MF b/adapters/mso-vnf-adapter/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..5e9495128c --- /dev/null +++ b/adapters/mso-vnf-adapter/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0
+Class-Path:
+
diff --git a/adapters/mso-vnf-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector b/adapters/mso-vnf-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector new file mode 100644 index 0000000000..1281d32948 --- /dev/null +++ b/adapters/mso-vnf-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector @@ -0,0 +1 @@ +com.woorea.openstack.connector.HttpClientConnector
\ No newline at end of file diff --git a/adapters/mso-vnf-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml b/adapters/mso-vnf-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 0000000000..58ddb4a08f --- /dev/null +++ b/adapters/mso-vnf-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml @@ -0,0 +1,16 @@ +<jboss-deployment-structure>
+ <deployment>
+ <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
+ <exclusions>
+ <module name="org.apache.log4j" />
+ <module name="org.slf4j" />
+ <module name="org.slf4j.impl" />
+ </exclusions>
+ <dependencies>
+ <module name="org.jboss.jandex" slot="main" />
+ <module name="org.javassist" slot="main" />
+ <module name="org.antlr" slot="main" />
+ <module name="org.dom4j" slot="main" />
+ </dependencies>
+ </deployment>
+</jboss-deployment-structure>
\ No newline at end of file diff --git a/adapters/mso-vnf-adapter/WebContent/WEB-INF/jboss-web.xml b/adapters/mso-vnf-adapter/WebContent/WEB-INF/jboss-web.xml new file mode 100644 index 0000000000..6224f07fef --- /dev/null +++ b/adapters/mso-vnf-adapter/WebContent/WEB-INF/jboss-web.xml @@ -0,0 +1,3 @@ +<jboss-web>
+ <context-root>vnfs</context-root>
+</jboss-web>
\ No newline at end of file diff --git a/adapters/mso-vnf-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-vnf-adapter/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000000..3a50781b22 --- /dev/null +++ b/adapters/mso-vnf-adapter/WebContent/WEB-INF/web.xml @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> + <display-name>mso-vnf-adapter</display-name> + + <context-param> + <param-name>resteasy.jndi.resources</param-name> + <param-value>java:module/MsoPropertiesFactory,java:module/CloudConfigFactory</param-value> + </context-param> + + <context-param> + <param-name>log.configuration</param-name> + <param-value>logback.vnf.xml</param-value> + </context-param> + <context-param> + <param-name>mso.configuration</param-name> + <param-value>MSO_PROP_VNF_ADAPTER=mso.vnf.properties,MSO_PROP_TOPOLOGY=topology.properties</param-value> + </context-param> + <context-param> + <param-name>mso.cloud_config.configuration</param-name> + <param-value>cloud_config.json=2</param-value> + </context-param> + <context-param> + <param-name>resteasy.resources</param-name> + <param-value> + org.openecomp.mso.MsoStatusHandler, + org.openecomp.mso.logger.MsoLoggingServlet, + org.openecomp.mso.adapters.vnf.HealthCheckHandler, + org.openecomp.mso.adapters.vnf.VnfAdapterRest, + org.openecomp.mso.adapters.vnf.VolumeAdapterRest + </param-value> + </context-param> + <context-param> + <param-name>resteasy.servlet.mapping.prefix</param-name> + <param-value>/rest</param-value> + </context-param> + <servlet> + <servlet-name>Resteasy</servlet-name> + <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>Resteasy</servlet-name> + <url-pattern>/rest/*</url-pattern> + </servlet-mapping> + + <security-constraint> + <web-resource-collection> + <web-resource-name>RestRequests</web-resource-name> + <description>Rest Ingress Requests</description> + <url-pattern>/rest/v1/*</url-pattern> + <http-method>POST</http-method> + <http-method>GET</http-method> + <http-method>PUT</http-method> + <http-method>DELETE</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>BPEL-Client</role-name> + </auth-constraint> + </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>SoapRequests</web-resource-name> + <description>Soap Ingress Requests</description> + <url-pattern>/VnfAdapter</url-pattern> + <url-pattern>/VnfAdapterAsync</url-pattern> + <http-method>POST</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>BPEL-Client</role-name> + </auth-constraint> + </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>SiteStatus</web-resource-name> + <description>SiteStatus APIs</description> + <url-pattern>/rest/setStatus/*</url-pattern> + <http-method>POST</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>SiteControl-Client</role-name> + </auth-constraint> + </security-constraint> + <login-config> + <auth-method>BASIC</auth-method> + <realm-name>ApplicationRealm</realm-name> + </login-config> + <security-role> + <role-name>BPEL-Client</role-name> + </security-role> + <security-role> + <role-name>SiteControl-Client</role-name> + </security-role> + + <filter> + <filter-name>LogFilter</filter-name> + <filter-class>org.openecomp.mso.logger.LogFilter</filter-class> + </filter> + <filter-mapping> + <filter-name>LogFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> +</web-app> diff --git a/adapters/mso-vnf-adapter/WebContent/check.html b/adapters/mso-vnf-adapter/WebContent/check.html new file mode 100644 index 0000000000..00f37d60d1 --- /dev/null +++ b/adapters/mso-vnf-adapter/WebContent/check.html @@ -0,0 +1,10 @@ +<!DOCTYPE html>
+<html>
+<head>
+<meta charset="ISO-8859-1">
+<title>Health Check</title>
+</head>
+<body>
+Application ready
+</body>
+</html>
\ No newline at end of file diff --git a/adapters/mso-vnf-adapter/pom.xml b/adapters/mso-vnf-adapter/pom.xml new file mode 100644 index 0000000000..1914eb14f8 --- /dev/null +++ b/adapters/mso-vnf-adapter/pom.xml @@ -0,0 +1,159 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp.mso</groupId> + <artifactId>adapters</artifactId> + <version>0.0.4-SNAPSHOT</version> + </parent> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-vnf-adapter</artifactId> + <packaging>war</packaging> + <name>mso-vnf-adapter</name> + <description>Web Service and REST endpoint for VNF operations</description> + + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>2.4</version> + <configuration> + <warSourceDirectory>WebContent</warSourceDirectory> + <failOnMissingWebXml>false</failOnMissingWebXml> + <attachClasses>true</attachClasses> + </configuration> + </plugin> + <plugin> + <groupId>org.jvnet.jax-ws-commons</groupId> + <artifactId>jaxws-maven-plugin</artifactId> + <version>2.3</version> + <executions> + <execution> + <id>Synch</id> + <goals> + <goal>wsgen</goal> + </goals> + <configuration> + <verbose>true</verbose> + <sei>org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl</sei> + <genWsdl>true</genWsdl> + <inlineSchemas>true</inlineSchemas> + </configuration> + </execution> + <execution> + <id>Asynch</id> + <goals> + <goal>wsgen</goal> + </goals> + <configuration> + <verbose>true</verbose> + <sei>org.openecomp.mso.adapters.vnf.MsoVnfAdapterAsyncImpl</sei> + <genWsdl>true</genWsdl> + <inlineSchemas>true</inlineSchemas> + </configuration> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.sun.xml.ws</groupId> + <artifactId>jaxws-tools</artifactId> + <version>2.2.7</version> + </dependency> + </dependencies> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <!--This plugin's configuration is used to store Eclipse m2e settings + only. It has no influence on the Maven build itself. --> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId> + org.jvnet.jax-ws-commons + </groupId> + <artifactId> + jaxws-maven-plugin + </artifactId> + <versionRange> + [2.3,) + </versionRange> + <goals> + <goal>wsgen</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore></ignore> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + <dependencies> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapters-rest-interface</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-vnf-adapter-async-client</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>javax</groupId> + <artifactId>javaee-web-api</artifactId> + <version>6.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.spec.javax.ejb</groupId> + <artifactId>jboss-ejb-api_3.2_spec</artifactId> + <version>1.0.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.ejb3</groupId> + <artifactId>jboss-ejb3-ext-api</artifactId> + <version>2.2.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>status-control</artifactId> + <version>${project.version}</version> + </dependency> + + <!-- <dependency> --> + <!-- <groupId>org.openecomp.mso</groupId> --> + <!-- <artifactId>mso-catalog-db</artifactId> --> + <!-- <version>${project.version}</version> --> + <!-- </dependency> --> + <!-- <dependency> --> + <!-- <groupId>log4j</groupId> --> + <!-- <artifactId>log4j</artifactId> --> + <!-- <version>1.2.17</version> --> + <!-- </dependency> --> + </dependencies> +</project> diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java new file mode 100644 index 0000000000..e76aa40304 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java @@ -0,0 +1,304 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf; + + +import java.io.IOException; +import java.util.Set; +import java.util.TreeSet; + +import javax.xml.bind.DatatypeConverter; + +import org.apache.http.HttpEntity; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; + +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +/** + * This is the class that is used to POST replies from the MSO adapters to the BPEL engine. + * It can be configured via property file, or modified using the member methods. + * The properties to use are: + * org.openecomp.mso.adapters.vnf.bpelauth encrypted authorization string to send to BEPL engine + * org.openecomp.mso.adapters.vnf.sockettimeout socket timeout value + * org.openecomp.mso.adapters.vnf.connecttimeout connect timeout value + * org.openecomp.mso.adapters.vnf.retrycount number of times to retry failed connections + * org.openecomp.mso.adapters.vnf.retryinterval interval (in seconds) between retries + * org.openecomp.mso.adapters.vnf.retrylist list of response codes that will trigger a retry (the special code + * 900 means "connection was not established") + */ +public class BpelRestClient { + public static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER"; + private static final String PROPERTY_DOMAIN = "org.openecomp.mso.adapters.vnf"; + private static final String BPEL_AUTH_PROPERTY = PROPERTY_DOMAIN+".bpelauth"; + private static final String SOCKET_TIMEOUT_PROPERTY = PROPERTY_DOMAIN+".sockettimeout"; + private static final String CONN_TIMEOUT_PROPERTY = PROPERTY_DOMAIN+".connecttimeout"; + private static final String RETRY_COUNT_PROPERTY = PROPERTY_DOMAIN+".retrycount"; + private static final String RETRY_INTERVAL_PROPERTY = PROPERTY_DOMAIN+".retryinterval"; + private static final String RETRY_LIST_PROPERTY = PROPERTY_DOMAIN+".retrylist"; + private static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + + /** Default socket timeout (in seconds) */ + public static final int DEFAULT_SOCKET_TIMEOUT = 5; + /** Default connect timeout (in seconds) */ + public static final int DEFAULT_CONNECT_TIMEOUT = 5; + /** By default, retry up to five times */ + public static final int DEFAULT_RETRY_COUNT = 5; + /** Default interval to wait between retries (in seconds), negative means use backoff algorithm */ + public static final int DEFAULT_RETRY_INTERVAL = -15; + /** Default list of response codes to trigger a retry */ + public static final String DEFAULT_RETRY_LIST = "408,429,500,502,503,504,900"; // 900 is "connection failed" + /** Default credentials */ + public static final String DEFAULT_CREDENTIALS = ""; + + // Properties of the BPEL client -- all are configurable + private int socketTimeout; + private int connectTimeout; + private int retryCount; + private int retryInterval; + private Set<Integer> retryList; + private String credentials; + + // last response from BPEL engine + private int lastResponseCode; + private String lastResponse; + + /** + * Create a client to send results to the BPEL engine, using configuration from the + * MSO_PROP_VNF_ADAPTER properties. + */ + public BpelRestClient() { + socketTimeout = DEFAULT_SOCKET_TIMEOUT; + connectTimeout = DEFAULT_CONNECT_TIMEOUT; + retryCount = DEFAULT_RETRY_COUNT; + retryInterval = DEFAULT_RETRY_INTERVAL; + setRetryList(DEFAULT_RETRY_LIST); + credentials = DEFAULT_CREDENTIALS; + lastResponseCode = 0; + lastResponse = ""; + + try { + MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + MsoJavaProperties jp = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER); + socketTimeout = jp.getIntProperty(SOCKET_TIMEOUT_PROPERTY, DEFAULT_SOCKET_TIMEOUT); + connectTimeout = jp.getIntProperty(CONN_TIMEOUT_PROPERTY, DEFAULT_CONNECT_TIMEOUT); + retryCount = jp.getIntProperty(RETRY_COUNT_PROPERTY, DEFAULT_RETRY_COUNT); + retryInterval = jp.getIntProperty(RETRY_INTERVAL_PROPERTY, DEFAULT_RETRY_INTERVAL); + setRetryList(jp.getProperty(RETRY_LIST_PROPERTY, DEFAULT_RETRY_LIST)); + credentials = jp.getEncryptedProperty(BPEL_AUTH_PROPERTY, DEFAULT_CREDENTIALS, ENCRYPTION_KEY); + } catch (MsoPropertiesException e) { + String error = "Unable to get properties:" + MSO_PROP_VNF_ADAPTER; + LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "MsoPropertiesException - Unable to get properties", e); + } + } + + public int getSocketTimeout() { + return socketTimeout; + } + + public void setSocketTimeout(int socketTimeout) { + this.socketTimeout = socketTimeout; + } + + public int getConnectTimeout() { + return connectTimeout; + } + + public void setConnectTimeout(int connectTimeout) { + this.connectTimeout = connectTimeout; + } + + public int getRetryCount() { + return retryCount; + } + + public void setRetryCount(int retryCount) { + if (retryCount < 0) + retryCount = DEFAULT_RETRY_COUNT; + this.retryCount = retryCount; + } + + public int getRetryInterval() { + return retryInterval; + } + + public void setRetryInterval(int retryInterval) { + this.retryInterval = retryInterval; + } + + public String getCredentials() { + return credentials; + } + + public void setCredentials(String credentials) { + this.credentials = credentials; + } + + public String getRetryList() { + if (retryList.size() == 0) + return ""; + String t = retryList.toString(); + return t.substring(1, t.length()-1); + } + + public void setRetryList(String retryList) { + Set<Integer> s = new TreeSet<Integer>(); + for (String t : retryList.split("[, ]")) { + try { + s.add(Integer.parseInt(t)); + } catch (NumberFormatException x) { + // ignore + } + } + this.retryList = s; + } + + public int getLastResponseCode() { + return lastResponseCode; + } + + public String getLastResponse() { + return lastResponse; + } + + /** + * Post a response to the URL of the BPEL engine. As long as the response code is one of those in + * the retryList, the post will be retried up to "retrycount" times with an interval (in seconds) + * of "retryInterval". If retryInterval is negative, then each successive retry interval will be + * double the previous one. + * @param toBpelStr the content (XML or JSON) to post + * @param bpelUrl the URL to post to + * @param isxml true if the content is XML, otherwise assumed to be JSON + * @return true if the post succeeded, false if all retries failed + */ + public boolean bpelPost(final String toBpelStr, final String bpelUrl, final boolean isxml) { + debug("Sending response to BPEL: " + toBpelStr); + int totalretries = 0; + int retryint = retryInterval; + while (true) { + sendOne(toBpelStr, bpelUrl, isxml); + // Note: really should handle response code 415 by switching between content types if needed + if (!retryList.contains(lastResponseCode)) { + debug("Got response code: " + lastResponseCode + ": returning."); + return true; + } + if (totalretries >= retryCount) { + debug("Retried " + totalretries + " times, giving up."); + LOGGER.error(MessageEnum.RA_SEND_VNF_NOTIF_ERR, "Could not deliver response to BPEL after "+totalretries+" tries: "+toBpelStr, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Could not deliver response to BPEL"); + return false; + } + totalretries++; + int sleepinterval = retryint; + if (retryint < 0) { + // if retry interval is negative double the retry on each pass + sleepinterval = -retryint; + retryint *= 2; + } + debug("Sleeping for " + sleepinterval + " seconds."); + try { + Thread.sleep(sleepinterval * 1000L); + } catch (InterruptedException e) { + // ignore + } + } + } + private void debug(String m) { + LOGGER.debug(m); +// System.err.println(m); + } + private void sendOne(final String toBpelStr, final String bpelUrl, final boolean isxml) { + LOGGER.debug("Sending to BPEL server: "+bpelUrl); + LOGGER.debug("Content is: "+toBpelStr); + + //POST + HttpPost post = new HttpPost(bpelUrl); + if (credentials != null && !credentials.isEmpty()) + post.addHeader("Authorization", "Basic " + DatatypeConverter.printBase64Binary(credentials.getBytes())); + + //ContentType + ContentType ctype = isxml ? ContentType.APPLICATION_XML : ContentType.APPLICATION_JSON; + post.setEntity(new StringEntity(toBpelStr, ctype)); + + //Timeouts + RequestConfig requestConfig = RequestConfig + .custom() + .setSocketTimeout(socketTimeout * 1000) + .setConnectTimeout(connectTimeout * 1000) + .build(); + post.setConfig(requestConfig); + + //Client 4.3+ + //Execute & GetResponse + try (CloseableHttpClient client = HttpClients.createDefault(); + CloseableHttpResponse response = client.execute(post)) { + if (response != null) { + lastResponseCode = response.getStatusLine().getStatusCode(); + HttpEntity entity = response.getEntity(); + lastResponse = (entity != null) ? EntityUtils.toString(entity) : ""; + } else { + lastResponseCode = 900; + lastResponse = ""; + } + } catch (Exception e) { + String error = "Error sending Bpel notification:" + toBpelStr; + LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, error, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Error sending Bpel notification", e); + lastResponseCode = 900; + lastResponse = ""; + } + LOGGER.debug("Response code from BPEL server: "+lastResponseCode); + LOGGER.debug("Response body is: "+lastResponse); + } + + public static void main(String[] a) throws MsoPropertiesException { + final String bpelengine = "http://mtmac1.research.att.com:8080/catch.jsp"; + final String propfile = "/tmp/mso.vnf.properties"; + // "/Users/eby/src/mso.rest/mso/packages/mso-config-centralized/mso-po-adapter-config/mso.vnf.properties" + final String xml = + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + + "<updateVolumeGroupResponse><volumeGroupId>1464013300723</volumeGroupId><volumeGroupOutputs>" + + "<entry><key>clyde</key><value>10</value></entry>" + + "<entry><key>wayne</key><value>99</value></entry>" + + "<entry><key>mickey</key><value>7</value></entry>" + + "</volumeGroupOutputs></updateVolumeGroupResponse>"; + + MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + msoPropertiesFactory.initializeMsoProperties (MSO_PROP_VNF_ADAPTER, propfile); + + BpelRestClient bc = new BpelRestClient(); + System.out.println(bc.getRetryList()); + System.out.println(bc.getCredentials()); // poAvos:Domain2.0! + + bc.bpelPost(xml, bpelengine, true); + System.out.println("respcode = "+bc.getLastResponseCode()); + System.out.println("resp = "+bc.getLastResponse()); + } +} diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/HealthCheckHandler.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/HealthCheckHandler.java new file mode 100644 index 0000000000..108baf3444 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/HealthCheckHandler.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf; + + +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.HealthCheckUtils; +import org.openecomp.mso.utils.UUIDChecker; + + +@Path("/") +public class HealthCheckHandler { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER"; + + @HEAD + @GET + @Path("/healthcheck") + @Produces(MediaType.TEXT_HTML) + public Response healthcheck (@QueryParam("requestId") String requestId) { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("Healthcheck"); + UUIDChecker.verifyOldUUID(requestId, msoLogger); + HealthCheckUtils healthCheck = new HealthCheckUtils (); + if (!healthCheck.siteStatusCheck(msoLogger, startTime)) { + return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; + } + + if (!healthCheck.configFileCheck(msoLogger, startTime, MSO_PROP_VNF_ADAPTER)) { + return HealthCheckUtils.NOT_STARTED_RESPONSE; + } + + if (!healthCheck.catalogDBCheck (msoLogger, startTime)) { + return HealthCheckUtils.NOT_STARTED_RESPONSE; + } + msoLogger.debug("healthcheck - Successful"); + return HealthCheckUtils.HEALTH_CHECK_RESPONSE; + } +} diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapter.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapter.java new file mode 100644 index 0000000000..95d8ee23a0 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapter.java @@ -0,0 +1,142 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf; + + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebParam.Mode; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.ws.Holder; + +import org.openecomp.mso.openstack.beans.VnfStatus; +import org.openecomp.mso.openstack.beans.VnfRollback; +import org.openecomp.mso.adapters.vnf.exceptions.VnfAlreadyExists; +import org.openecomp.mso.adapters.vnf.exceptions.VnfException; +import org.openecomp.mso.entity.MsoRequest; + +import java.util.Map; + +@WebService (name="VnfAdapter", targetNamespace="http://com.att.mso/vnf") +public interface MsoVnfAdapter +{ + /** + * This is the "Create VNF" Web Service Endpoint definition. + */ + @WebMethod + public void createVnf (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="vnfType") @XmlElement(required=true) String vnfType, + @WebParam(name="vnfVersion") @XmlElement(required=false) String vnfVersion, + @WebParam(name="vnfName") @XmlElement(required=true) String vnfName, + @WebParam(name="requestType") @XmlElement(required=false) String requestType, + @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId, + @WebParam(name="inputs") Map<String,String> inputs, + @WebParam(name="failIfExists") Boolean failIfExists, + @WebParam(name="backout") Boolean backout, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="vnfId", mode=Mode.OUT) Holder<String> vnfId, + @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs, + @WebParam(name="rollback", mode=Mode.OUT) Holder<VnfRollback> rollback ) + throws VnfException, VnfAlreadyExists; + + @WebMethod + public void updateVnf (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="vnfType") @XmlElement(required=true) String vnfType, + @WebParam(name="vnfVersion") @XmlElement(required=false) String vnfVersion, + @WebParam(name="vnfName") @XmlElement(required=true) String vnfName, + @WebParam(name="requestType") @XmlElement(required=false) String requestType, + @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId, + @WebParam(name="inputs") Map<String,String> inputs, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs, + @WebParam(name="rollback", mode=Mode.OUT) Holder<VnfRollback> rollback ) + throws VnfException; + + @WebMethod + public void queryVnf (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="vnfName") @XmlElement(required=true) String vnfName, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="vnfExists", mode=Mode.OUT) Holder<Boolean> vnfExists, + @WebParam(name="vnfId", mode=Mode.OUT) Holder<String> vnfId, + @WebParam(name="status", mode=Mode.OUT) Holder<VnfStatus> status, + @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs ) + throws VnfException; + + @WebMethod + public void deleteVnf (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="vnfName") @XmlElement(required=true) String vnfName, + @WebParam(name="request") MsoRequest msoRequest) + throws VnfException; + + + @WebMethod + public void rollbackVnf (@WebParam(name="rollback") @XmlElement(required=true) VnfRollback rollback) + throws VnfException; + + @WebMethod + public void createVfModule (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="vnfType") @XmlElement(required=true) String vnfType, + @WebParam(name="vnfVersion") @XmlElement(required=false) String vnfVersion, + @WebParam(name="vnfName") @XmlElement(required=true) String vnfName, + @WebParam(name="requestType") @XmlElement(required=false) String requestType, + @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId, + @WebParam(name="baseVfHeatStackId") @XmlElement(required=false) String baseVfHeatStackId, + @WebParam(name="inputs") Map<String,String> inputs, + @WebParam(name="failIfExists") Boolean failIfExists, + @WebParam(name="backout") Boolean backout, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="vnfId", mode=Mode.OUT) Holder<String> vnfId, + @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs, + @WebParam(name="rollback", mode=Mode.OUT) Holder<VnfRollback> rollback ) + throws VnfException, VnfAlreadyExists; + + @WebMethod + public void deleteVfModule (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="vfName") @XmlElement(required=true) String vfName, + @WebParam(name="request") MsoRequest msoRequest) + throws VnfException; + + @WebMethod + public void updateVfModule (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="vnfType") @XmlElement(required=true) String vnfType, + @WebParam(name="vnfVersion") @XmlElement(required=false) String vnfVersion, + @WebParam(name="vnfName") @XmlElement(required=true) String vnfName, + @WebParam(name="requestType") @XmlElement(required=false) String requestType, + @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId, + @WebParam(name="baseVfHeatStackId") @XmlElement(required=false) String baseVfHeatStackId, + @WebParam(name="vfModuleStackId") @XmlElement(required=false) String vfModuleStackId, + @WebParam(name="inputs") Map<String,String> inputs, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs, + @WebParam(name="rollback", mode=Mode.OUT) Holder<VnfRollback> rollback ) + throws VnfException; + + @WebMethod + public void healthCheck (); +} diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsync.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsync.java new file mode 100644 index 0000000000..d58e9ee6a8 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsync.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf; + + +import javax.jws.Oneway; +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlElement; + +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.VnfRollback; +import java.util.Map; + +/** + * This webservice defines the Asynchronous versions of VNF adapter calls. + * The notification messages for final responses are documented elsewhere + * (by the client service WSDL). + * + */ +@WebService (name="VnfAdapterAsync", targetNamespace="http://com.att.mso/vnfA") +public interface MsoVnfAdapterAsync +{ + /** + * This is the "Create VNF" Web Service Endpoint definition. + */ + @WebMethod + @Oneway + public void createVnfA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="vnfType") @XmlElement(required=true) String vnfType, + @WebParam(name="vnfVersion") @XmlElement(required=false) String vnfVersion, + @WebParam(name="vnfName") @XmlElement(required=true) String vnfName, + @WebParam(name="requestType") @XmlElement(required=false) String requestType, + @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId, + @WebParam(name="inputs") Map<String,String> inputs, + @WebParam(name="failIfExists") Boolean failIfExists, + @WebParam(name="backout") Boolean backout, + @WebParam(name="messageId") @XmlElement(required=true) String messageId, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl ); + + @WebMethod + @Oneway + public void updateVnfA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="vnfType") @XmlElement(required=true) String vnfType, + @WebParam(name="vnfVersion") @XmlElement(required=false) String vnfVersion, + @WebParam(name="vnfName") @XmlElement(required=true) String vnfName, + @WebParam(name="requestType") @XmlElement(required=false) String requestType, + @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId, + @WebParam(name="inputs") Map<String,String> inputs, + @WebParam(name="messageId") @XmlElement(required=true) String messageId, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl ); + + @WebMethod + @Oneway + public void queryVnfA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="vnfName") @XmlElement(required=true) String vnfName, + @WebParam(name="messageId") @XmlElement(required=true) String messageId, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl ); + + @WebMethod + @Oneway + public void deleteVnfA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, + @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, + @WebParam(name="vnfName") @XmlElement(required=true) String vnfName, + @WebParam(name="messageId") @XmlElement(required=true) String messageId, + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl ); + + @WebMethod + @Oneway + public void rollbackVnfA (@WebParam(name="rollback") @XmlElement(required=true) VnfRollback rollback, + @WebParam(name="messageId") @XmlElement(required=true) String messageId, + @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl ); + + + @WebMethod + public void healthCheckA (); +} diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java new file mode 100644 index 0000000000..c192eb6063 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java @@ -0,0 +1,652 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf; + + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.jws.WebService; +import javax.xml.bind.DatatypeConverter; +import javax.xml.namespace.QName; +import javax.xml.ws.BindingProvider; +import javax.xml.ws.Holder; +import javax.xml.ws.handler.MessageContext; + +import org.openecomp.mso.adapters.vnf.async.client.CreateVnfNotification; +import org.openecomp.mso.adapters.vnf.async.client.QueryVnfNotification; +import org.openecomp.mso.adapters.vnf.async.client.UpdateVnfNotification; +import org.openecomp.mso.adapters.vnf.async.client.VnfAdapterNotify; +import org.openecomp.mso.adapters.vnf.async.client.VnfAdapterNotify_Service; +import org.openecomp.mso.adapters.vnf.exceptions.VnfException; +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoPropertiesFactory; +import org.openecomp.mso.openstack.beans.VnfStatus; +import org.openecomp.mso.openstack.beans.VnfRollback; + +@WebService(serviceName = "VnfAdapterAsync", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapterAsync", targetNamespace = "http://com.att.mso/vnfA") +public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { + + MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + + CloudConfigFactory cloudConfigFactory=new CloudConfigFactory(); + + public static final String MSO_PROP_VNF_ADAPTER="MSO_PROP_VNF_ADAPTER"; + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + private static final String BPEL_AUTH_PROP = "org.openecomp.mso.adapters.vnf.bpelauth"; + private static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; + + /** + * Health Check web method. Does nothing but return to show the adapter is deployed. + */ + @Override + public void healthCheckA () { + LOGGER.debug ("Health check call in VNF Adapter"); + } + + /** + * This is the asynchronous "Create VNF" web service implementation. + * It will create a new VNF of the requested type in the specified cloud + * and tenant. The tenant must exist before this service is called. + * + * If a VNF with the same name already exists, this can be considered a + * success or failure, depending on the value of the 'failIfExists' parameter. + * + * All VNF types will be defined in the MSO catalog. The caller must request + * one of these pre-defined types or an error will be returned. Within the + * catalog, each VNF type references (among other things) a Heat template + * which is used to deploy the required VNF artifacts (VMs, networks, etc.) + * to the cloud. + * + * Depending on the Heat template, a variable set of input parameters will + * be defined, some of which are required. The caller is responsible to + * pass the necessary input data for the VNF or an error will be thrown. + * + * The method sends an asynchronous response to the notification URL when + * processing completes. The createAsyncResponse contains the vnfId (the + * canonical name of the stack), a Map of VNF output attributes, and a + * VnfRollback object. This last object can be passed as-is to the + * rollbackVnf operation to undo everything that was created for the VNF. + * This is useful if a VNF is successfully created but the orchestrator + * fails on a subsequent operation. + * + * Note: this method is implemented by calling the synchronous web method + * and translating the response to an asynchronous notification. + * + * @param cloudSiteId CLLI code of the cloud site in which to create the VNF + * @param tenantId Openstack tenant identifier + * @param vnfType VNF type key, should match a VNF definition in catalog DB + * @param vnfName Name to be assigned to the new VNF + * @param inputs Map of key=value inputs for VNF stack creation + * @param failIfExists Flag whether already existing VNF should be considered + * a success or failure + * @param msoRequest Request tracking information for logs + * @param notificationURL the target URL for asynchronous response + */ + @Override + public void createVnfA (String cloudSiteId, + String tenantId, + String vnfType, + String vnfVersion, + String vnfName, + String requestType, + String volumeGroupHeatStackId, + Map <String, String> inputs, + Boolean failIfExists, + Boolean backout, + String messageId, + MsoRequest msoRequest, + String notificationUrl) { + String error; + String serviceName = "CreateVnfA"; + MsoLogger.setLogContext (msoRequest); + MsoLogger.setServiceName (serviceName); + LOGGER.info (MessageEnum.RA_ASYNC_CREATE_VNF, vnfName, vnfType, cloudSiteId, tenantId, "", "createVnfA"); + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + // Use the synchronous method to perform the actual Create + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory, cloudConfigFactory); + + // Synchronous Web Service Outputs + Holder <String> vnfId = new Holder <String> (); + Holder <Map <String, String>> outputs = new Holder <Map <String, String>> (); + Holder <VnfRollback> vnfRollback = new Holder <VnfRollback> (); + + try { + vnfAdapter.createVnf (cloudSiteId, + tenantId, + vnfType, + vnfVersion, + vnfName, + requestType, + volumeGroupHeatStackId, + inputs, + failIfExists, + backout, + msoRequest, + vnfId, + outputs, + vnfRollback); + MsoLogger.setServiceName (serviceName); + } catch (VnfException e) { + MsoLogger.setServiceName (serviceName); + LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException in createVnfA", e); + org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory exCat = null; + String eMsg = null; + try { + eMsg = e.getFaultInfo ().getMessage (); + exCat = org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory.fromValue (e.getFaultInfo () + .getCategory () + .name ()); + } catch (Exception e1) { + LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Fault info", e1); + } + // Build and send Asynchronous error response + try { + VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.createVnfNotification (messageId, false, exCat, eMsg, null, null, null); + } catch (Exception e1) { + error = "Error sending createVnf notification " + e1.getMessage (); + LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending createVnf notification", e1); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + LOGGER.info (MessageEnum.RA_ASYNC_CREATE_VNF_COMPLETE, "", "createVnfA", "", "createVnfA"); + return; + } + LOGGER.debug ("Async Create VNF: " + vnfName + " VnfId:" + vnfId.value); + // Build and send Asynchronous response + try { + VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.createVnfNotification (messageId, + true, + null, + null, + vnfId.value, + copyCreateOutputs (outputs), + copyVrb (vnfRollback)); + } catch (Exception e) { + error = "Error sending createVnf notification " + e.getMessage (); + LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending createVnf notification", e); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + LOGGER.info (MessageEnum.RA_ASYNC_CREATE_VNF_COMPLETE, "", "createVnfA"); + return; + } + + @Override + public void updateVnfA (String cloudSiteId, + String tenantId, + String vnfType, + String vnfVersion, + String vnfName, + String requestType, + String volumeGroupHeatStackId, + Map <String, String> inputs, + String messageId, + MsoRequest msoRequest, + String notificationUrl) { + String error; + String serviceName = "UpdateVnfA"; + MsoLogger.setServiceName (serviceName); + MsoLogger.setLogContext (msoRequest); + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + LOGGER.info (MessageEnum.RA_ASYNC_UPDATE_VNF, vnfName, vnfType, cloudSiteId, tenantId, "", "UpdateVnfA"); + + // Use the synchronous method to perform the actual Create + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory,cloudConfigFactory); + + // Synchronous Web Service Outputs + Holder <String> vnfId = new Holder <String> (); + Holder <Map <String, String>> outputs = new Holder <Map <String, String>> (); + Holder <VnfRollback> vnfRollback = new Holder <VnfRollback> (); + + try { + vnfAdapter.updateVnf (cloudSiteId, tenantId, vnfType,vnfVersion, vnfName, requestType, volumeGroupHeatStackId, inputs, msoRequest, outputs, vnfRollback); + MsoLogger.setServiceName (serviceName); + } catch (VnfException e) { + MsoLogger.setServiceName (serviceName); + LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending updateVnf notification", e); + org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory exCat = null; + String eMsg = null; + try { + eMsg = e.getFaultInfo ().getMessage (); + exCat = org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory.fromValue (e.getFaultInfo () + .getCategory () + .name ()); + } catch (Exception e1) { + LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1); + } + // Build and send Asynchronous error response + try { + VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.updateVnfNotification (messageId, false, exCat, eMsg, null, null); + } catch (Exception e1) { + error = "Error sending updateVnf notification " + e1.getMessage (); + LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending updateVnf notification", e1); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + LOGGER.info (MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE, "", "UpdateVnfA"); + return; + } + LOGGER.debug ("Async Update VNF: " + vnfName + " VnfId:" + vnfId.value); + // Build and send Asynchronous response + try { + VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.updateVnfNotification (messageId, + true, + null, + null, + copyUpdateOutputs (outputs), + copyVrb (vnfRollback)); + } catch (Exception e) { + error = "Error sending updateVnf notification " + e.getMessage (); + LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending updateVnf notification", e); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + LOGGER.info (MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE, "", "UpdateVnfA"); + return; + } + + /** + * This is the "Query VNF" web service implementation. + * It will look up a VNF by name or ID in the specified cloud and tenant. + * + * The method returns an indicator that the VNF exists, its Openstack internal + * ID, its status, and the set of outputs (from when the stack was created). + * + * @param cloudSiteId CLLI code of the cloud site in which to query + * @param tenantId Openstack tenant identifier + * @param vnfName VNF Name or Openstack ID + * @param msoRequest Request tracking information for logs + * @param notificationURL the target URL for asynchronous response + */ + @Override + public void queryVnfA (String cloudSiteId, + String tenantId, + String vnfName, + String messageId, + MsoRequest msoRequest, + String notificationUrl) { + String error; + String serviceName = "QueryVnfA"; + MsoLogger.setServiceName (serviceName); + MsoLogger.setLogContext (msoRequest); + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + LOGGER.info (MessageEnum.RA_ASYNC_QUERY_VNF, vnfName, cloudSiteId, tenantId); + + // Use the synchronous method to perform the actual query + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory,cloudConfigFactory); + + // Synchronous Web Service Outputs + Holder <Boolean> vnfExists = new Holder <Boolean> (); + Holder <String> vnfId = new Holder <String> (); + Holder <VnfStatus> status = new Holder <VnfStatus> (); + Holder <Map <String, String>> outputs = new Holder <Map <String, String>> (); + + try { + vnfAdapter.queryVnf (cloudSiteId, tenantId, vnfName, msoRequest, vnfExists, vnfId, status, outputs); + MsoLogger.setServiceName (serviceName); + } catch (VnfException e) { + MsoLogger.setServiceName (serviceName); + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending queryVnfA notification", e); + org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory exCat = null; + String eMsg = null; + try { + eMsg = e.getFaultInfo ().getMessage (); + exCat = org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory.fromValue (e.getFaultInfo () + .getCategory () + .name ()); + } catch (Exception e1) { + LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1); + } + // Build and send Asynchronous error response + try { + VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.queryVnfNotification (messageId, false, exCat, eMsg, null, null, null, null); + } catch (Exception e1) { + error = "Error sending queryVnf notification " + e1.getMessage (); + LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending queryVnf notification", e1); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + LOGGER.info (MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE, "", "queryVnfA"); + return; + } + + if (!vnfExists.value) { + LOGGER.debug ("Async Query, VNF not found"); + } else { + LOGGER.debug ("Async Query, VNF=" + vnfId.value + ", status=" + status.value); + } + // Build and send Asynchronous response + try { + VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); + org.openecomp.mso.adapters.vnf.async.client.VnfStatus vnfS = org.openecomp.mso.adapters.vnf.async.client.VnfStatus.fromValue (status.value.name ()); + notifyPort.queryVnfNotification (messageId, + true, + null, + null, + vnfExists.value, + vnfId.value, + vnfS, + copyQueryOutputs (outputs)); + } catch (Exception e) { + error = "Error sending queryVnf notification " + e.getMessage (); + LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending queryVnf notification", e); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + + LOGGER.info (MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE, "", "queryVnfA"); + return; + } + + /** + * This is the Asynchronous "Delete VNF" web service implementation. + * It will delete a VNF by name or ID in the specified cloud and tenant. + * + * The method has no outputs. + * + * @param cloudSiteId CLLI code of the cloud site in which to delete + * @param tenantId Openstack tenant identifier + * @param vnfName VNF Name or Openstack ID + * @param msoRequest Request tracking information for logs + * @param notificationURL the target URL for asynchronous response + */ + @Override + public void deleteVnfA (String cloudSiteId, + String tenantId, + String vnfName, + String messageId, + MsoRequest msoRequest, + String notificationUrl) { + String error; + String serviceName = "DeleteVnfA"; + MsoLogger.setServiceName (serviceName); + MsoLogger.setLogContext (msoRequest); + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + LOGGER.info (MessageEnum.RA_ASYNC_DELETE_VNF, vnfName, cloudSiteId, tenantId); + + // Use the synchronous method to perform the actual delete + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory,cloudConfigFactory); + + try { + vnfAdapter.deleteVnf (cloudSiteId, tenantId, vnfName, msoRequest); + MsoLogger.setServiceName (serviceName); + } catch (VnfException e) { + MsoLogger.setServiceName (serviceName); + LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending deleteVnfA notification", e); + org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory exCat = null; + String eMsg = null; + try { + eMsg = e.getFaultInfo ().getMessage (); + exCat = org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory.fromValue (e.getFaultInfo () + .getCategory () + .name ()); + } catch (Exception e1) { + LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1); + } + // Build and send Asynchronous error response + try { + VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.deleteVnfNotification (messageId, false, exCat, eMsg); + } catch (Exception e1) { + error = "Error sending deleteVnf notification " + e1.getMessage (); + LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending deleteVnfA notification", e1); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + LOGGER.info (MessageEnum.RA_ASYNC_DELETE_VNF_COMPLETE, "", "deleteVnfA"); + return; + } + + LOGGER.debug ("Async Delete VNF: " + vnfName); + // Build and send Asynchronous response + try { + VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.deleteVnfNotification (messageId, true, null, null); + + } catch (Exception e) { + error = "Error sending deleteVnf notification " + e.getMessage (); + LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending deleteVnfA notification", e); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + + LOGGER.info (MessageEnum.RA_ASYNC_DELETE_VNF_COMPLETE, "", "deleteVnfA"); + return; + } + + /** + * This web service endpoint will rollback a previous Create VNF operation. + * A rollback object is returned to the client in a successful creation + * response. The client can pass that object as-is back to the rollbackVnf + * operation to undo the creation. + */ + @Override + public void rollbackVnfA (VnfRollback rollback, String messageId, String notificationUrl) { + String serviceName = "RollbackVnfA"; + MsoLogger.setServiceName (serviceName); + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + String error; + // rollback may be null (e.g. if stack already existed when Create was called) + if (rollback == null) { + error = "Empty Rollback: No action to perform"; + LOGGER.info (MessageEnum.RA_ROLLBACK_NULL, "", "rollbackVnfA"); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + return; + } + + MsoLogger.setLogContext (rollback.getMsoRequest ()); + LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK_VNF, "", "rollbackVnfA"); + + // Use the synchronous method to perform the actual rollback + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory,cloudConfigFactory); + + try { + vnfAdapter.rollbackVnf (rollback); + MsoLogger.setServiceName (serviceName); + } catch (VnfException e) { + MsoLogger.setServiceName (serviceName); + LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending rollbackVnfA notification", e); + org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory exCat = null; + String eMsg = null; + try { + eMsg = e.getFaultInfo ().getMessage (); + exCat = org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory.fromValue (e.getFaultInfo () + .getCategory () + .name ()); + } catch (Exception e1) { + LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1); + } + // Build and send Asynchronous error response + try { + VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.rollbackVnfNotification (messageId, false, exCat, eMsg); + } catch (Exception e1) { + error = "Error sending rollbackVnf notification " + e1.getMessage (); + LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending rollbackVnfA notification", e1); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE, "", "rollbackVnfA"); + return; + } + + LOGGER.debug ("Async Rollback VNF:" + rollback.getVnfId ()); + // Build and send Asynchronous response + try { + VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); + notifyPort.rollbackVnfNotification (messageId, true, null, null); + } catch (Exception e) { + error = "Error sending rollbackVnf notification " + e.getMessage (); + LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending rollbackVnfA notification", e); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + + LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE, "", "rollbackVnfA"); + return; + } + + private org.openecomp.mso.adapters.vnf.async.client.VnfRollback copyVrb (Holder <VnfRollback> hVrb) { + org.openecomp.mso.adapters.vnf.async.client.VnfRollback cvrb = new org.openecomp.mso.adapters.vnf.async.client.VnfRollback (); + + if (hVrb != null && hVrb.value != null) { + org.openecomp.mso.adapters.vnf.async.client.MsoRequest cmr = new org.openecomp.mso.adapters.vnf.async.client.MsoRequest (); + + cvrb.setCloudSiteId (hVrb.value.getCloudSiteId ()); + if (hVrb.value.getMsoRequest() != null) { + cmr.setRequestId (hVrb.value.getMsoRequest ().getRequestId ()); + cmr.setServiceInstanceId (hVrb.value.getMsoRequest ().getServiceInstanceId ()); + } else { + cmr.setRequestId (null); + cmr.setServiceInstanceId (null); + } + cvrb.setMsoRequest (cmr); + cvrb.setVnfId (hVrb.value.getVnfId ()); + cvrb.setTenantId (hVrb.value.getTenantId ()); + cvrb.setTenantCreated (hVrb.value.getTenantCreated ()); + cvrb.setVnfCreated (hVrb.value.getVnfCreated ()); + } + return cvrb; + } + + private CreateVnfNotification.Outputs copyCreateOutputs (Holder <Map <String, String>> hMap) { + + CreateVnfNotification.Outputs outputs = new CreateVnfNotification.Outputs (); + + if (hMap != null && hMap.value != null) { + Map <String, String> sMap = new HashMap <String, String> (); + sMap = hMap.value; + CreateVnfNotification.Outputs.Entry entry = new CreateVnfNotification.Outputs.Entry (); + + for (String key : sMap.keySet ()) { + entry.setKey (key); + entry.setValue (sMap.get (key)); + outputs.getEntry ().add (entry); + } + } + return outputs; + } + + private UpdateVnfNotification.Outputs copyUpdateOutputs (Holder <Map <String, String>> hMap) { + + UpdateVnfNotification.Outputs outputs = new UpdateVnfNotification.Outputs (); + + if (hMap != null && hMap.value != null) { + Map <String, String> sMap = new HashMap <String, String> (); + sMap = hMap.value; + UpdateVnfNotification.Outputs.Entry entry = new UpdateVnfNotification.Outputs.Entry (); + + for (String key : sMap.keySet ()) { + entry.setKey (key); + entry.setValue (sMap.get (key)); + outputs.getEntry ().add (entry); + } + } + return outputs; + } + + private QueryVnfNotification.Outputs copyQueryOutputs (Holder <Map <String, String>> hMap) { + + QueryVnfNotification.Outputs outputs = new QueryVnfNotification.Outputs (); + + if (hMap != null && hMap.value != null) { + Map <String, String> sMap = new HashMap <String, String> (); + sMap = hMap.value; + + QueryVnfNotification.Outputs.Entry entry = new QueryVnfNotification.Outputs.Entry (); + + for (String key : sMap.keySet ()) { + entry.setKey (key); + entry.setValue (sMap.get (key)); + outputs.getEntry ().add (entry); + } + } + return outputs; + } + + private VnfAdapterNotify getNotifyEP (String notificationUrl) { + + URL warWsdlLoc = null; + try { + warWsdlLoc = Thread.currentThread ().getContextClassLoader ().getResource ("VnfAdapterNotify.wsdl"); + } catch (Exception e) { + LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "VnfAdapterNotify.wsdl", "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - WSDL not found", e); + } + if (warWsdlLoc == null) { + LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "VnfAdapterNotify.wsdl", "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "WSDL not found"); + } else { + try { + LOGGER.debug ("VnfAdpaterNotify.wsdl location:" + warWsdlLoc.toURI ().toString ()); + } catch (Exception e) { + LOGGER.error (MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "VnfAdapterNotify.wsdl", "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - WSDL URL convention", e); + } + } + + VnfAdapterNotify_Service notifySvc = new VnfAdapterNotify_Service (warWsdlLoc, + new QName ("http://com.att.mso/vnfNotify", + "vnfAdapterNotify")); + + VnfAdapterNotify notifyPort = notifySvc.getMsoVnfAdapterAsyncImplPort (); + + BindingProvider bp = (BindingProvider) notifyPort; + + URL epUrl = null; + try { + epUrl = new URL (notificationUrl); + } catch (MalformedURLException e1) { + LOGGER.error (MessageEnum.RA_INIT_NOTIF_EXC, "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "MalformedURLException", e1); + } + + LOGGER.debug ("Notification Endpoint URL: " + epUrl.toExternalForm ()); + + bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ()); + + // authentication + try { + Map <String, Object> req_ctx = bp.getRequestContext (); + Map <String, List <String>> headers = new HashMap <String, List <String>> (); + + String userCredentials = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER).getEncryptedProperty (BPEL_AUTH_PROP, + "", + ENCRYPTION_KEY); + + String basicAuth = "Basic " + DatatypeConverter.printBase64Binary (userCredentials.getBytes ()); + req_ctx.put (MessageContext.HTTP_REQUEST_HEADERS, headers); + headers.put ("Authorization", Collections.singletonList (basicAuth)); + } catch (Exception e) { + LOGGER.error (MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Unable to set authorization in callback request", e); + alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, "Unable to set authorization in callback request"); + } + + return notifyPort; + } + +} diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java new file mode 100644 index 0000000000..757f875128 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java @@ -0,0 +1,2391 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf; + + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Scanner; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.jws.WebService; +import javax.xml.ws.Holder; + +import org.openecomp.mso.adapters.vnf.exceptions.VnfAlreadyExists; +import org.openecomp.mso.adapters.vnf.exceptions.VnfException; +import org.openecomp.mso.adapters.vnf.exceptions.VnfNotFound; +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.cloud.CloudConfig; +import org.openecomp.mso.cloud.CloudSite; +import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.HeatEnvironment; +import org.openecomp.mso.db.catalog.beans.HeatFiles; +import org.openecomp.mso.db.catalog.beans.HeatTemplate; +import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; +import org.openecomp.mso.db.catalog.beans.VnfResource; +import org.openecomp.mso.db.catalog.beans.VfModule; +import org.openecomp.mso.db.catalog.beans.VnfComponent; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.beans.HeatStatus; +import org.openecomp.mso.openstack.beans.StackInfo; +import org.openecomp.mso.openstack.beans.VnfStatus; +import org.openecomp.mso.openstack.beans.VnfRollback; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.openecomp.mso.openstack.utils.MsoHeatUtils; +import org.openecomp.mso.openstack.utils.MsoHeatUtilsWithUpdate; +import org.openecomp.mso.openstack.utils.MsoHeatEnvironmentEntry; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +import org.codehaus.jackson.JsonFactory; +import org.codehaus.jackson.JsonNode; +import org.codehaus.jackson.JsonParser; +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.map.ObjectMapper; + +@WebService(serviceName = "VnfAdapter", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapter", targetNamespace = "http://com.att.mso/vnf") +public class MsoVnfAdapterImpl implements MsoVnfAdapter { + + CloudConfigFactory cloudConfigFactory = new CloudConfigFactory(); + protected CloudConfig cloudConfig = null; + + MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory(); + + private static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER"; + private static final String MSO_CONFIGURATION_ERROR = "MsoConfigurationError"; + private static final String VNF_ADAPTER_SERVICE_NAME = "MSO-BPMN:MSO-VnfAdapter."; + private static final String LOG_REPLY_NAME = "MSO-VnfAdapter:MSO-BPMN."; + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + private static final String CHECK_REQD_PARAMS = "org.openecomp.mso.adapters.vnf.checkRequiredParameters"; + private static final String ADD_GET_FILES_ON_VOLUME_REQ = "org.openecomp.mso.adapters.vnf.addGetFilesOnVolumeReq"; + + /** + * Health Check web method. Does nothing but return to show the adapter is deployed. + */ + @Override + public void healthCheck () { + LOGGER.debug ("Health check call in VNF Adapter"); + } + + /** + * DO NOT use that constructor to instantiate this class, the msoPropertiesfactory will be NULL. + * @see MsoVnfAdapterImpl#MsoVnfAdapterImpl(MsoPropertiesFactory, CloudConfigFactory) + */ + public MsoVnfAdapterImpl() { + + } + + /** + * This constructor MUST be used if this class is called with the new operator. + * @param msoPropFactory + */ + public MsoVnfAdapterImpl(MsoPropertiesFactory msoPropFactory, CloudConfigFactory cloudConfigFact) { + this.msoPropertiesFactory = msoPropFactory; + this.cloudConfigFactory = cloudConfigFact; + } + + /** + * This is the "Create VNF" web service implementation. + * It will create a new VNF of the requested type in the specified cloud + * and tenant. The tenant must exist before this service is called. + * + * If a VNF with the same name already exists, this can be considered a + * success or failure, depending on the value of the 'failIfExists' parameter. + * + * All VNF types will be defined in the MSO catalog. The caller must request + * one of these pre-defined types or an error will be returned. Within the + * catalog, each VNF type references (among other things) a Heat template + * which is used to deploy the required VNF artifacts (VMs, networks, etc.) + * to the cloud. + * + * Depending on the Heat template, a variable set of input parameters will + * be defined, some of which are required. The caller is responsible to + * pass the necessary input data for the VNF or an error will be thrown. + * + * The method returns the vnfId (the canonical name), a Map of VNF output + * attributes, and a VnfRollback object. This last object can be passed + * as-is to the rollbackVnf operation to undo everything that was created + * for the VNF. This is useful if a VNF is successfully created but the + * orchestrator fails on a subsequent operation. + * + * @param cloudSiteId CLLI code of the cloud site in which to create the VNF + * @param tenantId Openstack tenant identifier + * @param vnfType VNF type key, should match a VNF definition in catalog DB + * @param vnfVersion VNF version key, should match a VNF definition in catalog DB + * @param vnfName Name to be assigned to the new VNF + * @param inputs Map of key=value inputs for VNF stack creation + * @param failIfExists Flag whether already existing VNF should be considered + * a success or failure + * @param msoRequest Request tracking information for logs + * @param vnfId Holder for output VNF Openstack ID + * @param outputs Holder for Map of VNF outputs from heat (assigned IPs, etc) + * @param rollback Holder for returning VnfRollback object + */ + @Override + public void createVnf (String cloudSiteId, + String tenantId, + String vnfType, + String vnfVersion, + String vnfName, + String requestType, + String volumeGroupHeatStackId, + Map <String, String> inputs, + Boolean failIfExists, + Boolean backout, + MsoRequest msoRequest, + Holder <String> vnfId, + Holder <Map <String, String>> outputs, + Holder <VnfRollback> rollback) throws VnfException { + // Create a hook here to catch shortcut createVf requests: + if (requestType != null) { + if (requestType.startsWith("VFMOD")) { + LOGGER.debug("Calling createVfModule from createVnf -- requestType=" + requestType); + String newRequestType = requestType.substring(5); + String vfVolGroupHeatStackId = ""; + String vfBaseHeatStackId = ""; + try { + if (volumeGroupHeatStackId != null) { + vfVolGroupHeatStackId = volumeGroupHeatStackId.substring(0, volumeGroupHeatStackId.lastIndexOf("|")); + vfBaseHeatStackId = volumeGroupHeatStackId.substring(volumeGroupHeatStackId.lastIndexOf("|")+1); + } + } catch (Exception e) { + // might be ok - both are just blank + LOGGER.debug("ERROR trying to parse the volumeGroupHeatStackId " + volumeGroupHeatStackId); + } + this.createVfModule(cloudSiteId, + tenantId, + vnfType, + vnfVersion, + vnfName, + newRequestType, + vfVolGroupHeatStackId, + vfBaseHeatStackId, + inputs, + failIfExists, + backout, + msoRequest, + vnfId, + outputs, + rollback); + return; + } + } + // createVf will know if the requestType starts with "X" that it's the "old" way + StringBuilder newRequestTypeSb = new StringBuilder("X"); + String vfVolGroupHeatStackId = ""; + String vfBaseHeatStackId = ""; + if (requestType != null) { + newRequestTypeSb.append(requestType); + } + this.createVfModule(cloudSiteId, + tenantId, + vnfType, + vnfVersion, + vnfName, + newRequestTypeSb.toString(), + vfVolGroupHeatStackId, + vfBaseHeatStackId, + inputs, + failIfExists, + backout, + msoRequest, + vnfId, + outputs, + rollback); + return; + // End createVf shortcut + } + + @Override + public void updateVnf (String cloudSiteId, + String tenantId, + String vnfType, + String vnfVersion, + String vnfName, + String requestType, + String volumeGroupHeatStackId, + Map <String, String> inputs, + MsoRequest msoRequest, + Holder <Map <String, String>> outputs, + Holder <VnfRollback> rollback) throws VnfException { + MsoLogger.setLogContext (msoRequest.getRequestId (), msoRequest.getServiceInstanceId ()); + MsoLogger.setServiceName ("UpdateVnf"); + String requestTypeString = ""; + if (requestType != null && !requestType.equals("")) { + requestTypeString = requestType; + } + String nestedStackId = null; + if (volumeGroupHeatStackId != null && !volumeGroupHeatStackId.equals("")) { + nestedStackId = volumeGroupHeatStackId; + } + + LOGGER.debug ("Updating VNF: " + vnfName + " of type " + vnfType + "in " + cloudSiteId + "/" + tenantId); + LOGGER.debug("requestTypeString = " + requestTypeString + ", nestedStackId = " + nestedStackId); + + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + + // Build a default rollback object (no actions performed) + VnfRollback vnfRollback = new VnfRollback (); + vnfRollback.setCloudSiteId (cloudSiteId); + vnfRollback.setTenantId (tenantId); + vnfRollback.setMsoRequest (msoRequest); + vnfRollback.setRequestType(requestTypeString); + + // First, look up to see if the VNF already exists. + MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + MsoHeatUtilsWithUpdate heatU = new MsoHeatUtilsWithUpdate (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + + StackInfo heatStack = null; + long queryStackStarttime1 = System.currentTimeMillis (); + try { + heatStack = heat.queryStack (cloudSiteId, tenantId, vnfName); + LOGGER.recordMetricEvent (queryStackStarttime1, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vnfName); + } catch (MsoException me) { + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + me.addContext ("UpdateVNF"); + String error = "Update VNF: Query " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me; + LOGGER.recordMetricEvent (queryStackStarttime1, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vnfName); + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in updateVnf", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } + + if (heatStack == null || heatStack.getStatus () == HeatStatus.NOTFOUND) { + // Not Found + String error = "Update VNF: Stack " + vnfName + " does not exist in " + cloudSiteId + "/" + tenantId; + LOGGER.error (MessageEnum.RA_VNF_NOT_EXIST, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Update VNF: Stack " + vnfName + " does not exist"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + throw new VnfNotFound (cloudSiteId, tenantId, vnfName); + } else { + LOGGER.debug ("Found Existing stack, status=" + heatStack.getStatus ()); + // Populate the outputs from the existing stack. + outputs.value = copyStringOutputs (heatStack.getOutputs ()); + rollback.value = vnfRollback; // Default rollback - no updates performed + } + + // 1604 Cinder Volume support - handle a nestedStackId if sent (volumeGroupHeatStackId): + StackInfo nestedHeatStack = null; + long queryStackStarttime2 = System.currentTimeMillis (); + if (nestedStackId != null) { + try { + LOGGER.debug("Querying for nestedStackId = " + nestedStackId); + nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId); + LOGGER.recordMetricEvent (queryStackStarttime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vnfName); + } catch (MsoException me) { + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + me.addContext ("UpdateVNF"); + String error = "Update VNF: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; + LOGGER.recordMetricEvent (queryStackStarttime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vnfName); + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.AvailabilityError, "Exception trying to query nested stack", me); + LOGGER.debug("ERROR trying to query nested stack= " + error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } + if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) { + String error = "Update VNF: Attached heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.AvailabilityError, "Attached heatStack ID DOES NOT EXIST"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + LOGGER.debug(error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } else { + LOGGER.debug("Found nested heat stack - copying values to inputs"); + this.sendMapToDebug(inputs); + heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); + this.sendMapToDebug(inputs); + } + } + + // Ready to deploy the new VNF + + try(CatalogDatabase db = new CatalogDatabase ()) { + // Retrieve the VNF definition + VnfResource vnf; + if (vnfVersion != null && !vnfVersion.isEmpty ()) { + vnf = db.getVnfResource (vnfType, vnfVersion); + } else { + vnf = db.getVnfResource (vnfType); + } + if (vnf == null) { + String error = "Update VNF: Unknown VNF Type: " + vnfType; + LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type", vnfType, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Update VNF: Unknown VNF Type"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } + LOGGER.debug ("Got VNF definition from Catalog: " + vnf.toString ()); + + // Currently, all VNFs are orchestrated via HEAT + if (!"HEAT".equals (vnf.getOrchestrationMode ())) { + String error = "Update VNF: Configuration error: VNF=" + vnfType; + LOGGER.error (MessageEnum.RA_CONFIG_EXC, " VNF=" + vnfType, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Update VNF: Configuration error"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + // Alarm on this error, configuration must be fixed + alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + throw new VnfException (error, MsoExceptionCategory.INTERNAL); + } + + //1604 - Need to handle an updateVolume request. + VnfComponent vnfComponent = null; + if (requestTypeString != null && !requestTypeString.equals("")) { + LOGGER.debug("About to query for vnfComponent id = " + vnf.getId() + ", type = " + requestTypeString.toUpperCase()); + vnfComponent = db.getVnfComponent(vnf.getId(), requestTypeString.toUpperCase()); + if (vnfComponent == null) { + String error = "Update VNF: Cannot find VNF Component entry for: " + vnfType + ", type = " + requestTypeString.toUpperCase(); + LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type", vnfType, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Update VNF: Cannot find VNF Component entry"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } + LOGGER.debug("FOUND VnfComponent: " + vnfComponent.toString()); + } + + HeatTemplate heatTemplate = db.getHeatTemplate (vnf.getTemplateId ()); + if (heatTemplate == null) { + String error = "Update VNF: undefined Heat Template. VNF=" + vnfType; + LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", String.valueOf(vnf.getTemplateId ()), "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Update VNF: undefined Heat Template"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + // Alarm on this error, configuration must be fixed + alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + + throw new VnfException (error, MsoExceptionCategory.INTERNAL); + } + + // If this is a component request - get the template associated for volumes + // May change this - for now get both templates - but volume will be 2nd, which makes sense + // for the rest of the code. Same with envt later + if (vnfComponent != null) { + LOGGER.debug("Querying db to find component template " + vnfComponent.getHeatTemplateId()); + heatTemplate = db.getHeatTemplate(vnfComponent + .getHeatTemplateId()); + if (heatTemplate == null) { + String error = "Update VNF: undefined Heat Template for Volume Component. VNF=" + + vnfType; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, + "Heat Template ID", + String.valueOf(vnfComponent.getHeatTemplateId()), "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Update VNF: undefined Heat Template for Volume Component"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, + MsoAlarmLogger.CRITICAL, error); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); + } + } + + LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ()); + + // Add check for any Environment variable + HeatEnvironment heatEnvironment = null; + String heatEnvironmentString = null; + + if (vnf.getEnvironmentId () != null) { + LOGGER.debug ("about to call getHeatEnvironment with :" + vnf.getEnvironmentId () + ":"); + heatEnvironment = db.getHeatEnvironment (vnf.getEnvironmentId ()); + if (heatEnvironment == null) { + + String error = "Create VNF: undefined Heat Environment. VNF=" + vnfType + + ", Environment ID=" + + vnf.getEnvironmentId (); + LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", String.valueOf(vnf.getEnvironmentId ()), "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Create VNF: undefined Heat Environment"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + // Alarm on this error, configuration must be fixed + alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + + throw new VnfException (error, MsoExceptionCategory.INTERNAL); + } else { + LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.toString ()); + heatEnvironmentString = heatEnvironment.getEnvironment (); //this.parseEnvironment (heatEnvironment.getEnvironment ()); + LOGGER.debug ("After parsing: " + heatEnvironmentString); + } + } else { + LOGGER.debug ("no environment parameter for this VNF " + vnfType); + } + + //1604 - override the VNF environment with the one for the component + if(vnfComponent != null) { + if (vnfComponent.getHeatEnvironmentId () != null) { + LOGGER.debug ("about to call getHeatEnvironment with :" + vnfComponent.getHeatEnvironmentId () + ":"); + heatEnvironment = db.getHeatEnvironment (vnfComponent.getHeatEnvironmentId ()); + if (heatEnvironment == null) { + String error = "Update VNF: undefined Heat Environment. VNF=" + vnfType + + ", Environment ID=" + + vnfComponent.getHeatEnvironmentId (); + LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", String.valueOf(vnfComponent.getHeatEnvironmentId ()), "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Update VNF: undefined Heat Environment"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + // Alarm on this error, configuration must be fixed + alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + + throw new VnfException (error, MsoExceptionCategory.INTERNAL); + } else { + LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.toString ()); + heatEnvironmentString = heatEnvironment.getEnvironment (); //this.parseEnvironment (heatEnvironment.getEnvironment ()); + LOGGER.debug ("after parsing: " + heatEnvironmentString); + } + } else { + LOGGER.debug ("no environment parameter for this VNF VOLUME component " + vnfType); + } + } + // End 1604 + + + LOGGER.debug ("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId=" + + heatTemplate.getId ()); + Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getId ()); + Map <String, Object> nestedTemplatesChecked = new HashMap <String, Object> (); + if (nestedTemplates != null) { + // for debugging print them out + LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:"); + for (String providerResourceFile : nestedTemplates.keySet ()) { + String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile); + String childTemplateBody = (String) nestedTemplates.get (providerResourceFile); + nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody); + LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody); + } + } else { + LOGGER.debug ("No nested templates found - nothing to do here"); + nestedTemplatesChecked = null; + } + + // Also add the files: for any get_files associated with this vnf_resource_id + // *if* there are any + LOGGER.debug ("In MsoVnfAdapterImpl.updateVnf, about to call db.getHeatFiles avec vnfResourceId=" + + vnf.getId ()); + Map <String, HeatFiles> heatFiles = db.getHeatFiles (vnf.getId ()); + Map <String, Object> heatFilesObjects = new HashMap <String, Object> (); + if (heatFiles != null) { + // add these to stack - to be done in createStack + // here, we will map them to Map<String, Object> from Map<String, HeatFiles> + // this will match the nested templates format + LOGGER.debug ("Contents of heatFiles - to be added to files: on stack:"); + + for (String heatFileName : heatFiles.keySet ()) { + String heatFileBody = heatFiles.get (heatFileName).getFileBody (); + // Remove the file:/// enforcement for get_file: + //String heatFileNameChecked = this.enforceFilePrefix (heatFileName); + String heatFileNameChecked = heatFileName; + LOGGER.debug (heatFileNameChecked + " -> " + heatFileBody); + heatFilesObjects.put (heatFileNameChecked, heatFileBody); + } + } else { + LOGGER.debug ("No heat files found -nothing to do here"); + heatFilesObjects = null; + } + + // Check that required parameters have been supplied + String missingParams = null; + List <String> paramList = new ArrayList <String> (); + + // New for 1510 - consult the PARAM_ALIAS field to see if we've been + // supplied an alias. Only check if we don't find it initially. + // Also new in 1510 - don't flag missing parameters if there's an environment - because they might be there. + // And also new - add parameter to turn off checking all together if we find we're blocking orders we + // shouldn't + boolean haveEnvironmentParameters = false; + boolean checkRequiredParameters = true; + try { + String propertyString = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER) + .getProperty (MsoVnfAdapterImpl.CHECK_REQD_PARAMS,null); + if ("false".equalsIgnoreCase (propertyString) || "n".equalsIgnoreCase (propertyString)) { + checkRequiredParameters = false; + LOGGER.debug ("CheckRequiredParameters is FALSE. Will still check but then skip blocking..." + + MsoVnfAdapterImpl.CHECK_REQD_PARAMS); + } + } catch (Exception e) { + // No problem - default is true + LOGGER.debug ("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e); + } + // 1604 - Add enhanced environment & parameter checking + // Part 1: parse envt entries to see if reqd parameter is there (before used a simple grep + // Part 2: only submit to openstack the parameters in the envt that are in the heat template + // Note this also removes any comments + MsoHeatEnvironmentEntry mhee = null; + if (heatEnvironmentString != null && heatEnvironmentString.toLowerCase ().contains ("parameters:")) { + LOGGER.debug("Enhanced environment checking enabled - 1604"); + haveEnvironmentParameters = true; + StringBuilder sb = new StringBuilder(heatEnvironmentString); + //LOGGER.debug("About to create MHEE with " + sb); + mhee = new MsoHeatEnvironmentEntry(sb); + StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n"); + for (HeatTemplateParam parm : heatTemplate.getParameters()) { + sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired()); + } + if (!mhee.isValid()) { + sb2.append("Environment says it's not valid! " + mhee.getErrorString()); + } else { + sb2.append("\nEnvironment:"); + sb2.append(mhee.toFullString()); + } + LOGGER.debug(sb2.toString()); + } else { + LOGGER.debug("NO ENVIRONMENT for this entry"); + } + + for (HeatTemplateParam parm : heatTemplate.getParameters ()) { + LOGGER.debug ("Parameter:'" + parm.getParamName () + + "', isRequired=" + + parm.isRequired () + + ", alias=" + + parm.getParamAlias ()); + if (parm.isRequired () && (inputs == null || !inputs.containsKey (parm.getParamName ()))) { + if (inputs.containsKey (parm.getParamAlias ())) { + // They've submitted using an alias name. Remove that from inputs, and add back using real name. + String realParamName = parm.getParamName (); + String alias = parm.getParamAlias (); + String value = inputs.get (alias); + LOGGER.debug ("*Found an Alias: paramName=" + realParamName + + ",alias=" + + alias + + ",value=" + + value); + inputs.remove (alias); + inputs.put (realParamName, value); + LOGGER.debug (alias + " entry removed from inputs, added back using " + realParamName); + } + // enhanced - check if it's in the Environment (note: that method + else if (mhee != null && mhee.containsParameter(parm.getParamName())) { + + LOGGER.debug ("Required parameter " + parm.getParamName () + + " appears to be in environment - do not count as missing"); + } + else { + LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ()); + if (missingParams == null) { + missingParams = parm.getParamName (); + } else { + missingParams += "," + parm.getParamName (); + } + } + } + paramList.add (parm.getParamName ()); + } + if (missingParams != null) { + // Problem - missing one or more required parameters + if (checkRequiredParameters) { + String error = "Update VNF: Missing Required inputs: " + missingParams; + LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Update VNF: Missing Required inputs"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } else { + LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block"); + } + } else { + LOGGER.debug ("No missing parameters found - ok to proceed"); + } + + // Here - modify heatEnvironmentString + StringBuilder parsedEnvironmentString = null; + String newEnvironmentString = null; + if (mhee != null) { + LOGGER.debug("Environment before:\n" + heatEnvironmentString); + parsedEnvironmentString = mhee.toFullStringExcludeNonParams(heatTemplate.getParameters()); + LOGGER.debug("Environment after:\n" + parsedEnvironmentString.toString()); + newEnvironmentString = parsedEnvironmentString.toString(); + } + + // Remove any extraneous parameters (don't throw an error) + if (inputs != null) { + List <String> extraParams = new ArrayList <String> (); + extraParams.addAll (inputs.keySet ()); + // This is not a valid parameter for this template + extraParams.removeAll (paramList); + if (!extraParams.isEmpty ()) { + LOGGER.warn (MessageEnum.RA_VNF_EXTRA_PARAM, vnfType, extraParams.toString(), "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "VNF Extra params"); + inputs.keySet ().removeAll (extraParams); + } + } + + // "Fix" the template if it has CR/LF (getting this from Oracle) + String template = heatTemplate.getHeatTemplate (); + template = template.replaceAll ("\r\n", "\n"); + + // Have the tenant. Now deploy the stack itself + // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions + // because we already checked for those. + long updateStackStarttime = System.currentTimeMillis (); + try { + heatStack = heatU.updateStack (cloudSiteId, + tenantId, + vnfName, + template, + copyStringInputs (inputs), + true, + heatTemplate.getTimeoutMinutes (), + newEnvironmentString, + //heatEnvironmentString, + nestedTemplatesChecked, + heatFilesObjects); + LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "UpdateStack", vnfName); + } catch (MsoException me) { + me.addContext ("UpdateVNF"); + String error = "Update VNF " + vnfType + " in " + cloudSiteId + "/" + tenantId + ": " + me; + LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", vnfName); + LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, vnfType, cloudSiteId, tenantId, "OpenStack", "updateStack", MsoLogger.ErrorCode.DataError, "Exception - updateStack", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } + } + + // Reach this point if updateStack is successful. + // Populate remaining rollback info and response parameters. + vnfRollback.setVnfId (heatStack.getCanonicalName ()); + vnfRollback.setVnfCreated (true); + + outputs.value = copyStringOutputs (heatStack.getOutputs ()); + rollback.value = vnfRollback; + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully update VNF"); + return; + } + + /** + * This is the "Query VNF" web service implementation. + * It will look up a VNF by name or ID in the specified cloud and tenant. + * + * The method returns an indicator that the VNF exists, its Openstack internal + * ID, its status, and the set of outputs (from when the stack was created). + * + * @param cloudSiteId CLLI code of the cloud site in which to query + * @param tenantId Openstack tenant identifier + * @param vnfName VNF Name or Openstack ID + * @param msoRequest Request tracking information for logs + * @param vnfExists Flag reporting the result of the query + * @param vnfId Holder for output VNF Openstack ID + * @param outputs Holder for Map of VNF outputs from heat (assigned IPs, etc) + */ + @Override + public void queryVnf (String cloudSiteId, + String tenantId, + String vnfName, + MsoRequest msoRequest, + Holder <Boolean> vnfExists, + Holder <String> vnfId, + Holder <VnfStatus> status, + Holder <Map <String, String>> outputs) throws VnfException { + MsoLogger.setLogContext (msoRequest); + MsoLogger.setServiceName ("QueryVnf"); + LOGGER.debug ("Querying VNF " + vnfName + " in " + cloudSiteId + "/" + tenantId); + + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + + MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + + StackInfo heatStack = null; + long subStartTime = System.currentTimeMillis (); + try { + heatStack = heat.queryStack (cloudSiteId, tenantId, vnfName); + LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vnfName); + } catch (MsoException me) { + me.addContext ("QueryVNF"); + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + String error = "Query VNF: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me; + LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vnfName); + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryVNF", MsoLogger.ErrorCode.DataError, "Exception - queryStack", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } + + // Populate the outputs based on the returned Stack information + // + if (heatStack == null || heatStack.getStatus () == HeatStatus.NOTFOUND) { + // Not Found + vnfExists.value = Boolean.FALSE; + status.value = VnfStatus.NOTFOUND; + vnfId.value = null; + outputs.value = new HashMap <String, String> (); // Return as an empty map + + LOGGER.debug ("VNF " + vnfName + " not found"); + } else { + vnfExists.value = Boolean.TRUE; + status.value = stackStatusToVnfStatus (heatStack.getStatus ()); + vnfId.value = heatStack.getCanonicalName (); + outputs.value = copyStringOutputs (heatStack.getOutputs ()); + + LOGGER.debug ("VNF " + vnfName + " found, ID = " + vnfId.value); + } + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully query VNF"); + return; + } + + /** + * This is the "Delete VNF" web service implementation. + * It will delete a VNF by name or ID in the specified cloud and tenant. + * + * The method has no outputs. + * + * @param cloudSiteId CLLI code of the cloud site in which to delete + * @param tenantId Openstack tenant identifier + * @param vnfName VNF Name or Openstack ID + * @param msoRequest Request tracking information for logs + */ + @Override + public void deleteVnf (String cloudSiteId, + String tenantId, + String vnfName, + MsoRequest msoRequest) throws VnfException { + MsoLogger.setLogContext (msoRequest); + MsoLogger.setServiceName ("DeleteVnf"); + LOGGER.debug ("Deleting VNF " + vnfName + " in " + cloudSiteId + "/" + tenantId); + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + + MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + + // Use the MsoHeatUtils to delete the stack. Set the polling flag to true. + // The possible outcomes of deleteStack are a StackInfo object with status + // of NOTFOUND (on success) or FAILED (on error). Also, MsoOpenstackException + // could be thrown. + long subStartTime = System.currentTimeMillis (); + try { + heat.deleteStack (tenantId, cloudSiteId, vnfName, true); + LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", vnfName); + } catch (MsoException me) { + me.addContext ("DeleteVNF"); + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + String error = "Delete VNF: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me; + LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", vnfName); + LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "DeleteVNF", MsoLogger.ErrorCode.DataError, "Exception - DeleteVNF", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } + + // On success, nothing is returned. + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VNF"); + return; + } + + /** + * This web service endpoint will rollback a previous Create VNF operation. + * A rollback object is returned to the client in a successful creation + * response. The client can pass that object as-is back to the rollbackVnf + * operation to undo the creation. + */ + @Override + public void rollbackVnf (VnfRollback rollback) throws VnfException { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("RollbackVnf"); + // rollback may be null (e.g. if stack already existed when Create was called) + if (rollback == null) { + LOGGER.info (MessageEnum.RA_ROLLBACK_NULL, "OpenStack", "rollbackVnf"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "Rollback request content is null"); + return; + } + + // Get the elements of the VnfRollback object for easier access + String cloudSiteId = rollback.getCloudSiteId (); + String tenantId = rollback.getTenantId (); + String vnfId = rollback.getVnfId (); + + MsoLogger.setLogContext (rollback.getMsoRequest()); + + LOGGER.debug ("Rolling Back VNF " + vnfId + " in " + cloudSiteId + "/" + tenantId); + + MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + + // Use the MsoHeatUtils to delete the stack. Set the polling flag to true. + // The possible outcomes of deleteStack are a StackInfo object with status + // of NOTFOUND (on success) or FAILED (on error). Also, MsoOpenstackException + // could be thrown. + long subStartTime = System.currentTimeMillis (); + try { + heat.deleteStack (tenantId, cloudSiteId, vnfId, true); + LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", null); + } catch (MsoException me) { + // Failed to rollback the Stack due to an openstack exception. + // Convert to a generic VnfException + me.addContext ("RollbackVNF"); + String error = "Rollback VNF: " + vnfId + " in " + cloudSiteId + "/" + tenantId + ": " + me; + LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null); + LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vnfId, cloudSiteId, tenantId, "OpenStack", "DeleteStack", MsoLogger.ErrorCode.DataError, "Exception - DeleteStack", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully roll back VNF"); + return; + } + + private VnfStatus stackStatusToVnfStatus (HeatStatus stackStatus) { + switch (stackStatus) { + case CREATED: + return VnfStatus.ACTIVE; + case UPDATED: + return VnfStatus.ACTIVE; + case FAILED: + return VnfStatus.FAILED; + default: + return VnfStatus.UNKNOWN; + } + } + + private Map <String, String> copyStringOutputs (Map <String, Object> stackOutputs) { + Map <String, String> stringOutputs = new HashMap <String, String> (); + for (String key : stackOutputs.keySet ()) { + if (stackOutputs.get (key) instanceof String) { + stringOutputs.put (key, (String) stackOutputs.get (key)); + } + } + return stringOutputs; + } + + private Map <String, Object> copyStringInputs (Map <String, String> stringInputs) { + return new HashMap <String, Object> (stringInputs); + } + + /* + * a helper method to make sure that any resource_registry entry of the format + * "xx::xx" : yyy.yaml (or yyy.template) + * has the file name prepended with "file:///" + * Return a String of the environment body that's passed in. + * Have to be careful not to mess up the original formatting. + */ + private String parseEnvironment (String environment) { + StringBuilder sb = new StringBuilder (); + try (Scanner scanner = new Scanner (environment)) { + scanner.useDelimiter ("\n"); + String line = null; + Pattern resource = Pattern.compile ("\\s*\"\\w+::\\S+\"\\s*:"); + LOGGER.debug ("regex pattern for finding a resource_registry: \\s*\"\\w+::\\S+\"\\s*:"); + while (scanner.hasNextLine ()) { + line = scanner.nextLine (); + if (line.toLowerCase ().contains ("resource_registry")) { + sb.append (line + "\n"); + boolean done = false; + // basically keep scanning until EOF or parameters: section + while (scanner.hasNextLine () && !done) { + line = scanner.nextLine (); + if ("parameters:".equalsIgnoreCase (line.trim ())) { + sb.append (line + "\n"); + done = true; + break; + } + Matcher m = resource.matcher (line); + if (m.find ()) { + sb.append (m.group ()); + String secondPart = line.substring (m.end ()).trim (); + String output = secondPart; + if (secondPart.endsWith (".yaml") + || secondPart.endsWith (".template") && !secondPart.startsWith ("file:///")) { + output = "file:///" + secondPart; + LOGGER.debug ("changed " + secondPart + " to " + output); + } // don't do anything if it's not .yaml or .template + sb.append (" " + output + "\n"); + } else { + sb.append (line + "\n"); + } + } + } else { + sb.append (line + "\n"); + continue; + } + } + scanner.close (); + } catch (Exception e) { + LOGGER.debug ("Error trying to scan " + environment, e); + return environment; + } + return sb.toString (); + } + + /* + * helper class to add file:/// to the Provider_Resource_File entry in HEAT_NESTED_TEMPLATE + * and the File_Name entry in HEAT_FILES if the file:/// part is missing. + */ + private String enforceFilePrefix (String string) { + if (string.trim ().startsWith ("file:///")) { + // just leave it + return string; + } + if (string.trim ().endsWith (".yaml") || string.trim ().endsWith (".template")) { + // only .yaml or .template are valid anyway - otherwise don't bother + return "file:///" + string.trim (); + } else { + LOGGER.debug (string + " is NOT a .yaml or .template file"); + } + return string; + } + + private void sendMapToDebug(Map<String, String> inputs) { + int i = 0; + StringBuilder sb = new StringBuilder("inputs:"); + if (inputs == null) { + sb.append("\tNULL"); + } + else if (inputs.size() < 1) { + sb.append("\tEMPTY"); + } else { + for (String str : inputs.keySet()) { + sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str)); + } + } + LOGGER.debug(sb.toString()); + return; + } + + public void createVfModule(String cloudSiteId, + String tenantId, + String vnfType, + String vnfVersion, + String vnfName, + String requestType, + String volumeGroupHeatStackId, + String baseVfHeatStackId, + Map <String, String> inputs, + Boolean failIfExists, + Boolean backout, + MsoRequest msoRequest, + Holder <String> vnfId, + Holder <Map <String, String>> outputs, + Holder <VnfRollback> rollback) throws VnfException { + String vfModuleName = vnfName; + String vfModuleType = vnfType; + String vfVersion = vnfVersion; + MsoLogger.setLogContext (msoRequest); + MsoLogger.setServiceName ("CreateVfModule"); + String requestTypeString = ""; + if (requestType != null && !requestType.equals("")) { + requestTypeString = requestType; + } + String nestedStackId = null; + if (volumeGroupHeatStackId != null && !volumeGroupHeatStackId.equals("")) { + if (!volumeGroupHeatStackId.equalsIgnoreCase("null")) { + nestedStackId = volumeGroupHeatStackId; + } + } + String nestedBaseStackId = null; + if (baseVfHeatStackId != null && !baseVfHeatStackId.equals("")) { + if (!baseVfHeatStackId.equalsIgnoreCase("null")) { + nestedBaseStackId = baseVfHeatStackId; + } + } + + if (inputs == null) { + // Create an empty set of inputs + inputs = new HashMap<String,String>(); + LOGGER.debug("inputs == null - setting to empty"); + } else { + this.sendMapToDebug(inputs); + } + //This method will also handle doing things the "old" way - i.e., just orchestrate a VNF + boolean oldWay = false; + if (requestTypeString.startsWith("X")) { + oldWay = true; + LOGGER.debug("orchestrating a VNF - *NOT* a module!"); + requestTypeString = requestTypeString.substring(1); + } + + // 1607 - let's parse out the request type we're being sent + boolean isBaseRequest = false; + boolean isVolumeRequest = false; + if (requestTypeString.startsWith("VOLUME")) { + isVolumeRequest = true; + } + + LOGGER.debug("requestTypeString = " + requestTypeString + ", nestedStackId = " + nestedStackId + ", nestedBaseStackId = " + nestedBaseStackId); + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + + // Build a default rollback object (no actions performed) + VnfRollback vfRollback = new VnfRollback(); + vfRollback.setCloudSiteId(cloudSiteId); + vfRollback.setTenantId(tenantId); + vfRollback.setMsoRequest(msoRequest); + vfRollback.setRequestType(requestTypeString); + vfRollback.setVolumeGroupHeatStackId(volumeGroupHeatStackId); + vfRollback.setBaseGroupHeatStackId(baseVfHeatStackId); + vfRollback.setIsBase(isBaseRequest); + + // First, look up to see if the VF already exists. + MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + + StackInfo heatStack = null; + long subStartTime1 = System.currentTimeMillis (); + try { + heatStack = heat.queryStack (cloudSiteId, tenantId, vfModuleName); + LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vfModuleName); + } catch (MsoException me) { + String error = "Create VF Module: Query " + vfModuleName + " in " + cloudSiteId + "/" + tenantId + ": " + me ; + LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vfModuleName); + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Exception - queryStack", me); + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + me.addContext ("CreateVFModule"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } + // New with 1607 - more precise handling/messaging if the stack already exists + if (heatStack != null && !(heatStack.getStatus () == HeatStatus.NOTFOUND)) { + // INIT, CREATED, NOTFOUND, FAILED, BUILDING, DELETING, UNKNOWN, UPDATING, UPDATED + HeatStatus status = heatStack.getStatus(); + if (status == HeatStatus.INIT || status == HeatStatus.BUILDING || status == HeatStatus.DELETING || status == HeatStatus.UPDATING) { + // fail - it's in progress - return meaningful error + String error = "Create VF: Stack " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; please wait for it to complete, or fix manually."; + LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); + } + if (status == HeatStatus.FAILED) { + // fail - it exists and is in a FAILED state + String error = "Create VF: Stack " + vfModuleName + " already exists and is in FAILED state in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; + LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists and is in FAILED state"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); + } + if (status == HeatStatus.UNKNOWN || status == HeatStatus.UPDATED) { + // fail - it exists and is in a FAILED state + String error = "Create VF: Stack " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; + LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists and is in UPDATED or UNKNOWN state"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); + } + if (status == HeatStatus.CREATED) { + // fail - it exists + if (failIfExists != null && failIfExists) { + String error = "Create VF: Stack " + vfModuleName + " already exists in " + cloudSiteId + "/" + tenantId; + LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); + } else { + LOGGER.debug ("Found Existing stack, status=" + heatStack.getStatus ()); + // Populate the outputs from the existing stack. + vnfId.value = heatStack.getCanonicalName (); + outputs.value = copyStringOutputs (heatStack.getOutputs ()); + rollback.value = vfRollback; // Default rollback - no updates performed + } + } + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module"); + return; + + } + + // handle a nestedStackId if sent- this one would be for the volume - so applies to both Vf and Vnf + StackInfo nestedHeatStack = null; + long subStartTime2 = System.currentTimeMillis (); + if (nestedStackId != null) { + try { + LOGGER.debug("Querying for nestedStackId = " + nestedStackId); + nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId); + LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vfModuleName); + } catch (MsoException me) { + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + me.addContext ("CreateVFModule"); + String error = "Create VFModule: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; + LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vfModuleName); + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested stack", me); + LOGGER.debug("ERROR trying to query nested stack= " + error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } + if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) { + String error = "Create VFModule: Attached heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached heatStack ID DOES NOT EXIST"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + LOGGER.debug(error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } else { + LOGGER.debug("Found nested volume heat stack - copying values to inputs"); + this.sendMapToDebug(inputs); + heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); + this.sendMapToDebug(inputs); + } + } + + // handle a nestedBaseStackId if sent- this is the stack ID of the base. Should be null for VNF requests + StackInfo nestedBaseHeatStack = null; + long subStartTime3 = System.currentTimeMillis (); + if (nestedBaseStackId != null) { + try { + LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId); + nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId); + LOGGER.recordMetricEvent (subStartTime3, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vfModuleName); + } catch (MsoException me) { + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + me.addContext ("CreateVFModule"); + String error = "Create VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; + LOGGER.recordMetricEvent (subStartTime3, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vfModuleName); + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested base stack", me); + LOGGER.debug("ERROR trying to query nested base stack= " + error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } + if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) { + String error = "Create VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached base heatStack ID DOES NOT EXIST"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + LOGGER.debug(error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } else { + LOGGER.debug("Found nested base heat stack - copying values to inputs"); + this.sendMapToDebug(inputs); + heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false); + this.sendMapToDebug(inputs); + } + } + + // Ready to deploy the new VNF + + try (CatalogDatabase db = new CatalogDatabase()) { + // Retrieve the VF + VfModule vf = null; + VnfResource vnfResource = null; + LOGGER.debug("version: " + vfVersion); + if (!oldWay) { + // Need to handle old and new schema methods - for a time. Try the new way first. + if (vfVersion != null && !vfVersion.isEmpty()) { + vf = db.getVfModuleType(vfModuleType, vfVersion); + if (vf == null) { + LOGGER.debug("Unable to find " + vfModuleType + " and version=" + vfVersion + " in the TYPE column - will try in MODEL_NAME"); + vf = db.getVfModuleModelName(vfModuleType, vfVersion); + if (vf == null) { + LOGGER.debug("Unable to find " + vfModuleType + " and version=" + vfVersion + " in the MODEL_NAME field either - ERROR"); + } + } + } else { + vf = db.getVfModuleType(vfModuleType); + if (vf == null) { + LOGGER.debug("Unable to find " + vfModuleType + " in the TYPE column - will try in MODEL_NAME"); + vf = db.getVfModuleModelName(vfModuleType); + if (vf == null) { + LOGGER.debug("Unable to find " + vfModuleType + " in the MODEL_NAME field either - ERROR"); + } + } + } + if (vf == null) { + String error = "Create VF Module: Unable to determine specific VF Module Type: " + + vfModuleType; + if (vfVersion != null && !vfVersion.isEmpty()) { + error += " with version = " + vfVersion; + } + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, + "VF Module Type", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Unable to determine specific VF Module Type"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); + } + LOGGER.debug("Got VF module definition from Catalog: " + + vf.toString()); + + if (vf.isBase()) { + isBaseRequest = true; + LOGGER.debug("This is a BASE VF request!"); + } else { + LOGGER.debug("This is *not* a BASE VF request!"); + if (!isVolumeRequest && nestedBaseStackId == null) { + LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); + } + } + } else { + if (vfVersion != null && !vfVersion.isEmpty()) { + vnfResource = db.getVnfResource(vnfType, vnfVersion); + } else { + vnfResource = db.getVnfResource(vnfType); + } + if (vnfResource == null) { + String error = "Create VNF: Unknown VNF Type: " + vnfType; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type", + vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VNF: Unknown VNF Type"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); + } + LOGGER.debug("Got VNF module definition from Catalog: " + + vnfResource.toString()); + } + // By here - we have either a vf or vnfResource + + //1607 - Add version check + // First - see if it's in the VnfResource record + // if we have a vf Module - then we have to query to get the VnfResource record. + if (!oldWay) { + if (vf.getVnfResourceId() != null) { + int vnfResourceId = vf.getVnfResourceId(); + vnfResource = db.getVnfResourceById(vnfResourceId); + if (vnfResource == null) { + LOGGER.debug("Unable to find vnfResource at " + vnfResourceId + " will not error for now..."); + } + } + } + String minVersionVnf = null; + String maxVersionVnf = null; + if (vnfResource != null) { + try { + minVersionVnf = vnfResource.getAicVersionMin(); + maxVersionVnf = vnfResource.getAicVersionMax(); + } catch (Exception e) { + LOGGER.debug("Unable to pull min/max version for this VNF Resource entry"); + minVersionVnf = null; + maxVersionVnf = null; + } + if (minVersionVnf != null && minVersionVnf.equals("")) { + minVersionVnf = null; + } + if (maxVersionVnf != null && maxVersionVnf.equals("")) { + maxVersionVnf = null; + } + } + if (minVersionVnf != null && maxVersionVnf != null) { + MavenLikeVersioning aicV = new MavenLikeVersioning(); + CloudSite cloudSite = null; + String aicVersion = ""; + if (this.cloudConfig == null) { + this.cloudConfig = this.cloudConfigFactory.getCloudConfig(); + } + // double check + if (this.cloudConfig != null) { + cloudSite = this.cloudConfig.getCloudSite(cloudSiteId); + if (cloudSite != null) { + aicV.setVersion(cloudSite.getAic_version()); + if ((aicV.isMoreRecentThan(minVersionVnf) || aicV.isTheSameVersion(minVersionVnf)) // aic >= min + && (aicV.isTheSameVersion(maxVersionVnf) || !(aicV.isMoreRecentThan(maxVersionVnf)))) { //aic <= max + LOGGER.debug("VNF Resource " + vnfResource.getVnfType() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version()); + } else { + // ERROR + String error = "VNF Resource type: " + vnfResource.getVnfType() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version(); + LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); + LOGGER.debug(error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); + } + } // let this error out downstream to avoid introducing uncertainty at this stage + } else { + LOGGER.debug("cloudConfig is NULL - cannot check cloud site version"); + } + + } else { + LOGGER.debug("AIC Version not set in VNF_Resource - this is expected thru 1607 - do not error here - not checked."); + } + // End Version check 1607 + + // with VF_MODULE - we have both the non-vol and vol template/envs in that object + // with VNF_RESOURCE - we use the old methods. + Integer heatTemplateId = null; + Integer heatEnvtId = null; + + if (!oldWay) { + if (isVolumeRequest) { + heatTemplateId = vf.getVolTemplateId(); + heatEnvtId = vf.getVolEnvironmentId(); + } else { + heatTemplateId = vf.getTemplateId(); + heatEnvtId = vf.getEnvironmentId(); + } + } else { + if (isVolumeRequest) { + VnfComponent vnfComponent = null; + vnfComponent = db.getVnfComponent(vnfResource.getId(), "VOLUME"); + if (vnfComponent == null) { + String error = "Create VNF: Cannot find VNF Component entry for: " + vnfType + ", type = VOLUME"; + LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type", vnfType, "OpenStack", "getVnfComponent", MsoLogger.ErrorCode.DataError, "Create VNF: Cannot find VNF Component entry"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } else { + heatTemplateId = vnfComponent.getHeatTemplateId(); + heatEnvtId = vnfComponent.getHeatEnvironmentId(); + } + } else { + heatTemplateId = vnfResource.getTemplateId(); + heatEnvtId = vnfResource.getEnvironmentId(); + } + } + // By the time we get here - heatTemplateId and heatEnvtId should be populated (or null) + HeatTemplate heatTemplate = null; + if (heatTemplateId == null) { + String error = "Create: No Heat Template ID defined in catalog database for " + vnfType + ", reqType=" + requestTypeString; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, + MsoAlarmLogger.CRITICAL, error); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); + } else { + heatTemplate = db.getHeatTemplate(heatTemplateId); + } + if (heatTemplate == null) { + String error = "Create VF/VNF: no entry found for heat template ID = " + heatTemplateId; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, + "Heat Template ID", + String.valueOf(heatTemplateId), "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create VF/VNF: no entry found for heat template ID = " + heatTemplateId); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, + MsoAlarmLogger.CRITICAL, error); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); + } + LOGGER.debug("Got HEAT Template from DB"); + + HeatEnvironment heatEnvironment = null; + String heatEnvironmentString = null; + + if (heatEnvtId != null && heatEnvtId != 0) { + LOGGER.debug ("about to call getHeatEnvironment with :" + heatEnvtId + ":"); + heatEnvironment = db.getHeatEnvironment (heatEnvtId); + if (heatEnvironment == null) { + String error = "Create VFModule: undefined Heat Environment. VFModule=" + vfModuleType + + ", Environment ID=" + + heatEnvtId; + LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", String.valueOf(heatEnvtId), "OpenStack", "getHeatEnvironment", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: undefined Heat Environment"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + // Alarm on this error, configuration must be fixed + alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + + throw new VnfException (error, MsoExceptionCategory.INTERNAL); + } else { + LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.toString ()); + heatEnvironmentString = heatEnvironment.getEnvironment (); //this.parseEnvironment (heatEnvironment.getEnvironment ()); + LOGGER.debug ("after parsing: " + heatEnvironmentString); + } + } else { + LOGGER.debug ("no environment parameter found for this Type " + vfModuleType); + } + + // 1510 - Add the files: for nested templates *if* there are any + LOGGER.debug ("In MsoVnfAdapterImpl, createVfModule about to call db.getNestedTemplates avec templateId=" + + heatTemplate.getId ()); + Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getId ()); + Map <String, Object> nestedTemplatesChecked = new HashMap <String, Object> (); + if (nestedTemplates != null) { + // for debugging print them out + LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:"); + for (String providerResourceFile : nestedTemplates.keySet ()) { + String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile); + String childTemplateBody = (String) nestedTemplates.get (providerResourceFile); + LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody); + nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody); + } + } else { + LOGGER.debug ("No nested templates found - nothing to do here"); + nestedTemplatesChecked = null; // just to make sure + } + + // 1510 - Also add the files: for any get_files associated with this vnf_resource_id + // *if* there are any + Map<String, HeatFiles> heatFiles = null; + Map<String, Object> heatFilesObjects = new HashMap<String, Object>(); + + // Add ability to turn on adding get_files with volume requests (by property). + boolean addGetFilesOnVolumeReq = false; + try { + String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null); + if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) { + addGetFilesOnVolumeReq = true; + LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString); + } + } catch (Exception e) { + LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e); + } + + if (!isVolumeRequest || addGetFilesOnVolumeReq) { + if (oldWay) { + LOGGER.debug("In MsoVnfAdapterImpl createVfModule, about to call db.getHeatFiles avec vnfResourceId=" + + vnfResource.getId()); + heatFiles = db.getHeatFiles(vnfResource.getId()); + } else { + // 1607 - now use VF_MODULE_TO_HEAT_FILES table + LOGGER.debug("In MsoVnfAdapterImpl createVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId=" + + vf.getId()); + heatFiles = db + .getHeatFilesForVfModule(vf.getId()); + } + if (heatFiles != null) { + // add these to stack - to be done in createStack + // here, we will map them to Map<String, Object> from + // Map<String, HeatFiles> + // this will match the nested templates format + LOGGER.debug("Contents of heatFiles - to be added to files: on stack:"); + + for (String heatFileName : heatFiles.keySet()) { + if (heatFileName.startsWith("_ERROR|")) { + // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found. + String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1); + String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId; + LOGGER.debug(error); + LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "HEAT_FILES entry not found"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + // Alarm on this error, configuration must be fixed + alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + throw new VnfException (error, MsoExceptionCategory.INTERNAL); + } + String heatFileBody = heatFiles.get(heatFileName) + .getFileBody(); + String heatFileNameChecked = heatFileName; + LOGGER.debug(heatFileNameChecked + " -> " + + heatFileBody); + heatFilesObjects.put(heatFileNameChecked, heatFileBody); + } + } else { + LOGGER.debug("No heat files found -nothing to do here"); + heatFilesObjects = null; + } + } else { + LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES"); + } + + // Check that required parameters have been supplied + String missingParams = null; + List <String> paramList = new ArrayList <String> (); + + // New for 1510 - consult the PARAM_ALIAS field to see if we've been + // supplied an alias. Only check if we don't find it initially. + // Also new in 1510 - don't flag missing parameters if there's an environment - because they might be there. + // And also new - add parameter to turn off checking all together if we find we're blocking orders we + // shouldn't + boolean haveEnvironmentParameters = false; + boolean checkRequiredParameters = true; + try { + String propertyString = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER) + .getProperty (MsoVnfAdapterImpl.CHECK_REQD_PARAMS,null); + if ("false".equalsIgnoreCase (propertyString) || "n".equalsIgnoreCase (propertyString)) { + checkRequiredParameters = false; + LOGGER.debug ("CheckRequiredParameters is FALSE. Will still check but then skip blocking..." + + MsoVnfAdapterImpl.CHECK_REQD_PARAMS); + } + } catch (Exception e) { + // No problem - default is true + LOGGER.debug ("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e); + } + // 1604 - Add enhanced environment & parameter checking + // Part 1: parse envt entries to see if reqd parameter is there (before used a simple grep + // Part 2: only submit to openstack the parameters in the envt that are in the heat template + // Note this also removes any comments + MsoHeatEnvironmentEntry mhee = null; + if (heatEnvironmentString != null && heatEnvironmentString.contains ("parameters:")) { + //LOGGER.debug ("Have an Environment argument with a parameters: section - will bypass checking for valid params - but will still check for aliases"); + LOGGER.debug("Enhanced environment checking enabled - 1604"); + haveEnvironmentParameters = true; + StringBuilder sb = new StringBuilder(heatEnvironmentString); + //LOGGER.debug("About to create MHEE with " + sb); + mhee = new MsoHeatEnvironmentEntry(sb); + StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n"); + for (HeatTemplateParam parm : heatTemplate.getParameters()) { + sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired()); + } + if (!mhee.isValid()) { + sb2.append("Environment says it's not valid! " + mhee.getErrorString()); + } else { + sb2.append("\nEnvironment:"); + sb2.append(mhee.toFullString()); + } + LOGGER.debug(sb2.toString()); + } else { + LOGGER.debug("NO ENVIRONMENT for this entry"); + } + // This is kind of a mess. inputs is a Map<String, String> -- + // if one of the parameters is json - we need to pass String, JsonNode - + // so we will store off the parameters that are json in its own HashMap + // if there are any json params - then we convert inputs to a Map<String, Object> + // and pass that to createStack + HashMap<String, JsonNode> jsonParams = new HashMap<String, JsonNode>(); + boolean hasJson = false; + + for (HeatTemplateParam parm : heatTemplate.getParameters ()) { + LOGGER.debug ("Parameter:'" + parm.getParamName () + + "', isRequired=" + + parm.isRequired () + + ", alias=" + + parm.getParamAlias ()); + // New 1607 - support json type + String parameterType = parm.getParamType(); + if (parameterType == null || parameterType.trim().equals("")) { + parameterType = "String"; + } + JsonNode jsonNode = null; + if (parameterType.equalsIgnoreCase("json") && inputs != null) { + if (inputs.containsKey(parm.getParamName()) ) { + hasJson = true; + String jsonString = null; + try { + jsonString = inputs.get(parm.getParamName()); + jsonNode = new ObjectMapper().readTree(jsonString); + } catch (JsonParseException jpe) { + //TODO - what to do here? + //for now - send the error to debug, but just leave it as a String + String errorMessage = jpe.getMessage(); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage); + hasJson = false; + jsonNode = null; + } catch (Exception e) { + // or here? + LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage()); + hasJson = false; + jsonNode = null; + } + if (jsonNode != null) { + jsonParams.put(parm.getParamName(), jsonNode); + } + } else if (inputs.containsKey(parm.getParamAlias())) { + hasJson = true; + String jsonString = null; + try { + jsonString = inputs.get(parm.getParamAlias()); + jsonNode = new ObjectMapper().readTree(jsonString); + } catch (JsonParseException jpe) { + //TODO - what to do here? + //for now - send the error to debug, but just leave it as a String + String errorMessage = jpe.getMessage(); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage); + hasJson = false; + jsonNode = null; + } catch (Exception e) { + // or here? + LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage()); + hasJson = false; + jsonNode = null; + } + if (jsonNode != null) { + // Notice here - we add it to the jsonParams hashMap with the actual name - + // then manipulate the inputs so when we check for aliases below - it will not + // get flagged. + jsonParams.put(parm.getParamName(), jsonNode); + inputs.remove(parm.getParamAlias()); + inputs.put(parm.getParamName(), jsonString); + } + } //TODO add a check for the parameter in the env file + } + if (parm.isRequired () && (inputs == null || !inputs.containsKey (parm.getParamName ()))) { + // Check if they have an alias + LOGGER.debug("**Parameter " + parm.getParamName() + " is required and not in the inputs..."); + if (inputs.containsKey (parm.getParamAlias ())) { + // They've submitted using an alias name. Remove that from inputs, and add back using real name. + String realParamName = parm.getParamName (); + String alias = parm.getParamAlias (); + String value = inputs.get (alias); + LOGGER.debug ("*Found an Alias: paramName=" + realParamName + + ",alias=" + + alias + + ",value=" + + value); + inputs.remove (alias); + inputs.put (realParamName, value); + LOGGER.debug (alias + " entry removed from inputs, added back using " + realParamName); + } + // enhanced - check if it's in the Environment (note: that method + else if (mhee != null && mhee.containsParameter(parm.getParamName())) { + + LOGGER.debug ("Required parameter " + parm.getParamName () + + " appears to be in environment - do not count as missing"); + } else { + LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ()); + if (missingParams == null) { + missingParams = parm.getParamName (); + } else { + missingParams += "," + parm.getParamName (); + } + } + } + paramList.add (parm.getParamName ()); + } + if (missingParams != null) { + if (checkRequiredParameters) { + // Problem - missing one or more required parameters + String error = "Create VFModule: Missing Required inputs: " + missingParams; + LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } else { + LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block"); + } + } else { + LOGGER.debug ("No missing parameters found - ok to proceed"); + } + + // Here - modify heatEnvironmentString + StringBuilder parsedEnvironmentString = null; + String newEnvironmentString = null; + if (mhee != null) { + LOGGER.debug("Environment before:\n" + heatEnvironmentString); + parsedEnvironmentString = mhee.toFullStringExcludeNonParams(heatTemplate.getParameters()); + LOGGER.debug("Environment after:\n" + parsedEnvironmentString.toString()); + newEnvironmentString = parsedEnvironmentString.toString(); + } + + // Remove any extraneous parameters (don't throw an error) + if (inputs != null) { + List <String> extraParams = new ArrayList <String> (); + extraParams.addAll (inputs.keySet ()); + extraParams.removeAll (paramList); + if (!extraParams.isEmpty ()) { + LOGGER.warn (MessageEnum.RA_VNF_EXTRA_PARAM, vnfType, extraParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, "Extra params"); + inputs.keySet ().removeAll (extraParams); + } + } + // 1607 - when we get here - we have clean inputs. Check if we have + Map<String, Object> inputsTwo = null; + if (hasJson && jsonParams.size() > 0) { + inputsTwo = new HashMap<String, Object>(); + for (String keyParamName : inputs.keySet()) { + if (jsonParams.containsKey(keyParamName)) { + inputsTwo.put(keyParamName, jsonParams.get(keyParamName)); + } else { + inputsTwo.put(keyParamName, inputs.get(keyParamName)); + } + } + } + + // "Fix" the template if it has CR/LF (getting this from Oracle) + String template = heatTemplate.getHeatTemplate (); + template = template.replaceAll ("\r\n", "\n"); + + // Have the tenant. Now deploy the stack itself + // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions + // because we already checked for those. + long createStackStarttime = System.currentTimeMillis (); + try { + // heatStack = heat.createStack(cloudSiteId, tenantId, vnfName, template, inputs, true, + // heatTemplate.getTimeoutMinutes()); + if (backout == null) { + backout = true; + } + if (heat != null) { + LOGGER.debug("heat is not null!!"); + } + + if (!hasJson) { + heatStack = heat.createStack (cloudSiteId, + tenantId, + vfModuleName, + template, + inputs, + true, + heatTemplate.getTimeoutMinutes (), + newEnvironmentString, + //heatEnvironmentString, + nestedTemplatesChecked, + heatFilesObjects, + backout.booleanValue()); + LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "CreateStack", vfModuleName); + } else { + heatStack = heat.createStack (cloudSiteId, + tenantId, + vfModuleName, + template, + inputsTwo, + true, + heatTemplate.getTimeoutMinutes (), + newEnvironmentString, + //heatEnvironmentString, + nestedTemplatesChecked, + heatFilesObjects, + backout.booleanValue()); + + } + LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "CreateStack", vfModuleName); + } catch (MsoException me) { + me.addContext ("CreateVFModule"); + String error = "Create VF Module " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me; + LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName); + LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "MsoException - createStack", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } catch (NullPointerException npe) { + String error = "Create VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + npe; + LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName); + LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "NullPointerException - createStack", npe); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + LOGGER.debug("NULL POINTER EXCEPTION at heat.createStack"); + //npe.addContext ("CreateVNF"); + throw new VnfException ("NullPointerException during heat.createStack"); + } catch (Exception e) { + LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack", "OpenStack", "CreateStack", vfModuleName); + LOGGER.debug("unhandled exception at heat.createStack"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack"); + throw new VnfException("Exception during heat.createStack! " + e.getMessage()); + } + } catch (Exception e) { + LOGGER.debug("unhandled exception in create VF"); + throw new VnfException("Exception during create VF " + e.getMessage()); + + } + + // Reach this point if createStack is successful. + // Populate remaining rollback info and response parameters. + vfRollback.setVnfId (heatStack.getCanonicalName ()); + vfRollback.setVnfCreated (true); + + vnfId.value = heatStack.getCanonicalName (); + outputs.value = copyStringOutputs (heatStack.getOutputs ()); + rollback.value = vfRollback; + + LOGGER.debug ("VF Module " + vfModuleName + " successfully created"); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module"); + return; + + + } + + public void deleteVfModule (String cloudSiteId, + String tenantId, + String vnfName, + MsoRequest msoRequest) throws VnfException { + MsoLogger.setLogContext (msoRequest); + MsoLogger.setServiceName ("DeleteVf"); + LOGGER.debug ("Deleting VF " + vnfName + " in " + cloudSiteId + "/" + tenantId); + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + + MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + + // Use the MsoHeatUtils to delete the stack. Set the polling flag to true. + // The possible outcomes of deleteStack are a StackInfo object with status + // of NOTFOUND (on success) or FAILED (on error). Also, MsoOpenstackException + // could be thrown. + long subStartTime = System.currentTimeMillis (); + try { + heat.deleteStack (tenantId, cloudSiteId, vnfName, true); + LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", vnfName); + } catch (MsoException me) { + me.addContext ("DeleteVNF"); + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + String error = "Delete VF: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me; + LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", vnfName); + LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "DeleteStack", MsoLogger.ErrorCode.DataError, "Exception - deleteStack", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } + + // On success, nothing is returned. + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VF"); + return; + } + + @Override + public void updateVfModule (String cloudSiteId, + String tenantId, + String vnfType, + String vnfVersion, + String vnfName, + String requestType, + String volumeGroupHeatStackId, + String baseVfHeatStackId, + String vfModuleStackId, + Map <String, String> inputs, + MsoRequest msoRequest, + Holder <Map <String, String>> outputs, + Holder <VnfRollback> rollback) throws VnfException { + String vfModuleName = vnfName; + String vfModuleType = vnfType; + String vfVersion = vnfVersion; + String methodName = "updateVfModule"; + MsoLogger.setLogContext (msoRequest.getRequestId (), msoRequest.getServiceInstanceId ()); + String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName; + MsoLogger.setServiceName (serviceName); + + String requestTypeString = ""; + if (requestType != null && !requestType.equals("")) { + requestTypeString = requestType; + } + String nestedStackId = null; + if (volumeGroupHeatStackId != null && !volumeGroupHeatStackId.equals("")) { + if (!volumeGroupHeatStackId.equalsIgnoreCase("null")) { + nestedStackId = volumeGroupHeatStackId; + } + } + String nestedBaseStackId = null; + if (baseVfHeatStackId != null && !baseVfHeatStackId.equals("")) { + if (!baseVfHeatStackId.equalsIgnoreCase("null")) { + nestedBaseStackId = baseVfHeatStackId; + } + } + + if (inputs == null) { + // Create an empty set of inputs + inputs = new HashMap<String,String>(); + LOGGER.debug("inputs == null - setting to empty"); + } else { + this.sendMapToDebug(inputs); + } + boolean isBaseRequest = false; + boolean isVolumeRequest = false; + if (requestTypeString.startsWith("VOLUME")) { + isVolumeRequest = true; + } + if (vfModuleName == null || vfModuleName.trim().equals("")) { + if (vfModuleStackId != null) { + vfModuleName = this.getVfModuleNameFromModuleStackId(vfModuleStackId); + } + } + + LOGGER.debug ("Updating VFModule: " + vfModuleName + " of type " + vfModuleType + "in " + cloudSiteId + "/" + tenantId); + LOGGER.debug("requestTypeString = " + requestTypeString + ", nestedStackId = " + nestedStackId + ", nestedBaseStackId = " + nestedBaseStackId); + + // Will capture execution time for metrics + long startTime = System.currentTimeMillis (); + + // Build a default rollback object (no actions performed) + VnfRollback vfRollback = new VnfRollback (); + vfRollback.setCloudSiteId (cloudSiteId); + vfRollback.setTenantId (tenantId); + vfRollback.setMsoRequest (msoRequest); + vfRollback.setRequestType(requestTypeString); + vfRollback.setVolumeGroupHeatStackId(volumeGroupHeatStackId); + vfRollback.setBaseGroupHeatStackId(baseVfHeatStackId); + vfRollback.setIsBase(isBaseRequest); + vfRollback.setVfModuleStackId(vfModuleStackId); + + // First, look up to see if the VNF already exists. + MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + MsoHeatUtilsWithUpdate heatU = new MsoHeatUtilsWithUpdate (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + + StackInfo heatStack = null; + long queryStackStarttime = System.currentTimeMillis (); + LOGGER.debug("UpdateVfModule - querying for " + vfModuleName); + try { + heatStack = heat.queryStack (cloudSiteId, tenantId, vfModuleName); + LOGGER.recordMetricEvent (queryStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "QueryStack", null); + } catch (MsoException me) { + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + me.addContext ("UpdateVFModule"); + String error = "Update VFModule: Query " + vfModuleName + " in " + cloudSiteId + "/" + tenantId + ": " + me; + LOGGER.recordMetricEvent (queryStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null); + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - QueryStack", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } + + //TODO - do we need to check for the other status possibilities? + if (heatStack == null || heatStack.getStatus () == HeatStatus.NOTFOUND) { + // Not Found + String error = "Update VF: Stack " + vfModuleName + " does not exist in " + cloudSiteId + "/" + tenantId; + LOGGER.error (MessageEnum.RA_VNF_NOT_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + throw new VnfNotFound (cloudSiteId, tenantId, vfModuleName); + } else { + LOGGER.debug ("Found Existing stack, status=" + heatStack.getStatus ()); + // Populate the outputs from the existing stack. + outputs.value = copyStringOutputs (heatStack.getOutputs ()); + rollback.value = vfRollback; // Default rollback - no updates performed + } + + // 1604 Cinder Volume support - handle a nestedStackId if sent (volumeGroupHeatStackId): + StackInfo nestedHeatStack = null; + long queryStackStarttime2 = System.currentTimeMillis (); + if (nestedStackId != null) { + try { + LOGGER.debug("Querying for nestedStackId = " + nestedStackId); + nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId); + LOGGER.recordMetricEvent (queryStackStarttime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "QueryStack", null); + } catch (MsoException me) { + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + me.addContext ("UpdateVFModule"); + String error = "Update VF: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; + LOGGER.recordMetricEvent (queryStackStarttime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null); + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me); + LOGGER.debug("ERROR trying to query nested stack= " + error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } + if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) { + MsoLogger.setServiceName (serviceName); + String error = "Update VFModule: Attached volume heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error); + LOGGER.debug(error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } else { + LOGGER.debug("Found nested heat stack - copying values to inputs"); + this.sendMapToDebug(inputs); + heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); + this.sendMapToDebug(inputs); + } + } + // handle a nestedBaseStackId if sent - this is the stack ID of the base. + StackInfo nestedBaseHeatStack = null; + if (nestedBaseStackId != null) { + long queryStackStarttime3 = System.currentTimeMillis (); + try { + LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId); + nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId); + LOGGER.recordMetricEvent (queryStackStarttime3, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "QueryStack", null); + } catch (MsoException me) { + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + me.addContext ("UpdateVfModule"); + String error = "Update VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; + LOGGER.recordMetricEvent (queryStackStarttime3, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null); + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me); + LOGGER.debug("ERROR trying to query nested base stack= " + error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } + if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) { + MsoLogger.setServiceName (serviceName); + String error = "Update VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + LOGGER.debug(error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } else { + LOGGER.debug("Found nested base heat stack - copying values to inputs"); + this.sendMapToDebug(inputs); + heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false); + this.sendMapToDebug(inputs); + } + } + + // Ready to deploy the new VNF + + try (CatalogDatabase db = new CatalogDatabase ()) { + // Retrieve the VF definition + //VnfResource vnf; + VfModule vf = null; + if (vfVersion != null && !vfVersion.isEmpty ()) { + vf = db.getVfModuleType(vfModuleType, vfVersion); + if (vf == null) { + LOGGER.debug("Unable to find " + vfModuleType + " and version = " + vfVersion + " in the TYPE column - will try in MODEL_NAME"); + vf = db.getVfModuleModelName(vfModuleType, vfVersion); + if (vf == null) { + LOGGER.debug("Unable to find " + vfModuleType + " and version = " + vfVersion + " in the MODEL_NAME field either - ERROR"); + } + } + } else { + vf = db.getVfModuleType(vfModuleType); + if (vf == null) { + LOGGER.debug("Unable to find " + vfModuleType + " in the TYPE column - will try in MODEL_NAME"); + vf = db.getVfModuleModelName(vfModuleType); + if (vf == null) { + LOGGER.debug("Unable to find " + vfModuleType + " in the MODEL_NAME field either - ERROR"); + } + } + } + if (vf == null) { + String error = "Update VFModule: Unknown VF Module Type: " + vfModuleType; + if (vfVersion != null && !vfVersion.isEmpty()) { + error += " with version = " + vfVersion; + } + LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VF Module Type", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } + LOGGER.debug ("Got VF module definition from Catalog: " + vf.toString ()); + + HeatTemplate heatTemplate = null; + Integer heatTemplateId = null; + Integer heatEnvtId = null; + if (!isVolumeRequest) { + heatTemplateId = vf.getTemplateId(); + heatEnvtId = vf.getEnvironmentId(); + } else { + heatTemplateId = vf.getVolTemplateId(); + heatEnvtId = vf.getVolEnvironmentId(); + } + if (heatTemplateId == null) { + String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + requestTypeString; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, + MsoAlarmLogger.CRITICAL, error); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); + } else { + heatTemplate = db.getHeatTemplate(heatTemplateId); + } + + if (heatTemplate == null) { + String error = "Update VNF: undefined Heat Template. VF=" + + vfModuleType + ", heat template id = " + heatTemplateId; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, + "Heat Template ID", + String.valueOf(heatTemplateId), "OpenStack", "", MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + // Alarm on this error, configuration must be fixed + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, + MsoAlarmLogger.CRITICAL, error); + + throw new VnfException(error, MsoExceptionCategory.INTERNAL); + } + + LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ()); + + // Add check for any Environment variable + HeatEnvironment heatEnvironment = null; + String heatEnvironmentString = null; + + if (heatEnvtId != null) { + LOGGER.debug ("about to call getHeatEnvironment with :" + heatEnvtId + ":"); + heatEnvironment = db.getHeatEnvironment (heatEnvtId); + if (heatEnvironment == null) { + + String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType + + ", Environment ID=" + + heatEnvtId; + LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", String.valueOf(heatEnvtId), "OpenStack", "", MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + // Alarm on this error, configuration must be fixed + alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + + throw new VnfException (error, MsoExceptionCategory.INTERNAL); + } else { + LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.toString ()); + heatEnvironmentString = heatEnvironment.getEnvironment (); //this.parseEnvironment (heatEnvironment.getEnvironment ()); + LOGGER.debug ("After parsing: " + heatEnvironmentString); + } + } else { + LOGGER.debug ("no environment parameter for this VFModuleType " + vfModuleType); + } + + + LOGGER.debug ("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId=" + + heatTemplate.getId ()); + Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getId ()); + Map <String, Object> nestedTemplatesChecked = new HashMap <String, Object> (); + if (nestedTemplates != null) { + // for debugging print them out + LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:"); + for (String providerResourceFile : nestedTemplates.keySet ()) { + String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile); + String childTemplateBody = (String) nestedTemplates.get (providerResourceFile); + nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody); + LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody); + } + } else { + LOGGER.debug ("No nested templates found - nothing to do here"); + nestedTemplatesChecked = null; + } + + // Also add the files: for any get_files associated with this VfModule + // *if* there are any + LOGGER.debug ("In MsoVnfAdapterImpl.updateVfModule, about to call db.getHeatFiles avec vfModuleId=" + + vf.getId ()); + + Map <String, HeatFiles> heatFiles = null; +// Map <String, HeatFiles> heatFiles = db.getHeatFiles (vnf.getId ()); + Map <String, Object> heatFilesObjects = new HashMap <String, Object> (); + + // Add ability to turn on adding get_files with volume requests (by property). + boolean addGetFilesOnVolumeReq = false; + try { + String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null); + if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) { + addGetFilesOnVolumeReq = true; + LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString); + } + } catch (Exception e) { + LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e); + } + if (!isVolumeRequest || addGetFilesOnVolumeReq) { + heatFiles = db.getHeatFilesForVfModule(vf.getId()); + if (heatFiles != null) { + // add these to stack - to be done in createStack + // here, we will map them to Map<String, Object> from Map<String, HeatFiles> + // this will match the nested templates format + LOGGER.debug ("Contents of heatFiles - to be added to files: on stack:"); + + for (String heatFileName : heatFiles.keySet ()) { + if (heatFileName.startsWith("_ERROR|")) { + // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found. + String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1); + String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId; + LOGGER.debug(error); + LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + // Alarm on this error, configuration must be fixed + alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + throw new VnfException (error, MsoExceptionCategory.INTERNAL); + } + String heatFileBody = heatFiles.get (heatFileName).getFileBody (); + LOGGER.debug (heatFileName + " -> " + heatFileBody); + heatFilesObjects.put (heatFileName, heatFileBody); + } + } else { + LOGGER.debug ("No heat files found -nothing to do here"); + heatFilesObjects = null; + } + } + + // Check that required parameters have been supplied + String missingParams = null; + List <String> paramList = new ArrayList <String> (); + + // New for 1510 - consult the PARAM_ALIAS field to see if we've been + // supplied an alias. Only check if we don't find it initially. + // Also new in 1510 - don't flag missing parameters if there's an environment - because they might be there. + // And also new - add parameter to turn off checking all together if we find we're blocking orders we + // shouldn't + boolean haveEnvironmentParameters = false; + boolean checkRequiredParameters = true; + try { + String propertyString = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER) + .getProperty (MsoVnfAdapterImpl.CHECK_REQD_PARAMS,null); + if ("false".equalsIgnoreCase (propertyString) || "n".equalsIgnoreCase (propertyString)) { + checkRequiredParameters = false; + LOGGER.debug ("CheckRequiredParameters is FALSE. Will still check but then skip blocking..." + + MsoVnfAdapterImpl.CHECK_REQD_PARAMS); + } + } catch (Exception e) { + // No problem - default is true + LOGGER.debug ("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e); + } + // 1604 - Add enhanced environment & parameter checking + // Part 1: parse envt entries to see if reqd parameter is there (before used a simple grep + // Part 2: only submit to openstack the parameters in the envt that are in the heat template + // Note this also removes any comments + MsoHeatEnvironmentEntry mhee = null; + if (heatEnvironmentString != null && heatEnvironmentString.toLowerCase ().contains ("parameters:")) { + LOGGER.debug("Enhanced environment checking enabled - 1604"); + haveEnvironmentParameters = true; + StringBuilder sb = new StringBuilder(heatEnvironmentString); + //LOGGER.debug("About to create MHEE with " + sb); + mhee = new MsoHeatEnvironmentEntry(sb); + StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n"); + for (HeatTemplateParam parm : heatTemplate.getParameters()) { + sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired()); + } + if (!mhee.isValid()) { + sb2.append("Environment says it's not valid! " + mhee.getErrorString()); + } else { + sb2.append("\nEnvironment:"); + sb2.append(mhee.toFullString()); + } + LOGGER.debug(sb2.toString()); + } else { + LOGGER.debug("NO ENVIRONMENT for this entry"); + } + + // New for 1607 - support params of json type + HashMap<String, JsonNode> jsonParams = new HashMap<String, JsonNode>(); + boolean hasJson = false; + + for (HeatTemplateParam parm : heatTemplate.getParameters ()) { + LOGGER.debug ("Parameter:'" + parm.getParamName () + + "', isRequired=" + + parm.isRequired () + + ", alias=" + + parm.getParamAlias ()); + // handle json + String parameterType = parm.getParamType(); + if (parameterType == null || parameterType.trim().equals("")) { + parameterType = "String"; + } + JsonNode jsonNode = null; + if (parameterType.equalsIgnoreCase("json") && inputs != null) { + if (inputs.containsKey(parm.getParamName()) ) { + hasJson = true; + String jsonString = null; + try { + jsonString = inputs.get(parm.getParamName()); + jsonNode = new ObjectMapper().readTree(jsonString); + } catch (JsonParseException jpe) { + //TODO - what to do here? + //for now - send the error to debug, but just leave it as a String + String errorMessage = jpe.getMessage(); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage); + hasJson = false; + jsonNode = null; + } catch (Exception e) { + // or here? + LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage()); + hasJson = false; + jsonNode = null; + } + if (jsonNode != null) { + jsonParams.put(parm.getParamName(), jsonNode); + } + } else if (inputs.containsKey(parm.getParamAlias())) { + hasJson = true; + String jsonString = null; + try { + jsonString = inputs.get(parm.getParamAlias()); + jsonNode = new ObjectMapper().readTree(jsonString); + } catch (JsonParseException jpe) { + //TODO - what to do here? + //for now - send the error to debug, but just leave it as a String + String errorMessage = jpe.getMessage(); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage); + hasJson = false; + jsonNode = null; + } catch (Exception e) { + // or here? + LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage()); + hasJson = false; + jsonNode = null; + } + if (jsonNode != null) { + // Notice here - we add it to the jsonParams hashMap with the actual name - + // then manipulate the inputs so when we check for aliases below - it will not + // get flagged. + jsonParams.put(parm.getParamName(), jsonNode); + inputs.remove(parm.getParamAlias()); + inputs.put(parm.getParamName(), jsonString); + } + } //TODO add a check for the parameter in the env file + } + + if (parm.isRequired () && (inputs == null || !inputs.containsKey (parm.getParamName ()))) { + if (inputs.containsKey (parm.getParamAlias ())) { + // They've submitted using an alias name. Remove that from inputs, and add back using real name. + String realParamName = parm.getParamName (); + String alias = parm.getParamAlias (); + String value = inputs.get (alias); + LOGGER.debug ("*Found an Alias: paramName=" + realParamName + + ",alias=" + + alias + + ",value=" + + value); + inputs.remove (alias); + inputs.put (realParamName, value); + LOGGER.debug (alias + " entry removed from inputs, added back using " + realParamName); + } + // enhanced - check if it's in the Environment (note: that method + else if (mhee != null && mhee.containsParameter(parm.getParamName())) { + + LOGGER.debug ("Required parameter " + parm.getParamName () + + " appears to be in environment - do not count as missing"); + } + else { + LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ()); + if (missingParams == null) { + missingParams = parm.getParamName (); + } else { + missingParams += "," + parm.getParamName (); + } + } + } + paramList.add (parm.getParamName ()); + } + if (missingParams != null) { + // Problem - missing one or more required parameters + if (checkRequiredParameters) { + String error = "Update VNF: Missing Required inputs: " + missingParams; + LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } else { + LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block"); + } + } else { + LOGGER.debug ("No missing parameters found - ok to proceed"); + } + + // Here - modify heatEnvironmentString + StringBuilder parsedEnvironmentString = null; + String newEnvironmentString = null; + if (mhee != null) { + LOGGER.debug("Environment before:\n" + heatEnvironmentString); + parsedEnvironmentString = mhee.toFullStringExcludeNonParams(heatTemplate.getParameters()); + LOGGER.debug("Environment after:\n" + parsedEnvironmentString.toString()); + newEnvironmentString = parsedEnvironmentString.toString(); + } + + // Remove any extraneous parameters (don't throw an error) + if (inputs != null) { + List <String> extraParams = new ArrayList <String> (); + extraParams.addAll (inputs.keySet ()); + // This is not a valid parameter for this template + extraParams.removeAll (paramList); + if (!extraParams.isEmpty ()) { + LOGGER.warn (MessageEnum.RA_VNF_EXTRA_PARAM, vnfType, extraParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, "Extra params"); + inputs.keySet ().removeAll (extraParams); + } + } + // 1607 - when we get here - we have clean inputs. Create inputsTwo in case we have json + Map<String, Object> inputsTwo = null; + if (hasJson && jsonParams.size() > 0) { + inputsTwo = new HashMap<String, Object>(); + for (String keyParamName : inputs.keySet()) { + if (jsonParams.containsKey(keyParamName)) { + inputsTwo.put(keyParamName, jsonParams.get(keyParamName)); + } else { + inputsTwo.put(keyParamName, inputs.get(keyParamName)); + } + } + } + + // "Fix" the template if it has CR/LF (getting this from Oracle) + String template = heatTemplate.getHeatTemplate (); + template = template.replaceAll ("\r\n", "\n"); + + // Have the tenant. Now deploy the stack itself + // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions + // because we already checked for those. + long updateStackStarttime = System.currentTimeMillis (); + try { + if (!hasJson) { + heatStack = heatU.updateStack (cloudSiteId, + tenantId, + vfModuleName, + template, + copyStringInputs (inputs), + true, + heatTemplate.getTimeoutMinutes (), + newEnvironmentString, + //heatEnvironmentString, + nestedTemplatesChecked, + heatFilesObjects); + LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null); + } else { + heatStack = heatU.updateStack (cloudSiteId, + tenantId, + vfModuleName, + template, + inputsTwo, + true, + heatTemplate.getTimeoutMinutes (), + newEnvironmentString, + //heatEnvironmentString, + nestedTemplatesChecked, + heatFilesObjects); + LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null); + + } + } catch (MsoException me) { + me.addContext ("UpdateVFModule"); + String error = "Update VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me; + LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null); + LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - " + error, me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } + } + + // Reach this point if updateStack is successful. + // Populate remaining rollback info and response parameters. + vfRollback.setVnfId (heatStack.getCanonicalName ()); + vfRollback.setVnfCreated (true); + + outputs.value = copyStringOutputs (heatStack.getOutputs ()); + rollback.value = vfRollback; + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully update VF Module"); + return; + } + + private String getVfModuleNameFromModuleStackId(String vfModuleStackId) { + // expected format of vfModuleStackId is "MSOTEST51-vSAMP3_base_module-0/1fc1f86c-7b35-447f-99a6-c23ec176ae24" + // before the "/" is the vfModuleName and after the "/" is the heat stack id in Openstack + if (vfModuleStackId == null) + return null; + int index = vfModuleStackId.lastIndexOf('/'); + if (index <= 0) + return null; + String vfModuleName = null; + try { + vfModuleName = vfModuleStackId.substring(0, index); + } catch (Exception e) { + vfModuleName = null; + } + return vfModuleName; + } + +} diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VfRollback.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VfRollback.java new file mode 100644 index 0000000000..90ab01bd8c --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VfRollback.java @@ -0,0 +1,137 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf; + + + +import org.openecomp.mso.entity.MsoRequest; + +public class VfRollback { + private String vnfId; + private String tenantId; + private String cloudSiteId; + private boolean tenantCreated = false; + private boolean vnfCreated = false; + private MsoRequest msoRequest; + private String volumeGroupName; + private String volumeGroupId; + private String requestType; + private String volumeGroupHeatStackId; + private String baseGroupHeatStackId; + private boolean isBase = false; + private String vfModuleStackId; + + + public String getVnfId() { + return vnfId; + } + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + public String getCloudSiteId() { + return cloudSiteId; + } + public void setCloudSiteId(String cloudId) { + this.cloudSiteId = cloudId; + } + public boolean getTenantCreated() { + return tenantCreated; + } + public void setTenantCreated(boolean tenantCreated) { + this.tenantCreated = tenantCreated; + } + public boolean getVnfCreated() { + return vnfCreated; + } + public void setVnfCreated(boolean vnfCreated) { + this.vnfCreated = vnfCreated; + } + public MsoRequest getMsoRequest() { + return msoRequest; + } + public void setMsoRequest (MsoRequest msoRequest) { + this.msoRequest = msoRequest; + } + public String getVolumeGroupName() { + return this.volumeGroupName; + } + public void setVolumeGroupName(String volumeGroupName) { + this.volumeGroupName = volumeGroupName; + } + public String getVolumeGroupId() { + return this.volumeGroupId; + } + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + public String getRequestType() { + return this.requestType; + } + public void setRequestType(String requestType) { + this.requestType = requestType; + } + /* + private String volumeGroupHeatStackId; + private String baseGroupHeatStackId; + private boolean isBase = false; + */ + public String getVolumeGroupHeatStackId() { + return this.volumeGroupHeatStackId; + } + public void setVolumeGroupHeatStackId(String volumeGroupHeatStackId) { + this.volumeGroupHeatStackId = volumeGroupHeatStackId; + } + + public String getBaseGroupHeatStackId() { + return this.baseGroupHeatStackId; + } + public void setBaseGroupHeatStackId(String baseGroupHeatStackId) { + this.baseGroupHeatStackId = baseGroupHeatStackId; + } + + public boolean isBase() { + return this.isBase; + } + public void setIsBase(boolean isBase) { + this.isBase = isBase; + } + public String getVfModuleStackId() { + return this.vfModuleStackId; + } + public void setVfModuleStackId(String vfModuleStackId) { + this.vfModuleStackId = vfModuleStackId; + } + + @Override + public String toString() { + return "VfRollback: cloud=" + cloudSiteId + ", tenant=" + tenantId + + ", vnf=" + vnfId + ", tenantCreated=" + tenantCreated + + ", vnfCreated=" + vnfCreated + ", requestType = " + requestType + + ", volumeGroupHeatStackId = " + this.volumeGroupHeatStackId; + } +} diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRest.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRest.java new file mode 100644 index 0000000000..6906f816a7 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRest.java @@ -0,0 +1,628 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf; + + +import java.util.Map; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.GenericEntity; +import javax.ws.rs.core.MediaType; +import javax.xml.ws.Holder; + +import org.apache.http.HttpStatus; + +import org.openecomp.mso.adapters.vnf.exceptions.VnfException; +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.beans.VnfStatus; +import org.openecomp.mso.openstack.beans.VnfRollback; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.openecomp.mso.properties.MsoPropertiesFactory; +import org.openecomp.mso.adapters.vnfrest.*; + +/** + * This class services calls to the REST interface for VF Modules (http://host:port/vnfs/rest/v1/vnfs) + * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. + * For testing, call with cloudSiteId = ___TESTING___ + * To test exceptions, also set tenantId = ___TESTING___ + */ +@Path("/v1/vnfs") +public class VnfAdapterRest { + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static final String TESTING_KEYWORD = "___TESTING___"; + private final CloudConfigFactory cloudConfigFactory = new CloudConfigFactory(); + private final MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + private final MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory, cloudConfigFactory); + //TODO Logging, SkipAAI, CREATED flags, Integrate with BPEL, Auth, + + @HEAD + @GET + @Path("/healthcheck") + @Produces(MediaType.TEXT_HTML) + public Response healthcheck () { + String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>"; + return Response.ok().entity(CHECK_HTML).build(); + } + + /* + * URL:http://localhost:8080/vnfs/rest/v1/vnfs/<aaivnfid>/vf-modules/<aaimodid> + * REQUEST: + * {"deleteVfModuleRequest": + {"cloudSiteId": "DAN", + "tenantId": "214b428a1f554c02935e66330f6a5409", + "vnfId": "somevnfid", + "vfModuleId": "somemodid", + "vfModuleStackId": "4e567676-e266-4594-a3a6-131c8a2baf73", + "messageId": "ra.1", + "notificationUrl": "http://localhost:8089/vnfmock", + "skipAAI": true, + "msoRequest": { + "requestId": "ra1", + "serviceInstanceId": "sa1" + }} + } + */ + @DELETE + @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response deleteVfModule ( + @PathParam("aaiVnfId") String aaiVnfId, + @PathParam("aaiVfModuleId") String aaiVfModuleId, + final DeleteVfModuleRequest req) + { + LOGGER.debug("Delete VfModule enter: " + req.toJsonString()); + if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) { + LOGGER.debug("Req rejected - aaiVnfId not provided or doesn't match URL"); + return Response + .status(HttpStatus.SC_BAD_REQUEST) + .type(MediaType.TEXT_PLAIN) + .entity("vnfid in URL does not match content") + .build(); + } + if (aaiVfModuleId == null || !aaiVfModuleId.equals(req.getVfModuleId())) { + LOGGER.debug("Req rejected - aaiVfModuleId not provided or doesn't match URL"); + return Response + .status(HttpStatus.SC_BAD_REQUEST) + .type(MediaType.TEXT_PLAIN) + .entity("vfModuleId in URL does not match content") + .build(); + } + DeleteVfModuleTask task = new DeleteVfModuleTask(req); + if (req.isSynchronous()) { + // This is a synchronous request + task.run(); + return Response + .status(task.getStatusCode()) + .entity(task.getGenericEntityResponse()) + .build(); + } else { + // This is an asynchronous request + try { + Thread t1 = new Thread(task); + t1.start(); + } catch (Exception e) { + // problem handling delete, send generic failure as sync resp to caller + LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "deleteVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in deleteVfModule", e); + return Response.serverError().build(); + } + // send sync response (ACK) to caller + LOGGER.debug ("deleteVNFVolumes exit"); + return Response.status(HttpStatus.SC_ACCEPTED).build(); + } + } + + public class DeleteVfModuleTask implements Runnable { + private final DeleteVfModuleRequest req; + private DeleteVfModuleResponse response = null; + private VfModuleExceptionResponse eresp = null; + private boolean sendxml; + + public DeleteVfModuleTask(DeleteVfModuleRequest req) { + this.req = req; + this.sendxml = true; // can be set with a field or header later + } + public int getStatusCode() { + return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; + } + public Object getGenericEntityResponse() { + return (response != null) + ? new GenericEntity<DeleteVfModuleResponse>(response) {} + : new GenericEntity<VfModuleExceptionResponse>(eresp) {}; + } + private String getResponse() { + if (response != null) { + return sendxml ? response.toXmlString() : response.toJsonString(); + } else { + return sendxml ? eresp.toXmlString() : eresp.toJsonString(); + } + } + + @Override + public void run() { + try { + String cloudsite = req.getCloudSiteId(); + if (cloudsite != null && !cloudsite.equals(TESTING_KEYWORD)) { + //vnfAdapter.deleteVnf (req.getCloudSiteId(), req.getTenantId(), req.getVfModuleStackId(), req.getMsoRequest()); + vnfAdapter.deleteVfModule (req.getCloudSiteId(), req.getTenantId(), req.getVfModuleStackId(), req.getMsoRequest()); + } + response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE, req.getMessageId()); + } catch (VnfException e) { + LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - Delete VNF Module", e); + eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId()); + } + if (!req.isSynchronous()) { + BpelRestClient bpelClient = new BpelRestClient(); + bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); + } + LOGGER.debug ("Delete vfModule exit: code=" + getStatusCode() + ", resp="+ getResponse()); + } + } + + /* + * URL:http://localhost:8080/vnfs/rest/v1/vnfs/<aaiVnfId>/vf-modules/<aaiVfModuleId>?cloudSiteId=DAN&tenantId=vfModule?&skipAAI=TRUE&msoRequest.requestId=ra1&msoRequest.serviceInstanceId=si1&vfModuleName=T2N2S1 + * RESP: + * {"queryVfModuleResponse": { + "vfModuleId": "AvfmodId", + "vfModuleOutputs": {"entry": { + "key": "server_private_ip_1", + "value": "10.100.1.25" + }}, + "vfModuleStackId": "RaaVnf1/abfa8a6d-feb1-40af-aea3-109403b1cf6b", + "vnfId": "AvnfID", + "vnfStatus": "ACTIVE" + }} + */ + @GET + @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response queryVfModule( + @PathParam("aaiVnfId") String aaiVnfId, + @PathParam("aaiVfModuleId") String aaiVfModuleId, + @QueryParam("cloudSiteId") String cloudSiteId, + @QueryParam("tenantId") String tenantId, + @QueryParam("vfModuleName") String vfModuleName, //RAA? Id in doc + @QueryParam("skipAAI") Boolean skipAAI, + @QueryParam("msoRequest.requestId") String requestId, + @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId) + { + //This request responds synchronously only + LOGGER.debug ("Query vfModule enter:" + vfModuleName); + MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId); + + try { + int respStatus = HttpStatus.SC_OK; + QueryVfModuleResponse qryResp = new QueryVfModuleResponse(aaiVnfId, aaiVfModuleId, null, null, null); + Holder<Boolean> vnfExists = new Holder<Boolean>(); + Holder<String> vfModuleId = new Holder<String>(); + Holder<VnfStatus> status = new Holder<VnfStatus>(); + Holder<Map<String, String>> outputs = new Holder <Map <String, String>> (); + vnfAdapter.queryVnf (cloudSiteId, tenantId, vfModuleName, msoRequest, vnfExists, vfModuleId, status, outputs); + if (!vnfExists.value) { + LOGGER.debug ("vfModule not found"); + respStatus = HttpStatus.SC_NOT_FOUND; + } else { + LOGGER.debug ("vfModule found" + vfModuleId.value + ", status=" + status.value); + qryResp.setVfModuleId(vfModuleId.value); + qryResp.setVnfStatus(status.value); + qryResp.setVfModuleOutputs(outputs.value); + } + LOGGER.debug ("Query vfModule exit"); + return Response + .status(respStatus) + .entity(new GenericEntity<QueryVfModuleResponse>(qryResp) {}) + .build(); + } catch (VnfException e) { + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, "", "queryVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - queryVfModule", e); + VfModuleExceptionResponse excResp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<VfModuleExceptionResponse>(excResp) {}) + .build(); + } + } + + /*URL: http://localhost:8080/vnfs/rest/v1/vnfs/<aaivnfid>/vf-modules + *REQUEST: + * {"createVfModuleRequest": + {"cloudSiteId": "DAN", + "tenantId": "214b428a1f554c02935e66330f6a5409", + "vnfId": "somevnfid", + "vfModuleId": "somemodid", + "vfModuleName": "RaaVnf1", + "vnfType": "ApacheVnf", + "vfModuleParams": {"entry": [ + {"key": "network_id", + "value": "59ed7b41-2983-413f-ba93-e7d437433916"}, + {"key": "subnet_id", + "value": "086c9298-5c57-49b7-bb2b-6fd5730c5d92"}, + {"key": "server_name_0", + "value": "RaaVnf1"} + ]}, + "failIfExists": true, + "messageId": "ra.1", + "notificationUrl": "http://localhost:8089/vnfmock", + "skipAAI": true, + "msoRequest": { + "requestId": "ra1", + "serviceInstanceId": "sa1" + }} + } + */ + @POST + @Path("{aaiVnfId}/vf-modules") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response createVfModule( + @PathParam("aaiVnfId") String aaiVnfId, + final CreateVfModuleRequest req) + { + LOGGER.debug("Create VfModule enter inside VnfAdapterRest: " + req.toJsonString()); + if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) { + LOGGER.debug("Req rejected - aaiVnfId not provided or doesn't match URL"); + return Response + .status(HttpStatus.SC_BAD_REQUEST) + .type(MediaType.TEXT_PLAIN) + .entity("vnfid in URL does not match content") + .build(); + } + CreateVfModuleTask task = new CreateVfModuleTask(req); + if (req.isSynchronous()) { + // This is a synchronous request + task.run(); + return Response + .status(task.getStatusCode()) + .entity(task.getGenericEntityResponse()) + .build(); + } else { + // This is an asynchronous request + try { + Thread t1 = new Thread(task); + t1.start(); + } catch (Exception e) { + // problem handling create, send generic failure as sync resp to caller + LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, "", "createVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - createVfModule", e); + return Response.serverError().build(); + } + // send sync response (ACK) to caller + LOGGER.debug ("createVfModule exit"); + return Response.status(HttpStatus.SC_ACCEPTED).build(); + } + } + + public class CreateVfModuleTask implements Runnable { + private final CreateVfModuleRequest req; + private CreateVfModuleResponse response = null; + private VfModuleExceptionResponse eresp = null; + private boolean sendxml; + + public CreateVfModuleTask(CreateVfModuleRequest req) { + this.req = req; + this.sendxml = true; // can be set with a field or header later + } + public int getStatusCode() { + return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; + } + public Object getGenericEntityResponse() { + return (response != null) + ? new GenericEntity<CreateVfModuleResponse>(response) {} + : new GenericEntity<VfModuleExceptionResponse>(eresp) {}; + } + private String getResponse() { + if (response != null) { + return sendxml ? response.toXmlString() : response.toJsonString(); + } else { + return sendxml ? eresp.toXmlString() : eresp.toJsonString(); + } + } + + @Override + public void run() { + LOGGER.debug ("CreateVfModuleTask start"); + try { + // Synchronous Web Service Outputs + Holder <String> vfModuleStackId = new Holder <String> (); + Holder <Map <String, String>> outputs = new Holder <Map <String, String>> (); + Holder <VnfRollback> vnfRollback = new Holder <VnfRollback> (); + String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); + LOGGER.debug("completeVnfVfModuleType=" + completeVnfVfModuleType); + String cloudsite = req.getCloudSiteId(); + if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) { + String tenant = req.getTenantId(); + if (tenant != null && tenant.equals(TESTING_KEYWORD)) { + throw new VnfException("testing."); + } + vnfRollback.value = new VnfRollback(req.getVnfId(), tenant, cloudsite, + true, false, new MsoRequest("reqid", "svcid"), + req.getVolumeGroupId(), req.getVolumeGroupId(), req.getRequestType()); + vfModuleStackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484"; + outputs.value = VolumeAdapterRest.testMap(); + } else { +// vnfAdapter.createVnf (createReq.getCloudSiteId(), +// createReq.getTenantId(), +// createReq.getVnfType(), +// createReq.getVnfVersion(), +// createReq.getVfModuleName(), +// createReq.getRequestType(), +// createReq.getVolumeGroupStackId(), +// createReq.getVfModuleParams(), +// createReq.getFailIfExists(), +// createReq.getBackout(), +// createReq.getMsoRequest(), +// vfModuleStackId, +// outputs, +// vnfRollback); + vnfAdapter.createVfModule(req.getCloudSiteId(), + req.getTenantId(), + //req.getVnfType(), + completeVnfVfModuleType, + req.getVnfVersion(), + req.getVfModuleName(), + req.getRequestType(), + req.getVolumeGroupStackId(), + req.getBaseVfModuleStackId(), + req.getVfModuleParams(), + req.getFailIfExists(), + req.getBackout(), + req.getMsoRequest(), + vfModuleStackId, + outputs, + vnfRollback); + } + VfModuleRollback modRollback = new VfModuleRollback(vnfRollback.value, req.getVfModuleId(), vfModuleStackId.value, req.getMessageId()); + response = new CreateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), + vfModuleStackId.value, Boolean.TRUE, outputs.value, modRollback, req.getMessageId()); + } catch (VnfException e) { + eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId()); + } + if (!req.isSynchronous()) { + BpelRestClient bpelClient = new BpelRestClient(); + bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); + } + LOGGER.debug ("CreateVfModuleTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); + } + } + + @PUT + @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response updateVfModule( + @PathParam("aaiVnfId") String aaiVnfId, + @PathParam("aaiVfModuleId") String aaiVfModuleId, + final UpdateVfModuleRequest req) + { + LOGGER.debug("Update VfModule enter: " + req.toJsonString()); + UpdateVfModulesTask task = new UpdateVfModulesTask(req); + if (req.isSynchronous()) { + // This is a synchronous request + task.run(); + return Response + .status(task.getStatusCode()) + .entity(task.getGenericEntityResponse()) + .build(); + } else { + // This is an asynchronous request + try { + Thread t1 = new Thread(task); + t1.start(); + } catch (Exception e) { + // problem handling create, send generic failure as sync resp to caller + LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, "", "updateVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - updateVfModule", e); + return Response.serverError().build(); + } + // send sync response (ACK) to caller + LOGGER.debug ("updateVfModules exit"); + return Response.status(HttpStatus.SC_ACCEPTED).build(); + } + } + + public class UpdateVfModulesTask implements Runnable { + private final UpdateVfModuleRequest req; + private UpdateVfModuleResponse response = null; + private VfModuleExceptionResponse eresp = null; + private boolean sendxml; + + public UpdateVfModulesTask(UpdateVfModuleRequest req) { + this.req = req; + this.sendxml = true; // can be set with a field or header later + } + public int getStatusCode() { + return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; + } + public Object getGenericEntityResponse() { + return (response != null) + ? new GenericEntity<UpdateVfModuleResponse>(response) {} + : new GenericEntity<VfModuleExceptionResponse>(eresp) {}; + } + private String getResponse() { + if (response != null) { + return sendxml ? response.toXmlString() : response.toJsonString(); + } else { + return sendxml ? eresp.toXmlString() : eresp.toJsonString(); + } + } + @Override + public void run() { + try { + //MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory, cloudConfigFactory); + + // Synchronous Web Service Outputs + Holder <String> vfModuleStackId = new Holder <String> (); + Holder <Map <String, String>> outputs = new Holder <Map <String, String>> (); + Holder <VnfRollback> vnfRollback = new Holder <VnfRollback> (); + String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); + LOGGER.debug("in updateVf - completeVnfVfModuleType=" + completeVnfVfModuleType); + + /* + vnfAdapter.updateVnf (updateReq.getCloudSiteId(), + updateReq.getTenantId(), + updateReq.getVnfType(), + updateReq.getVnfVersion(), + updateReq.getVfModuleName(), + updateReq.getRequestType(), + updateReq.getVolumeGroupStackId(), + updateReq.getVfModuleParams(), + updateReq.getMsoRequest(), + outputs, + vnfRollback); + */ + vnfAdapter.updateVfModule (req.getCloudSiteId(), + req.getTenantId(), + //req.getVnfType(), + completeVnfVfModuleType, + req.getVnfVersion(), + req.getVfModuleName(), + req.getRequestType(), + req.getVolumeGroupStackId(), + req.getBaseVfModuleId(), + req.getVfModuleStackId(), + req.getVfModuleParams(), + req.getMsoRequest(), + outputs, + vnfRollback); + + response = new UpdateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), + vfModuleStackId.value, outputs.value, req.getMessageId()); + } catch (VnfException e) { + eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId()); + } + if (!req.isSynchronous()) { + // This is asynch, so POST response back to caller + BpelRestClient bpelClient = new BpelRestClient (); + bpelClient.bpelPost (getResponse(), req.getNotificationUrl(), sendxml); + } + LOGGER.debug ("Update VfModule exit: code=" + getStatusCode() + ", resp="+ getResponse()); + } + } + /* + * URL:http://localhost:8080/vnfs/rest/v1/vnfs/<aaivnfid>/vf-modules/<aaimodid>/rollback + * REQUEST: + * {"deleteVfModuleRequest": + {"cloudSiteId": "DAN", + "tenantId": "214b428a1f554c02935e66330f6a5409", + "vnfId": "somevnfid", + "vfModuleId": "somemodid", + "vfModuleStackId": "4e567676-e266-4594-a3a6-131c8a2baf73", + "messageId": "ra.1", + "notificationUrl": "http://localhost:8089/vnfmock", + "skipAAI": true, + "msoRequest": { + "requestId": "ra1", + "serviceInstanceId": "sa1" + }} + } + */ + @DELETE + @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}/rollback") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response rollbackVfModule ( + @PathParam("aaiVnfId") String aaiVnfId, + @PathParam("aaiVfModuleId") String aaiVfModuleId, + //@QueryParam("rollback") String rollback, + final RollbackVfModuleRequest req) + { + LOGGER.debug("Rollback VfModule enter: " + req.toJsonString()); + RollbackVfModulesTask task = new RollbackVfModulesTask(req); + if (req.isSynchronous()) { + // This is a synchronous request + task.run(); + return Response + .status(task.getStatusCode()) + .entity(task.getGenericEntityResponse()) + .build(); + } else { + // This is an asynchronous request + try { + Thread t1 = new Thread(task); + t1.start(); + } catch (Exception e) { + // problem handling create, send generic failure as sync resp to caller + LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "rollbackVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVfModule", e); + return Response.serverError().build(); + } + // send sync response (ACK) to caller + LOGGER.debug ("rollbackVfModule exit"); + return Response.status(HttpStatus.SC_ACCEPTED).build(); + } + } + + public class RollbackVfModulesTask implements Runnable { + private final RollbackVfModuleRequest req; + private RollbackVfModuleResponse response = null; + private VfModuleExceptionResponse eresp = null; + private boolean sendxml; + + public RollbackVfModulesTask(RollbackVfModuleRequest req) { + this.req = req; + this.sendxml = true; // can be set with a field or header later + } + public int getStatusCode() { + return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; + } + public Object getGenericEntityResponse() { + return (response != null) + ? new GenericEntity<RollbackVfModuleResponse>(response) {} + : new GenericEntity<VfModuleExceptionResponse>(eresp) {}; + } + private String getResponse() { + if (response != null) { + return sendxml ? response.toXmlString() : response.toJsonString(); + } else { + return sendxml ? eresp.toXmlString() : eresp.toJsonString(); + } + } + @Override + public void run() { + try { + VfModuleRollback vmr = req.getVfModuleRollback(); + VnfRollback vrb = new VnfRollback( + vmr.getVfModuleStackId(), vmr.getTenantId(), vmr.getCloudSiteId(), true, true, + vmr.getMsoRequest(), null, null, null); + vnfAdapter.rollbackVnf (vrb); + response = new RollbackVfModuleResponse(Boolean.TRUE, req.getMessageId()); + } catch (VnfException e) { + LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVfModule", e); + eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, false, req.getMessageId()); + } + if (!req.isSynchronous()) { + // This is asynch, so POST response back to caller + BpelRestClient bpelClient = new BpelRestClient (); + bpelClient.bpelPost (getResponse(), req.getNotificationUrl(), sendxml); + } + LOGGER.debug ("RollbackVfModulesTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); + } + } +} diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRest.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRest.java new file mode 100644 index 0000000000..8fa1552bb0 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRest.java @@ -0,0 +1,576 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf; + + +import java.util.HashMap; +import java.util.Map; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.GenericEntity; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.xml.ws.Holder; + +import org.apache.http.HttpStatus; + +import org.openecomp.mso.adapters.vnf.exceptions.VnfException; +import org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupRequest; +import org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupResponse; +import org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupRequest; +import org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupResponse; +import org.openecomp.mso.adapters.vnfrest.QueryVolumeGroupResponse; +import org.openecomp.mso.adapters.vnfrest.RollbackVolumeGroupRequest; +import org.openecomp.mso.adapters.vnfrest.RollbackVolumeGroupResponse; +import org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupRequest; +import org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupResponse; +import org.openecomp.mso.adapters.vnfrest.VolumeGroupExceptionResponse; +import org.openecomp.mso.adapters.vnfrest.VolumeGroupRollback; +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.beans.VnfRollback; +import org.openecomp.mso.openstack.beans.VnfStatus; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +/** + * This class services calls to the REST interface for VNF Volumes (http://host:port/vnfs/rest/v1/volume-groups) + * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. + * For testing, call with cloudSiteId = ___TESTING___ + * To test exceptions, also set tenantId = ___TESTING___ + */ +@Path("/v1/volume-groups") +public class VolumeAdapterRest { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static final String TESTING_KEYWORD = "___TESTING___"; + private final CloudConfigFactory cloudConfigFactory = new CloudConfigFactory(); + private final MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + private final MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(msoPropertiesFactory, cloudConfigFactory); + + @POST + @Path("") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response createVNFVolumes(final CreateVolumeGroupRequest req) { + LOGGER.debug("createVNFVolumes enter: " + req.toJsonString()); + CreateVNFVolumesTask task = new CreateVNFVolumesTask(req); + if (req.isSynchronous()) { + // This is a synchronous request + task.run(); + return Response + .status(task.getStatusCode()) + .entity(task.getGenericEntityResponse()) + .build(); + } else { + // This is an asynchronous request + try { + Thread t1 = new Thread(task); + t1.start(); + } catch (Exception e) { + // problem handling create, send generic failure as sync resp to caller + LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, "", "createVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - createVNFVolumes", e); + return Response.serverError().build(); + } + // send sync response (ACK) to caller + LOGGER.debug ("createVNFVolumes exit"); + return Response.status(HttpStatus.SC_ACCEPTED).build(); + } + } + + public class CreateVNFVolumesTask implements Runnable { + private final CreateVolumeGroupRequest req; + private CreateVolumeGroupResponse response = null; + private VolumeGroupExceptionResponse eresp = null; + private boolean sendxml; + + public CreateVNFVolumesTask(CreateVolumeGroupRequest req) { + this.req = req; + this.sendxml = true; // can be set with a field or header later + } + public int getStatusCode() { + return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; + } + public Object getGenericEntityResponse() { + return (response != null) + ? new GenericEntity<CreateVolumeGroupResponse>(response) {} + : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {}; + } + private String getResponse() { + if (response != null) { + return sendxml ? response.toXmlString() : response.toJsonString(); + } else { + return sendxml ? eresp.toXmlString() : eresp.toJsonString(); + } + } + @Override + public void run() { + LOGGER.debug ("CreateVFModule VolumesTask start"); + try { + // Synchronous Web Service Outputs + Holder<String> stackId = new Holder<String>(); + Holder<Map<String, String>> outputs = new Holder<Map<String, String>>(); + Holder<VnfRollback> vnfRollback = new Holder<VnfRollback>(); + String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); + LOGGER.debug("in createVfModuleVolumes - completeVnfVfModuleType=" + completeVnfVfModuleType); + + String cloudsite = req.getCloudSiteId(); + if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) { + String tenant = req.getTenantId(); + if (tenant != null && tenant.equals(TESTING_KEYWORD)) { + throw new VnfException("testing."); + } + stackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484"; + outputs.value = testMap(); + } else { +// vnfAdapter.createVnf( +// req.getCloudSiteId(), +// req.getTenantId(), +// req.getVnfType(), +// req.getVnfVersion(), +// req.getVolumeGroupName(), +// "VOLUME", // request type is VOLUME +// null, // not sure about this +// req.getVolumeGroupParams(), +// req.getFailIfExists(), +// req.getSuppressBackout(), +// req.getMsoRequest(), +// stackId, +// outputs, +// vnfRollback); + vnfAdapter.createVfModule( + req.getCloudSiteId(), //cloudSiteId, + req.getTenantId(), //tenantId, + //req.getVnfType(), //vnfType, + completeVnfVfModuleType, + req.getVnfVersion(), //vnfVersion, + req.getVolumeGroupName(), //vnfName, + "VOLUME", //requestType, + null, //volumeGroupHeatStackId, + null, //baseVfHeatStackId, + req.getVolumeGroupParams(), //inputs, + req.getFailIfExists(), //failIfExists, + req.getSuppressBackout(), //backout, + req.getMsoRequest(), // msoRequest, + stackId, + outputs, + vnfRollback); + } + VolumeGroupRollback rb = new VolumeGroupRollback( + req.getVolumeGroupId(), + stackId.value, + true, // TODO boolean volumeGroupCreated, when would it be false? + req.getTenantId(), + req.getCloudSiteId(), + req.getMsoRequest(), + req.getMessageId()); + response = new CreateVolumeGroupResponse( + req.getVolumeGroupId(), + stackId.value, + true, // TODO boolean volumeGroupCreated, when would it be false? + outputs.value, + rb, + req.getMessageId()); + } catch (VnfException e) { + eresp = new VolumeGroupExceptionResponse( + e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); + } + if (!req.isSynchronous()) { + // This is asynch, so POST response back to caller + BpelRestClient bpelClient = new BpelRestClient(); + bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); + } + LOGGER.debug ("CreateVFModule VolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); + } + } + + @DELETE + @Path("{aaiVolumeGroupId}") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response deleteVNFVolumes( + @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId, + final DeleteVolumeGroupRequest req + ) + { + LOGGER.debug("deleteVNFVolumes enter: " + req.toJsonString()); + if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) { + return Response + .status(HttpStatus.SC_BAD_REQUEST) + .type(MediaType.TEXT_PLAIN) + .entity("VolumeGroupId in URL does not match content") + .build(); + } + DeleteVNFVolumesTask task = new DeleteVNFVolumesTask(req); + if (req.isSynchronous()) { + // This is a synchronous request + task.run(); + return Response + .status(task.getStatusCode()) + .entity(task.getGenericEntityResponse()) + .build(); + } else { + // This is an asynchronous request + try { + Thread t1 = new Thread(task); + t1.start(); + } catch (Exception e) { + // problem handling create, send generic failure as sync resp to caller + LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "deleteVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - deleteVNFVolumes", e); + return Response.serverError().build(); + } + // send sync response (ACK) to caller + LOGGER.debug ("deleteVNFVolumes exit"); + return Response.status(HttpStatus.SC_ACCEPTED).build(); + } + } + + public class DeleteVNFVolumesTask implements Runnable { + private final DeleteVolumeGroupRequest req; + private DeleteVolumeGroupResponse response = null; + private VolumeGroupExceptionResponse eresp = null; + private boolean sendxml; + + public DeleteVNFVolumesTask(DeleteVolumeGroupRequest req) { + this.req = req; + this.sendxml = true; // can be set with a field or header later + } + public int getStatusCode() { + return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; + } + public Object getGenericEntityResponse() { + return (response != null) + ? new GenericEntity<DeleteVolumeGroupResponse>(response) {} + : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {}; + } + private String getResponse() { + if (response != null) { + return sendxml ? response.toXmlString() : response.toJsonString(); + } else { + return sendxml ? eresp.toXmlString() : eresp.toJsonString(); + } + } + @Override + public void run() { + LOGGER.debug("DeleteVNFVolumesTask start"); + try { + if (!req.getCloudSiteId().equals(TESTING_KEYWORD)) { + vnfAdapter.deleteVnf(req.getCloudSiteId(), req.getTenantId(), req.getVolumeGroupStackId(), req.getMsoRequest()); + } + response = new DeleteVolumeGroupResponse(true, req.getMessageId()); + } catch (VnfException e) { + eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); + } + if (!req.isSynchronous()) { + // This is asynch, so POST response back to caller + BpelRestClient bpelClient = new BpelRestClient(); + bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); + } + LOGGER.debug("DeleteVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); + } + } + + @DELETE + @Path("{aaiVolumeGroupId}/rollback") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response rollbackVNFVolumes( + @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId, + final RollbackVolumeGroupRequest req + ) + { + LOGGER.debug("rollbackVNFVolumes enter: " + req.toJsonString()); + if (aaiVolumeGroupId == null || req.getVolumeGroupRollback() == null || !aaiVolumeGroupId.equals(req.getVolumeGroupRollback().getVolumeGroupId())) { + return Response + .status(HttpStatus.SC_BAD_REQUEST) + .type(MediaType.TEXT_PLAIN) + .entity("VolumeGroupId in URL does not match content") + .build(); + } + RollbackVNFVolumesTask task = new RollbackVNFVolumesTask(req); + if (req.isSynchronous()) { + // This is a synchronous request + task.run(); + return Response + .status(task.getStatusCode()) + .entity(task.getGenericEntityResponse()) + .build(); + } else { + // This is an asynchronous request + try { + Thread t1 = new Thread(task); + t1.start(); + } catch (Exception e) { + // problem handling create, send generic failure as sync resp to caller + LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "rollbackVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVNFVolumes", e); + return Response.serverError().build(); + } + // send sync response (ACK) to caller + LOGGER.debug("rollbackVNFVolumes exit"); + return Response.status(HttpStatus.SC_ACCEPTED).build(); + } + } + + public class RollbackVNFVolumesTask implements Runnable { + private final RollbackVolumeGroupRequest req; + private RollbackVolumeGroupResponse response = null; + private VolumeGroupExceptionResponse eresp = null; + private boolean sendxml; + + public RollbackVNFVolumesTask(RollbackVolumeGroupRequest req) { + this.req = req; + this.sendxml = true; // can be set with a field or header later + } + public int getStatusCode() { + return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; + } + public Object getGenericEntityResponse() { + return (response != null) + ? new GenericEntity<RollbackVolumeGroupResponse>(response) {} + : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {}; + } + private String getResponse() { + if (response != null) { + return sendxml ? response.toXmlString() : response.toJsonString(); + } else { + return sendxml ? eresp.toXmlString() : eresp.toJsonString(); + } + } + @Override + public void run() { + LOGGER.debug("DeleteVNFVolumesTask start"); + try { + VolumeGroupRollback vgr = req.getVolumeGroupRollback(); + VnfRollback vrb = new VnfRollback( + vgr.getVolumeGroupStackId(), vgr.getTenantId(), vgr.getCloudSiteId(), true, true, + vgr.getMsoRequest(), null, null, null); + vnfAdapter.rollbackVnf(vrb); + response = new RollbackVolumeGroupResponse(true, req.getMessageId()); + } catch (VnfException e) { + eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); + } + if (!req.isSynchronous()) { + // This is asynch, so POST response back to caller + BpelRestClient bpelClient = new BpelRestClient(); + bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); + } + LOGGER.debug("DeleteVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); + } + } + + @PUT + @Path("{aaiVolumeGroupId}") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response updateVNFVolumes( + @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId, + final UpdateVolumeGroupRequest req + ) + { + LOGGER.debug("updateVNFVolumes enter: " + req.toJsonString()); + if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) { + return Response + .status(HttpStatus.SC_BAD_REQUEST) + .type(MediaType.TEXT_PLAIN) + .entity("VolumeGroupId in URL does not match content") + .build(); + } + UpdateVNFVolumesTask task = new UpdateVNFVolumesTask(req); + if (req.isSynchronous()) { + // This is a synchronous request + task.run(); + return Response + .status(task.getStatusCode()) + .entity(task.getGenericEntityResponse()) + .build(); + } else { + // This is an asynchronous request + try { + Thread t1 = new Thread(task); + t1.start(); + } catch (Exception e) { + // problem handling create, send generic failure as sync resp to caller + LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, "", "updateVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - updateVNFVolumes", e); + return Response.serverError().build(); + } + // send sync response (ACK) to caller + LOGGER.debug ("updateVNFVolumes exit"); + return Response.status(HttpStatus.SC_ACCEPTED).build(); + } + } + + public class UpdateVNFVolumesTask implements Runnable { + private final UpdateVolumeGroupRequest req; + private UpdateVolumeGroupResponse response = null; + private VolumeGroupExceptionResponse eresp = null; + private boolean sendxml; + + public UpdateVNFVolumesTask(UpdateVolumeGroupRequest req) { + this.req = req; + this.sendxml = true; // can be set with a field or header later + } + public int getStatusCode() { + return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; + } + public Object getGenericEntityResponse() { + return (response != null) + ? new GenericEntity<UpdateVolumeGroupResponse>(response) {} + : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {}; + } + private String getResponse() { + if (response != null) { + return sendxml ? response.toXmlString() : response.toJsonString(); + } else { + return sendxml ? eresp.toXmlString() : eresp.toJsonString(); + } + } + @Override + public void run() { + LOGGER.debug("UpdateVNFVolumesTask start"); + try { + @SuppressWarnings("unused") + Holder<String> stackId = new Holder<String> (); + Holder<Map<String, String>> outputs = new Holder<Map <String, String>> (); + Holder<VnfRollback> vnfRollback = new Holder<VnfRollback> (); + String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); + LOGGER.debug("in updateVfModuleVolume - completeVnfVfModuleType=" + completeVnfVfModuleType); + + if (req.getCloudSiteId().equals(TESTING_KEYWORD)) { + outputs.value = testMap(); + } else { + //vnfAdapter.updateVnf( + // req.getCloudSiteId(), + // req.getTenantId(), + // req.getVnfType(), + // req.getVnfVersion(), + // req.getVfModuleType(), + // "VOLUME", // request type is VOLUME + // req.getVolumeGroupStackId(), + // req.getVolumeGroupParams(), + // req.getMsoRequest(), + // outputs, + // vnfRollback); + vnfAdapter.updateVfModule (req.getCloudSiteId(), + req.getTenantId(), + //req.getVnfType(), + completeVnfVfModuleType, + req.getVnfVersion(), + req.getVolumeGroupStackId(), + "VOLUME", + null, + null, + req.getVolumeGroupStackId(), + req.getVolumeGroupParams(), + req.getMsoRequest(), + outputs, + vnfRollback); + } + response = new UpdateVolumeGroupResponse( + req.getVolumeGroupId(), req.getVolumeGroupStackId(), + outputs.value, req.getMessageId()); + } catch (VnfException e) { + eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); + } + if (!req.isSynchronous()) { + // This is asynch, so POST response back to caller + BpelRestClient bpelClient = new BpelRestClient(); + bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); + } + LOGGER.debug("UpdateVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); + } + } + + @GET + @Path("{aaiVolumeGroupId}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response queryVNFVolumes( + @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId, + @QueryParam("cloudSiteId") String cloudSiteId, + @QueryParam("tenantId") String tenantId, + @QueryParam("volumeGroupStackId") String volumeGroupStackId, + @QueryParam("skipAAI") Boolean skipAAI, + @QueryParam("msoRequest.requestId") String requestId, + @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId + ) + { + //This request responds synchronously only + LOGGER.debug ("queryVNFVolumes enter:" + aaiVolumeGroupId + " " + volumeGroupStackId); + MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId); + + try { + int respStatus = HttpStatus.SC_OK; + QueryVolumeGroupResponse qryResp = new QueryVolumeGroupResponse(aaiVolumeGroupId, volumeGroupStackId, null, null); + Holder<Boolean> vnfExists = new Holder<Boolean>(); + Holder<String> vfModuleId = new Holder<String>(); + Holder<VnfStatus> status = new Holder<VnfStatus>(); + Holder<Map<String, String>> outputs = new Holder<Map<String, String>>(); + if (cloudSiteId != null && cloudSiteId.equals(TESTING_KEYWORD)) { + if (tenantId != null && tenantId.equals(TESTING_KEYWORD)) { + throw new VnfException("testing."); + } + vnfExists.value = true; + vfModuleId.value = TESTING_KEYWORD; + status.value = VnfStatus.ACTIVE; + outputs.value = testMap(); + } else { + vnfAdapter.queryVnf(cloudSiteId, tenantId, volumeGroupStackId, msoRequest, vnfExists, vfModuleId, status, outputs); + } + if (!vnfExists.value) { + LOGGER.debug ("VNFVolumes not found"); + qryResp.setVolumeGroupStatus(status.value); + respStatus = HttpStatus.SC_NOT_FOUND; + } else { + LOGGER.debug ("VNFVolumes found " + vfModuleId.value + ", status=" + status.value); + qryResp.setVolumeGroupStatus(status.value); + qryResp.setVolumeGroupOutputs(outputs.value); + } + LOGGER.debug("Query queryVNFVolumes exit"); + return Response + .status(respStatus) + .entity(new GenericEntity<QueryVolumeGroupResponse>(qryResp) {}) + .build(); + } catch (VnfException e) { + LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, aaiVolumeGroupId, "", "queryVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - queryVNFVolumes", e); + VolumeGroupExceptionResponse excResp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); + LOGGER.debug("Query queryVNFVolumes exit"); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<VolumeGroupExceptionResponse>(excResp) {}) + .build(); + } + } + public static Map<String, String> testMap() { + Map<String, String> m = new HashMap<String, String>(); + m.put("mickey", "7"); + m.put("clyde", "10"); + m.put("wayne", "99"); + return m; + } +} diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfAlreadyExists.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfAlreadyExists.java new file mode 100644 index 0000000000..7cec0cd99e --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfAlreadyExists.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf.exceptions; + + + +import javax.xml.ws.WebFault; + +/** + * This class reports an exception when trying to create a VNF when another + * VNF of the same name already exists in the target cloud/tenant. Note that + * the createVnf method suppresses this exception by default. + * + * + */ +@WebFault (name="VnfAlreadyExists", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://com.att.mso/vnf") +public class VnfAlreadyExists extends VnfException { + + private static final long serialVersionUID = 1L; + + public VnfAlreadyExists (String name, String cloudId, String tenantId, String vnfId) { + super("VNF " + name + " already exists in cloud/tenant " + cloudId + "/" + tenantId + " with ID " + vnfId); + } +} diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfException.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfException.java new file mode 100644 index 0000000000..ceef76b468 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfException.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf.exceptions; + + + +import javax.xml.ws.WebFault; + +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +/** + * This class simply extends Exception (without addition additional functionality) + * to provide an identifier for VNF related exceptions on create, delete, query. + * + * + */ +@WebFault (name="VnfException", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://com.att.mso/vnf") +public class VnfException extends Exception { + + private static final long serialVersionUID = 1L; + + private VnfExceptionBean faultInfo; + + public VnfException (String msg) { + super(msg); + faultInfo = new VnfExceptionBean (msg); + } + + public VnfException (Throwable e) { + super(e); + faultInfo = new VnfExceptionBean (e.getMessage()); + } + + public VnfException (String msg, Throwable e) { + super (msg, e); + faultInfo = new VnfExceptionBean (msg); + } + + public VnfException (String msg, MsoExceptionCategory category) { + super(msg); + faultInfo = new VnfExceptionBean (msg, category); + } + + public VnfException (String msg, MsoExceptionCategory category, Throwable e) { + super (msg, e); + faultInfo = new VnfExceptionBean (msg, category); + } + + public VnfException (MsoException e) { + super (e); + faultInfo = new VnfExceptionBean (e.getContextMessage(), e.getCategory()); + } + + public VnfExceptionBean getFaultInfo() { + return faultInfo; + } + + public void setFaultInfo(VnfExceptionBean faultInfo) { + this.faultInfo = faultInfo; + } +} diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfExceptionBean.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfExceptionBean.java new file mode 100644 index 0000000000..15918eabb8 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfExceptionBean.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf.exceptions; + + +import java.io.Serializable; + +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +/** + * Jax-WS Fault Bean for Vnf Exception + */ +public class VnfExceptionBean implements Serializable { + + private static final long serialVersionUID = -5699310749783790095L; + + private String message; + private MsoExceptionCategory category; + private Boolean rolledBack; + + public VnfExceptionBean () {} + + public VnfExceptionBean (String message) { + this.message = message; + } + + public VnfExceptionBean (String message, MsoExceptionCategory category) { + this.message = message; + this.category = category; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public MsoExceptionCategory getCategory () { + return category; + } + + public void setCategory (MsoExceptionCategory category) { + this.category = category; + } + + public Boolean isRolledBack() { + return rolledBack; + } + + public void setRolledBack(Boolean rolledBack) { + this.rolledBack = rolledBack; + } +} diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfNotFound.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfNotFound.java new file mode 100644 index 0000000000..3c27d03daa --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfNotFound.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf.exceptions; + + +import javax.xml.ws.WebFault; + +import org.openecomp.mso.adapters.vnf.exceptions.VnfException; + +/** + * This class reports an exception when trying to update a Network that does + * not exist in the target cloud/tenant. Note that deleteNetwork suppresses + * this exception (deletion of non-existent network is considered a success). + * + * + */ +@WebFault (name="VnfNotFound", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://com.att.mso/vnf") +public class VnfNotFound extends VnfException { + + private static final long serialVersionUID = 1L; + + public VnfNotFound (String cloudId, String tenantId, String vnfName) { + super("VNF " + vnfName + " not found in cloud/tenant " + cloudId + "/" + tenantId); + } +} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java new file mode 100644 index 0000000000..96e50d0959 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf.test; + + +import java.util.Map; + +import javax.xml.ws.Holder; + +import org.openecomp.mso.adapters.vnf.MsoVnfAdapter; +import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl; +import org.openecomp.mso.openstack.beans.VnfStatus; +import org.openecomp.mso.adapters.vnf.exceptions.VnfException; + +public class QueryTest { + public final static void main (String args[]) + { + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); + log ("Got a VnfAdapter"); + + String cloudId = "MT"; + String tenantId = "MSO_Test"; + String vnfName = "VNF_TEST1"; + Holder<Boolean> vnfExists = new Holder<Boolean>(); + Holder<String> vnfId = new Holder<String>(); + Holder<VnfStatus> status = new Holder<VnfStatus>(); + Holder<Map<String,String>> outputs = new Holder<Map<String,String>>(); + + try { + vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, + vnfExists, vnfId, status, outputs); + } catch (VnfException e) { + log ("Got an Exception: " + e); + } + + if (! vnfExists.value){ + log ("VNF Not Found"); + } else { + log ("Found VNF, ID = " + vnfId.value + ", status=" + status.value); + } + } + + private static void log (String msg) { + System.out.println (msg); + } +} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java new file mode 100644 index 0000000000..02691726d8 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf.test; + + +import java.util.HashMap; +import java.util.Map; + +import javax.xml.ws.Holder; + +import org.openecomp.mso.adapters.vnf.MsoVnfAdapter; +import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl; +import org.openecomp.mso.openstack.beans.VnfRollback; +import org.openecomp.mso.adapters.vnf.exceptions.VnfException; + +public class VnfCreateTest { + public final static void main (String args[]) + { + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); + log ("Got a VnfAdapter"); + + // Web Service Inputs + String cloudId = "MT"; + String tenantName = "John_Test"; + String vnfType = "ApacheDemo"; + String vnfName = "AdapterTest"; + Map<String,String> inputs = new HashMap<String,String>(); + inputs.put("vnf_id", "abc"); + inputs.put("extra", "whocares"); + inputs.put("private_subnet_gateway", "10.4.1.1"); + inputs.put("private_subnet_cidr", "10.4.1.0/29"); + + // Web Service Outputs + Holder<String> vnfId = new Holder<String>(); + Holder<Map<String,String>> outputs = new Holder<Map<String,String>>(); + Holder<VnfRollback> vnfRollback = new Holder<VnfRollback>(); + + try { + vnfAdapter.createVnf(cloudId, tenantName, vnfType,null, vnfName, null, null, inputs, false, true, null, + vnfId, outputs, vnfRollback); + } catch (VnfException e) { + log ("Got a Create Exception: " + e); + System.exit(1); + } + + log ("Created VNF, ID = " + vnfId.value); + for (String key : outputs.value.keySet()) { + log (" " + key + " = " + outputs.value.get(key)); + } + if (vnfRollback.value != null) + log (vnfRollback.value.toString()); + + try { + Thread.sleep(5000); + } catch (InterruptedException e) {} + + log ("Rolling Back VNF"); + try { + vnfAdapter.rollbackVnf(vnfRollback.value); + } catch (VnfException e) { + log ("Got a Rollback Exception: " + e); + } + log ("VNF Rolled Back"); + } + + private static void log (String msg) { + System.out.println (msg); + } +} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfDeleteTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfDeleteTest.java new file mode 100644 index 0000000000..0c35da7f64 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfDeleteTest.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf.test; + + + +import org.openecomp.mso.adapters.vnf.MsoVnfAdapter; +import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl; +import org.openecomp.mso.adapters.vnf.exceptions.VnfException; + +public class VnfDeleteTest { + public final static void main (String args[]) + { + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); + log ("Got a VnfAdapter"); + + // Web Service Inputs + String cloudId = "MT"; + String tenantName = "MSO_Test"; + String vnfName = "AdapterTest"; + + try { + vnfAdapter.deleteVnf(cloudId, tenantName, vnfName, null); + } catch (VnfException e) { + log ("Got an Exception: " + e); + } + + log ("Deleted VNF"); + } + + private static void log (String msg) { + System.out.println (msg); + } +} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java new file mode 100644 index 0000000000..923c222f60 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf.test; + + +import java.util.Map; + +import javax.xml.ws.Holder; + +import org.openecomp.mso.adapters.vnf.MsoVnfAdapter; +import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl; +import org.openecomp.mso.openstack.beans.VnfStatus; +import org.openecomp.mso.adapters.vnf.exceptions.VnfException; + +public class VnfQueryTest { + public final static void main (String args[]) + { + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); + log ("Got a VnfAdapter"); + + String cloudId = "MT"; + String tenantId = "MSO_Test"; + String vnfName = "VNF_TEST1"; + Holder<Boolean> vnfExists = new Holder<Boolean>(); + Holder<String> vnfId = new Holder<String>(); + Holder<VnfStatus> status = new Holder<VnfStatus>(); + Holder<Map<String,String>> outputs = new Holder<Map<String,String>>(); + + try { + vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, + vnfExists, vnfId, status, outputs); + } catch (VnfException e) { + log ("Got an Exception: " + e); + } + + if (! vnfExists.value){ + log ("VNF Not Found"); + } else { + log ("Found VNF, ID = " + vnfId.value + ", status=" + status.value); + } + } + + private static void log (String msg) { + System.out.println (msg); + } +} diff --git a/adapters/mso-vnf-adapter/src/test/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector b/adapters/mso-vnf-adapter/src/test/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector new file mode 100644 index 0000000000..1281d32948 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector @@ -0,0 +1 @@ +com.woorea.openstack.connector.HttpClientConnector
\ No newline at end of file diff --git a/adapters/mso-vnf-adapter/src/test/resources/logback-test.xml b/adapters/mso-vnf-adapter/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..238980e0c4 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/resources/logback-test.xml @@ -0,0 +1,48 @@ +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + 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. + ============LICENSE_END========================================================= + --> + +<configuration > + + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern> + </encoder> + </appender> + + + <logger name="com.att.eelf.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="trace" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <root level="info"> + <appender-ref ref="STDOUT" /> + </root> + + +</configuration> diff --git a/adapters/pom.xml b/adapters/pom.xml new file mode 100644 index 0000000000..d75fd57931 --- /dev/null +++ b/adapters/pom.xml @@ -0,0 +1,39 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp</groupId> + <artifactId>mso</artifactId> + <version>0.0.4-SNAPSHOT</version> + </parent> + + <groupId>org.openecomp.mso</groupId> + <artifactId>adapters</artifactId> + <name>MSO Adapters</name> + <description>Adapters for MSO</description> + <packaging>pom</packaging> + + <modules> + <module>mso-adapter-utils</module> + <module>mso-adapters-rest-interface</module> + <module>mso-network-adapter</module> + <module>mso-network-adapter-async-client</module> + <module>mso-sdnc-adapter</module> + <!--<module>mso-appc-adapter</module>--> + <module>mso-tenant-adapter</module> + <module>mso-vnf-adapter</module> + <module>mso-vnf-adapter-async-client</module> + <module>mso-requests-db-adapter</module> + </modules> + + <dependencies> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore</artifactId> + </dependency> + </dependencies> +</project> |