diff options
Diffstat (limited to 'adapters')
169 files changed, 11802 insertions, 2031 deletions
diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml index 959358761d..f80bfeb2cb 100644 --- a/adapters/mso-adapter-utils/pom.xml +++ b/adapters/mso-adapter-utils/pom.xml @@ -39,15 +39,6 @@ </execution> </executions> </plugin> - - <plugin> - <artifactId>maven-war-plugin</artifactId> - <version>2.3</version> - <configuration> - <warSourceDirectory>WebContent</warSourceDirectory> - <failOnMissingWebXml>false</failOnMissingWebXml> - </configuration> - </plugin> </plugins> </build> @@ -55,22 +46,22 @@ <dependency> <groupId>org.openecomp.mso.libs.openstack-java-sdk</groupId> <artifactId>keystone-client</artifactId> - <version>1.1.0</version> + <version>${openstack.version}</version> </dependency> <dependency> <groupId>org.openecomp.mso.libs.openstack-java-sdk</groupId> <artifactId>heat-client</artifactId> - <version>1.1.0</version> + <version>${openstack.version}</version> </dependency> <dependency> <groupId>org.openecomp.mso.libs.openstack-java-sdk</groupId> <artifactId>quantum-client</artifactId> - <version>1.1.0</version> + <version>${openstack.version}</version> </dependency> <dependency> <groupId>org.openecomp.mso.libs.openstack-java-sdk.client-connectors</groupId> <artifactId>http-connector</artifactId> - <version>1.1.0</version> + <version>${openstack.version}</version> </dependency> <dependency> <groupId>org.openecomp.mso</groupId> @@ -127,7 +118,7 @@ <version>2.2.0.Final</version> <scope>provided</scope> </dependency> - <dependency> + <dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> <version>1.15</version> diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigIdentityMapper.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigIdentityMapper.java new file mode 100644 index 0000000000..5ef33a3e04 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigIdentityMapper.java @@ -0,0 +1,29 @@ +/*-
+ * ============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;
+
+/**
+ * This interface provides the method signature for mapping registration.
+ * All mappings should be registered by the implementing class.
+ */
+public interface CloudConfigIdentityMapper {
+
+ public void registerAllMappings();
+}
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 index a777e4133c..db6ccde46c 100644 --- 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 @@ -1,32 +1,56 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * ============LICENSE_START========================================== + * =================================================================== + * 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 - * + * + * 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========================================================= + * ============LICENSE_END============================================ + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + * */ package org.openecomp.mso.cloud; +import java.io.IOException; +import java.net.URISyntaxException; import java.security.GeneralSecurityException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.JsonSerializer; +import org.codehaus.jackson.JsonGenerator; +import org.codehaus.jackson.map.SerializerProvider; +import org.codehaus.jackson.map.annotate.JsonDeserialize; +import org.codehaus.jackson.map.annotate.JsonSerialize; +import org.codehaus.jackson.JsonProcessingException; + +import org.openecomp.mso.openstack.exceptions.MsoAdapterException; import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.utils.MsoCommonUtils; +import org.openecomp.mso.openstack.utils.MsoKeystoneUtils; +import org.openecomp.mso.openstack.utils.MsoTenantUtils; +import org.openecomp.mso.openstack.utils.MsoTenantUtilsFactory; +import org.openecomp.mso.cloud.authentication.AuthenticationMethodFactory; +import org.openecomp.mso.cloud.authentication.AuthenticationWrapper; +import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication; +import org.openecomp.mso.cloud.authentication.wrappers.RackspaceAPIKeyWrapper; +import org.openecomp.mso.cloud.authentication.wrappers.UsernamePasswordWrapper; 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; @@ -43,11 +67,39 @@ import com.woorea.openstack.keystone.model.Authentication; */ public class CloudIdentity { + // This block is needed to trigger the class loader so that static initialization + // of both inner static classes occur. This is required when the Json Deserializer + // gets called and no access to any of these inner classes happened yet. + static { + IdentityServerType.bootstrap(); + IdentityAuthenticationType.bootstrap(); + } + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); - - public enum IdentityServerType {KEYSTONE}; - public enum IdentityAuthenticationType { USERNAME_PASSWORD, RACKSPACE_APIKEY }; + public final static class IdentityServerType extends IdentityServerTypeAbstract { + + public static final IdentityServerType KEYSTONE = new IdentityServerType("KEYSTONE", MsoKeystoneUtils.class); + + public IdentityServerType(String serverType, Class<? extends MsoTenantUtils> utilsClass) { + super(serverType, utilsClass); + } + + public static final void bootstrap() {} + } + + public static final class IdentityAuthenticationType extends IdentityAuthenticationTypeAbstract { + + public static final IdentityAuthenticationType USERNAME_PASSWORD = new IdentityAuthenticationType("USERNAME_PASSWORD", UsernamePasswordWrapper.class); + + public static final IdentityAuthenticationType RACKSPACE_APIKEY = new IdentityAuthenticationType("RACKSPACE_APIKEY", RackspaceAPIKeyWrapper.class); + + public IdentityAuthenticationType(String identityType, Class<? extends AuthenticationWrapper> wrapperClass) { + super(identityType, wrapperClass); + } + + public static final void bootstrap() {} + } @JsonProperty private String id; @@ -64,8 +116,12 @@ public class CloudIdentity { @JsonProperty("tenant_metadata") private Boolean tenantMetadata; @JsonProperty("identity_server_type") + @JsonSerialize(using=IdentityServerTypeJsonSerializer.class) + @JsonDeserialize(using=IdentityServerTypeJsonDeserializer.class) private IdentityServerType identityServerType; @JsonProperty("identity_authentication_type") + @JsonSerialize(using=IdentityAuthenticationTypeJsonSerializer.class) + @JsonDeserialize(using=IdentityAuthenticationTypeJsonDeserializer.class) private IdentityAuthenticationType identityAuthenticationType; private static String cloudKey = "aa3871669d893c7fb8abbcda31b88b4f"; @@ -92,26 +148,34 @@ public class CloudIdentity { public String getKeystoneUrl (String regionId, String msoPropID) throws MsoException { if (IdentityServerType.KEYSTONE.equals(this.identityServerType)) { return this.identityUrl; - } - else { - return null; + } else { + if (this.identityServerType == null) { + return null; + } + MsoTenantUtils tenantUtils = new MsoTenantUtilsFactory(msoPropID).getTenantUtilsByServerType(this.identityServerType.toString()); + if (tenantUtils != null) { + return tenantUtils.getKeystoneUrl(regionId, msoPropID, this); + } 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 ()); + if (this.getIdentityAuthenticationType() != null) { + try { + return AuthenticationMethodFactory.getAuthenticationFor(this); + } catch (IllegalAccessException | InstantiationException | ClassNotFoundException | IOException | URISyntaxException e) { + throw new MsoAdapterException("Could not retrieve authentication for " + this.identityAuthenticationType, e); + } + } else { // Fallback + return new UsernamePassword(this.getMsoId(), this.getMsoPass()); } - } public void setKeystoneUrl (String url) { if (IdentityServerType.KEYSTONE.equals(this.identityServerType)) { - this.identityUrl = url; + this.identityUrl = url; } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeAbstract.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeAbstract.java new file mode 100644 index 0000000000..d36f775be9 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeAbstract.java @@ -0,0 +1,75 @@ +/*-
+ * ============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.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.openecomp.mso.cloud.authentication.AuthenticationWrapper;
+
+public abstract class IdentityAuthenticationTypeAbstract {
+
+ // This map will prevent duplicates (as if it was an Enum).
+ // Without this, using an instance specific field for the class could allow
+ // different classes bound to the same entry name.
+ private static final Map<String, IdentityAuthenticationTypeAbstract> entries = new ConcurrentHashMap<>();
+
+ private String identityType;
+
+ private Class<? extends AuthenticationWrapper> wrapperClass;
+
+ protected IdentityAuthenticationTypeAbstract(String identityType, Class<? extends AuthenticationWrapper> wrapperClass) {
+ try {
+ this.identityType = identityType;
+ this.wrapperClass = wrapperClass;
+ entries.put(identityType, this);
+ AuthenticationWrapper.register(this.toString(), wrapperClass);
+ } catch (IllegalAccessException | InstantiationException e) {
+ // Do not add the class if an exception occurs as we won't get the class anyway
+ }
+ }
+
+ public static final IdentityAuthenticationTypeAbstract valueOf(String serverType) {
+ return entries.get(serverType);
+ }
+
+ @Override
+ public final String toString() {
+ return this.identityType;
+ }
+
+ public final String name() {
+ return this.identityType;
+ }
+
+ public static final IdentityAuthenticationTypeAbstract[] values() {
+ return (IdentityAuthenticationTypeAbstract[]) entries.values().stream().toArray(IdentityAuthenticationTypeAbstract[]::new);
+ }
+
+ public final Class<? extends AuthenticationWrapper> getWrapperClass() {
+ return this.wrapperClass;
+ }
+
+ @Override
+ public final boolean equals(Object other) {
+ return ((this.identityType != null) && (other != null) && (other instanceof IdentityAuthenticationTypeAbstract) && (this.identityType.equals(other.toString())));
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonDeserializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonDeserializer.java new file mode 100644 index 0000000000..fd6ead2223 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonDeserializer.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.cloud;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.JsonToken;
+import org.codehaus.jackson.map.DeserializationContext;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
+
+public class IdentityAuthenticationTypeJsonDeserializer extends JsonDeserializer<IdentityAuthenticationTypeAbstract> {
+
+ @Override
+ public IdentityAuthenticationTypeAbstract deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
+ throws IOException, JsonProcessingException {
+ JsonToken token = jsonParser.getCurrentToken();
+ if (JsonToken.VALUE_STRING.equals(token)) {
+ return IdentityAuthenticationTypeAbstract.valueOf(jsonParser.getText());
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java new file mode 100644 index 0000000000..b599066677 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java @@ -0,0 +1,38 @@ +/*-
+ * ============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 org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
+
+
+public class IdentityAuthenticationTypeJsonSerializer extends JsonSerializer<IdentityAuthenticationTypeAbstract> {
+
+ @Override
+ public void serialize(IdentityAuthenticationTypeAbstract tmpObj, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
+ throws IOException, JsonProcessingException {
+ jsonGenerator.writeObject(tmpObj.toString());
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeAbstract.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeAbstract.java new file mode 100644 index 0000000000..d2658bcd23 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeAbstract.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.cloud;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.openecomp.mso.openstack.utils.MsoTenantUtils;
+
+
+public abstract class IdentityServerTypeAbstract {
+
+ // This map will prevent duplicates (as if it was an Enum).
+ // Without this, using an instance specific field for the class could allow
+ // different classes bound to the same entry name.
+ private static final Map<String, IdentityServerTypeAbstract> entries = new ConcurrentHashMap<>();
+
+ private String serverType;
+
+ private Class<? extends MsoTenantUtils> utilsClass;
+
+ protected IdentityServerTypeAbstract(String serverType, Class<? extends MsoTenantUtils> utilsClass) {
+ if ((serverType == null) || (serverType.isEmpty())) {
+ throw new IllegalArgumentException("Server Type name cannot be null or empty, provided value was " + serverType);
+ }
+ if (entries.containsKey(serverType)) {
+ throw new IllegalArgumentException("Duplicate Server Type entry for registration: " + serverType);
+ }
+ this.serverType = serverType;
+ this.utilsClass = utilsClass;
+ entries.put(serverType, this);
+ }
+
+ public static final IdentityServerTypeAbstract valueOf(String serverType) {
+ return entries.get(serverType);
+ }
+
+ @Override
+ public final String toString() {
+ return this.serverType;
+ }
+
+ public final String name() {
+ return this.serverType;
+ }
+
+ public static final IdentityServerTypeAbstract[] values() {
+ return (IdentityServerTypeAbstract[]) entries.values().stream().toArray(IdentityServerTypeAbstract[]::new);
+ }
+
+ public final Class<? extends MsoTenantUtils> getMsoTenantUtilsClass() {
+ return this.utilsClass;
+ }
+
+ @Override
+ public final boolean equals(Object other) {
+ return ((this.serverType != null) && (other != null) && (other instanceof IdentityServerTypeAbstract) && (this.serverType.equals(other.toString())));
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonDeserializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonDeserializer.java new file mode 100644 index 0000000000..c07954d733 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonDeserializer.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.cloud;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.JsonToken;
+import org.codehaus.jackson.map.DeserializationContext;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
+
+
+public class IdentityServerTypeJsonDeserializer extends JsonDeserializer<IdentityServerTypeAbstract> {
+
+ @Override
+ public IdentityServerTypeAbstract deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
+ throws IOException, JsonProcessingException {
+ JsonToken token = jsonParser.getCurrentToken();
+ if (JsonToken.VALUE_STRING.equals(token)) {
+ return IdentityServerTypeAbstract.valueOf(jsonParser.getText());
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonSerializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonSerializer.java new file mode 100644 index 0000000000..6db8e5b7ac --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonSerializer.java @@ -0,0 +1,38 @@ +/*-
+ * ============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 org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
+
+
+public class IdentityServerTypeJsonSerializer extends JsonSerializer<IdentityServerTypeAbstract> {
+
+ @Override
+ public void serialize(IdentityServerTypeAbstract tmpObj, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
+ throws IOException, JsonProcessingException {
+ jsonGenerator.writeObject(tmpObj.toString());
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java new file mode 100644 index 0000000000..8236307f45 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java @@ -0,0 +1,79 @@ +/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * 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 and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ *
+ */
+
+package org.openecomp.mso.cloud.authentication;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.openecomp.mso.cloud.CloudIdentity;
+
+import com.woorea.openstack.keystone.model.Authentication;
+
+/**
+ * This factory manages all the wrappers associated to authentication types.
+ *
+ */
+public final class AuthenticationMethodFactory {
+
+ private static Map<String, AuthenticationWrapper> authWrappers = new ConcurrentHashMap<>();
+
+ /**
+ *
+ */
+ private AuthenticationMethodFactory() {}
+
+ /**
+ * Function to be called by classes implementing the abstract {@link AuthenticationWrapper#register(String, Class)}.
+ */
+ static final synchronized void register(String authenticationType, Class<? extends AuthenticationWrapper> wrapperClass) throws InstantiationException, IllegalAccessException {
+ if ((authenticationType == null) || ("".equals(authenticationType))) {
+ throw new IllegalArgumentException("Authentication Type to register cannot be null or an empty name string, provided value is " + authenticationType + ".");
+ }
+ if (wrapperClass == null) {
+ throw new IllegalArgumentException("Wrapper Class to register for Authentication cannot be null");
+ }
+
+ if (!authWrappers.containsKey(authenticationType)) {
+ authWrappers.put(authenticationType, wrapperClass.newInstance());
+ }
+ }
+
+ public static final synchronized Authentication getAuthenticationFor(CloudIdentity cloudIdentity) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException, URISyntaxException {
+ if (cloudIdentity == null) {
+ throw new IllegalArgumentException("Cloud identity cannot be null");
+ }
+ if ((cloudIdentity.getIdentityAuthenticationType() == null) || ("".equals(cloudIdentity.getIdentityAuthenticationType().toString()))) {
+ throw new IllegalArgumentException("Cloud identity authentication type cannot be null or empty, provided value is " + cloudIdentity.getIdentityAuthenticationType() + ".");
+ }
+ String authenticationType = cloudIdentity.getIdentityAuthenticationType().toString();
+
+ if (authWrappers.containsKey(authenticationType)) {
+ return authWrappers.get(authenticationType).getAuthentication(cloudIdentity);
+ } else {
+ throw new IllegalArgumentException("Provided authentication type (" + authenticationType + ") is not implemented by any wrapper.");
+ }
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationWrapper.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationWrapper.java new file mode 100644 index 0000000000..77f405a660 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationWrapper.java @@ -0,0 +1,58 @@ +/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * 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 and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ *
+ */
+
+package org.openecomp.mso.cloud.authentication;
+
+import org.openecomp.mso.cloud.CloudIdentity;
+
+import com.woorea.openstack.keystone.model.Authentication;
+
+/**
+ * This abstract class provides the necessary method for registering authentication
+ * types with wrapper classes, and also defines the contract for providing
+ * Openstack-compatible Authentication implementations for said authentication types.
+ *
+ */
+public abstract class AuthenticationWrapper {
+
+ /**
+ * Registers the implementing class to the list of Authentication Wrappers.
+ *
+ * @param authenticationType The authentication type that is provided by the implementing class
+ * @param wrapperClass The implementing class Class object
+ * @throws InstantiationException If the provided implementing class cannot be instantiated
+ * @throws IllegalAccessException If the provided implementing class cannot be instantiated
+ */
+ public static final void register(String authenticationType, Class<? extends AuthenticationWrapper> wrapperClass) throws InstantiationException, IllegalAccessException {
+ AuthenticationMethodFactory.register(authenticationType, wrapperClass);
+ }
+
+ /**
+ * Returns an OpenStack Authentication object for the provided CloudIdentity.
+ *
+ * @param cloudIdentity The input Cloud Identity instance
+ * @return the OpenStack Authentication associated with this cloud identity instance
+ */
+ protected abstract Authentication getAuthentication(CloudIdentity cloudIdentity);
+
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/models/RackspaceAuthentication.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/models/RackspaceAuthentication.java new file mode 100644 index 0000000000..2b8da9f641 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/models/RackspaceAuthentication.java @@ -0,0 +1,99 @@ +/* + * ============LICENSE_START========================================== + * =================================================================== + * 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 and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + * + */ + +package org.openecomp.mso.cloud.authentication.models; + +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; +import com.woorea.openstack.keystone.model.Authentication; + +@JsonRootName("auth") +public class RackspaceAuthentication extends Authentication { + + /** + * + */ + private static final long serialVersionUID = 5451283386875662918L; + + @JsonIgnore + private String tenantId; + + @JsonIgnore + private String tenantName; + + public static final class Token { + + private String username; + private String apiKey; + + /** + * @return the username + */ + public String getUsername() { + return username; + } + /** + * @param username the username to set + */ + public void setUsername(String username) { + this.username = username; + } + /** + * @return the apiKey + */ + public String getApiKey() { + return apiKey; + } + /** + * @param apiKey the apiKey to set + */ + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + } + + @JsonProperty("RAX-KSKEY:apiKeyCredentials") + private Token token = new Token(); + + public RackspaceAuthentication (String username, String apiKey) { + this.token.username = username; + this.token.apiKey = apiKey; + + } + + /** + * @return the token + */ + public Token getToken() { + return token; + } + + /** + * @param token the token to set + */ + public void setToken(Token token) { + this.token = token; + } + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapper.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapper.java new file mode 100644 index 0000000000..5cf5587481 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapper.java @@ -0,0 +1,55 @@ +/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * 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 and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ *
+ */
+
+package org.openecomp.mso.cloud.authentication.wrappers;
+
+import org.openecomp.mso.cloud.CloudIdentity;
+import org.openecomp.mso.cloud.authentication.AuthenticationWrapper;
+import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication;
+
+import com.woorea.openstack.keystone.model.Authentication;
+
+/**
+ * This class implements the authentication wrapper for Rackspace Authentication.
+ *
+ */
+public class RackspaceAPIKeyWrapper extends AuthenticationWrapper {
+
+ /**
+ *
+ */
+ public RackspaceAPIKeyWrapper() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.mso.cloud.authentication.AuthenticationWrapper#getAuthentication(org.openecomp.mso.cloud.CloudIdentity)
+ */
+ @Override
+ public Authentication getAuthentication(CloudIdentity cloudIdentity) {
+ if (cloudIdentity == null) {
+ throw new IllegalArgumentException("Provided cloud identity is null, cannot extract username and password");
+ }
+ return new RackspaceAuthentication (cloudIdentity.getMsoId (), cloudIdentity.getMsoPass ());
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapper.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapper.java new file mode 100644 index 0000000000..5fd3e521f0 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapper.java @@ -0,0 +1,55 @@ +/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * 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 and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ *
+ */
+
+package org.openecomp.mso.cloud.authentication.wrappers;
+
+import org.openecomp.mso.cloud.CloudIdentity;
+import org.openecomp.mso.cloud.authentication.AuthenticationWrapper;
+
+import com.woorea.openstack.keystone.model.Authentication;
+import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
+
+/**
+ * This class implements the authentication wrapper for Openstack provided for
+ * user name and password authentication.
+ *
+ */
+public class UsernamePasswordWrapper extends AuthenticationWrapper {
+
+ /**
+ *
+ */
+ public UsernamePasswordWrapper() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.mso.cloud.authentication.AuthenticationWrapper#getAuthentication(org.openecomp.mso.cloud.CloudIdentity)
+ */
+ @Override
+ public Authentication getAuthentication(CloudIdentity cloudIdentity) {
+ if (cloudIdentity == null) {
+ throw new IllegalArgumentException("Provided cloud identity is null, cannot extract username and password");
+ }
+ return new UsernamePassword (cloudIdentity.getMsoId (), cloudIdentity.getMsoPass ());
+ }
+}
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 index 11a74d4494..0125cce287 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -43,6 +43,7 @@ public class NetworkRollback { private String tenantId; private String cloudId; private String networkType; + private String modelCustomizationUuid; private boolean networkCreated = false; // Previous values for updates private String networkName = null; @@ -63,7 +64,7 @@ public class NetworkRollback { public void setNeutronNetworkId(String neutronNetworkId) { this.neutronNetworkId = neutronNetworkId; } - + public String getNetworkStackId() { return networkStackId; } @@ -91,6 +92,14 @@ public class NetworkRollback { this.networkType = networkType; } + public String getModelCustomizationUuid() { + return this.modelCustomizationUuid; + } + + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public boolean getNetworkCreated() { return networkCreated; } @@ -125,7 +134,7 @@ public class NetworkRollback { public void setMsoRequest (MsoRequest msoRequest) { this.msoRequest = msoRequest; } - + @Override public String toString() { return "NetworkRollback [networkId=" + networkId @@ -135,5 +144,5 @@ public class NetworkRollback { + ", networkCreated=" + networkCreated + ", networkName=" + networkName + ", physicalNetwork=" + physicalNetwork + "]"; } - + } 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 index b6e4a6e855..fc148746a0 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -42,13 +42,14 @@ public class VnfRollback { private String baseGroupHeatStackId; private boolean isBase = false; private String vfModuleStackId; + private String modelCustomizationUuid; //NOTE: this is the vfModule's modelCustomizationUuid public VnfRollback() {} - + public VnfRollback(String vnfId, String tenantId, String cloudSiteId, boolean tenantCreated, boolean vnfCreated, MsoRequest msoRequest, - String volumeGroupName, String volumeGroupId, String requestType) { + String volumeGroupName, String volumeGroupId, String requestType, String modelCustomizationUuid) { super(); this.vnfId = vnfId; this.tenantId = tenantId; @@ -59,6 +60,7 @@ public class VnfRollback { this.volumeGroupName = volumeGroupName; this.volumeGroupId = volumeGroupId; this.requestType = requestType; + this.modelCustomizationUuid = modelCustomizationUuid; } public String getVnfId() { @@ -122,14 +124,14 @@ public class VnfRollback { 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; } @@ -142,11 +144,17 @@ public class VnfRollback { public void setVfModuleStackId(String vfModuleStackId) { this.vfModuleStackId = vfModuleStackId; } - + public String getModelCustomizationUuid() { + return this.modelCustomizationUuid; + } + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } @Override public String toString() { return "VnfRollback: cloud=" + cloudSiteId + ", tenant=" + tenantId + ", vnf=" + vnfId + ", tenantCreated=" + tenantCreated + - ", vnfCreated=" + vnfCreated + ", requestType = " + requestType; + ", vnfCreated=" + vnfCreated + ", requestType = " + requestType + + ", modelCustomizationUuid=" + this.modelCustomizationUuid; } } 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 index 3d9c23cc32..05d9a70a2d 100644 --- 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 @@ -27,6 +27,7 @@ import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.cloud.CloudConfigIdentityMapper; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; @@ -73,6 +74,21 @@ public class CloudConfigInitializer implements ServletContextListener 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); } } + + // Second, obtain class name that will register all mappings + String msoMapperClassParam = event.getServletContext().getInitParameter("mso.cloud_config.mapper.class"); + if (msoMapperClassParam != null) { + Class<?> mapperClass = Class.forName(msoMapperClassParam); + if (CloudConfigIdentityMapper.class.isAssignableFrom(mapperClass)) { + ((CloudConfigIdentityMapper)mapperClass.newInstance()).registerAllMappings(); + initLogger.info(MessageEnum.RA_CONFIG_LOAD,msoMapperClassParam+"(Openstack authentication mapper class)","",""); + } else { + initLogger.info(MessageEnum.RA_CONFIG_LOAD,msoMapperClassParam+"(Openstack authentication mapper class not an implementation of CloudConfigIdentityMapper)","",""); + } + } else { + initLogger.info(MessageEnum.RA_CONFIG_LOAD,"Openstack authentication mapper class not specified in web.xml (ONLY core authentication mechanisms will be loaded)","",""); + } + } 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/MsoHeatEnvironmentParameter.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentParameter.java index 4cf9023b7c..7444e1c881 100644 --- 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 @@ -20,7 +20,7 @@ package org.openecomp.mso.openstack.utils; - +import java.util.Objects; public class MsoHeatEnvironmentParameter { @@ -66,20 +66,11 @@ public class MsoHeatEnvironmentParameter { } 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; + return hep.getName().equals(this.getName()); } public int hashCode() { - int result = 0; - try { - result = this.name.hashCode(); - } catch (Exception e) { - // in case it's null - return zero - } - return result; + return Objects.hashCode(this.name); } 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 index 8d66505c6a..1c91fe2430 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -58,6 +58,7 @@ 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.Stack.Output; import com.woorea.openstack.heat.model.Stacks; import com.woorea.openstack.keystone.Keystone; import com.woorea.openstack.keystone.model.Access; @@ -69,7 +70,7 @@ 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"; @@ -103,7 +104,7 @@ public class MsoHeatUtils extends MsoCommonUtils { private int deletePollIntervalDefault = 15; private int deletePollTimeoutDefault = 300; private String msoPropID; - + private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); /** @@ -127,7 +128,7 @@ public class MsoHeatUtils extends MsoCommonUtils { } cloudConfig = cloudConfigFactory.getCloudConfig (); LOGGER.debug("MsoHeatUtils:" + msoPropID); - + } @@ -201,7 +202,7 @@ public class MsoHeatUtils extends MsoCommonUtils { null, true); } - + // This method has environment, files, heatfiles public StackInfo createStack (String cloudSiteId, String tenantId, @@ -413,6 +414,11 @@ public class MsoHeatUtils extends MsoCommonUtils { try { heatStack = queryHeatStack (heatClient, canonicalName); LOGGER.debug (heatStack.getStackStatus () + " (" + canonicalName + ")"); + try { + LOGGER.debug("Current stack " + this.getOutputsAsStringBuilder(heatStack).toString()); + } catch (Exception e) { + LOGGER.debug("an error occurred trying to print out the current outputs of the stack"); + } if ("CREATE_IN_PROGRESS".equals (heatStack.getStackStatus ())) { // Stack creation is still running. @@ -443,7 +449,7 @@ public class MsoHeatUtils extends MsoCommonUtils { 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 { @@ -451,7 +457,7 @@ public class MsoHeatUtils extends MsoCommonUtils { 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? + // get another one, n'est-ce pas? boolean deleted = false; while (!deleted) { try { @@ -460,8 +466,8 @@ public class MsoHeatUtils extends MsoCommonUtils { 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, + LOGGER.error (MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, + heatStack.getStackStatus (), "", "", MsoLogger.ErrorCode.AvailabilityError, "Rollback: DELETE stack timeout"); break; } else { @@ -486,11 +492,11 @@ public class MsoHeatUtils extends MsoCommonUtils { 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) { @@ -529,8 +535,8 @@ public class MsoHeatUtils extends MsoCommonUtils { 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, + LOGGER.error (MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, + heatStack.getStackStatus (), "", "", MsoLogger.ErrorCode.AvailabilityError, "Rollback: DELETE stack timeout"); break; } else { @@ -561,13 +567,13 @@ public class MsoHeatUtils extends MsoCommonUtils { 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) { @@ -588,7 +594,7 @@ public class MsoHeatUtils extends MsoCommonUtils { // 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()); @@ -949,10 +955,10 @@ public class MsoHeatUtils extends MsoCommonUtils { 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) { @@ -978,16 +984,13 @@ public class MsoHeatUtils extends MsoCommonUtils { String heatUrl = null; try { heatUrl = KeystoneUtils.findEndpointURL (access.getServiceCatalog (), "orchestration", region, "public"); + LOGGER.debug("heatUrl=" + heatUrl + ", region=" + region); } 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 ()); @@ -1096,12 +1099,7 @@ public class MsoHeatUtils extends MsoCommonUtils { return true; } - Calendar now = Calendar.getInstance (); - if (now.after (expires)) { - return true; - } - - return false; + return System.currentTimeMillis() > expires.getTimeInMillis(); } } @@ -1124,7 +1122,7 @@ public class MsoHeatUtils extends MsoCommonUtils { 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)"); @@ -1213,7 +1211,7 @@ public class MsoHeatUtils extends MsoCommonUtils { } return sb; } - + private String convertNode(final JsonNode node) { try { final Object obj = JSON_MAPPER.treeToValue(node, Object.class); @@ -1226,4 +1224,53 @@ public class MsoHeatUtils extends MsoCommonUtils { } return "[Error converting json to string]"; } + + + private StringBuilder getOutputsAsStringBuilder(Stack heatStack) { + // This should only be used as a utility to print out the stack outputs + // to the log + StringBuilder sb = new StringBuilder(""); + if (heatStack == null) { + sb.append("(heatStack is null)"); + return sb; + } + List<Output> outputList = heatStack.getOutputs(); + if (outputList == null || outputList.isEmpty()) { + sb.append("(outputs is empty)"); + return sb; + } + Map<String, Object> outputs = new HashMap<String,Object>(); + for (Output outputItem : outputList) { + outputs.put(outputItem.getOutputKey(), outputItem.getOutputValue()); + } + int counter = 0; + sb.append("OUTPUTS:"); + for (String key : outputs.keySet()) { + sb.append("outputs[" + counter++ + "]: " + key + "="); + Object obj = outputs.get(key); + if (obj instanceof String) { + sb.append((String)obj); + } else if (obj instanceof JsonNode) { + sb.append(this.convertNode((JsonNode)obj)); + } else if (obj instanceof java.util.LinkedHashMap) { + try { + String str = JSON_MAPPER.writeValueAsString(obj); + sb.append(str); + } catch (Exception e) { + sb.append("(a LinkedHashMap value that would not convert nicely)"); + } + } else { + String str = ""; + try { + str = (String) obj; + } catch (Exception e) { + str = "(a value unable to be cast as a String)"; + } + sb.append(str); + } + sb.append("; "); + } + sb.append("[END]"); + return sb; + } } 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 index 82203d044c..e387ec4023 100644 --- 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 @@ -454,10 +454,6 @@ public class MsoKeystoneUtils extends MsoTenantUtils { 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. @@ -658,7 +654,11 @@ public class MsoKeystoneUtils extends MsoTenantUtils { } public boolean isExpired () { - return Calendar.getInstance ().after (expires); + if (expires == null) { + return true; + } + + return System.currentTimeMillis() > expires.getTimeInMillis(); } } @@ -681,4 +681,9 @@ public class MsoKeystoneUtils extends MsoTenantUtils { public static void adminCacheReset () { adminClientCache = new HashMap <String, KeystoneCacheEntry> (); } + + @Override + public String getKeystoneUrl(String regionId, String msoPropID, CloudIdentity cloudIdentity) throws MsoException { + return cloudIdentity.getIdentityUrl(); + } } 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 index 7e388a5ef8..5c21913a66 100644 --- 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 @@ -425,10 +425,6 @@ public class MsoNeutronUtils extends MsoCommonUtils 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()); @@ -585,12 +581,7 @@ public class MsoNeutronUtils extends MsoCommonUtils return true; } - Calendar now = Calendar.getInstance(); - if (now.after(expires)) { - return true; - } - - return false; + return System.currentTimeMillis() > expires.getTimeInMillis(); } } 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 index 41104707cb..5af535f2b5 100644 --- 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 @@ -28,6 +28,7 @@ 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.logger.MsoAlarmLogger; import org.openecomp.mso.logger.MsoLogger; import org.openecomp.mso.logger.MessageEnum; @@ -75,5 +76,8 @@ public abstract class MsoTenantUtils extends MsoCommonUtils { public abstract boolean deleteTenant (String tenantId, String cloudSiteId) throws MsoException; - + + public abstract String getKeystoneUrl (String regionId, String msoPropID, CloudIdentity cloudIdentity) + 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 index 6fd7a6364a..2a5b3ad994 100644 --- 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 @@ -20,6 +20,7 @@ package org.openecomp.mso.openstack.utils; +import java.lang.reflect.InvocationTargetException; import org.openecomp.mso.cloud.CloudConfig; import org.openecomp.mso.cloud.CloudConfigFactory; import org.openecomp.mso.cloud.CloudIdentity; @@ -36,7 +37,7 @@ public class MsoTenantUtilsFactory { protected CloudConfig cloudConfig; protected MsoJavaProperties msoProps = null; private String msoPropID; - + public MsoTenantUtilsFactory (String msoPropID) { this.msoPropID = msoPropID; } @@ -48,10 +49,20 @@ public class MsoTenantUtilsFactory { cloudConfig = cloudConfigFactory.getCloudConfig(); CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + return getTenantUtilsByServerType(cloudSite.getIdentityService().getIdentityServerType().toString()); + } + + public MsoTenantUtils getTenantUtilsByServerType(String serverType) { + MsoTenantUtils tenantU = null; - if (cloudSite.getIdentityService().getIdentityServerType() == CloudIdentity.IdentityServerType.KEYSTONE) - { + if (CloudIdentity.IdentityServerType.KEYSTONE.equals(serverType)) { tenantU = new MsoKeystoneUtils (msoPropID); + } else { + try { + tenantU = CloudIdentity.IdentityServerType.valueOf(serverType).getMsoTenantUtilsClass().getConstructor(String.class).newInstance(msoPropID); + } catch (InvocationTargetException | InstantiationException | NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException("Could not instantiate an MsoTenantUtils class for " + serverType, e); + } } return tenantU; } 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 index 8632d02164..6be668c056 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -39,14 +39,14 @@ import org.openecomp.mso.cloud.CloudSite; * */ 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 @@ -55,11 +55,11 @@ public class CloudConfigTest { 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. */ @@ -79,17 +79,19 @@ public class CloudConfigTest { CloudSite site1 = siteMap.get("MT"); CloudSite site2 = siteMap.get("DAN"); CloudSite site3 = siteMap.get("MTINJVCC101"); - + CloudSite site4 = siteMap.get("MTSNJA4LCP1"); + 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"); - + assertEquals (site4.getRegionId(), "mtsnjlcp1"); + assertEquals (site4.getIdentityServiceId(), "MTSNJA3DCP1"); } - - + + /** * This method implements a test for the getIdentityServices method. */ @@ -97,12 +99,12 @@ public class CloudConfigTest { 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"); @@ -110,7 +112,7 @@ public class CloudConfigTest { 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"); @@ -118,7 +120,7 @@ public class CloudConfigTest { 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"); @@ -126,7 +128,7 @@ public class CloudConfigTest { 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"); @@ -136,7 +138,7 @@ public class CloudConfigTest { assertEquals (identity4.hasTenantMetadata(), true); } - + /** * This method implements a test for the getCloudSite method. */ @@ -146,9 +148,6 @@ public class CloudConfigTest { assertNotNull(site1); assertEquals (site1.getRegionId(), "regionOne"); assertEquals (site1.getIdentityServiceId(), "MT_KEYSTONE"); - - - } /** @@ -165,7 +164,7 @@ public class CloudConfigTest { 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/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java index 6f8a6e93d8..3427e42304 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -47,45 +47,45 @@ 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); + msoHeatUtils = new MsoHeatUtils("NO_PROP",msoPropertiesFactory,cloudConfigFactory); } - + @Test - public final void testCreateStackBadCloudConfig () { + public final void testCreateStackBadCloudConfig () throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound { try { msoHeatUtils.createStack ("DOESNOTEXIST", "test", "stackName", "test", new HashMap<String,Object> (), Boolean.TRUE, 10); - } catch (MsoException e) { + } catch (MsoCloudSiteNotFound 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/cloud/authentication/AuthenticationMethodTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java new file mode 100644 index 0000000000..ccfede7297 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java @@ -0,0 +1,115 @@ +/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * 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 and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ *
+ */
+
+package org.openecomp.mso.cloud.authentication;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import org.junit.Test;
+import org.openecomp.mso.cloud.CloudIdentity;
+import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication;
+import org.openecomp.mso.openstack.exceptions.MsoException;
+
+import com.woorea.openstack.keystone.model.Authentication;
+import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
+
+/**
+ * A few JUnit tests to evaluate the new factory that manages authentication
+ * types and their associated wrapper classes. Here it is assumed that core types
+ * only are tested.
+ *
+ */
+public class AuthenticationMethodTest {
+
+ /**
+ *
+ */
+ public AuthenticationMethodTest() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Test
+ public void testCustomRackspaceAuth() {
+ CloudIdentity ci = new CloudIdentity();
+ ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY);
+ ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
+ ci.setMsoId("test");
+
+ try {
+ Authentication auth = AuthenticationMethodFactory.getAuthenticationFor(ci);
+ assertTrue(RackspaceAuthentication.class.equals(auth.getClass()));
+ } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | IOException
+ | URISyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCoreUsernamePasswordAuth() {
+ CloudIdentity ci = new CloudIdentity();
+ ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.USERNAME_PASSWORD);
+ ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
+ ci.setMsoId("someuser");
+
+ try {
+ Authentication auth = AuthenticationMethodFactory.getAuthenticationFor(ci);
+ assertTrue(UsernamePassword.class.equals(auth.getClass()));
+ } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | IOException
+ | URISyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCustomRackspaceAuthFromCloudIdentity() {
+ CloudIdentity ci = new CloudIdentity();
+ ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY);
+ ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
+ ci.setMsoId("test");
+
+ try {
+ Authentication auth = ci.getAuthentication();
+ assertTrue(RackspaceAuthentication.class.equals(auth.getClass()));
+ } catch (MsoException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCoreUsernamePasswordAuthFromCloudIdentity() {
+ CloudIdentity ci = new CloudIdentity();
+ ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.USERNAME_PASSWORD);
+ ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
+ ci.setMsoId("someuser");
+
+ try {
+ Authentication auth = ci.getAuthentication();
+ assertTrue(UsernamePassword.class.equals(auth.getClass()));
+ } catch (MsoException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/NewServerTypeUtils.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/NewServerTypeUtils.java new file mode 100644 index 0000000000..4b4f2b8c94 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/NewServerTypeUtils.java @@ -0,0 +1,56 @@ +/**
+ *
+ */
+package org.openecomp.mso.cloud.servertype;
+
+import java.util.Map;
+
+import org.openecomp.mso.cloud.CloudIdentity;
+import org.openecomp.mso.openstack.beans.MsoTenant;
+import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound;
+import org.openecomp.mso.openstack.exceptions.MsoException;
+import org.openecomp.mso.openstack.utils.MsoTenantUtils;
+
+
+public class NewServerTypeUtils extends MsoTenantUtils {
+
+ /**
+ * @param msoPropID
+ */
+ public NewServerTypeUtils(String msoPropID) {
+ super(msoPropID);
+ }
+
+ @Override
+ public String createTenant(String tenantName, String cloudSiteId, Map<String, String> metadata, boolean backout)
+ throws MsoException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public MsoTenant queryTenant(String tenantId, String cloudSiteId) throws MsoException, MsoCloudSiteNotFound {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public MsoTenant queryTenantByName(String tenantName, String cloudSiteId)
+ throws MsoException, MsoCloudSiteNotFound {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean deleteTenant(String tenantId, String cloudSiteId) throws MsoException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public String getKeystoneUrl(String regionId, String msoPropID, CloudIdentity cloudIdentity)
+ throws MsoException {
+ return msoPropID + ":" + regionId + ":NewServerTypeKeystoneURL/" + cloudIdentity.getIdentityUrl();
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/ServerTypeTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/ServerTypeTest.java new file mode 100644 index 0000000000..9ac25136cc --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/ServerTypeTest.java @@ -0,0 +1,63 @@ +/**
+ *
+ */
+package org.openecomp.mso.cloud.servertype;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.openecomp.mso.cloud.CloudIdentity;
+import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
+import org.openecomp.mso.cloud.IdentityServerTypeAbstract;
+import org.openecomp.mso.openstack.exceptions.MsoException;
+
+public class ServerTypeTest {
+
+ @Test
+ public void testKeystoneServerType() {
+ IdentityServerTypeAbstract keystoneServerType = IdentityServerType.valueOf("KEYSTONE");
+ assertNotNull(keystoneServerType);
+ }
+
+ @Test
+ public void testNewServerType() {
+ IdentityServerTypeAbstract customServerType = null;
+ try {
+ customServerType = new IdentityServerType("NewServerType", NewServerTypeUtils.class);
+
+ } catch (IllegalArgumentException e) {
+ fail("An exception should not be raised when we register a new server type for the first time");
+ } finally {
+ System.out.println(IdentityServerType.values().toString());
+ assertEquals(customServerType, IdentityServerType.valueOf("NewServerType"));
+ }
+
+ // Create it a second time
+ IdentityServerTypeAbstract customServerType2 = null;
+ try {
+ customServerType2 = new IdentityServerType("NewServerType", NewServerTypeUtils.class);
+ fail("An exception should be raised as server type does not exist");
+ } catch (IllegalArgumentException e) {
+ // Fail silently -- it simply indicates we already registered it
+ customServerType2 = IdentityServerType.valueOf("NewServerType");
+ } finally {
+ System.out.println(IdentityServerType.values().toString());
+ assertEquals(customServerType2, IdentityServerType.valueOf("NewServerType"));
+ }
+
+ // Check the KeystoneURL for this custom TenantUtils
+ CloudIdentity cloudIdentity = new CloudIdentity();
+ cloudIdentity.setIdentityUrl("LocalIdentity");
+ cloudIdentity.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY);
+ cloudIdentity.setIdentityServerType((CloudIdentity.IdentityServerType) CloudIdentity.IdentityServerType.valueOf("NewServerType"));
+ String regionId = "RegionA";
+ String msoPropID = "12345";
+ try {
+ assertEquals(cloudIdentity.getKeystoneUrl(regionId, msoPropID), msoPropID + ":" + regionId + ":NewServerTypeKeystoneURL/" + cloudIdentity.getIdentityUrl());
+ } catch (MsoException e) {
+ fail("No MSO Exception should have occured here");
+ }
+ }
+}
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 index e76ce410d4..27007a3ce1 100644 --- 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 @@ -1,6 +1,6 @@ /* * This file was automatically generated by EvoSuite - * Mon Nov 14 08:51:17 GMT 2016 + * Fri Feb 17 16:22:30 GMT 2017 */ package org.openecomp.mso.openstack.beans; @@ -8,396 +8,424 @@ 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 static org.evosuite.runtime.MockitoExtension.*; import org.evosuite.runtime.EvoRunner; import org.evosuite.runtime.EvoRunnerParameters; import org.evosuite.runtime.ViolatedAssumptionAnswer; import org.junit.runner.RunWith; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.VnfRollback; -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +@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()); - } + @Test(timeout = 4000) + public void test05() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVolumeGroupHeatStackId(""); + vnfRollback0.getVolumeGroupHeatStackId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getVnfId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVnfId()); + + vnfRollback0.setVnfId(""); + vnfRollback0.getVnfId(); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getTenantId()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + boolean boolean0 = vnfRollback0.getVnfCreated(); + assertFalse(vnfRollback0.isBase()); + assertFalse(boolean0); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVfModuleStackId("VnfRollback: cloud="); + vnfRollback0.getVfModuleStackId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVfModuleStackId(""); + vnfRollback0.getVfModuleStackId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback((String) null, (String) null, ", vnf=", false, true, (MsoRequest) null, "", ", vnf=", "", ""); + String string0 = vnfRollback0.getTenantId(); + assertTrue(vnfRollback0.getVnfCreated()); + assertEquals(", vnf=", vnfRollback0.getVolumeGroupId()); + assertNull(string0); + assertEquals("", vnfRollback0.getVolumeGroupName()); + assertEquals(", vnf=", vnfRollback0.getCloudSiteId()); + assertEquals("", vnfRollback0.getRequestType()); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + assertFalse(vnfRollback0.getTenantCreated()); + + vnfRollback0.setTenantCreated(true); + boolean boolean0 = vnfRollback0.getTenantCreated(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setRequestType("$W[I&I@KHseI MUVb"); + vnfRollback0.getRequestType(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback((String) null, (String) null, ", vnf=", false, true, (MsoRequest) null, "", ", vnf=", "", ""); + String string0 = vnfRollback0.getRequestType(); + assertTrue(vnfRollback0.getVnfCreated()); + assertEquals("", vnfRollback0.getVolumeGroupName()); + assertNotNull(string0); + assertEquals(", vnf=", vnfRollback0.getCloudSiteId()); + assertFalse(vnfRollback0.getTenantCreated()); + assertEquals("", string0); + assertEquals(", vnf=", vnfRollback0.getVolumeGroupId()); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(msoRequest0).toString(); + VnfRollback vnfRollback0 = new VnfRollback("b", "b", "b", true, false, msoRequest0, "b", "b", "*^0M|pdSi&sbx2u>4q#", (String) null); + vnfRollback0.getMsoRequest(); + assertEquals("b", vnfRollback0.getCloudSiteId()); + assertEquals("b", vnfRollback0.getTenantId()); + assertFalse(vnfRollback0.getVnfCreated()); + assertEquals("b", vnfRollback0.getVnfId()); + assertEquals("b", vnfRollback0.getVolumeGroupName()); + assertEquals("*^0M|pdSi&sbx2u>4q#", vnfRollback0.getRequestType()); + assertEquals("b", vnfRollback0.getVolumeGroupId()); + assertFalse(vnfRollback0.isBase()); + assertTrue(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getModelCustomizationUuid(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setModelCustomizationUuid("<W,?yK`bP1Yb75G%66"); + vnfRollback0.getModelCustomizationUuid(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setCloudSiteId("yqA[Rq2FB8g2"); + vnfRollback0.getCloudSiteId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); + VnfRollback vnfRollback0 = new VnfRollback("", ")\"J", "", true, true, msoRequest0, "%~~n", "%~~n", (String) null, "%~~n"); + String string0 = vnfRollback0.getCloudSiteId(); + assertEquals("", string0); + assertEquals(")\"J", vnfRollback0.getTenantId()); + assertFalse(vnfRollback0.isBase()); + assertEquals("%~~n", vnfRollback0.getModelCustomizationUuid()); + assertNotNull(string0); + assertTrue(vnfRollback0.getVnfCreated()); + assertEquals("%~~n", vnfRollback0.getVolumeGroupId()); + assertTrue(vnfRollback0.getTenantCreated()); + assertEquals("", vnfRollback0.getVnfId()); + assertEquals("%~~n", vnfRollback0.getVolumeGroupName()); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setBaseGroupHeatStackId("x|gP"); + vnfRollback0.getBaseGroupHeatStackId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setBaseGroupHeatStackId(""); + vnfRollback0.getBaseGroupHeatStackId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getVolumeGroupId(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setTenantId(""); + vnfRollback0.getTenantId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getRequestType(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getVolumeGroupHeatStackId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + String string0 = vnfRollback0.toString(); + assertEquals("VnfRollback: cloud=M+!!EJC*~uO, tenant=Q,@Ir,{J2Nuu, vnf=M+!!EJC*~uO, tenantCreated=true, vnfCreated=true, requestType = Q,@Ir,{J2Nuu, modelCustomizationUuid=", string0); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVolumeGroupName()); + assertFalse(vnfRollback0.isBase()); + assertEquals("", vnfRollback0.getVolumeGroupId()); + } + + @Test(timeout = 4000) + public void test27() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + String string0 = vnfRollback0.getTenantId(); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVolumeGroupName()); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getRequestType()); + assertEquals("Q,@Ir,{J2Nuu", string0); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getCloudSiteId()); + assertEquals("", vnfRollback0.getVolumeGroupId()); + assertTrue(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + assertTrue(vnfRollback0.getTenantCreated()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVnfId()); + } + + @Test(timeout = 4000) + public void test28() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVnfCreated(false); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test29() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + boolean boolean0 = vnfRollback0.isBase(); + assertFalse(boolean0); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test30() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getVfModuleStackId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test31() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + boolean boolean0 = vnfRollback0.getTenantCreated(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test32() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVolumeGroupName()); + + vnfRollback0.setVolumeGroupName(""); + vnfRollback0.getVolumeGroupName(); + assertEquals("", vnfRollback0.getVolumeGroupId()); + } + + @Test(timeout = 4000) + public void test33() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + String string0 = vnfRollback0.getVnfId(); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + assertTrue(vnfRollback0.getTenantCreated()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getCloudSiteId()); + assertFalse(vnfRollback0.isBase()); + assertEquals("", vnfRollback0.getVolumeGroupId()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVolumeGroupName()); + assertTrue(vnfRollback0.getVnfCreated()); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getTenantId()); + assertEquals("M+!!EJC*~uO", string0); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getRequestType()); + } + + @Test(timeout = 4000) + public void test34() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getCloudSiteId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test35() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + String string0 = vnfRollback0.getVolumeGroupName(); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getTenantId()); + assertTrue(vnfRollback0.getVnfCreated()); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getRequestType()); + assertEquals("M+!!EJC*~uO", string0); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getCloudSiteId()); + assertTrue(vnfRollback0.getTenantCreated()); + assertEquals("", vnfRollback0.getVolumeGroupId()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVnfId()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test36() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + vnfRollback0.setMsoRequest((MsoRequest) null); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVnfId()); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getRequestType()); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getTenantId()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getCloudSiteId()); + assertTrue(vnfRollback0.getVnfCreated()); + assertEquals("", vnfRollback0.getVolumeGroupId()); + assertTrue(vnfRollback0.getTenantCreated()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVolumeGroupName()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test37() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback((String) null, (String) null, ", vnf=", false, true, (MsoRequest) null, "", ", vnf=", "", ""); + String string0 = vnfRollback0.getModelCustomizationUuid(); + assertEquals("", vnfRollback0.getVolumeGroupName()); + assertEquals("", vnfRollback0.getRequestType()); + assertFalse(vnfRollback0.getTenantCreated()); + assertEquals(", vnf=", vnfRollback0.getCloudSiteId()); + assertNotNull(string0); + assertEquals(", vnf=", vnfRollback0.getVolumeGroupId()); + assertFalse(vnfRollback0.isBase()); + assertEquals("", string0); + assertTrue(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test38() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getBaseGroupHeatStackId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test39() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + vnfRollback0.getMsoRequest(); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVnfId()); + assertFalse(vnfRollback0.isBase()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVolumeGroupName()); + assertEquals("", vnfRollback0.getVolumeGroupId()); + assertTrue(vnfRollback0.getTenantCreated()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getCloudSiteId()); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getTenantId()); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + assertTrue(vnfRollback0.getVnfCreated()); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getRequestType()); + } + + @Test(timeout = 4000) + public void test40() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback((String) null, (String) null, ", vnf=", false, true, (MsoRequest) null, "", ", vnf=", "", ""); + boolean boolean0 = vnfRollback0.getVnfCreated(); + assertEquals("", vnfRollback0.getVolumeGroupName()); + assertEquals(", vnf=", vnfRollback0.getCloudSiteId()); + assertEquals(", vnf=", vnfRollback0.getVolumeGroupId()); + assertEquals("", vnfRollback0.getRequestType()); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + assertTrue(boolean0); + } } diff --git a/adapters/mso-adapter-utils/src/test/resources/cloud_config.json b/adapters/mso-adapter-utils/src/test/resources/cloud_config.json index 0230a7d4bf..ee3532fe15 100644 --- a/adapters/mso-adapter-utils/src/test/resources/cloud_config.json +++ b/adapters/mso-adapter-utils/src/test/resources/cloud_config.json @@ -45,7 +45,7 @@ "identity_server_type": "KEYSTONE", "identity_authentication_type": "USERNAME_PASSWORD" } - + }, "cloud_sites": { @@ -69,12 +69,19 @@ "clli": "MTINJVCC101", "aic_version": "2.5", "identity_service_id": "MTINJVCC101_DCP" + }, + "MTSNJA4LCP1": + { + "region_id": "mtsnjlcp1", + "clli": "MTSNJA4LCP1", + "aic_version": "2.5", + "identity_service_id": "MTSNJA3DCP1" } - + } } } - - + + diff --git a/adapters/mso-adapters-rest-interface/pom.xml b/adapters/mso-adapters-rest-interface/pom.xml index 0080d1b6a1..8619f4bfa6 100644 --- a/adapters/mso-adapters-rest-interface/pom.xml +++ b/adapters/mso-adapters-rest-interface/pom.xml @@ -11,7 +11,7 @@ <packaging>jar</packaging> <name>mso-adapters-rest-interface</name> <description> - Java Beans (Requests and Responses) for Network/Tenant/VNF REST Operations + Java Beans (Requests and Responses) for Network/Tenant/VNF/SDNC REST Operations </description> <build> <finalName>${project.artifactId}-${project.version}</finalName> diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/catalogrest/QueryAllottedResourceCustomization.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/catalogrest/QueryAllottedResourceCustomization.java new file mode 100644 index 0000000000..fc4cec9201 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/catalogrest/QueryAllottedResourceCustomization.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.catalogrest; + +import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; +import org.openecomp.mso.logger.MsoLogger; +import org.codehaus.jackson.map.ObjectMapper; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name = "serviceAllottedResources") +@NoJackson +public class QueryAllottedResourceCustomization { + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private List<AllottedResourceCustomization> allottedResourceCustomization; + + public QueryAllottedResourceCustomization() { super(); allottedResourceCustomization = new ArrayList<AllottedResourceCustomization>(); } + public QueryAllottedResourceCustomization(List<AllottedResourceCustomization> vlist) { allottedResourceCustomization = vlist; } + + public List<AllottedResourceCustomization> getServiceAllottedResources(){ return this.allottedResourceCustomization; } + public void setServiceAllottedResources(List<AllottedResourceCustomization> v) { this.allottedResourceCustomization = v; } + + @Override + public String toString () { + StringBuffer buf = new StringBuffer(); + + boolean first = true; + int i = 1; + for (AllottedResourceCustomization o : allottedResourceCustomization) { + buf.append(i+"\t"); + if (!first) buf.append("\n"); first = false; + buf.append(o); + } + return buf.toString(); + } + + public String toJsonString() { + String jsonString = null; + try { + ObjectMapper mapper = new ObjectMapper(); + jsonString = mapper.writeValueAsString(this); + LOGGER.debug ("AllottedResourceCustomization jsonString: "+jsonString); + } + catch (Exception e) { + LOGGER.debug ("AllottedResourceCustomization jsonString exception:"+e.getMessage()); + } + return jsonString; + } +}
\ No newline at end of file diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/catalogrest/QueryServiceMacroHolder.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/catalogrest/QueryServiceMacroHolder.java new file mode 100644 index 0000000000..2cb756b856 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/catalogrest/QueryServiceMacroHolder.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.catalogrest; + +import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder; +import org.openecomp.mso.logger.MsoLogger; +import org.codehaus.jackson.map.ObjectMapper; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "serviceResources") +@NoJackson +public class QueryServiceMacroHolder { + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private ServiceMacroHolder serviceMacroHolder; + + public QueryServiceMacroHolder() { super(); serviceMacroHolder = new ServiceMacroHolder(); } + public QueryServiceMacroHolder(ServiceMacroHolder vlist) { serviceMacroHolder = vlist; } + + public ServiceMacroHolder getServiceResources(){ return this.serviceMacroHolder; } + public void setServiceResources(ServiceMacroHolder v) { this.serviceMacroHolder = v; } + + @Override + public String toString () { return serviceMacroHolder.toString(); } + + public String toJsonString() { + String jsonString = null; + try { + ObjectMapper mapper = new ObjectMapper(); + jsonString = mapper.writeValueAsString(this); + LOGGER.debug ("QueryServiceMacroHolder jsonString: "+jsonString); + } + catch (Exception e) { + LOGGER.debug ("QueryServiceMacroHolder jsonString exception:"+e.getMessage()); + } + return jsonString; + } +}
\ No newline at end of file diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/catalogrest/QueryServiceNetworks.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/catalogrest/QueryServiceNetworks.java new file mode 100644 index 0000000000..dfc3683fad --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/catalogrest/QueryServiceNetworks.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.catalogrest; + +import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; +import org.openecomp.mso.logger.MsoLogger; +import org.codehaus.jackson.map.ObjectMapper; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name = "serviceNetworks") +@NoJackson +public class QueryServiceNetworks { + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private List<NetworkResourceCustomization> serviceNetworks; + + public QueryServiceNetworks() { super(); serviceNetworks = new ArrayList<NetworkResourceCustomization>(); } + public QueryServiceNetworks(List<NetworkResourceCustomization> vlist) { + LOGGER.debug ("QueryServiceNetworks:"); + serviceNetworks = new ArrayList<NetworkResourceCustomization>(); + for (NetworkResourceCustomization o : vlist) { + LOGGER.debug ("-- o is a serviceNetworks ----"); + LOGGER.debug (o.toString()); + serviceNetworks.add(o); + LOGGER.debug ("-------------------"); + } + } + + public List<NetworkResourceCustomization> getServiceNetworks(){ return this.serviceNetworks; } + public void setServiceNetworks(List<NetworkResourceCustomization> v) { this.serviceNetworks = v; } + + @Override + public String toString () { + StringBuffer buf = new StringBuffer(); + + boolean first = true; + int i = 1; + for (NetworkResourceCustomization o : serviceNetworks) { + buf.append(i+"\t"); + if (!first) buf.append("\n"); first = false; + buf.append(o); + } + return buf.toString(); + } + + public String toJsonString() { + String jsonString = null; + try { + ObjectMapper mapper = new ObjectMapper(); + jsonString = mapper.writeValueAsString(this); + LOGGER.debug ("QueryServiceNetworks jsonString: "+jsonString); + } + catch (Exception e) { + LOGGER.debug ("QueryServiceNetworks jsonString exception:"+e.getMessage()); + } + return jsonString; + } +}
\ No newline at end of file diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/catalogrest/QueryServiceVnfs.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/catalogrest/QueryServiceVnfs.java new file mode 100644 index 0000000000..0ea054309b --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/catalogrest/QueryServiceVnfs.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.adapters.catalogrest; +/* should be called QueryVnfResource.java */ + +import org.openecomp.mso.db.catalog.beans.VnfResource; +import org.openecomp.mso.logger.MsoLogger; +import org.codehaus.jackson.map.ObjectMapper; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name = "serviceVnfs") +@NoJackson +public class QueryServiceVnfs { + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private List<VnfResource> serviceVnfs; + + public QueryServiceVnfs() { super(); serviceVnfs = new ArrayList<VnfResource>(); } + public QueryServiceVnfs(List<VnfResource> vlist) { + LOGGER.debug ("QueryServiceVnfs:"); + serviceVnfs = new ArrayList<VnfResource>(); + for (VnfResource o : vlist) { + LOGGER.debug ("-- o is a serviceVnfs ----"); + LOGGER.debug (o.toString()); + serviceVnfs.add(o); + LOGGER.debug ("-------------------"); + } + } + + public List<VnfResource> getServiceVnfs(){ return this.serviceVnfs; } + public void setServiceVnfs(List<VnfResource> v) { this.serviceVnfs = v; } + + @Override + public String toString () { + StringBuffer buf = new StringBuffer(); + + boolean first = true; + int i = 1; + for (VnfResource o : serviceVnfs) { + buf.append(i+"\t"); + if (!first) buf.append("\n"); first = false; + buf.append(o); + } + return buf.toString(); + } + + public String toJsonString() { + String jsonString = null; + try { + ObjectMapper mapper = new ObjectMapper(); + jsonString = mapper.writeValueAsString(this); + LOGGER.debug ("QuerySrviceVnfs jsonString: "+jsonString); + } + catch (Exception e) { + LOGGER.debug ("QuerySrviceVnfs jsonString exception:"+e.getMessage()); + } + return jsonString; + } +}
\ No newline at end of file diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapDeserializer.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapDeserializer.java new file mode 100644 index 0000000000..03b8beae03 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapDeserializer.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.json; + +import org.codehaus.jackson.JsonNode; +import org.codehaus.jackson.JsonParser; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.map.DeserializationContext; +import org.codehaus.jackson.map.JsonDeserializer; +import org.codehaus.jackson.map.ObjectMapper; + +import java.io.IOException; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * Custom JSON Deserializer for Map<String, String>. + * In MSO with Jackson 1.9.12 and RestEasy 3.0.8, maps in JSON are serialized as + * follows: + * <pre> + * "params": { + * "entry": [ + * {"key": "P1", "value": "V1"}, + * {"key": "P2", "value": "V2"}, + * ... + * {"key": "PN", "value": "VN"} + * ] + * } + * The implementation uses a LinkedHashMap to preserve the ordering of entries. + * </pre> + */ +public class MapDeserializer extends JsonDeserializer<Map<String, String>> { + @Override + public Map<String, String> deserialize(JsonParser parser, + DeserializationContext context) throws IOException, + JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + JsonNode tree = mapper.readTree(parser); + + Map<String, String> map = new LinkedHashMap<String, String>(); + Iterator<JsonNode> iterator = tree.iterator(); + + while (iterator.hasNext()) { + JsonNode element = iterator.next(); + Iterator<JsonNode> arrayIterator = element.iterator(); + while (arrayIterator.hasNext()) { + JsonNode arrayElement = arrayIterator.next(); + String key = arrayElement.get("key").getTextValue(); + String value = arrayElement.get("value").getTextValue(); + map.put(key, value); + } + } + + return map; + } +}
\ No newline at end of file diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapSerializer.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapSerializer.java new file mode 100644 index 0000000000..e3f55a0e69 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapSerializer.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.json; + +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.JsonGenerator; +import org.codehaus.jackson.map.JsonSerializer; +import org.codehaus.jackson.map.SerializerProvider; + +import java.io.IOException; +import java.util.Map; + +/** + * Custom JSON Serializer for Map<String, String>. + * In MSO with Jackson 1.9.12 and RestEasy 3.0.8, maps in JSON are serialized as + * follows: + * <pre> + * "params": { + * "entry": [ + * {"key": "P1", "value": "V1"}, + * {"key": "P2", "value": "V2"}, + * ... + * {"key": "PN", "value": "VN"} + * ] + * } + * </pre> + * The implementation uses a TreeMap, so entries are always sorted according + * to the natural ordering of the keys. + */ +public class MapSerializer extends JsonSerializer<Map<String, String>> { + @Override + public void serialize(Map<String, String> map, JsonGenerator jsonGenerator, + SerializerProvider serializerProvider) throws IOException, + JsonGenerationException { + + jsonGenerator.writeStartObject(); + jsonGenerator.writeArrayFieldStart("entry"); + + for (String key : map.keySet()) { + String value = map.get(key); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("key", key); + jsonGenerator.writeStringField("value", value); + jsonGenerator.writeEndObject(); + } + + jsonGenerator.writeEndArray(); + jsonGenerator.writeEndObject(); + } +}
\ No newline at end of file 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 index b8c70dd193..4183cbb974 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -37,7 +37,7 @@ 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 +* 2) due to 1) Maps need to use this format "networkParams": {"entry": [ {"key": "network_id", @@ -47,7 +47,7 @@ import org.codehaus.jackson.map.annotate.JsonRootName; {"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 + * 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") @@ -60,6 +60,7 @@ public class CreateNetworkRequest extends NetworkRequestCommon { private String networkName; private String networkType; private String networkTypeVersion; + private String modelCustomizationUuid; private NetworkTechnology networkTechnology = NetworkTechnology.NEUTRON; private List<Subnet> subnets; private ProviderVlanNetwork providerVlanNetwork; @@ -113,6 +114,14 @@ public class CreateNetworkRequest extends NetworkRequestCommon { this.networkType = networkType; } + public String getModelCustomizationUuid() { + return this.modelCustomizationUuid; + } + + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public String getNetworkTypeVersion() { return networkTypeVersion; } 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 index 62c308d142..8bfad978d0 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -39,10 +39,11 @@ public class DeleteNetworkRequest extends NetworkRequestCommon { private String networkId; private String networkStackId; private String networkType; + private String modelCustomizationUuid; private MsoRequest msoRequest = new MsoRequest(); public DeleteNetworkRequest() {} - + public String getCloudSiteId() { return cloudSiteId; } @@ -83,6 +84,14 @@ public class DeleteNetworkRequest extends NetworkRequestCommon { this.networkType = networkType; } + public String getModelCustomizationUuid() { + return this.modelCustomizationUuid; + } + + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public MsoRequest getMsoRequest() { return msoRequest; } 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 index 5ddc050131..db2c2132e6 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -44,6 +44,7 @@ public class UpdateNetworkRequest extends NetworkRequestCommon { private String networkName; private String networkType; private String networkTypeVersion; + private String modelCustomizationUuid; private NetworkTechnology networkTechnology = NetworkTechnology.NEUTRON; private List<Subnet> subnets; private ProviderVlanNetwork providerVlanNetwork; @@ -104,6 +105,14 @@ public class UpdateNetworkRequest extends NetworkRequestCommon { this.networkType = networkType; } + public String getModelCustomizationUuid() { + return this.modelCustomizationUuid; + } + + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public String getNetworkTypeVersion() { return networkTypeVersion; } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/RequestInformation.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/RequestInformation.java new file mode 100644 index 0000000000..24a543c4f0 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/RequestInformation.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.sdncrest; + +import org.codehaus.jackson.annotate.JsonProperty; + +import javax.xml.bind.annotation.XmlElement; +import java.io.Serializable; + +/** + * Request Information specified by the SDNC "agnostic" API. + */ +public class RequestInformation implements Serializable { + private static final long serialVersionUID = 1L; + + // Identifies the transaction MSO has with the calling system. + private String requestId; + + // Identifies the calling system, e.g. CCD. + private String source; + + // The calling system's endpoint for receiving notifications from MSO. + private String notificationUrl; + + // NOTE: these are defined in the SDNC AID, but not used by MSO: + // request-action + // request-sub-action + + public RequestInformation(String requestId, String source, String notificationUrl) { + this.requestId = requestId; + this.source = source; + this.notificationUrl = notificationUrl; + } + + public RequestInformation() { + } + + @JsonProperty("requestId") + @XmlElement(name = "requestId") + public String getRequestId() { + return requestId; + } + + @JsonProperty("requestId") + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + @JsonProperty("source") + @XmlElement(name = "source") + public String getSource() { + return source; + } + + @JsonProperty("source") + public void setSource(String source) { + this.source = source; + } + + @JsonProperty("notificationUrl") + @XmlElement(name = "notificationUrl") + public String getNotificationUrl() { + return notificationUrl; + } + + @JsonProperty("notificationUrl") + public void setNotificationUrl(String notificationUrl) { + this.notificationUrl = notificationUrl; + } +}
\ No newline at end of file diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCErrorCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCErrorCommon.java new file mode 100644 index 0000000000..20fc0498f4 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCErrorCommon.java @@ -0,0 +1,37 @@ +/*- + * ============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.sdncrest; + +import java.io.Serializable; + +/** + * Base class for all SDNC adapter error responses. + */ +public abstract class SDNCErrorCommon extends SDNCResponseCommon implements Serializable { + private static final long serialVersionUID = 1L; + + public SDNCErrorCommon(String sdncRequestId, String responseCode, + String responseMessage, String ackFinalIndicator) { + super(sdncRequestId, responseCode, responseMessage, ackFinalIndicator); + } + + public SDNCErrorCommon() { + } +}
\ No newline at end of file diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCEvent.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCEvent.java new file mode 100644 index 0000000000..038aaa4bba --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCEvent.java @@ -0,0 +1,151 @@ +/*- + * ============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.sdncrest; + +import org.openecomp.mso.adapters.json.MapDeserializer; +import org.openecomp.mso.adapters.json.MapSerializer; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; +import org.codehaus.jackson.map.annotate.JsonDeserialize; +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.codehaus.jackson.map.annotate.JsonSerialize; +import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.io.IOException; +import java.io.Serializable; +import java.util.LinkedHashMap; +import java.util.Map; + +// NOTE: the JAXB (XML) annotations are required with JBoss AS7 and RESTEasy, +// even though we are using JSON exclusively. The @NoJackson annotation +// is also required in this environment. + +/** + * SDNC adapter success response for "agnostic" API services. Note that the + * map of response parameters is represented this way in JSON: + * <pre> + * "params": { + * "entry": [ + * {"key": "P1", "value": "V1"}, + * {"key": "P2", "value": "V2"}, + * ... + * {"key": "PN", "value": "VN"} + * ] + * } + * </pre> + */ +@JsonRootName("SDNCEvent") +@JsonSerialize(include= Inclusion.NON_NULL) +@XmlRootElement(name = "SDNCEvent") +@NoJackson +public class SDNCEvent implements Serializable { + private static final long serialVersionUID = 1L; + + // Event type + private String eventType; + + // Event correlator type + private String eventCorrelatorType; + + // Event correlator value. + private String eventCorrelator; + + // Map of response parameters (possibly none). + private Map<String, String> params = null; + + public SDNCEvent(String eventType, String eventCorrelatorType, String eventCorrelator) { + this.eventType = eventType; + this.eventCorrelatorType = eventCorrelatorType; + this.eventCorrelator = eventCorrelator; + } + + public SDNCEvent() { + } + + @JsonProperty("eventType") + @XmlElement(name = "eventType") + public String getEventType() { + return eventType; + } + + @JsonProperty("eventType") + public void setEventType(String eventType) { + this.eventType = eventType; + } + + @JsonProperty("eventCorrelatorType") + @XmlElement(name = "eventCorrelatorType") + public String getEventCorrelatorType() { + return eventCorrelatorType; + } + + @JsonProperty("eventCorrelatorType") + public void setEventCorrelatorType(String eventCorrelatorType) { + this.eventCorrelatorType = eventCorrelatorType; + } + + @JsonProperty("eventCorrelator") + @XmlElement(name = "eventCorrelator") + public String getEventCorrelator() { + return eventCorrelator; + } + + @JsonProperty("eventCorrelator") + public void setEventCorrelator(String eventCorrelator) { + this.eventCorrelator = eventCorrelator; + } + + @JsonProperty("params") + @JsonDeserialize(using = MapDeserializer.class) + @XmlElement(name = "params") + public Map<String, String> getParams() { + return params; + } + + @JsonProperty("params") + @JsonSerialize(using = MapSerializer.class, include= Inclusion.NON_NULL) + public void setParams(Map<String, String> params) { + this.params = params; + } + + public void addParam(String name, String value) { + if (params == null) { + params = new LinkedHashMap<String, String>(); + } + params.put(name, value); + } + + public String toJson() { + try { + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.setSerializationInclusion(Inclusion.NON_NULL); + return mapper.writeValueAsString(this); + } catch (IOException e) { + e.printStackTrace(); + throw new UnsupportedOperationException("Cannot convert " + + getClass().getSimpleName() + " to JSON", e); + } + } +}
\ No newline at end of file diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCRequestCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCRequestCommon.java new file mode 100644 index 0000000000..6232af6f79 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCRequestCommon.java @@ -0,0 +1,109 @@ +/*- + * ============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.sdncrest; + +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; +import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; + +import javax.xml.bind.annotation.XmlElement; +import java.io.IOException; +import java.io.Serializable; + +/** + * Base class for all SDNC adapter requests. + */ +public abstract class SDNCRequestCommon implements Serializable { + private static final long serialVersionUID = 1L; + + // Endpoint on which BPMN can receive notifications from the SDNC adapter. + private String bpNotificationUrl; + + // BPMN flow timeout value in ISO 8601 format, e.g. PT5M. + // Not currently used by the SDNC adapter. + private String bpTimeout; + + // Identifies the MSO transaction with SDNC. + // Maps to sdnc-request-header/requestId in the SDNC request. + private String sdncRequestId; + + public SDNCRequestCommon(String sdncRequestId, String bpNotificationUrl, + String bpTimeout) { + this.sdncRequestId = sdncRequestId; + this.bpNotificationUrl = bpNotificationUrl; + this.bpTimeout = bpTimeout; + } + + public SDNCRequestCommon() { + } + + @JsonProperty("bpNotificationUrl") + @XmlElement(name = "bpNotificationUrl") + public String getBPNotificationUrl() { + return bpNotificationUrl; + } + + @JsonProperty("bpNotificationUrl") + public void setBPNotificationUrl(String bpNotificationUrl) { + this.bpNotificationUrl = bpNotificationUrl; + } + + @JsonProperty("bpTimeout") + @XmlElement(name = "bpTimeout") + public String getBPTimeout() { + return bpTimeout; + } + + @JsonProperty("bpTimeout") + public void setBPTimeout(String bpTimeout) { + this.bpTimeout = bpTimeout; + } + + @JsonProperty("sdncRequestId") + @XmlElement(name = "sdncRequestId") + public String getSDNCRequestId() { + return sdncRequestId; + } + + @JsonProperty("sdncRequestId") + public void setSDNCRequestId(String sdncRequestId) { + this.sdncRequestId = sdncRequestId; + } + + @JsonIgnore + public boolean isSynchronous() { + return bpNotificationUrl == null || bpNotificationUrl.isEmpty(); + } + + public String toJson() { + try { + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.setSerializationInclusion(Inclusion.NON_NULL); + return mapper.writeValueAsString(this); + } catch (IOException e) { + e.printStackTrace(); + throw new UnsupportedOperationException("Cannot convert " + + getClass().getSimpleName() + " to JSON", e); + } + } +}
\ No newline at end of file diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCResponseCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCResponseCommon.java new file mode 100644 index 0000000000..aa0be2702b --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCResponseCommon.java @@ -0,0 +1,117 @@ +/*- + * ============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.sdncrest; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; +import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; + +import javax.xml.bind.annotation.XmlElement; +import java.io.IOException; +import java.io.Serializable; + +/** + * Base class for all SDNC adapter responses, including errors. + */ +public abstract class SDNCResponseCommon implements Serializable { + private static final long serialVersionUID = 1L; + + // Identifies the MSO transaction with SDNC. + private String sdncRequestId; + + // Response code, either from SDNC, or generated by the SDNC adapter. + // 2XX responses are considered success responses. + private String responseCode; + + // Response message, either from SDNC, or generated by the SDNC adapter. + private String responseMessage; + + // Indicates if the response is final (Y or N). + private String ackFinalIndicator; + + public SDNCResponseCommon(String sdncRequestId, String responseCode, + String responseMessage, String ackFinalIndicator) { + this.sdncRequestId = sdncRequestId; + this.responseCode = responseCode; + this.responseMessage = responseMessage; + this.ackFinalIndicator = ackFinalIndicator; + } + + public SDNCResponseCommon() { + } + + @JsonProperty("sdncRequestId") + @XmlElement(name = "sdncRequestId") + public String getSDNCRequestId() { + return sdncRequestId; + } + + @JsonProperty("sdncRequestId") + public void setSDNCRequestId(String sdncRequestId) { + this.sdncRequestId = sdncRequestId; + } + + @JsonProperty("responseCode") + @XmlElement(name = "responseCode") + public String getResponseCode() { + return responseCode; + } + + @JsonProperty("responseCode") + public void setResponseCode(String responseCode) { + this.responseCode = responseCode; + } + + @JsonProperty("responseMessage") + @XmlElement(name = "responseMessage") + public String getResponseMessage() { + return responseMessage; + } + + @JsonProperty("responseMessage") + public void setResponseMessage(String responseMessage) { + this.responseMessage = responseMessage; + } + + @JsonProperty("ackFinalIndicator") + @XmlElement(name = "ackFinalIndicator") + public String getAckFinalIndicator() { + return ackFinalIndicator; + } + + @JsonProperty("ackFinalIndicator") + public void setAckFinalIndicator(String ackFinalIndicator) { + this.ackFinalIndicator = ackFinalIndicator; + } + + public String toJson() { + try { + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.setSerializationInclusion(Inclusion.NON_NULL); + return mapper.writeValueAsString(this); + } catch (IOException e) { + e.printStackTrace(); + throw new UnsupportedOperationException("Cannot convert " + + getClass().getSimpleName() + " to JSON", e); + } + } +}
\ No newline at end of file diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceError.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceError.java new file mode 100644 index 0000000000..a789316754 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceError.java @@ -0,0 +1,50 @@ +/*- + * ============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.sdncrest; + +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.codehaus.jackson.map.annotate.JsonSerialize; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; + +// NOTE: the JAXB (XML) annotations are required with JBoss AS7 and RESTEasy, +// even though we are using JSON exclusively. The @NoJackson annotation +// is also required in this environment. + +/** + * SDNC adapter error response for "agnostic" API services. + */ +@JsonRootName("SDNCServiceError") +@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL) +@XmlRootElement(name = "SDNCServiceError") +@NoJackson +public class SDNCServiceError extends SDNCErrorCommon implements Serializable { + private static final long serialVersionUID = 1; + + public SDNCServiceError(String sdncRequestId, String responseCode, + String responseMessage, String ackFinalIndicator) { + super(sdncRequestId, responseCode, responseMessage, ackFinalIndicator); + } + + public SDNCServiceError() { + } +}
\ No newline at end of file diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceRequest.java new file mode 100644 index 0000000000..814b603783 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceRequest.java @@ -0,0 +1,146 @@ +/*- + * ============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.sdncrest; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.codehaus.jackson.map.annotate.JsonSerialize; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; + +// NOTE: the JAXB (XML) annotations are required with JBoss AS7 and RESTEasy, +// even though we are using JSON exclusively. The @NoJackson annotation +// is also required in this environment. + +/** + * SDNC adapter request for "agnostic" API services. + * The target action is determined by a service type and an operation. + */ +@JsonRootName("SDNCServiceRequest") +@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL) +@XmlRootElement(name = "SDNCServiceRequest") +@NoJackson +public class SDNCServiceRequest extends SDNCRequestCommon implements Serializable { + private static final long serialVersionUID = 1L; + + // Request Information specified by SDNC "agnostic" API + private RequestInformation requestInformation; + + // Service Information specified by: SDNC "agnostic" API + private ServiceInformation serviceInformation; + + // The SDNC service type specified by SDNC "agnostic" API + private String sdncService; + + // The SDNC operation specified by SDNC "agnostic" API + private String sdncOperation; + + // The SDNC service data type specified by SDNC "agnostic" API + private String sdncServiceDataType; + + // The SDNC service data specified by SDNC "agnostic" API + private String sndcServiceData; + + public SDNCServiceRequest() { + } + + public SDNCServiceRequest(String bpNotificationUrl, String bpTimeout, + String sdncRequestId, String sdncService, String sdncOperation, + RequestInformation requestInformation, + ServiceInformation serviceInformation, String sdncServiceDataType, + String sndcServiceData) { + super(bpNotificationUrl, bpTimeout, sdncRequestId); + this.requestInformation = requestInformation; + this.serviceInformation = serviceInformation; + this.sdncService = sdncService; + this.sdncOperation = sdncOperation; + this.sdncServiceDataType = sdncServiceDataType; + this.sndcServiceData = sndcServiceData; + } + + @JsonProperty("requestInformation") + @XmlElement(name = "requestInformation") + public RequestInformation getRequestInformation() { + return requestInformation; + } + + @JsonProperty("requestInformation") + public void setRequestInformation(RequestInformation requestInformation) { + this.requestInformation = requestInformation; + } + + @JsonProperty("serviceInformation") + @XmlElement(name = "serviceInformation") + public ServiceInformation getServiceInformation() { + return serviceInformation; + } + + @JsonProperty("serviceInformation") + public void setServiceInformation(ServiceInformation serviceInformation) { + this.serviceInformation = serviceInformation; + } + + @JsonProperty("sdncService") + @XmlElement(name = "sdncService") + public String getSDNCService() { + return sdncService; + } + + @JsonProperty("sdncService") + public void setSDNCService(String sdncService) { + this.sdncService = sdncService; + } + + @JsonProperty("sdncOperation") + @XmlElement(name = "sdncOperation") + public String getSDNCOperation() { + return sdncOperation; + } + + @JsonProperty("sdncOperation") + public void setSDNCOperation(String sdncOperation) { + this.sdncOperation = sdncOperation; + } + + @JsonProperty("sdncServiceDataType") + @XmlElement(name = "sdncServiceDataType") + public String getSDNCServiceDataType() { + return sdncServiceDataType; + } + + @JsonProperty("sdncServiceDataType") + public void setSDNCServiceDataType(String sdncServiceDataType) { + this.sdncServiceDataType = sdncServiceDataType; + } + + @JsonProperty("sdncServiceData") + @XmlElement(name = "sdncServiceData") + public String getSDNCServiceData() { + return sndcServiceData; + } + + @JsonProperty("sdncServiceData") + public void setSDNCServiceData(String sndcServiceData) { + this.sndcServiceData = sndcServiceData; + } +}
\ No newline at end of file diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceResponse.java new file mode 100644 index 0000000000..2ab6ed5a8a --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceResponse.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.adapters.sdncrest; + +import org.openecomp.mso.adapters.json.MapDeserializer; +import org.openecomp.mso.adapters.json.MapSerializer; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonDeserialize; +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.codehaus.jackson.map.annotate.JsonSerialize; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; +import java.util.LinkedHashMap; +import java.util.Map; + +// NOTE: the JAXB (XML) annotations are required with JBoss AS7 and RESTEasy, +// even though we are using JSON exclusively. The @NoJackson annotation +// is also required in this environment. + +/** + * SDNC adapter success response for "agnostic" API services. Note that the + * map of response parameters is represented this way in JSON: + * <pre> + * "params": { + * "entry": [ + * {"key": "P1", "value": "V1"}, + * {"key": "P2", "value": "V2"}, + * ... + * {"key": "PN", "value": "VN"} + * ] + * } + * </pre> + */ +@JsonRootName("SDNCServiceResponse") +@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL) +@XmlRootElement(name = "SDNCServiceResponse") +@NoJackson +public class SDNCServiceResponse extends SDNCResponseCommon implements Serializable { + private static final long serialVersionUID = 1L; + + // Map of response parameters (possibly none). + private Map<String, String> params = null; + + public SDNCServiceResponse(String sdncRequestId, String responseCode, + String responseMessage, String ackFinalIndicator) { + super(sdncRequestId, responseCode, responseMessage, ackFinalIndicator); + } + + public SDNCServiceResponse() { + } + + @JsonProperty("params") + @JsonDeserialize(using = MapDeserializer.class) + @XmlElement(name = "params") + public Map<String, String> getParams() { + return params; + } + + @JsonProperty("params") + @JsonSerialize(using = MapSerializer.class, include=JsonSerialize.Inclusion.NON_NULL) + public void setParams(Map<String, String> params) { + this.params = params; + } + + public void addParam(String name, String value) { + if (params == null) { + params = new LinkedHashMap<String, String>(); + } + params.put(name, value); + } +}
\ No newline at end of file diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/ServiceInformation.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/ServiceInformation.java new file mode 100644 index 0000000000..628ef9c071 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/ServiceInformation.java @@ -0,0 +1,102 @@ +/*- + * ============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.sdncrest; + +import org.codehaus.jackson.annotate.JsonProperty; + +import javax.xml.bind.annotation.XmlElement; +import java.io.Serializable; + +/** + * Service Information specified by the SDNC "agnostic" API. + */ +public class ServiceInformation implements Serializable { + private static final long serialVersionUID = 1L; + + // The subscription's service type for the target service instance. + private String serviceType; + + // Identifies the target service instance for this particular SDNC request. + // NOTE: this could be a child of the parent model instance, i.e. this + // service instance ID may be different from the service instance ID + // associated with the transaction MSO has with the system that invoked it. + private String serviceInstanceId; + + // The subscriber name. + private String subscriberName; + + // The subscriber global ID (customer ID). + private String subscriberGlobalId; + + public ServiceInformation(String serviceType, String serviceInstanceId, + String subscriberName, String subscriberGlobalId) { + this.serviceType = serviceType; + this.serviceInstanceId = serviceInstanceId; + this.subscriberName = subscriberName; + this.subscriberGlobalId = subscriberGlobalId; + } + + public ServiceInformation() { + } + + @JsonProperty("serviceType") + @XmlElement(name = "serviceType") + public String getServiceType() { + return serviceType; + } + + @JsonProperty("serviceType") + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + @JsonProperty("serviceInstanceId") + @XmlElement(name = "serviceInstanceId") + public String getServiceInstanceId() { + return serviceInstanceId; + } + + @JsonProperty("serviceInstanceId") + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + @JsonProperty("subscriberName") + @XmlElement(name = "subscriberName") + public String getSubscriberName() { + return subscriberName; + } + + @JsonProperty("subscriberName") + public void setSubscriberName(String subscriberName) { + this.subscriberName = subscriberName; + } + + @JsonProperty("subscriberGlobalId") + @XmlElement(name = "subscriberGlobalId") + public String getSubscriberGlobalId() { + return subscriberGlobalId; + } + + @JsonProperty("subscriberGlobalId") + public void setSubscriberGlobalId(String subscriberGlobalId) { + this.subscriberGlobalId = subscriberGlobalId; + } +}
\ No newline at end of file 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 index f337c4c9de..bcee2ffd8a 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -66,6 +66,7 @@ public class CreateVfModuleRequest extends VfRequestCommon { private String volumeGroupStackId; private String baseVfModuleId; private String baseVfModuleStackId; + private String modelCustomizationUuid; private String requestType; private Boolean failIfExists; @@ -170,6 +171,14 @@ public class CreateVfModuleRequest extends VfRequestCommon { this.baseVfModuleStackId = baseVfModuleStackId; } + public String getModelCustomizationUuid() { + return this.modelCustomizationUuid; + } + + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public String getRequestType() { return requestType; } 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 index b93a26031f..840edf7fbc 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -42,6 +42,7 @@ public class CreateVolumeGroupRequest extends VfRequestCommon { private String vnfType; private String vnfVersion; private String vfModuleType; + private String modelCustomizationUuid; private Map<String,String> volumeGroupParams = new HashMap<String, String>(); private Boolean failIfExists; private Boolean suppressBackout; @@ -111,6 +112,14 @@ public class CreateVolumeGroupRequest extends VfRequestCommon { return volumeGroupId; } + public String getModelCustomizationUuid() { + return this.modelCustomizationUuid; + } + + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public void setVolumeGroupId(String volumeGroupId) { this.volumeGroupId = volumeGroupId; } 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 index a3d00a95cd..8f719c88c8 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -25,6 +25,9 @@ import javax.xml.bind.annotation.XmlRootElement; import org.jboss.resteasy.annotations.providers.NoJackson; import org.codehaus.jackson.map.annotate.JsonRootName; +import java.util.HashMap; +import java.util.Map; + @JsonRootName("deleteVfModuleResponse") @XmlRootElement(name = "deleteVfModuleResponse") @NoJackson @@ -32,16 +35,17 @@ public class DeleteVfModuleResponse extends VfResponseCommon { private String vnfId; private String vfModuleId; private Boolean vfModuleDeleted; - + private Map<String,String> vfModuleOutputs = new HashMap<String, String>(); public DeleteVfModuleResponse() { super(); } - public DeleteVfModuleResponse(String vnfId, String vfModuleId, Boolean vfModuleDeleted, String messageId) { + public DeleteVfModuleResponse(String vnfId, String vfModuleId, Boolean vfModuleDeleted, String messageId, Map<String,String> outputs) { super(messageId); this.vnfId = vnfId; this.vfModuleId = vfModuleId; this.vfModuleDeleted = vfModuleDeleted; + this.vfModuleOutputs = outputs; } public String getVnfId() { @@ -67,4 +71,11 @@ public class DeleteVfModuleResponse extends VfResponseCommon { public void setVfModuleDeleted(Boolean vfModuleDeleted) { this.vfModuleDeleted = vfModuleDeleted; } + 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/UpdateVfModuleRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/UpdateVfModuleRequest.java index a234e749ba..6c11232bfa 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -52,6 +52,8 @@ public class UpdateVfModuleRequest extends VfRequestCommon { private String baseVfModuleId; private String baseVfModuleStackId; + private String modelCustomizationUuid; + private String requestType; private Boolean failIfExists; private Boolean backout; @@ -151,6 +153,14 @@ public class UpdateVfModuleRequest extends VfRequestCommon { return baseVfModuleId; } + public String getModelCustomizationUuid() { + return this.modelCustomizationUuid; + } + + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public void setBaseVfModuleId(String baseVfModuleId) { this.baseVfModuleId = baseVfModuleId; } 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 index 50c60b30d6..596021e5e8 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -42,6 +42,7 @@ public class UpdateVolumeGroupRequest extends VfRequestCommon { private String vnfType; private String vnfVersion; private String vfModuleType; + private String modelCustomizationUuid; private Map<String,String> volumeGroupParams = new HashMap<String, String>(); private MsoRequest msoRequest = new MsoRequest(); @@ -105,6 +106,14 @@ public class UpdateVolumeGroupRequest extends VfRequestCommon { this.vfModuleType = vfModuleType; } + public String getModelCustomizationUuid() { + return this.modelCustomizationUuid; + } + + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public Map<String, String> getVolumeGroupParams() { return volumeGroupParams; } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryAllottedResourceCustomizationESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryAllottedResourceCustomizationESTest.java new file mode 100644 index 0000000000..5addb999ce --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryAllottedResourceCustomizationESTest.java @@ -0,0 +1,97 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Feb 20 14:08:31 GMT 2017 + */ + +package org.openecomp.mso.adapters.catalogrest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; +import java.util.LinkedList; +import java.util.List; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; +import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class QueryAllottedResourceCustomizationESTest extends QueryAllottedResourceCustomizationESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + QueryAllottedResourceCustomization queryAllottedResourceCustomization0 = new QueryAllottedResourceCustomization(); + queryAllottedResourceCustomization0.setServiceAllottedResources((List<AllottedResourceCustomization>) null); + List<AllottedResourceCustomization> list0 = queryAllottedResourceCustomization0.getServiceAllottedResources(); + assertNull(list0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + LinkedList<AllottedResourceCustomization> linkedList0 = new LinkedList<AllottedResourceCustomization>(); + AllottedResourceCustomization allottedResourceCustomization0 = new AllottedResourceCustomization(); + linkedList0.add(allottedResourceCustomization0); + QueryAllottedResourceCustomization queryAllottedResourceCustomization0 = new QueryAllottedResourceCustomization((List<AllottedResourceCustomization>) linkedList0); + List<AllottedResourceCustomization> list0 = queryAllottedResourceCustomization0.getServiceAllottedResources(); + assertFalse(list0.isEmpty()); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + LinkedList<AllottedResourceCustomization> linkedList0 = new LinkedList<AllottedResourceCustomization>(); + AllottedResourceCustomization allottedResourceCustomization0 = new AllottedResourceCustomization(); + linkedList0.add(allottedResourceCustomization0); + QueryAllottedResourceCustomization queryAllottedResourceCustomization0 = new QueryAllottedResourceCustomization((List<AllottedResourceCustomization>) linkedList0); + linkedList0.add(allottedResourceCustomization0); + String string0 = queryAllottedResourceCustomization0.toString(); + assertEquals("1\tmodelName=null,modelVersion=null,version=null,modelUuid=null,modelInvariantUuid=null,modelCustomizationUuid=null,modelInstanceName=null,description=null,modelInstanceName=null,created=null1\t\nmodelName=null,modelVersion=null,version=null,modelUuid=null,modelInvariantUuid=null,modelCustomizationUuid=null,modelInstanceName=null,description=null,modelInstanceName=null,created=null", string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + QueryAllottedResourceCustomization queryAllottedResourceCustomization0 = new QueryAllottedResourceCustomization(); + String string0 = queryAllottedResourceCustomization0.toString(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + QueryAllottedResourceCustomization queryAllottedResourceCustomization0 = new QueryAllottedResourceCustomization(); + List<AllottedResourceCustomization> list0 = queryAllottedResourceCustomization0.getServiceAllottedResources(); + assertTrue(list0.isEmpty()); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + QueryAllottedResourceCustomization queryAllottedResourceCustomization0 = new QueryAllottedResourceCustomization(); + queryAllottedResourceCustomization0.setServiceAllottedResources((List<AllottedResourceCustomization>) null); + // Undeclared exception! + try { + queryAllottedResourceCustomization0.toString(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.adapters.catalogrest.QueryAllottedResourceCustomization", e); + } + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + LinkedList<AllottedResourceCustomization> linkedList0 = new LinkedList<AllottedResourceCustomization>(); + QueryAllottedResourceCustomization queryAllottedResourceCustomization0 = new QueryAllottedResourceCustomization((List<AllottedResourceCustomization>) linkedList0); + // Undeclared exception! + try { + queryAllottedResourceCustomization0.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); + } + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryAllottedResourceCustomizationESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryAllottedResourceCustomizationESTestscaffolding.java new file mode 100644 index 0000000000..0ce23dc7c2 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryAllottedResourceCustomizationESTestscaffolding.java @@ -0,0 +1,264 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Feb 20 14:08:31 GMT 2017 + */ + +package org.openecomp.mso.adapters.catalogrest; + +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 QueryAllottedResourceCustomizationESTestscaffolding { + + @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.catalogrest.QueryAllottedResourceCustomization"; + 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(QueryAllottedResourceCustomizationESTestscaffolding.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.JsonProcessingException", + "org.codehaus.jackson.map.introspect.AnnotationMap", + "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", + "com.att.eelf.i18n.EELFResolvableErrorEnum", + "org.codehaus.jackson.node.BaseJsonNode", + "org.openecomp.mso.logger.MsoLogger$StatusCode", + "org.codehaus.jackson.map.ObjectReader", + "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.JsonSerializer", + "org.codehaus.jackson.map.introspect.AnnotatedWithParams", + "com.att.eelf.i18n.EELFMsgs", + "org.codehaus.jackson.map.AnnotationIntrospector", + "org.codehaus.jackson.map.MappingJsonFactory", + "com.att.eelf.configuration.EELFLogger$Level", + "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.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.openecomp.mso.adapters.catalogrest.QueryAllottedResourceCustomization", + "org.codehaus.jackson.map.type.TypeBase", + "org.codehaus.jackson.map.ser.BasicSerializerFactory", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "org.codehaus.jackson.map.PropertyNamingStrategy", + "org.codehaus.jackson.node.ContainerNode", + "org.codehaus.jackson.map.ser.FilterProvider", + "org.codehaus.jackson.map.jsontype.NamedType", + "org.codehaus.jackson.map.introspect.NopAnnotationIntrospector", + "com.att.eelf.configuration.EELFLogger", + "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.JsonEncoding", + "org.codehaus.jackson.map.type.MapLikeType", + "org.codehaus.jackson.map.JsonDeserializer", + "org.codehaus.jackson.map.PropertyNamingStrategy$PropertyNamingStrategyBase", + "org.codehaus.jackson.node.ObjectNode", + "org.openecomp.mso.logger.MsoLogger$ErrorCode", + "org.codehaus.jackson.map.ser.std.SerializerBase", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$MinimalMethodFilter", + "org.codehaus.jackson.map.type.CollectionLikeType", + "org.openecomp.mso.logger.MessageEnum", + "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.map.util.StdDateFormat", + "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", + "com.att.eelf.configuration.SLF4jWrapper", + "org.codehaus.jackson.FormatSchema", + "org.codehaus.jackson.format.MatchStrength", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.codehaus.jackson.ObjectCodec", + "org.codehaus.jackson.map.introspect.AnnotatedMethod", + "org.openecomp.mso.db.catalog.utils.MavenLikeVersioning", + "org.codehaus.jackson.JsonGenerationException", + "org.openecomp.mso.entity.MsoRequest", + "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.logger.MsoLogger$ResponseCode", + "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.MappingIterator", + "org.codehaus.jackson.map.annotate.JsonSerialize$Inclusion", + "org.codehaus.jackson.map.DeserializationContext", + "org.codehaus.jackson.impl.JsonParserBase", + "org.codehaus.jackson.map.ObjectMapper$DefaultTyping", + "org.codehaus.jackson.map.JsonMappingException", + "org.codehaus.jackson.map.introspect.AnnotatedMember", + "org.codehaus.jackson.node.JsonNodeFactory", + "org.codehaus.jackson.type.JavaType", + "com.att.eelf.i18n.EELFResourceManager", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.annotate.JsonTypeInfo$As", + "org.codehaus.jackson.JsonParser", + "org.codehaus.jackson.node.NullNode", + "org.codehaus.jackson.map.InjectableValues", + "org.codehaus.jackson.map.jsontype.impl.StdSubtypeResolver", + "org.codehaus.jackson.node.TreeTraversingParser", + "org.codehaus.jackson.map.type.CollectionType", + "com.att.eelf.configuration.EELFManager", + "org.codehaus.jackson.map.MapperConfig", + "org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization", + "org.codehaus.jackson.map.Module$SetupContext", + "org.codehaus.jackson.io.UTF8Writer", + "org.codehaus.jackson.map.introspect.VisibilityChecker$1", + "org.codehaus.jackson.map.type.MapType", + "org.codehaus.jackson.annotate.JsonAutoDetect", + "org.codehaus.jackson.map.type.ArrayType", + "org.openecomp.mso.logger.MsoLogger", + "org.codehaus.jackson.map.ClassIntrospector$MixInResolver" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(QueryAllottedResourceCustomizationESTestscaffolding.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.catalogrest.QueryAllottedResourceCustomization", + "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/catalogrest/QueryServiceMacroHolderESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryServiceMacroHolderESTest.java new file mode 100644 index 0000000000..6f3fa5aec5 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryServiceMacroHolderESTest.java @@ -0,0 +1,109 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Feb 20 14:12:21 GMT 2017 + */ + +package org.openecomp.mso.adapters.catalogrest; + +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.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; +import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class QueryServiceMacroHolderESTest extends QueryServiceMacroHolderESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + ServiceMacroHolder serviceMacroHolder0 = mock(ServiceMacroHolder.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(serviceMacroHolder0).toString(); + QueryServiceMacroHolder queryServiceMacroHolder0 = new QueryServiceMacroHolder(serviceMacroHolder0); + String string0 = queryServiceMacroHolder0.toString(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + ServiceMacroHolder serviceMacroHolder0 = mock(ServiceMacroHolder.class, new ViolatedAssumptionAnswer()); + doReturn("com.att.eelf.policy").when(serviceMacroHolder0).toString(); + QueryServiceMacroHolder queryServiceMacroHolder0 = new QueryServiceMacroHolder(serviceMacroHolder0); + String string0 = queryServiceMacroHolder0.toString(); + assertEquals("com.att.eelf.policy", string0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + ServiceMacroHolder serviceMacroHolder0 = mock(ServiceMacroHolder.class, new ViolatedAssumptionAnswer()); + doReturn("com.att.eelf.policy").when(serviceMacroHolder0).toString(); + QueryServiceMacroHolder queryServiceMacroHolder0 = new QueryServiceMacroHolder(serviceMacroHolder0); + ServiceMacroHolder serviceMacroHolder1 = queryServiceMacroHolder0.getServiceResources(); + assertSame(serviceMacroHolder1, serviceMacroHolder0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + QueryServiceMacroHolder queryServiceMacroHolder0 = new QueryServiceMacroHolder((ServiceMacroHolder) null); + // Undeclared exception! + try { + queryServiceMacroHolder0.toString(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.adapters.catalogrest.QueryServiceMacroHolder", e); + } + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + ServiceMacroHolder serviceMacroHolder0 = mock(ServiceMacroHolder.class, new ViolatedAssumptionAnswer()); + doReturn("").when(serviceMacroHolder0).toString(); + QueryServiceMacroHolder queryServiceMacroHolder0 = new QueryServiceMacroHolder(serviceMacroHolder0); + String string0 = queryServiceMacroHolder0.toString(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + QueryServiceMacroHolder queryServiceMacroHolder0 = new QueryServiceMacroHolder(); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + ServiceMacroHolder serviceMacroHolder0 = mock(ServiceMacroHolder.class, new ViolatedAssumptionAnswer()); + QueryServiceMacroHolder queryServiceMacroHolder0 = new QueryServiceMacroHolder(serviceMacroHolder0); + // Undeclared exception! + try { + queryServiceMacroHolder0.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 test7() throws Throwable { + QueryServiceMacroHolder queryServiceMacroHolder0 = new QueryServiceMacroHolder((ServiceMacroHolder) null); + ServiceMacroHolder serviceMacroHolder0 = queryServiceMacroHolder0.getServiceResources(); + assertNull(serviceMacroHolder0); + } + + @Test(timeout = 4000) + public void test8() throws Throwable { + ServiceMacroHolder serviceMacroHolder0 = mock(ServiceMacroHolder.class, new ViolatedAssumptionAnswer()); + QueryServiceMacroHolder queryServiceMacroHolder0 = new QueryServiceMacroHolder(serviceMacroHolder0); + ServiceMacroHolder serviceMacroHolder1 = mock(ServiceMacroHolder.class, new ViolatedAssumptionAnswer()); + queryServiceMacroHolder0.setServiceResources(serviceMacroHolder1); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryServiceMacroHolderESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryServiceMacroHolderESTestscaffolding.java new file mode 100644 index 0000000000..4a5898649b --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryServiceMacroHolderESTestscaffolding.java @@ -0,0 +1,221 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Feb 20 14:12:21 GMT 2017 + */ + +package org.openecomp.mso.adapters.catalogrest; + +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 QueryServiceMacroHolderESTestscaffolding { + + @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.catalogrest.QueryServiceMacroHolder"; + 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(QueryServiceMacroHolderESTestscaffolding.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", + "com.att.eelf.i18n.EELFResolvableErrorEnum", + "org.codehaus.jackson.node.BaseJsonNode", + "org.openecomp.mso.logger.MsoLogger$StatusCode", + "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", + "com.att.eelf.i18n.EELFMsgs", + "org.codehaus.jackson.map.AnnotationIntrospector", + "org.codehaus.jackson.map.MappingJsonFactory", + "com.att.eelf.configuration.EELFLogger$Level", + "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.openecomp.mso.db.catalog.beans.NetworkResourceCustomization", + "org.codehaus.jackson.map.type.TypeBase", + "org.codehaus.jackson.map.ser.BasicSerializerFactory", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "org.codehaus.jackson.node.ContainerNode", + "org.codehaus.jackson.map.introspect.NopAnnotationIntrospector", + "com.att.eelf.configuration.EELFLogger", + "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.openecomp.mso.db.catalog.beans.VnfResource", + "org.openecomp.mso.logger.MsoLogger$ErrorCode", + "org.codehaus.jackson.node.ObjectNode", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$MinimalMethodFilter", + "org.codehaus.jackson.map.type.CollectionLikeType", + "org.openecomp.mso.logger.MessageEnum", + "org.codehaus.jackson.sym.CharsToNameCanonicalizer$Bucket", + "org.codehaus.jackson.impl.JsonParserMinimalBase", + "org.openecomp.mso.db.catalog.beans.ServiceMacroHolder", + "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", + "com.att.eelf.configuration.SLF4jWrapper", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.codehaus.jackson.ObjectCodec", + "org.codehaus.jackson.map.introspect.AnnotatedMethod", + "org.openecomp.mso.db.catalog.utils.MavenLikeVersioning", + "org.openecomp.mso.entity.MsoRequest", + "org.codehaus.jackson.JsonFactory", + "org.codehaus.jackson.node.ArrayNode", + "org.codehaus.jackson.io.SegmentedStringWriter", + "org.openecomp.mso.logger.MsoLogger$ResponseCode", + "org.codehaus.jackson.map.jsontype.TypeResolverBuilder", + "org.openecomp.mso.adapters.catalogrest.QueryServiceMacroHolder", + "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.openecomp.mso.db.catalog.beans.Service", + "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", + "com.att.eelf.i18n.EELFResourceManager", + "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", + "com.att.eelf.configuration.EELFManager", + "org.codehaus.jackson.map.MapperConfig", + "org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization", + "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.openecomp.mso.logger.MsoLogger", + "org.codehaus.jackson.map.ClassIntrospector$MixInResolver" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(QueryServiceMacroHolderESTestscaffolding.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.catalogrest.QueryServiceMacroHolder", + "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/catalogrest/QueryServiceNetworksESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryServiceNetworksESTest.java new file mode 100644 index 0000000000..0219fb52fa --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryServiceNetworksESTest.java @@ -0,0 +1,163 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Feb 20 14:04:40 GMT 2017 + */ + +package org.openecomp.mso.adapters.catalogrest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.EvoAssertions.*; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; +import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class QueryServiceNetworksESTest extends QueryServiceNetworksESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + LinkedList<NetworkResourceCustomization> linkedList0 = new LinkedList<NetworkResourceCustomization>(); + QueryServiceNetworks queryServiceNetworks0 = new QueryServiceNetworks((List<NetworkResourceCustomization>) linkedList0); + queryServiceNetworks0.setServiceNetworks((List<NetworkResourceCustomization>) null); + List<NetworkResourceCustomization> list0 = queryServiceNetworks0.getServiceNetworks(); + assertNull(list0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + LinkedList<NetworkResourceCustomization> linkedList0 = new LinkedList<NetworkResourceCustomization>(); + QueryServiceNetworks queryServiceNetworks0 = new QueryServiceNetworks(); + Object[] objectArray0 = new Object[3]; + objectArray0[0] = (Object) queryServiceNetworks0; + Collection<NetworkResourceCustomization> collection0 = (Collection<NetworkResourceCustomization>) mock(Collection.class, new ViolatedAssumptionAnswer()); + doReturn(objectArray0).when(collection0).toArray(); + linkedList0.addAll(collection0); + queryServiceNetworks0.setServiceNetworks(linkedList0); + // Undeclared exception! + try { + queryServiceNetworks0.toString(); + fail("Expecting exception: ClassCastException"); + + } catch(ClassCastException e) { + // + // org.openecomp.mso.adapters.catalogrest.QueryServiceNetworks cannot be cast to org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization + // + verifyException("org.openecomp.mso.adapters.catalogrest.QueryServiceNetworks", e); + } + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + QueryServiceNetworks queryServiceNetworks0 = null; + try { + queryServiceNetworks0 = new QueryServiceNetworks((List<NetworkResourceCustomization>) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.adapters.catalogrest.QueryServiceNetworks", e); + } + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + LinkedList<NetworkResourceCustomization> linkedList0 = new LinkedList<NetworkResourceCustomization>(); + NetworkResourceCustomization networkResourceCustomization0 = new NetworkResourceCustomization(); + linkedList0.add(networkResourceCustomization0); + Object[] objectArray0 = new Object[4]; + objectArray0[0] = (Object) linkedList0; + Collection<NetworkResourceCustomization> collection0 = (Collection<NetworkResourceCustomization>) mock(Collection.class, new ViolatedAssumptionAnswer()); + doReturn(objectArray0).when(collection0).toArray(); + linkedList0.addAll(1, collection0); + QueryServiceNetworks queryServiceNetworks0 = null; + try { + queryServiceNetworks0 = new QueryServiceNetworks((List<NetworkResourceCustomization>) linkedList0); + fail("Expecting exception: ClassCastException"); + + } catch(ClassCastException e) { + // + // java.util.LinkedList cannot be cast to org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization + // + verifyException("org.openecomp.mso.adapters.catalogrest.QueryServiceNetworks", e); + } + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + LinkedList<NetworkResourceCustomization> linkedList0 = new LinkedList<NetworkResourceCustomization>(); + QueryServiceNetworks queryServiceNetworks0 = new QueryServiceNetworks(); + queryServiceNetworks0.setServiceNetworks(linkedList0); + NetworkResourceCustomization networkResourceCustomization0 = new NetworkResourceCustomization(); + linkedList0.add(networkResourceCustomization0); + linkedList0.add(networkResourceCustomization0); + String string0 = queryServiceNetworks0.toString(); + assertEquals("1\tmodelName=nullmodelUuid=nullmodelUuid=nullmodelInvariantUuid=nullmodelVersion=nullmodelCustomizationUuid=nullmodelInstanceName=nullnetworkResourceId=0networkType=null1\t\nmodelName=nullmodelUuid=nullmodelUuid=nullmodelInvariantUuid=nullmodelVersion=nullmodelCustomizationUuid=nullmodelInstanceName=nullnetworkResourceId=0networkType=null", string0); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + QueryServiceNetworks queryServiceNetworks0 = new QueryServiceNetworks(); + String string0 = queryServiceNetworks0.toString(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + LinkedList<NetworkResourceCustomization> linkedList0 = new LinkedList<NetworkResourceCustomization>(); + NetworkResourceCustomization networkResourceCustomization0 = new NetworkResourceCustomization(); + linkedList0.add(networkResourceCustomization0); + QueryServiceNetworks queryServiceNetworks0 = new QueryServiceNetworks((List<NetworkResourceCustomization>) linkedList0); + List<NetworkResourceCustomization> list0 = queryServiceNetworks0.getServiceNetworks(); + assertEquals(1, list0.size()); + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + LinkedList<NetworkResourceCustomization> linkedList0 = new LinkedList<NetworkResourceCustomization>(); + QueryServiceNetworks queryServiceNetworks0 = new QueryServiceNetworks((List<NetworkResourceCustomization>) linkedList0); + queryServiceNetworks0.setServiceNetworks((List<NetworkResourceCustomization>) null); + // Undeclared exception! + try { + queryServiceNetworks0.toString(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.adapters.catalogrest.QueryServiceNetworks", e); + } + } + + @Test(timeout = 4000) + public void test8() throws Throwable { + QueryServiceNetworks queryServiceNetworks0 = new QueryServiceNetworks(); + List<NetworkResourceCustomization> list0 = queryServiceNetworks0.getServiceNetworks(); + assertTrue(list0.isEmpty()); + } + + @Test(timeout = 4000) + public void test9() throws Throwable { + QueryServiceNetworks queryServiceNetworks0 = new QueryServiceNetworks(); + // Undeclared exception! + try { + queryServiceNetworks0.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); + } + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryServiceNetworksESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryServiceNetworksESTestscaffolding.java new file mode 100644 index 0000000000..e47d9b2a5b --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryServiceNetworksESTestscaffolding.java @@ -0,0 +1,265 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Feb 20 14:04:40 GMT 2017 + */ + +package org.openecomp.mso.adapters.catalogrest; + +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 QueryServiceNetworksESTestscaffolding { + + @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.catalogrest.QueryServiceNetworks"; + 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(QueryServiceNetworksESTestscaffolding.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.JsonProcessingException", + "org.codehaus.jackson.map.introspect.AnnotationMap", + "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", + "com.att.eelf.i18n.EELFResolvableErrorEnum", + "org.codehaus.jackson.node.BaseJsonNode", + "org.openecomp.mso.logger.MsoLogger$StatusCode", + "org.codehaus.jackson.map.ObjectReader", + "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.JsonSerializer", + "org.codehaus.jackson.map.introspect.AnnotatedWithParams", + "com.att.eelf.i18n.EELFMsgs", + "org.codehaus.jackson.map.AnnotationIntrospector", + "org.codehaus.jackson.map.MappingJsonFactory", + "com.att.eelf.configuration.EELFLogger$Level", + "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.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.openecomp.mso.db.catalog.beans.NetworkResourceCustomization", + "org.codehaus.jackson.map.type.TypeBase", + "org.codehaus.jackson.map.ser.BasicSerializerFactory", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "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.NopAnnotationIntrospector", + "com.att.eelf.configuration.EELFLogger", + "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.JsonEncoding", + "org.codehaus.jackson.map.type.MapLikeType", + "org.codehaus.jackson.map.JsonDeserializer", + "org.codehaus.jackson.map.PropertyNamingStrategy$PropertyNamingStrategyBase", + "org.codehaus.jackson.node.ObjectNode", + "org.openecomp.mso.logger.MsoLogger$ErrorCode", + "org.codehaus.jackson.map.ser.std.SerializerBase", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$MinimalMethodFilter", + "org.codehaus.jackson.map.type.CollectionLikeType", + "org.openecomp.mso.logger.MessageEnum", + "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.map.util.StdDateFormat", + "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", + "com.att.eelf.configuration.SLF4jWrapper", + "org.codehaus.jackson.FormatSchema", + "org.codehaus.jackson.format.MatchStrength", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.codehaus.jackson.ObjectCodec", + "org.codehaus.jackson.map.introspect.AnnotatedMethod", + "org.openecomp.mso.db.catalog.utils.MavenLikeVersioning", + "org.codehaus.jackson.JsonGenerationException", + "org.openecomp.mso.entity.MsoRequest", + "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.logger.MsoLogger$ResponseCode", + "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.MappingIterator", + "org.codehaus.jackson.map.annotate.JsonSerialize$Inclusion", + "org.codehaus.jackson.map.DeserializationContext", + "org.codehaus.jackson.impl.JsonParserBase", + "org.codehaus.jackson.map.ObjectMapper$DefaultTyping", + "org.codehaus.jackson.map.JsonMappingException", + "org.codehaus.jackson.map.introspect.AnnotatedMember", + "org.codehaus.jackson.node.JsonNodeFactory", + "org.codehaus.jackson.type.JavaType", + "com.att.eelf.i18n.EELFResourceManager", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.annotate.JsonTypeInfo$As", + "org.codehaus.jackson.JsonParser", + "org.codehaus.jackson.node.NullNode", + "org.codehaus.jackson.map.InjectableValues", + "org.codehaus.jackson.map.jsontype.impl.StdSubtypeResolver", + "org.codehaus.jackson.node.TreeTraversingParser", + "org.codehaus.jackson.map.type.CollectionType", + "com.att.eelf.configuration.EELFManager", + "org.codehaus.jackson.map.MapperConfig", + "org.codehaus.jackson.map.Module$SetupContext", + "org.openecomp.mso.adapters.catalogrest.QueryServiceNetworks", + "org.codehaus.jackson.io.UTF8Writer", + "org.openecomp.mso.db.catalog.beans.NetworkResource", + "org.codehaus.jackson.map.introspect.VisibilityChecker$1", + "org.codehaus.jackson.map.type.MapType", + "org.codehaus.jackson.annotate.JsonAutoDetect", + "org.codehaus.jackson.map.type.ArrayType", + "org.openecomp.mso.logger.MsoLogger", + "org.codehaus.jackson.map.ClassIntrospector$MixInResolver" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(QueryServiceNetworksESTestscaffolding.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.catalogrest.QueryServiceNetworks", + "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/catalogrest/QueryServiceVnfsESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryServiceVnfsESTest.java new file mode 100644 index 0000000000..4f963032d0 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryServiceVnfsESTest.java @@ -0,0 +1,188 @@ +/* + * This file was automatically generated by EvoSuite + * Wed Feb 22 12:31:50 GMT 2017 + */ + +package org.openecomp.mso.adapters.catalogrest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.MockitoExtension.*; +import static org.evosuite.runtime.EvoAssertions.*; +import java.util.Collection; +import java.util.ConcurrentModificationException; +import java.util.LinkedList; +import java.util.List; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; +import org.openecomp.mso.adapters.catalogrest.QueryServiceVnfs; +import org.openecomp.mso.db.catalog.beans.VnfResource; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class QueryServiceVnfsESTest extends QueryServiceVnfsESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + QueryServiceVnfs queryServiceVnfs0 = new QueryServiceVnfs(); + queryServiceVnfs0.setServiceVnfs((List<VnfResource>) null); + List<VnfResource> list0 = queryServiceVnfs0.getServiceVnfs(); + assertNull(list0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + LinkedList<VnfResource> linkedList0 = new LinkedList<VnfResource>(); + VnfResource vnfResource0 = new VnfResource(); + linkedList0.add(vnfResource0); + List<VnfResource> list0 = linkedList0.subList(1, 1); + linkedList0.add(vnfResource0); + QueryServiceVnfs queryServiceVnfs0 = new QueryServiceVnfs(); + queryServiceVnfs0.setServiceVnfs(list0); + // Undeclared exception! + try { + queryServiceVnfs0.toString(); + fail("Expecting exception: ConcurrentModificationException"); + + } catch(ConcurrentModificationException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("java.util.SubList", e); + } + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + QueryServiceVnfs queryServiceVnfs0 = new QueryServiceVnfs(); + queryServiceVnfs0.setServiceVnfs((List<VnfResource>) null); + // Undeclared exception! + try { + queryServiceVnfs0.toString(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.adapters.catalogrest.QueryServiceVnfs", e); + } + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + LinkedList<VnfResource> linkedList0 = new LinkedList<VnfResource>(); + QueryServiceVnfs queryServiceVnfs0 = new QueryServiceVnfs(); + Object[] objectArray0 = new Object[3]; + objectArray0[1] = (Object) queryServiceVnfs0; + queryServiceVnfs0.setServiceVnfs(linkedList0); + Collection<VnfResource> collection0 = (Collection<VnfResource>) mock(Collection.class, new ViolatedAssumptionAnswer()); + doReturn(objectArray0).when(collection0).toArray(); + linkedList0.addAll(collection0); + // Undeclared exception! + try { + queryServiceVnfs0.toString(); + fail("Expecting exception: ClassCastException"); + + } catch(ClassCastException e) { + // + // org.openecomp.mso.adapters.catalogrest.QueryServiceVnfs cannot be cast to org.openecomp.mso.db.catalog.beans.VnfResource + // + verifyException("org.openecomp.mso.adapters.catalogrest.QueryServiceVnfs", e); + } + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + LinkedList<VnfResource> linkedList0 = new LinkedList<VnfResource>(); + linkedList0.add((VnfResource) null); + QueryServiceVnfs queryServiceVnfs0 = null; + try { + queryServiceVnfs0 = new QueryServiceVnfs((List<VnfResource>) linkedList0); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.adapters.catalogrest.QueryServiceVnfs", e); + } + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + LinkedList<VnfResource> linkedList0 = new LinkedList<VnfResource>(); + QueryServiceVnfs queryServiceVnfs0 = new QueryServiceVnfs(); + Object[] objectArray0 = new Object[8]; + objectArray0[0] = (Object) queryServiceVnfs0; + Collection<VnfResource> collection0 = (Collection<VnfResource>) mock(Collection.class, new ViolatedAssumptionAnswer()); + doReturn(objectArray0).when(collection0).toArray(); + linkedList0.addAll(0, collection0); + QueryServiceVnfs queryServiceVnfs1 = null; + try { + queryServiceVnfs1 = new QueryServiceVnfs((List<VnfResource>) linkedList0); + fail("Expecting exception: ClassCastException"); + + } catch(ClassCastException e) { + // + // org.openecomp.mso.adapters.catalogrest.QueryServiceVnfs cannot be cast to org.openecomp.mso.db.catalog.beans.VnfResource + // + verifyException("org.openecomp.mso.adapters.catalogrest.QueryServiceVnfs", e); + } + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + LinkedList<VnfResource> linkedList0 = new LinkedList<VnfResource>(); + VnfResource vnfResource0 = new VnfResource(); + linkedList0.add(vnfResource0); + QueryServiceVnfs queryServiceVnfs0 = new QueryServiceVnfs(); + queryServiceVnfs0.setServiceVnfs(linkedList0); + linkedList0.add(vnfResource0); + String string0 = queryServiceVnfs0.toString(); + assertEquals("1\tVNF=null,version=null,mode=null,template=null,envtId=null,asdcUuid=null,aicVersionMin=null,aicVersionMax=null,modelInvariantUuid=null,modelVersion=null,modelCustomizationName=null,modelName=null,serviceModelInvariantUUID=null,modelCustomizationUuid=nullVfModules: NONE1\t\nVNF=null,version=null,mode=null,template=null,envtId=null,asdcUuid=null,aicVersionMin=null,aicVersionMax=null,modelInvariantUuid=null,modelVersion=null,modelCustomizationName=null,modelName=null,serviceModelInvariantUUID=null,modelCustomizationUuid=nullVfModules: NONE", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + QueryServiceVnfs queryServiceVnfs0 = new QueryServiceVnfs(); + String string0 = queryServiceVnfs0.toString(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + LinkedList<VnfResource> linkedList0 = new LinkedList<VnfResource>(); + VnfResource vnfResource0 = new VnfResource(); + linkedList0.add(vnfResource0); + QueryServiceVnfs queryServiceVnfs0 = new QueryServiceVnfs((List<VnfResource>) linkedList0); + List<VnfResource> list0 = queryServiceVnfs0.getServiceVnfs(); + assertEquals(1, list0.size()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + QueryServiceVnfs queryServiceVnfs0 = new QueryServiceVnfs(); + List<VnfResource> list0 = queryServiceVnfs0.getServiceVnfs(); + queryServiceVnfs0.setServiceVnfs(list0); + assertTrue(list0.isEmpty()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + QueryServiceVnfs queryServiceVnfs0 = new QueryServiceVnfs(); + // Undeclared exception! + try { + queryServiceVnfs0.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); + } + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryServiceVnfsESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryServiceVnfsESTestscaffolding.java new file mode 100644 index 0000000000..aa9a411de2 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/catalogrest/QueryServiceVnfsESTestscaffolding.java @@ -0,0 +1,264 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Feb 20 14:04:40 GMT 2017 + */ + +package org.openecomp.mso.adapters.catalogrest; + +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 QueryServiceVnfsESTestscaffolding { + + @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.catalogrest.QueryServiceVnfs"; + 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(QueryServiceVnfsESTestscaffolding.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.JsonProcessingException", + "org.codehaus.jackson.map.introspect.AnnotationMap", + "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", + "com.att.eelf.i18n.EELFResolvableErrorEnum", + "org.codehaus.jackson.node.BaseJsonNode", + "org.openecomp.mso.logger.MsoLogger$StatusCode", + "org.codehaus.jackson.map.ObjectReader", + "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.JsonSerializer", + "org.codehaus.jackson.map.introspect.AnnotatedWithParams", + "com.att.eelf.i18n.EELFMsgs", + "org.codehaus.jackson.map.AnnotationIntrospector", + "org.codehaus.jackson.map.MappingJsonFactory", + "com.att.eelf.configuration.EELFLogger$Level", + "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.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", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "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.NopAnnotationIntrospector", + "com.att.eelf.configuration.EELFLogger", + "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.JsonEncoding", + "org.codehaus.jackson.map.type.MapLikeType", + "org.codehaus.jackson.map.JsonDeserializer", + "org.openecomp.mso.db.catalog.beans.VnfResource", + "org.codehaus.jackson.map.PropertyNamingStrategy$PropertyNamingStrategyBase", + "org.codehaus.jackson.node.ObjectNode", + "org.openecomp.mso.logger.MsoLogger$ErrorCode", + "org.codehaus.jackson.map.ser.std.SerializerBase", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$MinimalMethodFilter", + "org.codehaus.jackson.map.type.CollectionLikeType", + "org.openecomp.mso.logger.MessageEnum", + "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.map.util.StdDateFormat", + "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", + "com.att.eelf.configuration.SLF4jWrapper", + "org.codehaus.jackson.FormatSchema", + "org.codehaus.jackson.format.MatchStrength", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.codehaus.jackson.ObjectCodec", + "org.codehaus.jackson.map.introspect.AnnotatedMethod", + "org.openecomp.mso.db.catalog.utils.MavenLikeVersioning", + "org.codehaus.jackson.JsonGenerationException", + "org.openecomp.mso.entity.MsoRequest", + "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.logger.MsoLogger$ResponseCode", + "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.impl.JsonParserBase", + "org.codehaus.jackson.map.ObjectMapper$DefaultTyping", + "org.codehaus.jackson.map.JsonMappingException", + "org.codehaus.jackson.map.introspect.AnnotatedMember", + "org.codehaus.jackson.node.JsonNodeFactory", + "org.codehaus.jackson.type.JavaType", + "com.att.eelf.i18n.EELFResourceManager", + "org.codehaus.jackson.map.introspect.VisibilityChecker$Std", + "org.codehaus.jackson.annotate.JsonTypeInfo$As", + "org.codehaus.jackson.JsonParser", + "org.codehaus.jackson.node.NullNode", + "org.codehaus.jackson.map.InjectableValues", + "org.codehaus.jackson.map.jsontype.impl.StdSubtypeResolver", + "org.codehaus.jackson.node.TreeTraversingParser", + "org.codehaus.jackson.map.type.CollectionType", + "com.att.eelf.configuration.EELFManager", + "org.codehaus.jackson.map.MapperConfig", + "org.codehaus.jackson.map.Module$SetupContext", + "org.codehaus.jackson.io.UTF8Writer", + "org.codehaus.jackson.map.introspect.VisibilityChecker$1", + "org.codehaus.jackson.map.type.MapType", + "org.codehaus.jackson.annotate.JsonAutoDetect", + "org.openecomp.mso.adapters.catalogrest.QueryServiceVnfs", + "org.codehaus.jackson.map.type.ArrayType", + "org.openecomp.mso.logger.MsoLogger", + "org.codehaus.jackson.map.ClassIntrospector$MixInResolver" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(QueryServiceVnfsESTestscaffolding.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.catalogrest.QueryServiceVnfs", + "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/sdncrest/RequestInformationESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/RequestInformationESTest.java new file mode 100644 index 0000000000..293a91e4f3 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/RequestInformationESTest.java @@ -0,0 +1,108 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Feb 20 14:10:13 GMT 2017 + */ + +package org.openecomp.mso.adapters.sdncrest; + +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 RequestInformationESTest extends RequestInformationESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + RequestInformation requestInformation0 = new RequestInformation(); + String string0 = requestInformation0.getSource(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + RequestInformation requestInformation0 = new RequestInformation("", "", ""); + String string0 = requestInformation0.getSource(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + RequestInformation requestInformation0 = new RequestInformation(); + String string0 = requestInformation0.getRequestId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + RequestInformation requestInformation0 = new RequestInformation("82W?GC", "", "82W?GC"); + String string0 = requestInformation0.getNotificationUrl(); + assertEquals("82W?GC", string0); + assertEquals("82W?GC", requestInformation0.getRequestId()); + assertEquals("", requestInformation0.getSource()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + RequestInformation requestInformation0 = new RequestInformation("", "3*5=IrA", ""); + String string0 = requestInformation0.getSource(); + assertEquals("3*5=IrA", string0); + assertEquals("", requestInformation0.getNotificationUrl()); + assertEquals("", requestInformation0.getRequestId()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + RequestInformation requestInformation0 = new RequestInformation("", "3*5=IrA", ""); + assertEquals("", requestInformation0.getRequestId()); + + requestInformation0.setRequestId("3*5=IrA"); + requestInformation0.getRequestId(); + assertEquals("3*5=IrA", requestInformation0.getSource()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + RequestInformation requestInformation0 = new RequestInformation(); + String string0 = requestInformation0.getNotificationUrl(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + RequestInformation requestInformation0 = new RequestInformation("", "3*5=IrA", ""); + assertEquals("", requestInformation0.getNotificationUrl()); + + requestInformation0.setNotificationUrl("3*5=IrA"); + assertEquals("3*5=IrA", requestInformation0.getSource()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + RequestInformation requestInformation0 = new RequestInformation("", "3*5=IrA", ""); + String string0 = requestInformation0.getNotificationUrl(); + assertEquals("", string0); + assertEquals("", requestInformation0.getRequestId()); + assertEquals("3*5=IrA", requestInformation0.getSource()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + RequestInformation requestInformation0 = new RequestInformation("", "3*5=IrA", ""); + String string0 = requestInformation0.getRequestId(); + assertEquals("", string0); + assertEquals("", requestInformation0.getNotificationUrl()); + assertEquals("3*5=IrA", requestInformation0.getSource()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + RequestInformation requestInformation0 = new RequestInformation("", "3*5=IrA", ""); + assertEquals("3*5=IrA", requestInformation0.getSource()); + + requestInformation0.setSource(""); + assertEquals("", requestInformation0.getNotificationUrl()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/RequestInformationESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/RequestInformationESTestscaffolding.java new file mode 100644 index 0000000000..a2d81096c4 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/RequestInformationESTestscaffolding.java @@ -0,0 +1,81 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Feb 20 14:10:13 GMT 2017 + */ + +package org.openecomp.mso.adapters.sdncrest; + +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 RequestInformationESTestscaffolding { + + @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.sdncrest.RequestInformation"; + 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(RequestInformationESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.sdncrest.RequestInformation" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(RequestInformationESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.sdncrest.RequestInformation" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCErrorCommonESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCErrorCommonESTest.java new file mode 100644 index 0000000000..047735f8d9 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCErrorCommonESTest.java @@ -0,0 +1,28 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Feb 20 14:06:32 GMT 2017 + */ + +package org.openecomp.mso.adapters.sdncrest; + +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 SDNCErrorCommonESTest extends SDNCErrorCommonESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + SDNCServiceError sDNCServiceError0 = new SDNCServiceError(); + assertNull(sDNCServiceError0.getAckFinalIndicator()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + SDNCServiceError sDNCServiceError0 = new SDNCServiceError("8F;T;=}$'$-(v5P;/wC", "8F;T;=}$'$-(v5P;/wC", "", ""); + assertEquals("8F;T;=}$'$-(v5P;/wC", sDNCServiceError0.getSDNCRequestId()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCErrorCommonESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCErrorCommonESTestscaffolding.java new file mode 100644 index 0000000000..e90d27a622 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCErrorCommonESTestscaffolding.java @@ -0,0 +1,96 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Feb 20 14:06:32 GMT 2017 + */ + +package org.openecomp.mso.adapters.sdncrest; + +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 SDNCErrorCommonESTestscaffolding { + + @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.sdncrest.SDNCErrorCommon"; + 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(SDNCErrorCommonESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.sdncrest.SDNCErrorCommon", + "org.openecomp.mso.adapters.sdncrest.SDNCServiceError", + "org.codehaus.jackson.map.annotate.JsonSerialize$Typing", + "org.codehaus.jackson.map.annotate.JsonSerialize$Inclusion", + "org.openecomp.mso.adapters.sdncrest.SDNCResponseCommon", + "org.codehaus.jackson.map.JsonSerializer", + "org.codehaus.jackson.map.JsonSerializer$None", + "org.codehaus.jackson.map.annotate.NoClass", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonSerialize", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(SDNCErrorCommonESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.annotate.JsonSerialize$Inclusion", + "org.codehaus.jackson.map.annotate.JsonSerialize$Typing", + "org.openecomp.mso.adapters.sdncrest.SDNCServiceError", + "org.openecomp.mso.adapters.sdncrest.SDNCResponseCommon", + "org.openecomp.mso.adapters.sdncrest.SDNCErrorCommon" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceErrorESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceErrorESTest.java new file mode 100644 index 0000000000..3a980a345f --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceErrorESTest.java @@ -0,0 +1,28 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Feb 20 14:12:21 GMT 2017 + */ + +package org.openecomp.mso.adapters.sdncrest; + +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 SDNCServiceErrorESTest extends SDNCServiceErrorESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + SDNCServiceError sDNCServiceError0 = new SDNCServiceError("org.openecomp.mso.adapters.sdncrest.SDNCServiceError", "org.openecomp.mso.adapters.sdncrest.SDNCServiceError", "org.openecomp.mso.adapters.sdncrest.SDNCServiceError", ""); + assertEquals("org.openecomp.mso.adapters.sdncrest.SDNCServiceError", sDNCServiceError0.getSDNCRequestId()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + SDNCServiceError sDNCServiceError0 = new SDNCServiceError(); + assertNull(sDNCServiceError0.getResponseCode()); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceErrorESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceErrorESTestscaffolding.java new file mode 100644 index 0000000000..0baefc00dc --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceErrorESTestscaffolding.java @@ -0,0 +1,96 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Feb 20 14:12:21 GMT 2017 + */ + +package org.openecomp.mso.adapters.sdncrest; + +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 SDNCServiceErrorESTestscaffolding { + + @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.sdncrest.SDNCServiceError"; + 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(SDNCServiceErrorESTestscaffolding.class.getClassLoader() , + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.openecomp.mso.adapters.sdncrest.SDNCErrorCommon", + "org.openecomp.mso.adapters.sdncrest.SDNCServiceError", + "org.codehaus.jackson.map.annotate.JsonSerialize$Typing", + "org.codehaus.jackson.map.annotate.JsonSerialize$Inclusion", + "org.openecomp.mso.adapters.sdncrest.SDNCResponseCommon", + "org.codehaus.jackson.map.annotate.NoClass", + "org.codehaus.jackson.map.JsonSerializer", + "org.codehaus.jackson.map.JsonSerializer$None", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.codehaus.jackson.map.annotate.JsonSerialize", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(SDNCServiceErrorESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.annotate.JsonSerialize$Typing", + "org.codehaus.jackson.map.annotate.JsonSerialize$Inclusion", + "org.openecomp.mso.adapters.sdncrest.SDNCResponseCommon", + "org.openecomp.mso.adapters.sdncrest.SDNCErrorCommon", + "org.openecomp.mso.adapters.sdncrest.SDNCServiceError" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceRequestESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceRequestESTest.java new file mode 100644 index 0000000000..5df036600a --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceRequestESTest.java @@ -0,0 +1,172 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Feb 20 14:08:11 GMT 2017 + */ + +package org.openecomp.mso.adapters.sdncrest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; + +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 SDNCServiceRequestESTest extends SDNCServiceRequestESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + RequestInformation requestInformation0 = mock(RequestInformation.class, new ViolatedAssumptionAnswer()); + ServiceInformation serviceInformation0 = mock(ServiceInformation.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(serviceInformation0).toString(); + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest("org.openecomp.mso.adapters.sdncrest.SDNCServiceRequest", "org.openecomp.mso.adapters.sdncrest.SDNCServiceRequest", "", "{", "org.openecomp.mso.adapters.sdncrest.SDNCServiceRequest", requestInformation0, serviceInformation0, "6`.", "{"); + sDNCServiceRequest0.getServiceInformation(); + assertEquals("{", sDNCServiceRequest0.getSDNCService()); + assertEquals("{", sDNCServiceRequest0.getSDNCServiceData()); + assertEquals("org.openecomp.mso.adapters.sdncrest.SDNCServiceRequest", sDNCServiceRequest0.getSDNCOperation()); + assertEquals("6`.", sDNCServiceRequest0.getSDNCServiceDataType()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest(); + sDNCServiceRequest0.setSDNCServiceDataType("2u]\"aLx"); + String string0 = sDNCServiceRequest0.getSDNCServiceDataType(); + assertEquals("2u]\"aLx", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest(); + sDNCServiceRequest0.setSDNCServiceData("}=uO{e7dUj.<"); + String string0 = sDNCServiceRequest0.getSDNCServiceData(); + assertEquals("}=uO{e7dUj.<", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest(); + sDNCServiceRequest0.setSDNCServiceData(""); + String string0 = sDNCServiceRequest0.getSDNCServiceData(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + RequestInformation requestInformation0 = mock(RequestInformation.class, new ViolatedAssumptionAnswer()); + ServiceInformation serviceInformation0 = mock(ServiceInformation.class, new ViolatedAssumptionAnswer()); + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest("STATIC", "STATIC", "", "", "STATIC", requestInformation0, serviceInformation0, "STATIC", "+VFyyH0:WXAf=Y+|K"); + String string0 = sDNCServiceRequest0.getSDNCService(); + assertEquals("", string0); + assertEquals("STATIC", sDNCServiceRequest0.getSDNCServiceDataType()); + assertEquals("STATIC", sDNCServiceRequest0.getSDNCOperation()); + assertEquals("+VFyyH0:WXAf=Y+|K", sDNCServiceRequest0.getSDNCServiceData()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest(); + String string0 = sDNCServiceRequest0.getSDNCOperation(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest(); + sDNCServiceRequest0.setSDNCOperation(""); + String string0 = sDNCServiceRequest0.getSDNCOperation(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest(); + RequestInformation requestInformation0 = mock(RequestInformation.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(requestInformation0).toString(); + sDNCServiceRequest0.setRequestInformation(requestInformation0); + RequestInformation requestInformation1 = sDNCServiceRequest0.getRequestInformation(); + assertSame(requestInformation1, requestInformation0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest(); + String string0 = sDNCServiceRequest0.getSDNCServiceDataType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest(); + String string0 = sDNCServiceRequest0.getSDNCService(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + RequestInformation requestInformation0 = mock(RequestInformation.class, new ViolatedAssumptionAnswer()); + ServiceInformation serviceInformation0 = mock(ServiceInformation.class, new ViolatedAssumptionAnswer()); + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest("STATIC", "STATIC", "", "", "STATIC", requestInformation0, serviceInformation0, "STATIC", "+VFyyH0:WXAf=Y+|K"); + String string0 = sDNCServiceRequest0.getSDNCOperation(); + assertEquals("", sDNCServiceRequest0.getSDNCService()); + assertEquals("+VFyyH0:WXAf=Y+|K", sDNCServiceRequest0.getSDNCServiceData()); + assertEquals("STATIC", string0); + assertEquals("STATIC", sDNCServiceRequest0.getSDNCServiceDataType()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest(); + ServiceInformation serviceInformation0 = sDNCServiceRequest0.getServiceInformation(); + assertNull(serviceInformation0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest(); + RequestInformation requestInformation0 = sDNCServiceRequest0.getRequestInformation(); + assertNull(requestInformation0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + RequestInformation requestInformation0 = mock(RequestInformation.class, new ViolatedAssumptionAnswer()); + ServiceInformation serviceInformation0 = mock(ServiceInformation.class, new ViolatedAssumptionAnswer()); + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest("33M*~O'k?", "33M*~O'k?", "33M*~O'k?", "33M*~O'k?", "33M*~O'k?", requestInformation0, serviceInformation0, "33M*~O'k?", "[t["); + sDNCServiceRequest0.setServiceInformation((ServiceInformation) null); + assertEquals("33M*~O'k?", sDNCServiceRequest0.getSDNCService()); + assertEquals("[t[", sDNCServiceRequest0.getSDNCServiceData()); + assertEquals("33M*~O'k?", sDNCServiceRequest0.getSDNCOperation()); + assertEquals("33M*~O'k?", sDNCServiceRequest0.getSDNCServiceDataType()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + RequestInformation requestInformation0 = mock(RequestInformation.class, new ViolatedAssumptionAnswer()); + ServiceInformation serviceInformation0 = mock(ServiceInformation.class, new ViolatedAssumptionAnswer()); + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest("", "M6Oxa*g8~:)0BdUFX/", "org.openecomp.mso.adapters.sdncrest.SDNCServiceRequest", "M6Oxa*g8~:)0BdUFX/", "org.openecomp.mso.adapters.sdncrest.SDNCServiceRequest", requestInformation0, serviceInformation0, "", "TWqSFP>PXW"); + String string0 = sDNCServiceRequest0.getSDNCServiceDataType(); + assertEquals("org.openecomp.mso.adapters.sdncrest.SDNCServiceRequest", sDNCServiceRequest0.getSDNCOperation()); + assertEquals("TWqSFP>PXW", sDNCServiceRequest0.getSDNCServiceData()); + assertEquals("", string0); + assertEquals("M6Oxa*g8~:)0BdUFX/", sDNCServiceRequest0.getSDNCService()); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest(); + String string0 = sDNCServiceRequest0.getSDNCServiceData(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + SDNCServiceRequest sDNCServiceRequest0 = new SDNCServiceRequest(); + sDNCServiceRequest0.setSDNCService("-3eOw~BRI3K>O"); + String string0 = sDNCServiceRequest0.getSDNCService(); + assertEquals("-3eOw~BRI3K>O", string0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceRequestESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceRequestESTestscaffolding.java new file mode 100644 index 0000000000..4de6c0ca7c --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceRequestESTestscaffolding.java @@ -0,0 +1,110 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Feb 20 14:08:11 GMT 2017 + */ + +package org.openecomp.mso.adapters.sdncrest; + +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 SDNCServiceRequestESTestscaffolding { + + @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.sdncrest.SDNCServiceRequest"; + 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(SDNCServiceRequestESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.sdncrest.ServiceInformation", + "org.openecomp.mso.adapters.sdncrest.SDNCRequestCommon", + "org.codehaus.jackson.map.annotate.JsonSerialize$Typing", + "org.codehaus.jackson.map.annotate.JsonSerialize$Inclusion", + "org.codehaus.jackson.map.JsonSerializer", + "org.openecomp.mso.adapters.sdncrest.SDNCServiceRequest", + "org.jboss.resteasy.annotations.providers.NoJackson", + "org.openecomp.mso.adapters.sdncrest.RequestInformation", + "org.codehaus.jackson.annotate.JacksonAnnotation", + "org.codehaus.jackson.map.annotate.NoClass", + "org.codehaus.jackson.map.JsonSerializer$None", + "org.codehaus.jackson.map.annotate.JsonSerialize", + "org.codehaus.jackson.map.annotate.JsonRootName" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(SDNCServiceRequestESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.annotate.JsonSerialize$Inclusion", + "org.codehaus.jackson.map.annotate.JsonSerialize$Typing", + "org.openecomp.mso.adapters.sdncrest.ServiceInformation", + "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.sdncrest.RequestInformation", + "org.openecomp.mso.adapters.sdncrest.SDNCRequestCommon", + "org.openecomp.mso.adapters.sdncrest.SDNCServiceRequest" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceResponseESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceResponseESTest.java new file mode 100644 index 0000000000..fc05ed5b6c --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceResponseESTest.java @@ -0,0 +1,63 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Feb 20 14:07:08 GMT 2017 + */ + +package org.openecomp.mso.adapters.sdncrest; + +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 SDNCServiceResponseESTest extends SDNCServiceResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + SDNCServiceResponse sDNCServiceResponse0 = new SDNCServiceResponse(); + sDNCServiceResponse0.addParam((String) null, ""); + assertNull(sDNCServiceResponse0.getResponseMessage()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + SDNCServiceResponse sDNCServiceResponse0 = new SDNCServiceResponse(); + sDNCServiceResponse0.addParam("", ""); + Map<String, String> map0 = sDNCServiceResponse0.getParams(); + assertEquals(1, map0.size()); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + SDNCServiceResponse sDNCServiceResponse0 = new SDNCServiceResponse(); + sDNCServiceResponse0.addParam("", ""); + sDNCServiceResponse0.addParam("DYNAMIC", "DYNAMIC"); + assertNull(sDNCServiceResponse0.getResponseMessage()); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + SDNCServiceResponse sDNCServiceResponse0 = new SDNCServiceResponse(); + HashMap<String, String> hashMap0 = new HashMap<String, String>(); + sDNCServiceResponse0.setParams(hashMap0); + Map<String, String> map0 = sDNCServiceResponse0.getParams(); + assertEquals(0, map0.size()); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + SDNCServiceResponse sDNCServiceResponse0 = new SDNCServiceResponse("", "", "", ""); + assertEquals("", sDNCServiceResponse0.getResponseCode()); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + SDNCServiceResponse sDNCServiceResponse0 = new SDNCServiceResponse(); + Map<String, String> map0 = sDNCServiceResponse0.getParams(); + assertNull(map0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceResponseESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceResponseESTestscaffolding.java new file mode 100644 index 0000000000..243140efff --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceResponseESTestscaffolding.java @@ -0,0 +1,246 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Feb 20 14:07:08 GMT 2017 + */ + +package org.openecomp.mso.adapters.sdncrest; + +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 SDNCServiceResponseESTestscaffolding { + + @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.sdncrest.SDNCServiceResponse"; + 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(SDNCServiceResponseESTestscaffolding.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.JsonSerializer", + "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.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.annotate.JsonSerialize$Typing", + "org.codehaus.jackson.map.type.TypeBase", + "org.codehaus.jackson.map.ser.BasicSerializerFactory", + "org.openecomp.mso.adapters.sdncrest.SDNCServiceResponse", + "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.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.codehaus.jackson.map.jsontype.TypeResolverBuilder", + "org.codehaus.jackson.map.type.HierarchicType", + "org.openecomp.mso.adapters.sdncrest.SDNCResponseCommon", + "org.codehaus.jackson.map.introspect.BasicClassIntrospector$GetterMethodFilter", + "org.codehaus.jackson.JsonParser$Feature", + "org.codehaus.jackson.map.annotate.JsonSerialize", + "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.map.annotate.JsonSerialize$Inclusion", + "org.codehaus.jackson.util.TokenBuffer", + "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.annotate.NoClass", + "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.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.codehaus.jackson.map.type.MapType", + "org.codehaus.jackson.map.JsonSerializer$None", + "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(SDNCServiceResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.codehaus.jackson.map.annotate.JsonSerialize$Inclusion", + "org.codehaus.jackson.map.annotate.JsonSerialize$Typing", + "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.sdncrest.SDNCResponseCommon", + "org.openecomp.mso.adapters.sdncrest.SDNCServiceResponse" + ); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/ServiceInformationESTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/ServiceInformationESTest.java new file mode 100644 index 0000000000..0cfe6dcd67 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/ServiceInformationESTest.java @@ -0,0 +1,118 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Feb 20 14:09:38 GMT 2017 + */ + +package org.openecomp.mso.adapters.sdncrest; + +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 ServiceInformationESTest extends ServiceInformationESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + ServiceInformation serviceInformation0 = new ServiceInformation("J|^", ":N1Q`D JY", "org.openecomp.mso.adapters.sdncrest.ServiceInformation", ":N1Q`D JY"); + String string0 = serviceInformation0.getSubscriberName(); + assertEquals("org.openecomp.mso.adapters.sdncrest.ServiceInformation", string0); + assertEquals("J|^", serviceInformation0.getServiceType()); + assertEquals(":N1Q`D JY", serviceInformation0.getSubscriberGlobalId()); + assertEquals(":N1Q`D JY", serviceInformation0.getServiceInstanceId()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + ServiceInformation serviceInformation0 = new ServiceInformation("", (String) null, "", ""); + String string0 = serviceInformation0.getSubscriberName(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + ServiceInformation serviceInformation0 = new ServiceInformation("J|^", ":N1Q`D JY", "org.openecomp.mso.adapters.sdncrest.ServiceInformation", ":N1Q`D JY"); + String string0 = serviceInformation0.getSubscriberGlobalId(); + assertEquals(":N1Q`D JY", serviceInformation0.getServiceInstanceId()); + assertEquals("org.openecomp.mso.adapters.sdncrest.ServiceInformation", serviceInformation0.getSubscriberName()); + assertEquals("J|^", serviceInformation0.getServiceType()); + assertEquals(":N1Q`D JY", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + ServiceInformation serviceInformation0 = new ServiceInformation(); + serviceInformation0.setSubscriberGlobalId(""); + String string0 = serviceInformation0.getSubscriberGlobalId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + ServiceInformation serviceInformation0 = new ServiceInformation(); + serviceInformation0.setServiceType("org.openecomp.mso.adapters.sdncrest.ServiceInformation"); + String string0 = serviceInformation0.getServiceType(); + assertEquals("org.openecomp.mso.adapters.sdncrest.ServiceInformation", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + ServiceInformation serviceInformation0 = new ServiceInformation(); + serviceInformation0.setServiceInstanceId("q3jc2(qb=E+3uz_L%"); + String string0 = serviceInformation0.getServiceInstanceId(); + assertEquals("q3jc2(qb=E+3uz_L%", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + ServiceInformation serviceInformation0 = new ServiceInformation(); + serviceInformation0.setServiceInstanceId(""); + String string0 = serviceInformation0.getServiceInstanceId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + ServiceInformation serviceInformation0 = new ServiceInformation(); + String string0 = serviceInformation0.getSubscriberName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + ServiceInformation serviceInformation0 = new ServiceInformation(); + serviceInformation0.setSubscriberName((String) null); + assertNull(serviceInformation0.getServiceInstanceId()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + ServiceInformation serviceInformation0 = new ServiceInformation(); + String string0 = serviceInformation0.getServiceInstanceId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + ServiceInformation serviceInformation0 = new ServiceInformation(); + String string0 = serviceInformation0.getSubscriberGlobalId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + ServiceInformation serviceInformation0 = new ServiceInformation(); + String string0 = serviceInformation0.getServiceType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + ServiceInformation serviceInformation0 = new ServiceInformation(); + serviceInformation0.setServiceType(""); + String string0 = serviceInformation0.getServiceType(); + assertEquals("", string0); + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/ServiceInformationESTestscaffolding.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/ServiceInformationESTestscaffolding.java new file mode 100644 index 0000000000..c9d31980c2 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/ServiceInformationESTestscaffolding.java @@ -0,0 +1,81 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Feb 20 14:09:38 GMT 2017 + */ + +package org.openecomp.mso.adapters.sdncrest; + +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 ServiceInformationESTestscaffolding { + + @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.sdncrest.ServiceInformation"; + 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(ServiceInformationESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.adapters.sdncrest.ServiceInformation" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ServiceInformationESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.adapters.sdncrest.ServiceInformation" + ); + } +} 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 index b6719ef398..77f48a1232 100644 --- 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 @@ -1,193 +1,127 @@ /* * This file was automatically generated by EvoSuite - * Mon Nov 14 09:29:29 GMT 2016 + * Mon Feb 20 14:10:17 GMT 2017 */ 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; +import org.openecomp.mso.adapters.vnfrest.CreateVfModuleResponse; +import org.openecomp.mso.adapters.vnfrest.VfModuleRollback; -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +@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()); - } + @Test(timeout = 4000) + public void test00() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + createVfModuleResponse0.setVnfId(""); + String string0 = createVfModuleResponse0.getVnfId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + createVfModuleResponse0.setVfModuleStackId("}V=E6z^$czD"); + String string0 = createVfModuleResponse0.getVfModuleStackId(); + assertEquals("}V=E6z^$czD", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + createVfModuleResponse0.setVfModuleOutputs((Map<String, String>) null); + Map<String, String> map0 = createVfModuleResponse0.getVfModuleOutputs(); + assertNull(map0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + createVfModuleResponse0.setVfModuleId("Zc%GM]/E*oKC:3T=N_"); + String string0 = createVfModuleResponse0.getVfModuleId(); + assertEquals("Zc%GM]/E*oKC:3T=N_", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + Boolean boolean0 = createVfModuleResponse0.getVfModuleCreated(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + String string0 = createVfModuleResponse0.getVnfId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + Map<String, String> map0 = createVfModuleResponse0.getVfModuleOutputs(); + CreateVfModuleResponse createVfModuleResponse1 = new CreateVfModuleResponse((String) null, (String) null, (String) null, (Boolean) null, map0, (VfModuleRollback) null, "g[03BX;$B"); + VfModuleRollback vfModuleRollback0 = createVfModuleResponse1.getRollback(); + assertNull(vfModuleRollback0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + String string0 = createVfModuleResponse0.getVfModuleStackId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + VfModuleRollback vfModuleRollback0 = createVfModuleResponse0.getRollback(); + createVfModuleResponse0.setRollback(vfModuleRollback0); + assertNull(vfModuleRollback0.getVnfId()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + createVfModuleResponse0.setVnfId("z"); + String string0 = createVfModuleResponse0.getVnfId(); + assertEquals("z", string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + createVfModuleResponse0.setVfModuleStackId(""); + String string0 = createVfModuleResponse0.getVfModuleStackId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + createVfModuleResponse0.setVfModuleId(""); + String string0 = createVfModuleResponse0.getVfModuleId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + String string0 = createVfModuleResponse0.getVfModuleId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + CreateVfModuleResponse createVfModuleResponse0 = new CreateVfModuleResponse(); + createVfModuleResponse0.setVfModuleCreated((Boolean) null); + assertNull(createVfModuleResponse0.getVnfId()); + } } 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 index e141f4b4e1..e11a30e336 100644 --- 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 @@ -1,112 +1,100 @@ /* * This file was automatically generated by EvoSuite - * Mon Nov 14 09:11:34 GMT 2016 + * Mon Feb 20 14:09:17 GMT 2017 */ package org.openecomp.mso.adapters.vnfrest; 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; +import org.openecomp.mso.adapters.vnfrest.DeleteVfModuleResponse; -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +@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()); - } + @Test(timeout = 4000) + public void test00() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse(); + deleteVfModuleResponse0.setVnfId("|Hny"); + String string0 = deleteVfModuleResponse0.getVnfId(); + assertEquals("|Hny", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse(); + deleteVfModuleResponse0.setVnfId(""); + String string0 = deleteVfModuleResponse0.getVnfId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse(); + deleteVfModuleResponse0.setVfModuleOutputs((Map<String, String>) null); + Map<String, String> map0 = deleteVfModuleResponse0.getVfModuleOutputs(); + assertNull(map0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse(); + deleteVfModuleResponse0.setVfModuleId("z"); + String string0 = deleteVfModuleResponse0.getVfModuleId(); + assertEquals("z", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse(); + String string0 = deleteVfModuleResponse0.getVnfId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse(); + Boolean boolean0 = deleteVfModuleResponse0.getVfModuleDeleted(); + assertNull(boolean0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse(); + Map<String, String> map0 = deleteVfModuleResponse0.getVfModuleOutputs(); + deleteVfModuleResponse0.setVfModuleOutputs(map0); + assertNull(deleteVfModuleResponse0.getVnfId()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse(); + String string0 = deleteVfModuleResponse0.getVfModuleId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse("as~HC[>z,.,Z :hLu", "as~HC[>z,.,Z :hLu", (Boolean) null, "as~HC[>z,.,Z :hLu", (Map<String, String>) null); + assertEquals("as~HC[>z,.,Z :hLu", deleteVfModuleResponse0.getVnfId()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse(); + deleteVfModuleResponse0.setVfModuleDeleted((Boolean) null); + assertNull(deleteVfModuleResponse0.getMessageId()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + DeleteVfModuleResponse deleteVfModuleResponse0 = new DeleteVfModuleResponse(); + deleteVfModuleResponse0.setVfModuleId(""); + String string0 = deleteVfModuleResponse0.getVfModuleId(); + assertEquals("", string0); + } } 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 index 326205981a..919475eb5d 100644 --- 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 @@ -1,48 +1,32 @@ /* * This file was automatically generated by EvoSuite - * Mon Nov 14 09:14:23 GMT 2016 + * Mon Feb 20 14:11:28 GMT 2017 */ 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; +import org.openecomp.mso.adapters.vnfrest.RollbackVfModuleRequest; +import org.openecomp.mso.adapters.vnfrest.VfModuleRollback; -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +@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 test0() throws Throwable { + RollbackVfModuleRequest rollbackVfModuleRequest0 = new RollbackVfModuleRequest(); + VfModuleRollback vfModuleRollback0 = rollbackVfModuleRequest0.getVfModuleRollback(); + assertNull(vfModuleRollback0); + } - @Test(timeout = 4000) - public void test2() throws Throwable { - RollbackVfModuleRequest rollbackVfModuleRequest0 = new RollbackVfModuleRequest(); - VfModuleRollback vfModuleRollback0 = rollbackVfModuleRequest0.getVfModuleRollback(); - assertNull(vfModuleRollback0); - } + @Test(timeout = 4000) + public void test1() throws Throwable { + RollbackVfModuleRequest rollbackVfModuleRequest0 = new RollbackVfModuleRequest(); + rollbackVfModuleRequest0.setVfModuleRollback((VfModuleRollback) null); + assertTrue(rollbackVfModuleRequest0.isSynchronous()); + } } 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 index 1ba09e124f..470fff5981 100644 --- 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 @@ -1,6 +1,6 @@ /* * This file was automatically generated by EvoSuite - * Mon Nov 14 09:20:21 GMT 2016 + * Mon Feb 20 14:10:44 GMT 2017 */ package org.openecomp.mso.adapters.vnfrest; @@ -8,239 +8,252 @@ 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.MockitoExtension.*; 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; +import org.openecomp.mso.adapters.vnfrest.VfModuleRollback; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.VnfRollback; -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +@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()); - } + @Test(timeout = 4000) + public void test00() throws Throwable { + VnfRollback vnfRollback0 = mock(VnfRollback.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(vnfRollback0).getCloudSiteId(); + doReturn((MsoRequest) null).when(vnfRollback0).getMsoRequest(); + doReturn((String) null).when(vnfRollback0).getTenantId(); + doReturn(false).when(vnfRollback0).getVnfCreated(); + doReturn((String) null).when(vnfRollback0).getVnfId(); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, "Gf(%P^Jj)\u0005JzrF?~", "Gf(%P^Jj)\u0005JzrF?~", "Gf(%P^Jj)\u0005JzrF?~"); + vfModuleRollback0.setVfModuleCreated(true); + boolean boolean0 = vfModuleRollback0.isVfModuleCreated(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.setVnfId("G\"nvy<Sfjr`hfI8Zl"); + vfModuleRollback0.getVnfId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + VnfRollback vnfRollback0 = mock(VnfRollback.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(vnfRollback0).getCloudSiteId(); + doReturn((MsoRequest) null).when(vnfRollback0).getMsoRequest(); + doReturn((String) null).when(vnfRollback0).getTenantId(); + doReturn(false).when(vnfRollback0).getVnfCreated(); + doReturn((String) null).when(vnfRollback0).getVnfId(); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, "RS,v^T.EEJZW/qj~EC", "RS,v^T.EEJZW/qj~EC", ""); + vfModuleRollback0.setVnfId(""); + vfModuleRollback0.getVnfId(); + assertEquals("RS,v^T.EEJZW/qj~EC", vfModuleRollback0.getVfModuleId()); + assertEquals("RS,v^T.EEJZW/qj~EC", vfModuleRollback0.getVfModuleStackId()); + assertEquals("", vfModuleRollback0.getMessageId()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.getVfModuleStackId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.setVfModuleStackId("G8yt`J"); + vfModuleRollback0.getVfModuleStackId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.setVfModuleId("<V0(ch?1"); + vfModuleRollback0.getVfModuleId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.setVfModuleId(""); + vfModuleRollback0.getVfModuleId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + VnfRollback vnfRollback0 = mock(VnfRollback.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(vnfRollback0).getCloudSiteId(); + doReturn((MsoRequest) null).when(vnfRollback0).getMsoRequest(); + doReturn((String) null).when(vnfRollback0).getTenantId(); + doReturn(false).when(vnfRollback0).getVnfCreated(); + doReturn((String) null).when(vnfRollback0).getVnfId(); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(vnfRollback0, "RS,v^T.EEJZW/qj~EC", "RS,v^T.EEJZW/qj~EC", ""); + vfModuleRollback0.setTenantId("RS,v^T.EEJZW/qj~EC"); + vfModuleRollback0.getTenantId(); + assertEquals("", vfModuleRollback0.getMessageId()); + assertEquals("RS,v^T.EEJZW/qj~EC", vfModuleRollback0.getVfModuleStackId()); + assertEquals("RS,v^T.EEJZW/qj~EC", vfModuleRollback0.getVfModuleId()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback("", "", "", false, "72M#WP;7?8*Y~!q", "72M#WP;7?8*Y~!q", msoRequest0, ""); + assertEquals("72M#WP;7?8*Y~!q", vfModuleRollback0.getTenantId()); + + vfModuleRollback0.setTenantId(""); + vfModuleRollback0.getTenantId(); + assertEquals("", vfModuleRollback0.getMessageId()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(msoRequest0).toString(); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(", vnfCreated=", ", vnfCreated=", ", vnfCreated=", false, ", vnfCreated=", "Jd,{S<BvHJAw+", msoRequest0, "Jd,{S<BvHJAw+"); + vfModuleRollback0.getMsoRequest(); + assertEquals("Jd,{S<BvHJAw+", vfModuleRollback0.getCloudSiteId()); + assertEquals(", vnfCreated=", vfModuleRollback0.getTenantId()); + assertEquals(", vnfCreated=", vfModuleRollback0.getVfModuleId()); + assertEquals(", vnfCreated=", vfModuleRollback0.getVfModuleStackId()); + assertEquals(", vnfCreated=", vfModuleRollback0.getVnfId()); + assertEquals("Jd,{S<BvHJAw+", vfModuleRollback0.getMessageId()); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.setMessageId(""); + vfModuleRollback0.getMessageId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.setCloudSiteId("G8yt`J"); + vfModuleRollback0.getCloudSiteId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.getMessageId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback("", "", "", false, "72M#WP;7?8*Y~!q", "72M#WP;7?8*Y~!q", msoRequest0, ""); + MsoRequest msoRequest1 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); + vfModuleRollback0.setMsoRequest(msoRequest1); + assertEquals("", vfModuleRollback0.getVnfId()); + assertEquals("72M#WP;7?8*Y~!q", vfModuleRollback0.getCloudSiteId()); + assertEquals("", vfModuleRollback0.getVfModuleStackId()); + assertEquals("", vfModuleRollback0.getMessageId()); + assertEquals("72M#WP;7?8*Y~!q", vfModuleRollback0.getTenantId()); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + assertEquals("", vfModuleRollback0.getVfModuleId()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.getTenantId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.getVnfId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.getVfModuleId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.setMessageId("{2)+G6]E#s_=J_S&"); + vfModuleRollback0.getMessageId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.getCloudSiteId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.setCloudSiteId(""); + vfModuleRollback0.getCloudSiteId(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + vfModuleRollback0.getMsoRequest(); + assertFalse(vfModuleRollback0.isVfModuleCreated()); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); + VfModuleRollback vfModuleRollback0 = new VfModuleRollback("!y-*0?6`~", "", "", true, "", "", msoRequest0, "2<6zlA_/MQ2I~c6U0"); + String string0 = vfModuleRollback0.getVfModuleStackId(); + assertEquals("2<6zlA_/MQ2I~c6U0", vfModuleRollback0.getMessageId()); + assertEquals("", vfModuleRollback0.getTenantId()); + assertEquals("", string0); + assertTrue(vfModuleRollback0.isVfModuleCreated()); + assertEquals("!y-*0?6`~", vfModuleRollback0.getVnfId()); + assertEquals("", vfModuleRollback0.getCloudSiteId()); + assertEquals("", vfModuleRollback0.getVfModuleId()); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + VfModuleRollback vfModuleRollback0 = null; + try { + vfModuleRollback0 = new VfModuleRollback((VnfRollback) null, "", "VnfRollback: cloud=", ""); + 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 test23() throws Throwable { + VfModuleRollback vfModuleRollback0 = new VfModuleRollback(); + boolean boolean0 = vfModuleRollback0.isVfModuleCreated(); + assertFalse(boolean0); + } } diff --git a/adapters/mso-catalog-db-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml b/adapters/mso-catalog-db-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 0000000000..05f0a32844 --- /dev/null +++ b/adapters/mso-catalog-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-catalog-db-adapter/WebContent/WEB-INF/jboss-web.xml b/adapters/mso-catalog-db-adapter/WebContent/WEB-INF/jboss-web.xml new file mode 100644 index 0000000000..2493bdb8b1 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/WebContent/WEB-INF/jboss-web.xml @@ -0,0 +1,3 @@ +<jboss-web> + <context-root>ecomp/mso/catalog</context-root> +</jboss-web>
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-catalog-db-adapter/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000000..750bba7633 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/WebContent/WEB-INF/web.xml @@ -0,0 +1,64 @@ +<?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-catalog-db</display-name> + + <context-param> + <param-name>log.configuration</param-name> + <param-value>logback.catalog.xml</param-value> + </context-param> + <context-param> + <param-name>mso.configuration</param-name> + <param-value>MSO_PROP_TOPOLOGY=topology.properties</param-value> + </context-param> + <context-param> + <param-name>resteasy.resources</param-name> + <param-value> + org.openecomp.mso.adapters.catalogdb.CatalogDbAdapterRest + </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> + <security-constraint> + <web-resource-collection> + <web-resource-name>MSO internal Requests</web-resource-name> + <description>Internal Requests</description> + <url-pattern>/logging/*</url-pattern> + <url-pattern>/properties/*</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-role> + <role-name>MSO-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> + <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> + +</web-app> diff --git a/adapters/mso-catalog-db-adapter/pom.xml b/adapters/mso-catalog-db-adapter/pom.xml new file mode 100644 index 0000000000..e7c4b533c7 --- /dev/null +++ b/adapters/mso-catalog-db-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>1.1.0-SNAPSHOT</version> + </parent> + + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-catalog-db-adapter</artifactId> + <packaging>war</packaging> + + <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> + + </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</groupId> + <artifactId>mso-catalog-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.jboss.resteasy</groupId> + <artifactId>resteasy-jackson-provider</artifactId> + <version>3.0.16.Final</version> + </dependency> + <!--<dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>status-control</artifactId> + <version>${project.version}</version> + </dependency>--> + </dependencies> + +</project>
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java new file mode 100644 index 0000000000..20198d1543 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java @@ -0,0 +1,435 @@ +/*- + * ============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.catalogdb; + +/* +Create an initial query to retrieve a VNF Resource definition (including a list of possible module types) +within the context of a given service. Input is a vnf resource model customization ID (new field for 1702), +or a composite key (from 1610) of service name, service version, vnf instance name + +Returns a structure (JSON?) containing VNF RESOURCE attributes, plus a list of VF Module structures. + +Query a NETWORK_RESOURCE from the MSO Catalog, based on a networkModelCustomizationUUID (new for 1702), +a network type (unique type identifier in 1610), or based on network role within a service. + +Create Adapter framework for access to Catalog DB, including connection management, +login/password access, transaction logic, etc. This can be modeled after the Request DB Adapter + +Update the MSO Catalog DB schema to include the new fields defined in this user story. + +Note that the resourceModelCustomizationUUID (or vfModuleModelCustomizationUUID) will be unique keys (indexes) +on the VNF_RESOURCE and VF_MODULE tables respectively. +The previously constructed "vnf-type" and "vf-module-type" field may continue to be populated, +but should no longer be needed and can deprecate in future release. + +For migration, a new randomly generated UUID field may be generated for the *ModelCustomizationUUID" fields +until such time that the model is redistributed from ASDC. + +All other fields Check with Mike Z for appropriate value for the vfModuleLabel. +We might be able to derive it's value from the current vnf-type (using the "middle" piece that identifies the module type). + +min and initial counts can be 0. max can be null to indicate no maximum. + +Once the network-level distribution artifacts are defined, similar updates can be made to the NETWORK_RESOURCE table. +*/ + +import java.util.Map; +import java.util.List; + +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.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.xml.ws.Holder; + +import org.apache.http.HttpStatus; + +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQueryException; +import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQueryExceptionCategory; +import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQuery; +import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceVnfs; +import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceNetworks; +import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceMacroHolder; +import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.VnfResource; +import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; +import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder; +import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; + +/** + * This class services calls to the REST interface for VF Modules (http://host:port/ecomp/mso/catalog/v1) + * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. + * Requests respond synchronously only + */ +@Path("/{version: v[0-9]+}") +public class CatalogDbAdapterRest { + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static final boolean IS_ARRAY = true; + + public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) { + return Response + .status(respStatus) + //.entity(new GenericEntity<QueryServiceVnfs>(qryResp) {}) + .entity(qryResp.toJsonString(version, isArray)) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .build(); + } + + @HEAD + @GET + @Path("healthcheck") + @Produces(MediaType.TEXT_HTML) + public Response healthcheck ( + @PathParam("version") String version + ) { + String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application "+ version+ " ready</body></html>"; + return Response.ok().entity(CHECK_HTML).build(); + } + + /* + * GET {http-catalog-adapter-root}/v1/serviceVnfs?vnfModelCustomizationUuid=<vnf-model-customization-uuid> + * URL:http://localhost:8080/ecomp/mso/catalog/v1/getVfModuleType?vnfType=Test/vSAMP10&vfModuleType=vSAMP10::base::module-0 + * RESP: + * {"queryVfModule":{"version":1,"asdcUuid":"MANUAL RECORD","created":{"nanos":0},"description":"vSAMP10","environmentId":15184,"id":2312,"isBase":1,"modelName":"vSAMP10::base::module-0","modelVersion":1,"templateId":15123,"type":"Test\/vSAMP10::vSAMP10::base::module-0","vnfResourceId":15187}} + */ + + @GET + @Path("vnfs/{vnfModelCustomizationUuid}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response serviceVnfs ( + @PathParam("version") String version, + @PathParam("vnfModelCustomizationUuid") String vnfUuid + ) { + return serviceVnfsImpl (version, !IS_ARRAY, vnfUuid, null, null, null, null); + } + + @GET + @Path("serviceVnfs") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response serviceVnfs( + @PathParam("version") String version, + @QueryParam("vnfModelCustomizationUuid") String vnfUuid, + @QueryParam("serviceModelUuid") String smUuid, + @QueryParam("serviceModelInvariantUuid") String smiUuid, + @QueryParam("serviceModelVersion") String smVer, + @QueryParam("serviceModelName") String smName + ) { + return serviceVnfsImpl (version, IS_ARRAY, vnfUuid, smUuid, smiUuid, smVer, smName); + } + + public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String smUuid, String smiUuid, String smVer, String smName) { + QueryServiceVnfs qryResp; + int respStatus = HttpStatus.SC_OK; + String uuid = ""; + List<VnfResource> ret; + + try (CatalogDatabase db = new CatalogDatabase()) { + if (vnfUuid != null && !vnfUuid.equals("")) { + uuid = vnfUuid; + LOGGER.debug ("Query serviceVnfs getAllVnfsByVnfModelCustomizationUuid vnfModelCustomizationUuid: " + uuid); + ret = db.getAllVnfsByVnfModelCustomizationUuid(uuid); + } + else if (smUuid != null && !smUuid.equals("")) { + uuid = smUuid; + LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceModelUuid serviceModelUuid: " + uuid); + ret = db.getAllVnfsByServiceModelUuid(uuid); + } + else if (smiUuid != null && !smiUuid.equals("")) { + uuid = smiUuid; + if (smVer != null && !smVer.equals("")) { + LOGGER.debug ("Query serviceVnfs getAllNetworksByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer); + ret = db.getAllVnfsByServiceModelInvariantUuid(uuid, smVer); + } + else { + LOGGER.debug ("Query serviceVnfs getAllNetworksByServiceModelInvariantUuid serviceModelUuid: " + uuid); + ret = db.getAllVnfsByServiceModelInvariantUuid(uuid); + } + } + else if (smName != null && !smName.equals("")) { + if (smVer != null && !smVer.equals("")) { + LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceName serviceModelInvariantName: " + smName+ " serviceModelVersion: "+ smVer); + ret = db.getAllVnfsByServiceName(smName, smVer); + } + else { + LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceName serviceModelName: " + smName); + ret = db.getAllVnfsByServiceName(smName); + } + } + else if (smName != null && !smName.equals("")) { + if (smVer != null && !smVer.equals("")) { + LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceName serviceModelInvariantName: " + smName+ " serviceModelVersion: "+ smVer); + ret = db.getAllVnfsByServiceName(smName, smVer); + } + else { + LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceName serviceModelName: " + smName); + ret = db.getAllVnfsByServiceName(smName); + } + } + else { + throw(new Exception("no matching parameters")); + } + + if (ret == null || ret.isEmpty()) { + LOGGER.debug ("serviceVnfs not found"); + respStatus = HttpStatus.SC_NOT_FOUND; + qryResp = new QueryServiceVnfs(); + } else { + LOGGER.debug ("serviceVnfs found"); + qryResp = new QueryServiceVnfs(ret); + LOGGER.debug ("serviceVnfs qryResp="+ qryResp); + } + LOGGER.debug ("Query serviceVnfs exit"); + return respond(version, respStatus, isArray, qryResp); + } catch (Exception e) { + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceVnfs", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceVnfs", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) {}) + .build(); + } + } + + @GET + @Path("networks/{networkModelCustomizationUuid}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response serviceNetworks ( + @PathParam("version") String version, + @PathParam("networkModelCustomizationUuid") String nUuid + ) { + return serviceNetworksImpl (version, !IS_ARRAY, nUuid, null, null, null, null); + } + + @GET + @Path("serviceNetworks") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response serviceNetworks ( + @PathParam("version") String version, + @QueryParam("networkModelCustomizationUuid") String nUuid, + @QueryParam("networkType") String nType, + @QueryParam("serviceModelUuid") String smUuid, + @QueryParam("serviceModelInvariantUuid") String smiUuid, + @QueryParam("serviceModelVersion") String smVer + ) { + return serviceNetworksImpl (version, IS_ARRAY, nUuid, nType, smUuid, smiUuid, smVer); + } + + public Response serviceNetworksImpl (String version, boolean isArray, String nUuid, String nType, String smUuid, String smiUuid, String smVer) { + QueryServiceNetworks qryResp; + int respStatus = HttpStatus.SC_OK; + String uuid = ""; + List<NetworkResourceCustomization> ret; + + try (CatalogDatabase db = new CatalogDatabase()) { + if (nUuid != null && !nUuid.equals("")) { + uuid = nUuid; + LOGGER.debug ("Query serviceNetworks getAllNetworksByNetworkModelCustomizationUuid networkModelCustomizationUuid: " + uuid); + ret = db.getAllNetworksByNetworkModelCustomizationUuid(uuid); + } + else if (smUuid != null && !smUuid.equals("")) { + uuid = smUuid; + LOGGER.debug ("Query serviceNetworks getAllNetworksByServiceModelUuid serviceModelUuid: " + uuid); + ret = db.getAllNetworksByServiceModelUuid(uuid); + } + else if (nType != null && !nType.equals("")) { + uuid = nType; + LOGGER.debug ("Query serviceNetworks getAllNetworksByNetworkType serviceModelUuid: " + uuid); + ret = db.getAllNetworksByNetworkType(uuid); + } + else if (smiUuid != null && !smiUuid.equals("")) { + uuid = smiUuid; + if (smVer != null && !smVer.equals("")) { + LOGGER.debug ("Query serviceNetworks getAllNetworksByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer); + ret = db.getAllNetworksByServiceModelInvariantUuid(uuid, smVer); + } + else { + LOGGER.debug ("Query serviceNetworks getAllNetworksByServiceModelInvariantUuid serviceModelUuid: " + uuid); + ret = db.getAllNetworksByServiceModelInvariantUuid(uuid); + } + } + else { + throw(new Exception("no matching parameters")); + } + + if (ret == null || ret.isEmpty()) { + LOGGER.debug ("serviceNetworks not found"); + respStatus = HttpStatus.SC_NOT_FOUND; + qryResp = new QueryServiceNetworks(); + } else { + LOGGER.debug ("serviceNetworks found"); + qryResp = new QueryServiceNetworks(ret); + LOGGER.debug ("serviceNetworks qryResp="+ qryResp); + } + LOGGER.debug ("Query serviceNetworks exit"); + return respond(version, respStatus, isArray, qryResp); + } catch (Exception e) { + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceNetworks", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceNetworks", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) {}) + .build(); + } + } + + @GET + @Path("serviceResources") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response serviceResources( + @PathParam("version") String version, + @QueryParam("serviceModelUuid") String smUuid, + @QueryParam("serviceModelInvariantUuid") String smiUuid, + @QueryParam("serviceModelVersion") String smVer) { + QueryServiceMacroHolder qryResp; + int respStatus = HttpStatus.SC_OK; + String uuid = ""; + ServiceMacroHolder ret; + + try (CatalogDatabase db = new CatalogDatabase()) { + if (smUuid != null && !smUuid.equals("")) { + uuid = smUuid; + LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelUuid serviceModelUuid: " + uuid); + ret = db.getAllResourcesByServiceModelUuid(uuid); + } + else if (smiUuid != null && !smiUuid.equals("")) { + uuid = smiUuid; + if (smVer != null && !smVer.equals("")) { + LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer); + ret = db.getAllResourcesByServiceModelInvariantUuid(uuid, smVer); + } + else { + LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelUuid: " + uuid); + ret = db.getAllResourcesByServiceModelInvariantUuid(uuid); + } + } + else { + throw(new Exception("no matching parameters")); + } + + if (ret == null) { + LOGGER.debug ("serviceMacroHolder not found"); + respStatus = HttpStatus.SC_NOT_FOUND; + qryResp = new QueryServiceMacroHolder(); + } else { + LOGGER.debug ("serviceMacroHolder found"); + qryResp = new QueryServiceMacroHolder(ret); + LOGGER.debug ("serviceMacroHolder qryResp="+ qryResp); + } + LOGGER.debug ("Query serviceMacroHolder exit"); + return respond(version, respStatus, IS_ARRAY, qryResp); + } catch (Exception e) { + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceMacroHolder", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceMacroHolder", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) {}) + .build(); + } + } + + @GET + @Path("allottedResources/{arModelCustomizationUuid}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response serviceAllottedResources ( + @PathParam("version") String version, + @PathParam("arModelCustomizationUuid") String aUuid + ) { + return serviceAllottedResourcesImpl(version, !IS_ARRAY, aUuid, null, null, null); + } + + @GET + @Path("serviceAllottedResources") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response serviceAllottedResources( + @PathParam("version") String version, + @QueryParam("serviceModelUuid") String smUuid, + @QueryParam("serviceModelInvariantUuid") String smiUuid, + @QueryParam("serviceModelVersion") String smVer, + @QueryParam("arModelCustomizationUuid") String aUuid + ) { + return serviceAllottedResourcesImpl(version, IS_ARRAY, aUuid, smUuid, smiUuid, smVer); + } + + public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid, String smiUuid, String smVer) { + QueryAllottedResourceCustomization qryResp; + int respStatus = HttpStatus.SC_OK; + String uuid = ""; + List<AllottedResourceCustomization > ret; + + try (CatalogDatabase db = new CatalogDatabase()) { + if (smUuid != null && !smUuid.equals("")) { + uuid = smUuid; + LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelUuid serviceModelUuid: " + uuid); + ret = db.getAllAllottedResourcesByServiceModelUuid(uuid); + } + else if (smiUuid != null && !smiUuid.equals("")) { + uuid = smiUuid; + if (smVer != null && !smVer.equals("")) { + LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer); + ret = db.getAllAllottedResourcesByServiceModelInvariantUuid(uuid, smVer); + } + else { + LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelInvariantUuid serviceModelUuid: " + uuid); + ret = db.getAllAllottedResourcesByServiceModelInvariantUuid(uuid); + } + } + else if (aUuid != null && !aUuid.equals("")) { + uuid = aUuid; + LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByArModelCustomizationUuid serviceModelUuid: " + uuid); + ret = db.getAllAllottedResourcesByArModelCustomizationUuid(uuid); + } + else { + throw(new Exception("no matching parameters")); + } + + if (ret == null || ret.isEmpty()) { + LOGGER.debug ("AllottedResourceCustomization not found"); + respStatus = HttpStatus.SC_NOT_FOUND; + qryResp = new QueryAllottedResourceCustomization(); + } else { + LOGGER.debug ("AllottedResourceCustomization found"); + qryResp = new QueryAllottedResourceCustomization(ret); + LOGGER.debug ("AllottedResourceCustomization qryResp="+ qryResp); + } + LOGGER.debug ("Query AllottedResourceCustomization exit"); + return respond(version, respStatus, isArray, qryResp); + } catch (Exception e) { + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryAllottedResourceCustomization", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryAllottedResourceCustomization", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) {}) + .build(); + } + } +}
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java new file mode 100644 index 0000000000..565c4ff1e9 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java @@ -0,0 +1,90 @@ +/*- + * ============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.catalogdb.catalogrest; + +import org.openecomp.mso.logger.MsoLogger; +import org.codehaus.jackson.map.ObjectMapper; + +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public abstract class CatalogQuery { + protected static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static final boolean IS_EMBED = true; + + public abstract String JSON2(boolean isArray, boolean isEmbed); + + protected void put(Map<String, String> valueMap, String key, String value) { + valueMap.put(key, value == null? "null": '"'+ value+ '"'); + } + + protected void put(Map<String, String> valueMap, String key, Integer value) { + valueMap.put(key, value == null? "null": value.toString()); + } + + protected void put(Map<String, String> valueMap, String key, Boolean value) { + valueMap.put(key, value == null? "null": value? "true": "false"); + } + + protected String setTemplate(String template, Map<String, String> valueMap) { + LOGGER.debug ("CatalogQuery setTemplate"); + StringBuffer result = new StringBuffer(); + + String pattern = "<.*>"; + Pattern r = Pattern.compile(pattern); + Matcher m = r.matcher(template); + + LOGGER.debug ("CatalogQuery template:"+ template); + while(m.find()) { + String key = template.substring(m.start()+1, m.end()-1); + LOGGER.debug ("CatalogQuery key:"+ key+ " contains key? "+ valueMap.containsKey(key)); + m.appendReplacement(result, valueMap.containsKey(key)? valueMap.get(key): "\"TBD\""); + } + m.appendTail(result); + LOGGER.debug ("CatalogQuery return:"+ result.toString()); + return result.toString(); + } + + /** + * The simple, clean, generic way to handle the interface + */ + protected String smartToJSON() { + String jsonString = null; + try { + ObjectMapper mapper = new ObjectMapper(); + jsonString = mapper.writeValueAsString(this); + } + catch (Exception e) { + LOGGER.debug ("jsonString exception:"+e.getMessage()); + jsonString = "invalid"; //throws instead? + } + return jsonString; + } + + public String toJsonString(String version, boolean isArray) { + switch(version) { + case "v1": return smartToJSON(); + case "v2": return JSON2(isArray, !IS_EMBED); + default: + return ("invalid version: "+ version); + } + } +}
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryException.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryException.java new file mode 100644 index 0000000000..0fed791b0e --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryException.java @@ -0,0 +1,57 @@ +/*- + * ============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.catalogdb.catalogrest; + +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; + +@XmlRootElement(name = "catalogQueryException") +@NoJackson +public class CatalogQueryException extends CatalogQueryExceptionCommon implements Serializable { + private static final long serialVersionUID = -9062290006520066109L; + + private String message; + private CatalogQueryExceptionCategory category; + private Boolean rolledBack; + + public CatalogQueryException () {} + + public CatalogQueryException (String message) { + this.message = message; + } + + public CatalogQueryException (String message, CatalogQueryExceptionCategory 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 CatalogQueryExceptionCategory getCategory () { return category; } + public void setCategory (CatalogQueryExceptionCategory category) { this.category = category; } + + public Boolean getRolledBack() { return rolledBack; } + public void setRolledBack(Boolean rolledBack) { this.rolledBack = rolledBack; } +} diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCategory.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCategory.java new file mode 100644 index 0000000000..4fef8ac777 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCategory.java @@ -0,0 +1,22 @@ +/*- + * ============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.catalogdb.catalogrest; + +public enum CatalogQueryExceptionCategory { OPENSTACK, IO, INTERNAL, USERDATA } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java new file mode 100644 index 0000000000..09a469d893 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.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.catalogdb.catalogrest; + +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; +import java.io.ByteArrayOutputStream; + +public abstract class CatalogQueryExceptionCommon { + private String messageId; + + public CatalogQueryExceptionCommon() { messageId = null; } + public CatalogQueryExceptionCommon(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) { + 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) { + e.printStackTrace(); + return ""; + } + } +} diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java new file mode 100644 index 0000000000..9c81476f5d --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.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.catalogdb.catalogrest; + +import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@XmlRootElement(name = "serviceAllottedResources") +@NoJackson +public class QueryAllottedResourceCustomization extends CatalogQuery { + private List<AllottedResourceCustomization> allottedResourceCustomization; + private final String template = + "\t{ \"allottedResource\" : {\n"+ + "\t\t\"modelName\" : <MODEL_NAME>,\n"+ + "\t\t\"modelUuid\" : <MODEL_UUID>,\n"+ + "\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_ID>,\n"+ + "\t\t\"modelVersion\" : <MODEL_VERSION>,\n"+ + "\t\t\"modelCustomizationUuid\" : <MODEL_CUSTOMIZATION_UUID>,\n"+ + "\t\t\"modelInstanceName\" : <MODEL_INSTANCE_NAME>\n"+ + "\t}}"; + + public QueryAllottedResourceCustomization() { super(); allottedResourceCustomization = new ArrayList<AllottedResourceCustomization>(); } + public QueryAllottedResourceCustomization(List<AllottedResourceCustomization> vlist) { allottedResourceCustomization = vlist; } + + public List<AllottedResourceCustomization> getServiceAllottedResources(){ return this.allottedResourceCustomization; } + public void setServiceAllottedResources(List<AllottedResourceCustomization> v) { this.allottedResourceCustomization = v; } + + @Override + public String toString () { + StringBuffer buf = new StringBuffer(); + + boolean first = true; + int i = 1; + for (AllottedResourceCustomization o : allottedResourceCustomization) { + buf.append(i+"\t"); + if (!first) buf.append("\n"); first = false; + buf.append(o); + } + return buf.toString(); + } + + @Override + public String JSON2(boolean isArray, boolean isEmbed) { + StringBuffer buf = new StringBuffer(); + if (!isEmbed && isArray) buf.append("{ "); + if (isArray) buf.append("\"serviceAllottedResources\": ["); + Map<String, String> valueMap = new HashMap<String, String>(); + String sep = ""; + boolean first = true; + + for (AllottedResourceCustomization o : allottedResourceCustomization) { + if (first) buf.append("\n"); first = false; + + put(valueMap, "MODEL_NAME", o.getModelName()); + put(valueMap, "MODEL_UUID", o.getModelUuid()); + put(valueMap, "MODEL_INVARIANT_ID", o.getModelInvariantId()); + put(valueMap, "MODEL_VERSION", o.getModelVersion()); + put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid()); + put(valueMap, "MODEL_INSTANCE_NAME", o.getModelInstanceName()); + + buf.append(sep+ this.setTemplate(template, valueMap)); + sep = ",\n"; + } + if (!first) buf.append("\n"); + if (isArray) buf.append("]"); + if (!isEmbed && isArray) buf.append("}"); + return buf.toString(); + } + +}
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java new file mode 100644 index 0000000000..5ac54164c7 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java @@ -0,0 +1,82 @@ +/*- + * ============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.catalogdb.catalogrest; + +import org.openecomp.mso.db.catalog.beans.Service; +import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.HashMap; +import java.util.Map; + +@XmlRootElement(name = "serviceResources") +@NoJackson +public class QueryServiceMacroHolder extends CatalogQuery { + private ServiceMacroHolder serviceMacroHolder; + private final String template = + "{ \"serviceResources\" : {\n"+ + "\t\"modelName\" : <SERVICE_MODEL_NAME>,\n"+ + "\t\"modelUuid\" : <SERVICE_MODEL_UUID>,\n"+ + "\t\"modelInvariantUuid\" : <SERVICE_MODEL_INVARIANT_ID>,\n"+ + "\t\"modelVersion\" : <SERVICE_MODEL_VERSION>,\n"+ + + "<_SERVICEVNFS_>,\n"+ + "<_SERVICENETWORKS_>,\n"+ + "<_SERVICEALLOTTEDRESOURCES_>\n"+ + "\t}}"; + + public QueryServiceMacroHolder() { super(); serviceMacroHolder = new ServiceMacroHolder(); } + public QueryServiceMacroHolder(ServiceMacroHolder vlist) { serviceMacroHolder = vlist; } + + public ServiceMacroHolder getServiceResources(){ return this.serviceMacroHolder; } + public void setServiceResources(ServiceMacroHolder v) { this.serviceMacroHolder = v; } + + @Override + public String toString () { return serviceMacroHolder.toString(); } + + @Override + public String JSON2(boolean isArray, boolean x) { + Service service = serviceMacroHolder.getService(); + if (service == null) return "\"serviceResources\": null"; + + StringBuffer buf = new StringBuffer(); + Map<String, String> valueMap = new HashMap<String, String>(); + + put(valueMap, "SERVICE_MODEL_NAME", service.getServiceName()); //getServiceModelName()); + put(valueMap, "SERVICE_MODEL_UUID", service.getServiceNameVersionId()); //getServiceModelUuid()); + put(valueMap, "SERVICE_MODEL_INVARIANT_ID", service.getModelInvariantUUID()); //getServiceModelInvariantId()); + put(valueMap, "SERVICE_MODEL_VERSION", service.getServiceVersion()); //getServiceModelVersion()); + + String subitem; + subitem = new QueryServiceVnfs(serviceMacroHolder.getVnfResources()).JSON2(true, true); + valueMap.put("_SERVICEVNFS_", subitem.replaceAll("(?m)^", "\t")); + + subitem = new QueryServiceNetworks(serviceMacroHolder.getNetworkResourceCustomization()).JSON2(true, true); + valueMap.put("_SERVICENETWORKS_", subitem.replaceAll("(?m)^", "\t")); + + subitem = new QueryAllottedResourceCustomization(serviceMacroHolder.getAllottedResourceCustomization()).JSON2(true, true); + valueMap.put("_SERVICEALLOTTEDRESOURCES_", subitem.replaceAll("(?m)^", "\t")); + + buf.append(this.setTemplate(template, valueMap)); + return buf.toString(); + } + +}
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java new file mode 100644 index 0000000000..573a0c77a2 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java @@ -0,0 +1,102 @@ +/*- + * ============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.catalogdb.catalogrest; + +import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@XmlRootElement(name = "serviceNetworks") +@NoJackson +public class QueryServiceNetworks extends CatalogQuery { + private List<NetworkResourceCustomization> serviceNetworks; + private final String template = + "\t{ \"network\" : {\n"+ + "\t\t\"modelName\" : <MODEL_NAME>,\n"+ + "\t\t\"modelUuid\" : <MODEL_UUID>,\n"+ + "\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_ID>,\n"+ + "\t\t\"modelVersion\" : <MODEL_VERSION>,\n"+ + "\t\t\"modelCustomizationUuid\" : <MODEL_CUSTOMIZATION_UUID>,\n"+ + "\t\t\"modelInstanceName\" : <MODEL_INSTANCE_NAME>,\n"+ + "\t\t\"networkType\" : <NETWORK_TYPE>\n"+ + "\t}}"; + + public QueryServiceNetworks() { super(); serviceNetworks = new ArrayList<NetworkResourceCustomization>(); } + public QueryServiceNetworks(List<NetworkResourceCustomization> vlist) { + LOGGER.debug ("QueryServiceNetworks:"); + serviceNetworks = new ArrayList<NetworkResourceCustomization>(); + for (NetworkResourceCustomization o : vlist) { + LOGGER.debug (o.toString()); + serviceNetworks.add(o); + LOGGER.debug ("-------------------"); + } + } + + public List<NetworkResourceCustomization> getServiceNetworks(){ return this.serviceNetworks; } + public void setServiceNetworks(List<NetworkResourceCustomization> v) { this.serviceNetworks = v; } + + @Override + public String toString () { + StringBuffer buf = new StringBuffer(); + + boolean first = true; + int i = 1; + for (NetworkResourceCustomization o : serviceNetworks) { + buf.append(i+"\t"); + if (!first) buf.append("\n"); first = false; + buf.append(o); + } + return buf.toString(); + } + + @Override + public String JSON2(boolean isArray, boolean isEmbed) { + StringBuffer buf = new StringBuffer(); + if (!isEmbed && isArray) buf.append("{ "); + if (isArray) buf.append("\"serviceNetworks\": ["); + Map<String, String> valueMap = new HashMap<String, String>(); + String sep = ""; + boolean first = true; + + for (NetworkResourceCustomization o : serviceNetworks) { + if (first) buf.append("\n"); first = false; + + put(valueMap, "MODEL_NAME", o.getModelName()); + put(valueMap, "MODEL_UUID", o.getModelUuid()); + put(valueMap, "MODEL_INVARIANT_ID", o.getModelInvariantId()); + put(valueMap, "MODEL_VERSION", o.getModelVersion()); + put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid()); + put(valueMap, "MODEL_INSTANCE_NAME", o.getModelInstanceName()); + put(valueMap, "NETWORK_TYPE", o.getNetworkType()); + + buf.append(sep+ this.setTemplate(template, valueMap)); + sep = ",\n"; + } + if (!first) buf.append("\n"); + if (isArray) buf.append("]"); + if (!isEmbed && isArray) buf.append("}"); + return buf.toString(); + } +}
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java new file mode 100644 index 0000000000..a917cd9efe --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.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.catalogdb.catalogrest; +/* should be called QueryVnfResource.java */ + +import org.openecomp.mso.db.catalog.beans.VnfResource; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@XmlRootElement(name = "serviceVnfs") +@NoJackson +public class QueryServiceVnfs extends CatalogQuery { + private List<VnfResource> serviceVnfs; + private final String template = + "\t{ \"vnf\" : {\n"+ + "\t\t\"modelName\" : <MODEL_NAME>,\n"+ + "\t\t\"modelUuid\" : <MODEL_UUID>,\n"+ + "\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_ID>,\n"+ + "\t\t\"modelVersion\" : <MODEL_VERSION>,\n"+ + "\t\t\"modelCustomizationUuid\" : <MODEL_CUSTOMIZATION_UUID>,\n"+ + "\t\t\"modelInstanceName\" : <MODEL_INSTANCE_NAME>,\n"+ + "<_VFMODULES_>\n"+ + "\t}}"; + + public QueryServiceVnfs() { super(); serviceVnfs = new ArrayList<VnfResource>(); } + public QueryServiceVnfs(List<VnfResource> vlist) { + LOGGER.debug ("QueryServiceVnfs:"); + serviceVnfs = new ArrayList<VnfResource>(); + for (VnfResource o : vlist) { + LOGGER.debug ("-- o is a serviceVnfs ----"); + LOGGER.debug (o.toString()); + serviceVnfs.add(o); + LOGGER.debug ("-------------------"); + } + } + + public List<VnfResource> getServiceVnfs(){ return this.serviceVnfs; } + public void setServiceVnfs(List<VnfResource> v) { this.serviceVnfs = v; } + + @Override + public String toString () { + StringBuffer buf = new StringBuffer(); + + boolean first = true; + int i = 1; + for (VnfResource o : serviceVnfs) { + buf.append(i+"\t"); + if (!first) buf.append("\n"); first = false; + buf.append(o); + } + return buf.toString(); + } + + @Override + public String JSON2(boolean isArray, boolean isEmbed) { + StringBuffer buf = new StringBuffer(); + if (!isEmbed && isArray) buf.append("{ "); + if (isArray) buf.append("\"serviceVnfs\": ["); + Map<String, String> valueMap = new HashMap<String, String>(); + String sep = ""; + boolean first = true; + + for (VnfResource o : serviceVnfs) { + if (first) buf.append("\n"); first = false; + + put(valueMap, "MODEL_NAME", o.getModelName()); + put(valueMap, "MODEL_UUID", o.getModelUuid()); + put(valueMap, "MODEL_INVARIANT_ID", o.getModelInvariantId()); + put(valueMap, "MODEL_VERSION", o.getModelVersion()); + put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid()); + put(valueMap, "MODEL_INSTANCE_NAME", o.getModelInstanceName()); + + String subitem = new QueryVfModule(o.getVfModules()).JSON2(true, true); + valueMap.put("_VFMODULES_", subitem.replaceAll("(?m)^", "\t\t")); + + buf.append(sep+ this.setTemplate(template, valueMap)); + sep = ",\n"; + } + if (!first) buf.append("\n"); + if (isArray) buf.append("]"); + if (!isEmbed && isArray) buf.append("}"); + return buf.toString(); + } +}
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java new file mode 100644 index 0000000000..e7113e60c5 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.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.catalogdb.catalogrest; + +import org.openecomp.mso.db.catalog.beans.VfModule; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@XmlRootElement(name = "vfModules") +@NoJackson +public class QueryVfModule extends CatalogQuery { + private List<VfModule> vfModules; + private final String template = + "\t{ \"vfModule\" : { \n"+ + "\t\t\"modelName\" : <MODEL_NAME>,\n"+ + "\t\t\"modelUuid\" : <MODEL_UUID>,\n"+ + "\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_ID>,\n"+ + "\t\t\"modelVersion\" : <MODEL_VERSION>,\n"+ + "\t\t\"modelCustomizationUuid\" : <MODEL_CUSTOMIZATION_UUID>,\n"+ + "\t\t\"vfModuleType\" : <VF_MODULE_TYPE>,\n"+ + "\t\t\"isBase\" : <IS_BASE>,\n"+ + "\t\t\"vfModuleLabel\" : <VF_MODULE_LABEL>,\n"+ + "\t\t\"initialCount\" : <INITIAL_COUNT>\n"+ + "\t}}"; + + public QueryVfModule() { super(); vfModules = new ArrayList<VfModule>(); } + public QueryVfModule(List<VfModule> vlist) { + LOGGER.debug ("QueryVfModule:"); + vfModules = new ArrayList<VfModule>(); + for (VfModule o : vlist) { + LOGGER.debug ("-- o is a vfModules ----"); + LOGGER.debug (o.toString()); + vfModules.add(o); + LOGGER.debug ("-------------------"); + } + } + + public List<VfModule> getVfModule(){ return this.vfModules; } + public void setVfModule(List<VfModule> v) { this.vfModules = v; } + + @Override + public String toString () { + StringBuffer buf = new StringBuffer(); + + boolean first = true; + int i = 1; + for (VfModule o : vfModules) { + buf.append(i+"\t"); + if (!first) buf.append("\n"); first = false; + buf.append(o); + } + return buf.toString(); + } + + @Override + public String JSON2(boolean isArray, boolean x) { + StringBuffer buf = new StringBuffer(); + if (isArray) buf.append("\"vfModules\": ["); + Map<String, String> valueMap = new HashMap<String, String>(); + String sep = ""; + boolean first = true; + + for (VfModule o : vfModules) { + if (first) buf.append("\n"); first = false; + + put(valueMap, "MODEL_NAME", o.getModelName()); + put(valueMap, "MODEL_UUID", o.getModelUuid()); + put(valueMap, "MODEL_INVARIANT_ID", o.getModelInvariantId()); + put(valueMap, "MODEL_VERSION", o.getModelVersion()); + put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid()); + put(valueMap, "VF_MODULE_TYPE", o.getVfModuleType()); + put(valueMap, "IS_BASE", new Boolean(o.isBase()? true: false)); + put(valueMap, "VF_MODULE_LABEL", o.getVfModuleLabel()); + put(valueMap, "INITIAL_COUNT", o.getInitialCount()); + + buf.append(sep+ this.setTemplate(template, valueMap)); + sep = ",\n"; + } + if (!first) buf.append("\n"); + if (isArray) buf.append("]"); + return buf.toString(); + } +}
\ No newline at end of file diff --git a/adapters/mso-network-adapter-async-client/pom.xml b/adapters/mso-network-adapter-async-client/pom.xml index a8b96154af..7fad404f9b 100644 --- a/adapters/mso-network-adapter-async-client/pom.xml +++ b/adapters/mso-network-adapter-async-client/pom.xml @@ -1,90 +1,91 @@ -<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> +<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>1.1.0-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> + </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 index fe5346da49..ae3c31b625 100644 --- a/adapters/mso-network-adapter-async-client/src/main/resources/NetworkAdapterNotify.wsdl +++ b/adapters/mso-network-adapter-async-client/src/main/resources/NetworkAdapterNotify.wsdl @@ -1,8 +1,8 @@ <?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"> +<definitions targetNamespace="http://org.openecomp.mso/networkNotify" name="networkAdapterNotify" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:tns="http://org.openecomp.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:schema version="1.0" targetNamespace="http://org.openecomp.mso/networkNotify" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="createNetworkNotification" type="tns:createNetworkNotification"/> @@ -218,24 +218,24 @@ </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"/> + <input wsam:Action="http://org.openecomp.mso/notify/adapterNotify/rollbackNetworkNotificationRequest" message="tns:rollbackNetworkNotification"/> + <output wsam:Action="http://org.openecomp.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"/> + <input wsam:Action="http://org.openecomp.mso/notify/adapterNotify/queryNetworkNotificationRequest" message="tns:queryNetworkNotification"/> + <output wsam:Action="http://org.openecomp.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"/> + <input wsam:Action="http://org.openecomp.mso/notify/adapterNotify/createNetworkNotificationRequest" message="tns:createNetworkNotification"/> + <output wsam:Action="http://org.openecomp.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"/> + <input wsam:Action="http://org.openecomp.mso/notify/adapterNotify/deleteNetworkNotificationRequest" message="tns:deleteNetworkNotification"/> + <output wsam:Action="http://org.openecomp.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"/> + <input wsam:Action="http://org.openecomp.mso/notify/adapterNotify/updateNetworkNotificationRequest" message="tns:updateNetworkNotification"/> + <output wsam:Action="http://org.openecomp.mso/notify/adapterNotify/updateNetworkNotificationResponse" message="tns:updateNetworkNotificationResponse"/> </operation> </portType> <binding name="MsoNetworkAdapterAsyncImplPortBinding" type="tns:networkAdapterNotify"> diff --git a/adapters/mso-network-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-network-adapter/WebContent/WEB-INF/web.xml index a0c726a6f4..c02d2a52d0 100644 --- a/adapters/mso-network-adapter/WebContent/WEB-INF/web.xml +++ b/adapters/mso-network-adapter/WebContent/WEB-INF/web.xml @@ -77,6 +77,19 @@ <role-name>BPEL-Client</role-name> </auth-constraint> </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>MSO internal Requests</web-resource-name> + <description>Internal Requests</description> + <url-pattern>/rest/logging/*</url-pattern> + <url-pattern>/rest/properties/*</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> <login-config> <auth-method>BASIC</auth-method> <realm-name>ApplicationRealm</realm-name> @@ -87,9 +100,12 @@ <security-role> <role-name>SiteControl-Client</role-name> </security-role> + <security-role> + <role-name>MSO-Client</role-name> + </security-role> <filter> <filter-name>LogFilter</filter-name> - <filter-class>org.openecomp.mso.logger.LogFilter</filter-class> + <filter-class>org.openecomp.mso.logger.LogFilter</filter-class> </filter> <filter-mapping> <filter-name>LogFilter</filter-name> 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 index dcd12d24e7..4218ad8d2f 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -239,7 +239,10 @@ public class BpelRestClient { LOGGER.debug("Sending to BPEL server: "+bpelUrl); LOGGER.debug("Content is: "+toBpelStr); - //POST + //Client 4.3+ + CloseableHttpClient client = HttpClients.createDefault(); + + //POST HttpPost post = new HttpPost(bpelUrl); if (credentials != null && !credentials.isEmpty()) post.addHeader("Authorization", "Basic " + DatatypeConverter.printBase64Binary(credentials.getBytes())); @@ -258,8 +261,8 @@ public class BpelRestClient { //Client 4.3+ //Execute & GetResponse - try (CloseableHttpClient client = HttpClients.createDefault(); - CloseableHttpResponse response = client.execute(post)) { + try { + CloseableHttpResponse response = client.execute(post); if (response != null) { lastResponseCode = response.getStatusLine().getStatusCode(); HttpEntity entity = response.getEntity(); @@ -273,32 +276,15 @@ public class BpelRestClient { LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, error, "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "Exception sending Bpel notification", e); lastResponseCode = 900; lastResponse = ""; + } finally { + try { + client.close(); + } catch (IOException e) { + // ignore + } } 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/MsoNetworkAdapter.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java index 4960877b8a..01f2e752e4 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -37,7 +37,7 @@ 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") +@WebService (name="NetworkAdapter", targetNamespace="http://org.openecomp.mso/network") public interface MsoNetworkAdapter { // TODO: Rename all of these to include Vlan in the service name? At least for the @@ -50,6 +50,7 @@ public interface MsoNetworkAdapter 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="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkName") @XmlElement(required=true) String networkName, @WebParam(name="physicalNetworkName") String physicalNetworkName, @WebParam(name="vlans") List<Integer> vlans, @@ -67,6 +68,7 @@ public interface MsoNetworkAdapter 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="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkName") @XmlElement(required=true) String networkName, @WebParam(name="routeTargets") List<String> routeTargets, @WebParam(name="shared") String shared, @@ -92,6 +94,7 @@ public interface MsoNetworkAdapter 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="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkId") @XmlElement(required=true) String networkId, @WebParam(name="networkName") @XmlElement(required=true) String networkName, @WebParam(name="physicalNetworkName") @XmlElement(required=true) String physicalNetworkName, @@ -106,6 +109,7 @@ public interface MsoNetworkAdapter 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="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkId") @XmlElement(required=true) String networkId, @WebParam(name="networkName") @XmlElement(required=true) String networkName, @WebParam(name="routeTargets") List<String> routeTargets, @@ -199,6 +203,7 @@ public interface MsoNetworkAdapter 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="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkId") @XmlElement(required=true) String networkId, @WebParam(name="request") MsoRequest msoRequest, @WebParam(name="networkDeleted", mode=Mode.OUT) Holder<Boolean> networkDeleted) 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 index e79ba125e2..e5152578bb 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -38,7 +38,7 @@ import java.util.List; * (by the client service WSDL). * */ -@WebService (name="NetworkAdapterAsync", targetNamespace="http://com.att.mso/networkA") +@WebService (name="NetworkAdapterAsync", targetNamespace="http://org.openecomp.mso/networkA") public interface MsoNetworkAdapterAsync { /** @@ -49,6 +49,7 @@ public interface MsoNetworkAdapterAsync 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="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkName") @XmlElement(required=true) String networkName, @WebParam(name="physicalNetworkName") String physicalNetworkName, @WebParam(name="vlans") List<Integer> vlans, @@ -58,12 +59,13 @@ public interface MsoNetworkAdapterAsync @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="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkId") @XmlElement(required=true) String networkId, @WebParam(name="networkName") @XmlElement(required=true) String networkName, @WebParam(name="physicalNetworkName") @XmlElement(required=true) String physicalNetworkName, @@ -87,6 +89,7 @@ public interface MsoNetworkAdapterAsync 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="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkId") @XmlElement(required=true) String networkId, @WebParam(name="messageId") @XmlElement(required=true) String messageId, @WebParam(name="request") MsoRequest msoRequest, @@ -97,7 +100,7 @@ public interface MsoNetworkAdapterAsync 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 index 75cbc636cc..c643443791 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -53,7 +53,7 @@ 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") +@WebService(serviceName = "NetworkAdapterAsync", endpointInterface = "org.openecomp.mso.adapters.network.MsoNetworkAdapterAsync", targetNamespace = "http://org.openecomp.mso/networkA") public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory(); @@ -105,6 +105,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { public void createNetworkA (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkName, String physicalNetworkName, List <Integer> vlans, @@ -140,6 +141,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { networkAdapter.createNetwork (cloudSiteId, tenantId, networkType, + modelCustomizationUuid, networkName, physicalNetworkName, vlans, @@ -222,6 +224,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { public void updateNetworkA (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkId, String networkName, String physicalNetworkName, @@ -255,6 +258,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { networkAdapter.updateNetwork (cloudSiteId, tenantId, networkType, + modelCustomizationUuid, networkId, networkName, physicalNetworkName, @@ -416,6 +420,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { public void deleteNetworkA (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkId, String messageId, MsoRequest msoRequest, @@ -435,7 +440,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { Holder <Boolean> networkDeleted = new Holder <Boolean> (); try { - networkAdapter.deleteNetwork (cloudSiteId, tenantId, networkType, networkId, msoRequest, networkDeleted); + networkAdapter.deleteNetwork (cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkId, msoRequest, networkDeleted); MsoLogger.setServiceName (serviceName); } catch (NetworkException e) { MsoLogger.setServiceName (serviceName); @@ -584,7 +589,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { } NetworkAdapterNotify_Service notifySvc = new NetworkAdapterNotify_Service (warWsdlLoc, - new QName ("http://com.att.mso/networkNotify", + new QName ("http://org.openecomp.mso/networkNotify", "networkAdapterNotify")); NetworkAdapterNotify notifyPort = notifySvc.getMsoNetworkAdapterAsyncImplPort (); 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 index 97624dae30..e9288ab408 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -64,7 +64,7 @@ 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") +@WebService(serviceName = "NetworkAdapter", endpointInterface = "org.openecomp.mso.adapters.network.MsoNetworkAdapter", targetNamespace = "http://org.openecomp.mso/network") public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory(); @@ -117,6 +117,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { public void createNetwork (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkName, String physicalNetworkName, List <Integer> vlans, @@ -132,6 +133,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { createNetwork (cloudSiteId, tenantId, networkType, + modelCustomizationUuid, networkName, physicalNetworkName, vlans, @@ -155,6 +157,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { public void createNetworkContrail (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkName, List <String> routeTargets, String shared, @@ -173,6 +176,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { createNetwork (cloudSiteId, tenantId, networkType, + modelCustomizationUuid, networkName, null, null, @@ -224,6 +228,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private void createNetwork (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkName, String physicalNetworkName, List <Integer> vlans, @@ -260,6 +265,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { networkRollback.setCloudId (cloudSiteId); networkRollback.setTenantId (tenantId); networkRollback.setMsoRequest (msoRequest); + networkRollback.setModelCustomizationUuid(modelCustomizationUuid); // 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). @@ -281,10 +287,15 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { throw new NetworkException (error, MsoExceptionCategory.USERDATA); } - try (CatalogDatabase db = getCatalogDb()) { + // Get a handle to the Catalog Database + CatalogDatabase db = getCatalogDB (); + + // Make sure DB connection is always closed + try { NetworkResource networkResource = networkCheck (db, startTime, networkType, + modelCustomizationUuid, networkName, physicalNetworkName, vlans, @@ -387,7 +398,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // 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; @@ -401,11 +412,11 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } 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 { @@ -414,10 +425,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { 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; @@ -466,14 +477,14 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { if (outputs != null) { for (String key : outputs.keySet ()) { if (key != null && key.startsWith ("subnet")) { - if (aic3template) //one subnet_id output + if (aic3template) //one subnet_id output { - Map <String, String> map = getSubnetUUId(key, outputs, subnets); + Map <String, String> map = getSubnetUUId(key, outputs, subnets); sMap.putAll(map); } else //multiples subnet_%aaid% outputs { - String subnetUUId = (String) outputs.get(key); + String subnetUUId = (String) outputs.get(key); sMap.put (key.substring("subnet_id_".length()), subnetUUId); } } @@ -494,7 +505,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { physicalNetworkName, vlans, routeTargets, - shared, + shared, external, aic3template); @@ -557,7 +568,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { throw new NetworkException (me); } } - + if (routeTableFqdns != null && !routeTableFqdns.isEmpty() && aic3template) { try { mergeRouteTableRefs (routeTableFqdns, stackParams); @@ -624,12 +635,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { if (key != null && key.startsWith ("subnet")) { if (aic3template) //one subnet output expected { - Map <String, String> map = getSubnetUUId(key, outputs, subnets); + Map <String, String> map = getSubnetUUId(key, outputs, subnets); sMap.putAll(map); } else //multiples subnet_%aaid% outputs allowed { - String subnetUUId = (String) outputs.get(key); + String subnetUUId = (String) outputs.get(key); sMap.put (key.substring("subnet_id_".length()), subnetUUId); } } @@ -646,6 +657,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { LOGGER.debug ("Network " + networkName + " successfully created via HEAT"); } + } finally { + db.close (); } LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc, "Successfully created network"); return; @@ -655,6 +668,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { public void updateNetwork (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkId, String networkName, String physicalNetworkName, @@ -666,6 +680,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { updateNetwork (cloudSiteId, tenantId, networkType, + modelCustomizationUuid, networkId, networkName, physicalNetworkName, @@ -686,6 +701,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { public void updateNetworkContrail (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkId, String networkName, List <String> routeTargets, @@ -700,6 +716,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { updateNetwork (cloudSiteId, tenantId, networkType, + modelCustomizationUuid, networkId, networkName, null, @@ -744,6 +761,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private void updateNetwork (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkId, String networkName, String physicalNetworkName, @@ -792,295 +810,296 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { 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 ()); + // Get a handle to the Catalog Database + CatalogDatabase db = getCatalogDB (); + + // Make sure DB connection is always closed + try { + NetworkResource networkResource = networkCheck(db, + startTime, + networkType, + modelCustomizationUuid, + 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); + MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory); - if (NEUTRON_MODE.equals (mode)) { + 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 (); + 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); + 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); + 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 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 (); + 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); + 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); + 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); + + " 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); + 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 ()); + 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)) { + 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); + 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 (); + 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); + 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); + 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); + + " 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)) { + 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); + + " 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 (); + Map<String, Object> heatParams = heatStack.getParameters(); - String previousNetworkName = (String) heatParams.get ("network_name"); - String previousPhysicalNetwork = (String) heatParams.get (PHYSICAL_NETWORK); + 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); + List<Integer> previousVlans = new ArrayList<Integer>(); + String vlansParam = (String) heatParams.get(VLANS); if (vlansParam != null) { - for (String vlan : vlansParam.split (",")) { + for (String vlan : vlansParam.split(",")) { try { - previousVlans.add (Integer.parseInt (vlan)); + previousVlans.add(Integer.parseInt(vlan)); } catch (NumberFormatException e) { - LOGGER.warn (MessageEnum.RA_VLAN_PARSE, networkId, vlansParam, "", "", MsoLogger.ErrorCode.DataError, "Exception - VLAN parse", e); + LOGGER.warn(MessageEnum.RA_VLAN_PARSE, networkId, vlansParam, "", "", MsoLogger.ErrorCode.DataError, "Exception - VLAN parse", e); } } } - LOGGER.debug ("Update Stack: Previous VLANS: " + previousVlans); + LOGGER.debug("Update Stack: Previous VLANS: " + previousVlans); // Ready to deploy the updated Network via Heat - HeatTemplate heatTemplate = db.getHeatTemplate (networkResource.getTemplateId ()); + 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.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 ()); - + 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 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); - } + 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; + aic3template = true; // Build the common set of HEAT template parameters - Map <String, Object> stackParams = populateNetworkParams (neutronNetworkType, - networkName, - physicalNetworkName, - vlans, - routeTargets, - shared, - external, - aic3template); + 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); + 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); + 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); - } + if (aic3template) { + template = mergeSubnetsAIC3(template, subnets, stackParams); + } else { + template = mergeSubnets(template, subnets); + } } catch (MsoException me) { - me.addContext (UPDATE_NETWORK_CONTEXT); + 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); + + " 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); + 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); + 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); + 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); + 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 (); + 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); + 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); + 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); + 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> (); + 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); - } + 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); + } } } } @@ -1088,18 +1107,20 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // 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); + 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); + networkRollback.setNetworkName(previousNetworkName); + networkRollback.setPhysicalNetwork(previousPhysicalNetwork); + networkRollback.setVlans(previousVlans); rollback.value = networkRollback; - LOGGER.debug ("Network " + networkId + " successfully updated via HEAT"); + LOGGER.debug("Network " + networkId + " successfully updated via HEAT"); } + } finally { + db.close (); } LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully updated network"); return; @@ -1108,16 +1129,24 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private NetworkResource networkCheck (CatalogDatabase db, long startTime, String networkType, + String modelCustomizationUuid, String networkName, String physicalNetworkName, List <Integer> vlans, List <String> routeTargets, CloudSite cloudSite) throws NetworkException { // Retrieve the Network Resource definition - NetworkResource networkResource = db.getNetworkResource (networkType); + NetworkResource networkResource = null; + if (isNullOrEmpty(modelCustomizationUuid)) { + networkResource = db.getNetworkResource (networkType); + } + else + { + networkResource = db.getNetworkResourceByModelCustUuid(modelCustomizationUuid); + } 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"); + String error = "Create/UpdateNetwork: Unable to get network resource with NetworkType:" + networkType + " or ModelCustomizationUUID:" + modelCustomizationUuid ; + LOGGER.error (MessageEnum.RA_UNKOWN_PARAM, "NetworkType/ModelCustomizationUUID", networkType + "/" + modelCustomizationUuid, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create/UpdateNetwork: Unknown NetworkType/ModelCustomizationUUID"); throw new NetworkException (error, MsoExceptionCategory.USERDATA); } @@ -1138,26 +1167,31 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { 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); - } + try { + 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); + } + } catch (Exception e) { + String error = "Exception during Network version check"; + LOGGER.error (MessageEnum.RA_GENERAL_EXCEPTION_ARG, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, error); + + throw new NetworkException (error, MsoExceptionCategory.INTERNAL); + } // Validate the Network parameters. @@ -1317,12 +1351,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { for (String key : outputs.keySet ()) { if (key != null && key.startsWith ("subnet_id_")) //multiples subnet_%aaid% outputs { - String subnetUUId = (String) outputs.get(key); + 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); + Map <String, String> map = getSubnetUUId(key, outputs, null); sMap.putAll(map); } @@ -1411,6 +1445,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { public void deleteNetwork (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkId, MsoRequest msoRequest, Holder <Boolean> networkDeleted) throws NetworkException { @@ -1425,7 +1460,11 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Will capture execution time for metrics long startTime = System.currentTimeMillis (); - try (CatalogDatabase db = getCatalogDb()) { + // Get a handle to the Catalog Database + CatalogDatabase db = getCatalogDB (); + + // Make sure DB connection is always closed + try { if (isNullOrEmpty (cloudSiteId) || isNullOrEmpty(tenantId) || isNullOrEmpty(networkId)) { @@ -1436,16 +1475,20 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } // 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); + NetworkResource networkResource = null; + if (isNullOrEmpty(modelCustomizationUuid)) { + networkResource = db.getNetworkResource (networkType); } - LOGGER.debug ("Got Network definition from Catalog: " + networkResource.toString ()); + else if (!isNullOrEmpty(networkType)) + { + networkResource = db.getNetworkResourceByModelCustUuid(modelCustomizationUuid); + } + String mode = ""; + if (networkResource != null) { + LOGGER.debug ("Got Network definition from Catalog: " + networkResource.toString ()); - String mode = networkResource.getOrchestrationMode (); + mode = networkResource.getOrchestrationMode (); + } if (NEUTRON_MODE.equals (mode)) { @@ -1472,14 +1515,14 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); throw new NetworkException (me); } - } else if ("HEAT".equals (mode)) { + } else { // DEFAULT to ("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 + // 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) @@ -1507,6 +1550,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { throw new NetworkException (me); } } + } finally { + db.close (); } // On success, nothing is returned. @@ -1514,7 +1559,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { return; } - public CatalogDatabase getCatalogDb() { + public CatalogDatabase getCatalogDB() { return new CatalogDatabase(); } @@ -1546,25 +1591,33 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String tenantId = rollback.getTenantId (); String networkId = rollback.getNetworkStackId (); String networkType = rollback.getNetworkType (); + String modelCustomizationUuid = rollback.getModelCustomizationUuid(); 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 + CatalogDatabase db = getCatalogDB (); - try (CatalogDatabase db = getCatalogDb()){ + // Make sure DB connection is always closed + try { // 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); + NetworkResource networkResource = null; + if (isNullOrEmpty(modelCustomizationUuid)) { + networkResource = db.getNetworkResource (networkType); + } + else + { + networkResource = db.getNetworkResourceByModelCustUuid(modelCustomizationUuid); } - LOGGER.debug ("Got Network definition from Catalog: " + networkResource.toString ()); + String mode = ""; + if (networkResource != null) { - String mode = networkResource.getOrchestrationMode (); + LOGGER.debug ("Got Network definition from Catalog: " + networkResource.toString ()); + + mode = networkResource.getOrchestrationMode (); + } if (rollback.getNetworkCreated ()) { // Rolling back a newly created network, so delete it. @@ -1591,7 +1644,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); throw new NetworkException (me); } - } else if ("HEAT".equals (mode)) { + } else { // DEFAULT to if ("HEAT".equals (mode)) // Use MsoHeatUtils for all HEAT commands MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,cloudConfigFactory); long deleteStackStarttime = System.currentTimeMillis (); @@ -1615,7 +1668,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { throw new NetworkException (me); } } - } + } + } finally { + db.close (); } LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully rolled back network"); return; @@ -1710,9 +1765,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } return stackParams; } - - + + /** policyRef_list structure in stackParams [ { @@ -1743,11 +1798,11 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { prlist.add(pr); } } - + JsonNode node = null; try { - ObjectMapper mapper = new ObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); node = mapper.convertValue(prlist, JsonNode.class); String jsonString = mapper.writeValueAsString(prlist); LOGGER.debug("Json PolicyRefs Data:" + jsonString); @@ -1778,9 +1833,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { 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) { @@ -1801,7 +1856,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { return; } - + /*** Subnet Output structure from Juniper { "ipam_subnets": [ @@ -1909,13 +1964,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { /* make these optional + " ip_version: %ipversion%\n" + " enable_dhcp: %enabledhcp%\n" - + " gateway_ip: %gatewayip%\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"; @@ -1934,13 +1989,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { 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 { @@ -1957,11 +2012,11 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } if (subnet.getGatewayIp () != null && !subnet.getGatewayIp ().isEmpty() ) { curR = curR + " gateway_ip: " + subnet.getGatewayIp () + "\n"; - } + } - if (subnet.getAllocationPools() != null) { + if (subnet.getAllocationPools() != null) { curR = curR + " allocation_pools:\n"; - for (Pool pool : subnet.getAllocationPools()) + for (Pool pool : subnet.getAllocationPools()) { if (!isNullOrEmpty(pool.getStart()) && !isNullOrEmpty(pool.getEnd())) { @@ -2013,10 +2068,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { for (Subnet subnet : subnets) { if ( subnet != null && !isNullOrEmpty(subnet.getSubnetName())) - { + { if (subnet.getSubnetName().equals(name)) { - aaiId = subnet.getSubnetId(); + aaiId = subnet.getSubnetId(); break; } } 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 index c813534212..18d55096e4 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -162,6 +162,7 @@ public class NetworkAdapterRest { req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), + req.getModelCustomizationUuid(), req.getNetworkName(), req.getContrailNetwork().getRouteTargets(), req.getContrailNetwork().getShared(), @@ -187,6 +188,7 @@ public class NetworkAdapterRest { req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), + req.getModelCustomizationUuid(), req.getNetworkName(), req.getProviderVlanNetwork().getPhysicalNetworkName(), req.getProviderVlanNetwork().getVlans(), @@ -298,6 +300,7 @@ public class NetworkAdapterRest { req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), + req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getMsoRequest(), networkDeleted); @@ -538,6 +541,7 @@ public class NetworkAdapterRest { req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), + req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getNetworkName(), req.getContrailNetwork().getRouteTargets(), @@ -559,6 +563,7 @@ public class NetworkAdapterRest { req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), + req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getNetworkName(), req.getProviderVlanNetwork().getPhysicalNetworkName(), 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 index 0fd4d02933..1b9fde7a88 100644 --- 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 @@ -34,7 +34,7 @@ import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; * * */ -@WebFault (name="NetworkException", faultBean="org.openecomp.mso.adapters.network.exceptions.NetworkExceptionBean", targetNamespace="http://com.att.mso/network") +@WebFault (name="NetworkException", faultBean="org.openecomp.mso.adapters.network.exceptions.NetworkExceptionBean", targetNamespace="http://org.openecomp.mso/network") public class NetworkException extends Exception { private static final long serialVersionUID = 1L; 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 index 41cc3f5533..4900d28556 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -29,6 +29,7 @@ import java.util.Map; import javax.xml.ws.Holder; +import org.evosuite.runtime.System; import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mock; @@ -60,7 +61,7 @@ public class NetworkAdapterTest { networkResource.setId (1); networkResource.setOrchestrationMode ("toto"); Mockito.when (db.getNetworkResource ("PROVIDER")).thenReturn (networkResource); - Mockito.when (adapter.getCatalogDb()).thenReturn (db); + Mockito.when (adapter.getCatalogDB()).thenReturn (db); } @Test @@ -80,6 +81,7 @@ public class NetworkAdapterTest { adapter.createNetwork ("toto", "tenant", "PROVIDER", + "modelCustUuid", "networkName", "physicalNetworkName", vlans, @@ -120,6 +122,7 @@ public class NetworkAdapterTest { adapter.createNetworkContrail ("toto", "tenant", "PROVIDER", + "modelCustUuid", "networkName", routeTargets, "shared", @@ -154,6 +157,7 @@ public class NetworkAdapterTest { adapter.updateNetwork ("toto", "tenant", "PROVIDER", + "modelCustUuid", "networkId", "networkName", "physicalNetworkName", @@ -187,6 +191,7 @@ public class NetworkAdapterTest { adapter.updateNetworkContrail ("toto", "tenant", "PROVIDER", + "modelCustUuid", "networkId", "networkName", routeTargets, @@ -258,9 +263,10 @@ public class NetworkAdapterTest { Holder <Boolean> networkDeleted = new Holder<> (); MsoRequest msoRequest = new MsoRequest (); try { - adapter.deleteNetwork ("toto", "tenant", "PROVIDER", "networkId", msoRequest, networkDeleted); + adapter.deleteNetwork ("toto", "tenant", "PROVIDER", "modelCustUuid","networkId", msoRequest, networkDeleted); } catch (NetworkException e) { - assertTrue (e.getMessage ().contains ("Configuration Error")); + e.printStackTrace(); + assertTrue (e.getMessage ().contains ("Cloud Site [toto] not found")); } } } diff --git a/adapters/mso-requests-db-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/web.xml index 7fa3f2a24c..977ab76050 100644 --- a/adapters/mso-requests-db-adapter/WebContent/WEB-INF/web.xml +++ b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/web.xml @@ -29,7 +29,7 @@ <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>
@@ -56,6 +56,17 @@ <param-value>true</param-value>
</context-param>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>SoapRequests</web-resource-name>
+ <description>Soap Ingress Requests</description>
+ <url-pattern>/RequestsDbAdapter</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>
@@ -67,6 +78,19 @@ <role-name>SiteControl-Client</role-name>
</auth-constraint>
</security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>MSO internal Requests</web-resource-name>
+ <description>Internal Requests</description>
+ <url-pattern>/logging/*</url-pattern>
+ <url-pattern>/properties/*</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>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ApplicationRealm</realm-name>
@@ -74,4 +98,7 @@ <security-role>
<role-name>SiteControl-Client</role-name>
</security-role>
+ <security-role>
+ <role-name>MSO-Client</role-name>
+ </security-role>
</web-app>
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 index 5b4009fb77..58299ea9d9 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -32,7 +32,7 @@ import org.openecomp.mso.requestsdb.SiteStatus; /** * MSO Request DB Adapter Web Service */ -@WebService(name = "RequestsDbAdapter", targetNamespace = "http://com.att.mso/requestsdb") +@WebService(name = "RequestsDbAdapter", targetNamespace = "http://org.openecomp.mso/requestsdb") public interface MsoRequestsDbAdapter { @WebMethod @@ -47,7 +47,8 @@ public interface MsoRequestsDbAdapter { @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; + @WebParam(name = "volumeGroupId") @XmlElement(required = false) String volumeGroupId, + @WebParam(name = "serviceInstanceName") @XmlElement(required = false) String serviceInstanceName) throws MsoRequestsDbException; @WebMethod public InfraActiveRequests getInfraRequest (@WebParam(name="requestId") @XmlElement(required = true) String requestId) throws MsoRequestsDbException; 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 index e1b752af24..0ff8b5ff43 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -34,12 +34,15 @@ 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.db.HibernateUtils; +import org.openecomp.mso.requestsdb.HibernateUtilsRequestsDb; import org.openecomp.mso.requestsdb.InfraActiveRequests; -@WebService(serviceName = "RequestsDbAdapter", endpointInterface = "org.openecomp.mso.adapters.requestsdb.MsoRequestsDbAdapter", targetNamespace = "http://com.att.mso/requestsdb") +@WebService(serviceName = "RequestsDbAdapter", endpointInterface = "org.openecomp.mso.adapters.requestsdb.MsoRequestsDbAdapter", targetNamespace = "http://org.openecomp.mso/requestsdb") public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { + protected HibernateUtils hibernateUtils = new HibernateUtilsRequestsDb (); + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); @Override @@ -54,9 +57,10 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { String networkId, String vnfId, String vfModuleId, - String volumeGroupId) throws MsoRequestsDbException { + String volumeGroupId, + String serviceInstanceName) throws MsoRequestsDbException { MsoLogger.setLogContext (requestId, null); - Session session = HibernateUtil.getSessionFactory ().openSession (); + Session session = hibernateUtils.getSessionFactory ().openSession (); int result = 0; long startTime = System.currentTimeMillis (); try { @@ -92,20 +96,23 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { if (volumeGroupId != null) { queryString += "volumeGroupId = :volumeGroupId, "; } + if (serviceInstanceName != null) { + queryString += "serviceInstanceName = :serviceInstanceName, "; + } 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); - + + 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); + LOGGER.debug ("StatusMessage in updateInfraRequest is set to: " + statusMessage); } if (responseBody != null) { query.setParameter ("responseBody", responseBody); @@ -115,7 +122,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { 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); @@ -144,6 +151,10 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { query.setParameter ("volumeGroupId", volumeGroupId); LOGGER.debug ("VolumeGroupId in updateInfraRequest is set to: " + volumeGroupId); } + if (serviceInstanceName != null) { + query.setParameter ("serviceInstanceName", serviceInstanceName); + LOGGER.debug ("ServiceInstanceName in updateInfraRequest is set to: " + serviceInstanceName); + } Timestamp nowTimeStamp = new Timestamp (System.currentTimeMillis ()); if (requestStatus == RequestStatusType.COMPLETE || requestStatus == RequestStatusType.FAILED) { query.setParameter ("endTime", nowTimeStamp); @@ -156,7 +167,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { LOGGER.debug ("LastModifiedBy in updateInfraRequest is set to: " + lastModifiedBy); result = query.executeUpdate (); checkIfExists (result, requestId, startTime); - session.getTransaction ().commit (); + 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); @@ -184,7 +195,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { public InfraActiveRequests getInfraRequest (String requestId) throws MsoRequestsDbException { long startTime = System.currentTimeMillis (); MsoLogger.setLogContext (requestId, null); - Session session = HibernateUtil.getSessionFactory ().openSession (); + Session session = hibernateUtils.getSessionFactory ().openSession (); LOGGER.debug ("Call to MSO Infra RequestsDb adapter get method with request Id: " + requestId); @@ -218,7 +229,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { */ public boolean getSiteStatus (String siteName) { UUIDChecker.generateUUID (LOGGER); - Session session = HibernateUtil.getSessionFactory ().openSession (); + Session session = hibernateUtils.getSessionFactory ().openSession (); long startTime = System.currentTimeMillis (); SiteStatus siteStatus = null; 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 index 8e4fcf4083..5de06ca1c1 100644 --- 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 @@ -30,7 +30,7 @@ import javax.xml.ws.WebFault; * * */ -@WebFault (name="MsoRequestsDbException", faultBean="org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbExceptionBean", targetNamespace="http://com.att.mso/requestsdb") +@WebFault (name="MsoRequestsDbException", faultBean="org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbExceptionBean", targetNamespace="http://org.openecomp.mso/requestsdb") public class MsoRequestsDbException extends Exception { private static final long serialVersionUID = 1L; diff --git a/adapters/mso-sdnc-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-sdnc-adapter/WebContent/WEB-INF/web.xml index bb58197bf1..cce3f14ff9 100644 --- a/adapters/mso-sdnc-adapter/WebContent/WEB-INF/web.xml +++ b/adapters/mso-sdnc-adapter/WebContent/WEB-INF/web.xml @@ -4,7 +4,7 @@ <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> @@ -23,7 +23,7 @@ </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> + <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,org.openecomp.mso.adapters.sdnc.sdncrest.SNIROResponse,org.openecomp.mso.adapters.sdnc.sdncrest.SDNCAdapterRest</param-value> </context-param> <context-param> <param-name>resteasy.servlet.mapping.prefix</param-name> @@ -78,6 +78,7 @@ <web-resource-name>SDNCNotification</web-resource-name> <description>Rest Async Notification from SDNC</description> <url-pattern>/rest/SDNCNotify</url-pattern> + <url-pattern>/rest/SDNCNotify/*</url-pattern> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> @@ -86,9 +87,10 @@ </security-constraint> <security-constraint> <web-resource-collection> - <web-resource-name>SoapRequests</web-resource-name> + <web-resource-name>SDNCRequests</web-resource-name> <description>Soap Ingress Requests</description> <url-pattern>/SDNCAdapter</url-pattern> + <url-pattern>/rest/v1/sdnc/*</url-pattern> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> diff --git a/adapters/mso-sdnc-adapter/null/mso-config/uuid/uuid_null b/adapters/mso-sdnc-adapter/null/mso-config/uuid/uuid_null deleted file mode 100644 index 1e111235e7..0000000000 --- a/adapters/mso-sdnc-adapter/null/mso-config/uuid/uuid_null +++ /dev/null @@ -1 +0,0 @@ -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 index 5e6c5c6b36..f439459955 100644 --- a/adapters/mso-sdnc-adapter/pom.xml +++ b/adapters/mso-sdnc-adapter/pom.xml @@ -100,5 +100,11 @@ <artifactId>mso-adapters-rest-interface</artifactId> <version>${project.version}</version> </dependency> + <!-- For UriUtils which does URL encoding according to RFC 3986 Section 2 --> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>4.3.2.RELEASE</version> + </dependency> </dependencies> </project>
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/readme b/adapters/mso-sdnc-adapter/readme index 34c09fdf7c..aa112c8578 100644 --- a/adapters/mso-sdnc-adapter/readme +++ b/adapters/mso-sdnc-adapter/readme @@ -19,7 +19,7 @@ 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.sdncurl=https://sdnchost: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 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 index 254fea0ba3..f4c8234407 100644 --- 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 @@ -36,15 +36,15 @@ import javax.xml.bind.annotation.XmlSeeAlso; * */ //BPEL SDNCAdapter SOAP WebService - impl class in impl pkg -@WebService(targetNamespace = "http://domain2.att.com/workflow/sdnc/adapter/wsdl/v1", name = "SDNCAdapterPortType") +@WebService(targetNamespace = "http://org.openecomp/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") + @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.openecomp/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") + @WebParam(partName = "SDNCAdapterRequest", name = "SDNCAdapterRequest", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1") SDNCAdapterRequest sdncAdapterRequest ); 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 index 6b75949453..5da1e51d43 100644 --- 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 @@ -41,7 +41,7 @@ import org.openecomp.mso.adapters.sdnc.impl.Utils; * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> - * <element ref="{http://domain2.att.com/workflow/sdnc/adapter/schema/v1}RequestHeader"/> + * <element ref="{http://org.openecomp/workflow/sdnc/adapter/schema/v1}RequestHeader"/> * <element name="RequestData" type="{http://www.w3.org/2001/XMLSchema}anyType"/> * </sequence> * </restriction> 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 index 0b63ad6dea..1e33789ba8 100644 --- 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 @@ -42,15 +42,15 @@ import org.openecomp.mso.logger.MessageEnum; //BPEL SDNCAdapter SOAP WebService @WebServiceClient(name = "SDNCAdapterService", wsdlLocation = "main/resources/SDNCAdapter.wsdl", - targetNamespace = "http://domain2.att.com/workflow/sdnc/adapter/wsdl/v1") + targetNamespace = "http://org.openecomp/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"); + public final static QName SERVICE = new QName("http://org.openecomp/workflow/sdnc/adapter/wsdl/v1", "SDNCAdapterService"); + public final static QName SDNCAdapterSoapHttpPort = new QName("http://org.openecomp/workflow/sdnc/adapter/wsdl/v1", "SDNCAdapterSoapHttpPort"); static { URL wsdlUrl = null; try { 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 index fd16e4754c..f62c984ef9 100644 --- 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 @@ -42,7 +42,7 @@ import org.openecomp.mso.logger.MessageEnum; * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> - * <element ref="{http://domain2.att.com/workflow/sdnc/adapter/schema/v1}CallbackHeader"/> + * <element ref="{http://org.openecomp/workflow/sdnc/adapter/schema/v1}CallbackHeader"/> * <element name="RequestData" type="{http://www.w3.org/2001/XMLSchema}anyType"/> * </sequence> * </restriction> 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 index 6818e67e75..d792b9ca18 100644 --- 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 @@ -37,15 +37,15 @@ import org.openecomp.mso.adapters.sdnc.SDNCAdapterResponse; * */ //SDNCAdapter to BPEL Async response WEB Service -@WebService(targetNamespace = "http://domain2.att.com/workflow/sdnc/adapter/callback/wsdl/v1", name = "SDNCCallbackAdapterPortType") +@WebService(targetNamespace = "http://org.openecomp/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") + @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.openecomp/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") + @WebParam(partName = "SDNCAdapterCallbackRequest", name = "SDNCAdapterCallbackRequest", targetNamespace = "http://org.openecomp/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 index 6fa8e035a5..bbac6a30cb 100644 --- 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 @@ -40,14 +40,14 @@ import org.openecomp.mso.logger.MsoLogger; //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") + targetNamespace = "http://org.openecomp/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"); + public final static QName SERVICE = new QName("http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1", "SDNCCallbackAdapterService"); + public final static QName SDNCCallbackAdapterSoapHttpPort = new QName("http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1", "SDNCCallbackAdapterSoapHttpPort"); static { URL wsdlUrl = null; try { 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 index 0d6f900f47..35334dfa74 100644 --- 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 @@ -18,6 +18,6 @@ * ============LICENSE_END========================================================= */ -@javax.xml.bind.annotation.XmlSchema(namespace = "http://domain2.att.com/workflow/sdnc/adapter/schema/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.openecomp/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 index 6cc0ecbd92..78983291c6 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -23,11 +23,12 @@ package org.openecomp.mso.adapters.sdnc.impl; public interface Constants { + public static final String BPEL_REST_URL_PROP = "org.openecomp.mso.adapters.sdnc.rest.bpelurl"; 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 DEFAULT_BPEL_URL = "http://localhost: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 DEFAULT_MY_URL = "https://localhost: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"; 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 index 887c0a9990..0eeacaf5fc 100644 --- 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 @@ -35,7 +35,7 @@ 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") +@WebService(serviceName = "SDNCAdapterService", endpointInterface = "org.openecomp.mso.adapters.sdnc.SDNCAdapterPortType", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/wsdl/v1") public class SDNCAdapterPortTypeImpl implements SDNCAdapterPortType { private MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory(); 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 index 58359c69b0..55819c6e4d 100644 --- 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 @@ -18,6 +18,6 @@ * ============LICENSE_END========================================================= */ -@javax.xml.bind.annotation.XmlSchema(namespace = "http://domain2.att.com/workflow/sdnc/adapter/schema/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.openecomp/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/sdncrest/BPRestCallback.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.java new file mode 100644 index 0000000000..0e3e6278b5 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.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.adapters.sdnc.sdncrest; + +import org.openecomp.mso.adapters.sdnc.impl.Constants; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.config.RequestConfig; +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.HttpClientBuilder; +import org.apache.http.util.EntityUtils; + +import javax.xml.bind.DatatypeConverter; + +/** + * Sends asynchronous messages to the BPMN WorkflowMessage service. + */ +public class BPRestCallback { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger(); + + /** + * Sends a message to the BPMN workflow message service. The URL path is + * constructed using the specified message type and correlator. + * @param workflowMessageUrl the base BPMN WorkflowMessage URL + * @param messageType the message type + * @param correlator the message correlator + * @param message the JSON content + * @return true if the message was consumed successfully by the endpoint + */ + public boolean send(String workflowMessageUrl, String messageType, String correlator, String message) { + LOGGER.debug(getClass().getSimpleName() + ".send(" + + "workflowMessageUrl=" + workflowMessageUrl + + " messageType=" + messageType + + " correlator=" + correlator + + " message=" + message + + ")"); + + while (workflowMessageUrl.endsWith("/")) { + workflowMessageUrl = workflowMessageUrl.substring(0, workflowMessageUrl.length()-1); + } + + String endpoint = workflowMessageUrl + "/" + SDNCAdapterUtils.encodeURLPathSegment(messageType) + + "/" + SDNCAdapterUtils.encodeURLPathSegment(correlator); + + return send(endpoint, message); + } + + /** + * Sends a message to the BPMN workflow message service. The specified URL + * must have the message type and correlator already embedded in it. + * @param url the endpoint URL + * @param message the JSON content + * @return true if the message was consumed successfully by the endpoint + */ + public boolean send(String url, String message) { + LOGGER.debug(getClass().getSimpleName() + ".send(" + + "url=" + url + + " message=" + message + + ")"); + + LOGGER.info(MessageEnum.RA_CALLBACK_BPEL, message == null ? "[no content]" : message, "Camunda", ""); + + HttpPost method = null; + HttpResponse httpResponse = null; + + try { + // TODO: configurable timeout? + int timeout = 60 * 1000; + + RequestConfig requestConfig = RequestConfig.custom() + .setSocketTimeout(timeout) + .setConnectTimeout(timeout) + .setConnectionRequestTimeout(timeout) + .build(); + + HttpClient client = HttpClientBuilder.create().build(); + method = new HttpPost(url); + method.setConfig(requestConfig); + + if (message != null) { + method.setEntity(new StringEntity(message, ContentType.APPLICATION_JSON)); + } + + boolean error = false; + + try { + // AAF Integration, disabled for now due to the constrains from other party + // String userCredentials = CredentialConstants.getDecryptedCredential(Constants.DEFAULT_BPEL_AUTH); + // Once AAF enabled, the credential shall be get by triggering the CredentialConstants.getDecryptedCredential -- remove line + String userCredentials = SDNCAdapterProperties.getEncryptedProperty(Constants.BPEL_AUTH_PROP, + Constants.DEFAULT_BPEL_AUTH, Constants.ENCRYPTION_KEY); + String authorization = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); + method.setHeader("Authorization", authorization); + } catch (Exception e) { + LOGGER.error(MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, + "Unable to set authorization in callback request", e); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, + "Unable to set authorization in callback request: " + e.getMessage()); + error = true; + } + + if (!error) { + httpResponse = client.execute(method); + + @SuppressWarnings("unused") + String responseContent = null; + + if (httpResponse.getEntity() != null) { + responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); + } + + if (httpResponse.getStatusLine().getStatusCode() >= 300) { + String msg = "Received error response to callback request: " + httpResponse.getStatusLine(); + LOGGER.error(MessageEnum.RA_CALLBACK_BPEL_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, msg); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, msg); + } + + httpResponse = null; + } + + method.reset(); + method = null; + return true; + } catch (Exception e) { + LOGGER.error(MessageEnum.RA_CALLBACK_BPEL_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, + "Error sending callback request", e); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, + "Error sending callback request: " + e.getMessage()); + return false; + } finally { + if (httpResponse != null) { + try { + EntityUtils.consume(httpResponse.getEntity()); + } catch (Exception e) { + // Ignore + } + } + + if (method != null) { + try { + method.reset(); + } catch (Exception e) { + // Ignore + } + } + + LOGGER.info(MessageEnum.RA_CALLBACK_BPEL_COMPLETE, "Camunda", ""); + } + } +}
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterProperties.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterProperties.java new file mode 100644 index 0000000000..ba8fdfb936 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterProperties.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.sdnc.sdncrest; + +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; + +/** + * Static methods to access SDNC adapter properties. + */ +public final class SDNCAdapterProperties { + private static final String MSO_PROPERTIES_ID = "MSO_PROP_SDNC_ADAPTER"; + private static final MsoPropertiesFactory MSO_PROPERTIES_FACTORY = new MsoPropertiesFactory(); + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + + /** + * Gets the value of an SDNC adapter property. + * @param key the property key + * @param defaultValue the default value to use if the property does not + * exist or if an error occurs + */ + public static String getProperty(String key, String defaultValue) { + MsoJavaProperties properties; + + try { + properties = MSO_PROPERTIES_FACTORY.getMsoJavaProperties(MSO_PROPERTIES_ID); + } catch (MsoPropertiesException e) { + LOGGER.error (MessageEnum.NO_PROPERTIES, "Unknown. Mso Properties ID not found in cache: " + MSO_PROPERTIES_ID, + "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - Mso Properties ID not found in cache", e); + return defaultValue; + } + + String value = properties.getProperty(key, defaultValue); + LOGGER.debug("Config read for " + MSO_PROPERTIES_ID + " - key:" + key + " value:" + value); + return value; + } + + /** + * Gets the value of an SDNC adapter property. + * @param key the property key + * @param defaultValue the default value to use if the property does not + * exist or if an error occurs + */ + public static String getEncryptedProperty(String key, String defaultValue, String encryptionKey) { + MsoJavaProperties properties; + + try { + properties = MSO_PROPERTIES_FACTORY.getMsoJavaProperties(MSO_PROPERTIES_ID); + } catch (MsoPropertiesException e) { + LOGGER.error (MessageEnum.NO_PROPERTIES, "Unknown. Mso Properties ID not found in cache: " + MSO_PROPERTIES_ID, + "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - Mso Properties ID not found in cache", e); + return defaultValue; + } + + String value = properties.getEncryptedProperty(key, defaultValue, encryptionKey); + LOGGER.debug("Config read for " + MSO_PROPERTIES_ID + " - key:" + key); + return value; + } + + /** + * Instantiation is not allowed. + */ + private SDNCAdapterProperties() { + } +}
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterRest.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterRest.java new file mode 100644 index 0000000000..c4ed50a1b1 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterRest.java @@ -0,0 +1,239 @@ +/*- + * ============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.sdncrest; + +import org.openecomp.mso.HealthCheckUtils; +import org.openecomp.mso.adapters.sdnc.impl.Constants; +import org.openecomp.mso.adapters.sdncrest.SDNCEvent; +import org.openecomp.mso.adapters.sdncrest.SDNCResponseCommon; +import org.openecomp.mso.adapters.sdncrest.SDNCServiceError; +import org.openecomp.mso.adapters.sdncrest.SDNCServiceRequest; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.utils.UUIDChecker; +import org.apache.http.HttpStatus; + +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.GenericEntity; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.text.ParseException; + +/** + * SDNC REST adapter interface added in 1702 to support the SDNC "agnostic" API. + */ +@Path("/") +public class SDNCAdapterRest { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger(); + + private static final String MSO_PROPERTIES_ID = "MSO_PROP_SDNC_ADAPTER"; + + @HEAD + @GET + @Path("/v1/sdnc/healthcheck") + @Produces(MediaType.TEXT_HTML) + public Response healthcheck(@QueryParam("requestId") String requestId) { + long startTime = System.currentTimeMillis(); + MsoLogger.setServiceName("Healthcheck"); + UUIDChecker.verifyOldUUID(requestId, LOGGER); + HealthCheckUtils healthCheck = new HealthCheckUtils(); + + if (!healthCheck.siteStatusCheck(LOGGER, startTime)) { + return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; + } + + if (!healthCheck.configFileCheck(LOGGER, startTime, MSO_PROPERTIES_ID)) { + return HealthCheckUtils.NOT_STARTED_RESPONSE; + } + + LOGGER.debug("healthcheck - Successful"); + return HealthCheckUtils.HEALTH_CHECK_RESPONSE; + } + + /** + * Processes an SDNCServiceRequest (a request for "agnostic" API services) from BP. + * @param request the request + * @param msoRequestId the request ID for the top-level MSO flow (used for logging only) + * @param msoServiceInstanceId the top-level service-instance-id (used for logging only) + */ + @POST + @Path("/v1/sdnc/services") + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + public Response service( + SDNCServiceRequest request, + @HeaderParam(value="att-mso-request-id") String msoRequestId, + @HeaderParam(value="att-mso-service-instance-id") String msoServiceInstanceId) { + + MsoLogger.setLogContext(msoRequestId, msoServiceInstanceId); + + try { + LOGGER.debug(getClass().getSimpleName() + ".service(request)" + + " entered with request: " + request.toJson()); + + SDNCServiceRequestTask task = new SDNCServiceRequestTask(request, msoRequestId, + msoServiceInstanceId, "/services"); + + try { + Thread thread = new Thread(task); + thread.start(); + } catch (Exception e) { + String msg = "Failed to start thread to run SDNCServiceTask"; + LOGGER.error(MessageEnum.RA_SEND_REQUEST_SDNC_ERR, "SDNC", "", MsoLogger.ErrorCode.BusinessProcesssError, msg, e); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, msg); + SDNCServiceError error = new SDNCServiceError(request.getSDNCRequestId(), + String.valueOf(HttpStatus.SC_INTERNAL_SERVER_ERROR), e.toString(), "Y"); + LOGGER.debug(getClass().getSimpleName() + ".service(request)" + + " exited with error: " + msg); + return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<SDNCServiceError>(error){}) + .build(); + } + + // Send sync response to caller + LOGGER.debug(getClass().getSimpleName() + ".service(request)" + + " exited successfully"); + return Response.status(HttpStatus.SC_ACCEPTED).build(); + } catch (Exception e) { + String msg = "Caught " + e.getClass().getSimpleName() + " in 'service' method"; + LOGGER.error(MessageEnum.RA_SEND_REQUEST_SDNC_ERR, "SDNC", "", MsoLogger.ErrorCode.BusinessProcesssError, msg, e); + LOGGER.debug(getClass().getSimpleName() + ".service(request)" + + " exited with error: " + msg); + SDNCServiceError error = new SDNCServiceError(request.getSDNCRequestId(), + String.valueOf(HttpStatus.SC_INTERNAL_SERVER_ERROR), e.toString(), "Y"); + return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<SDNCServiceError>(error){}) + .build(); + } + } + + /** + * Processes a notification from SDNC for "agnostic" API services. + * Note that the "myurl" configuration property specifies the path + * up to and including /SDNCNotify. The /services part of the path + * is added by this class. + * @param content the notification content + */ + @POST + @Path("/SDNCNotify/services") + @Consumes({MediaType.APPLICATION_XML}) + @Produces({MediaType.APPLICATION_XML}) + public Response serviceNotification(String content) { + LOGGER.info(MessageEnum.RA_RECEIVE_SDNC_NOTIF, content, "SDNC", "SDNCNotify/services"); + + long startTime = System.currentTimeMillis(); + + try { + // Because the format of a notification is exactly the same as that of + // a synchronous response, we can use the same code to parse it. + SDNCResponseCommon response = SDNCServiceRequestConnector.parseResponseContent(content); + + String bpUrl = SDNCAdapterProperties.getProperty(Constants.BPEL_REST_URL_PROP, null); + + if (bpUrl == null) { + String error = "Missing configuration for: " + Constants.BPEL_REST_URL_PROP; + LOGGER.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, Constants.BPEL_REST_URL_PROP, "SDNC", "", + MsoLogger.ErrorCode.DataError, "Missing config param"); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(error).build(); + } + + long bpStartTime = System.currentTimeMillis(); + BPRestCallback callback = new BPRestCallback(); + boolean callbackSuccess = callback.send(bpUrl, "SDNCAResponse", response.getSDNCRequestId(), response.toJson()); + + if (callbackSuccess) { + LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + "Sent notification", "BPMN", bpUrl, null); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + } else { + LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + "Failed to send notification", "BPMN", bpUrl, null); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + "Failed to send notification"); + } + + return Response.ok().build(); + } catch (ParseException e) { + LOGGER.error(MessageEnum.RA_PARSING_REQUEST_ERROR, "SDNC", "SDNCNotify/services", + MsoLogger.ErrorCode.SchemaError, e.getMessage()); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.SchemaError, e.getMessage()); + return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(e.getMessage()).build(); + } + } + + /** + * Processes an event notification from SDNC. + * Note that the "myurl" configuration property specifies the path + * up to and including /SDNCNotify. The /activate part of the path + * is added by this class. + * @param content the notification content + */ + @POST + @Path("/SDNCNotify/event") + @Consumes({MediaType.APPLICATION_XML}) + @Produces({MediaType.APPLICATION_XML}) + public Response eventNotification(String content) { + LOGGER.info(MessageEnum.RA_RECEIVE_SDNC_NOTIF, content, "SDNC", "SDNCNotify/event"); + + long startTime = System.currentTimeMillis(); + + try { + SDNCEvent event = SDNCEventParser.parse(content); + + String bpUrl = SDNCAdapterProperties.getProperty(Constants.BPEL_REST_URL_PROP, null); + + if (bpUrl == null) { + String error = "Missing configuration for: " + Constants.BPEL_REST_URL_PROP; + LOGGER.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, Constants.BPEL_REST_URL_PROP, "SDNC", "", + MsoLogger.ErrorCode.DataError, "Missing config param"); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(error).build(); + } + + long bpStartTime = System.currentTimeMillis(); + BPRestCallback callback = new BPRestCallback(); + boolean callbackSuccess = callback.send(bpUrl, "SDNCAEvent", event.getEventCorrelator(), event.toJson()); + + if (callbackSuccess) { + LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + "Sent notification", "BPMN", bpUrl, null); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + } else { + LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + "Failed to send notification", "BPMN", bpUrl, null); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + "Failed to send notification"); + } + + return Response.ok().build(); + } catch (ParseException e) { + LOGGER.error(MessageEnum.RA_PARSING_REQUEST_ERROR, "SDNC", "SDNCNotify/event", + MsoLogger.ErrorCode.SchemaError, e.getMessage()); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.SchemaError, e.getMessage()); + return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(e.getMessage()).build(); + } + } +}
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterUtils.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterUtils.java new file mode 100644 index 0000000000..d97f340a7c --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterUtils.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.sdnc.sdncrest; + +import org.springframework.web.util.UriUtils; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.List; + +/** + * Utility methods used by SDNCAdapterRest. + */ +public final class SDNCAdapterUtils { + /** + * Returns a node's child elements in a list. + */ + public static List<Element> childElements(Node node) { + List<Element> elements = new ArrayList<Element>(); + + NodeList nodeList = node.getChildNodes(); + for (int i = 0; i < nodeList.getLength(); i++) { + Node child = nodeList.item(i); + if (child.getNodeType() == Node.ELEMENT_NODE) { + elements.add((Element) child); + } + } + + return elements; + } + + /** + * Encodes a URL path segment according to RFC 3986 Section 2. + * @param pathSegment the path segment to encode + * @return the encoded path segment + */ + public static String encodeURLPathSegment(String pathSegment) { + try { + return UriUtils.encodePathSegment(pathSegment, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("UTF-8 encoding is not supported"); + } + } + + /** + * Instantiation is not allowed. + */ + private SDNCAdapterUtils() { + } +}
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java new file mode 100644 index 0000000000..26c186599c --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java @@ -0,0 +1,309 @@ +/*- + * ============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.sdncrest; + +import org.openecomp.mso.adapters.sdnc.impl.Constants; +import org.openecomp.mso.adapters.sdncrest.SDNCErrorCommon; +import org.openecomp.mso.adapters.sdncrest.SDNCResponseCommon; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.*; +import org.apache.http.conn.ConnectTimeoutException; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; + +import javax.xml.XMLConstants; +import javax.xml.bind.DatatypeConverter; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; +import java.io.StringReader; +import java.net.HttpURLConnection; +import java.net.SocketTimeoutException; + +/** + * Sends requests to SDNC and processes the responses. + */ +public abstract class SDNCConnector { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger(); + + public SDNCResponseCommon send(String content, TypedRequestTunables rt) { + LOGGER.info(MessageEnum.RA_SEND_REQUEST_SDNC, rt.toString(), "SDNC", ""); + LOGGER.debug("SDNC Request Body:\n" + content); + + HttpRequestBase method = null; + HttpResponse httpResponse = null; + + try { + int timeout = Integer.parseInt(rt.getTimeout()); + + RequestConfig requestConfig = RequestConfig.custom() + .setSocketTimeout(timeout) + .setConnectTimeout(timeout) + .setConnectionRequestTimeout(timeout) + .build(); + + HttpClient client = HttpClientBuilder.create().build(); + + if ("POST".equals(rt.getReqMethod())) { + HttpPost httpPost = new HttpPost(rt.getSdncUrl()); + httpPost.setConfig(requestConfig); + httpPost.setEntity(new StringEntity(content, ContentType.APPLICATION_XML)); + method = httpPost; + } else if ("PUT".equals(rt.getReqMethod())) { + HttpPut httpPut = new HttpPut(rt.getSdncUrl()); + httpPut.setConfig(requestConfig); + httpPut.setEntity(new StringEntity(content, ContentType.APPLICATION_XML)); + method = httpPut; + } else if ("GET".equals(rt.getReqMethod())) { + HttpGet httpGet = new HttpGet(rt.getSdncUrl()); + httpGet.setConfig(requestConfig); + method = httpGet; + } else if ("DELETE".equals(rt.getReqMethod())) { + HttpDelete httpDelete = new HttpDelete(rt.getSdncUrl()); + httpDelete.setConfig(requestConfig); + method = httpDelete; + } + + // AAF Integration, disabled for now due to the constrains from other party + // String userCredentials = CredentialConstants.getSecurityProperties().getEncryptedProperty(CredentialConstants.DEFAULT_AUTH, "", CredentialConstants.getEncryptionKey()); + // if (userCredentials == null) { + // userCredentials = ""; + //} + String userCredentials = SDNCAdapterProperties.getEncryptedProperty(Constants.SDNC_AUTH_PROP, + Constants.DEFAULT_SDNC_AUTH, Constants.ENCRYPTION_KEY); + String authorization = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); + method.setHeader("Authorization", authorization); + + method.setHeader("Accept", "application/yang.data+xml"); + + httpResponse = client.execute(method); + + String responseContent = null; + if (httpResponse.getEntity() != null) { + responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); + } + + int statusCode = httpResponse.getStatusLine().getStatusCode(); + String statusMessage = httpResponse.getStatusLine().getReasonPhrase(); + + LOGGER.debug("SDNC Response: " + statusCode + " " + statusMessage + + (responseContent == null ? "" : System.lineSeparator() + responseContent)); + + if (httpResponse.getStatusLine().getStatusCode() >= 300) { + String errMsg = "SDNC returned " + statusCode + " " + statusMessage; + + String errors = analyzeErrors(responseContent); + if (errors != null) { + errMsg += " " + errors; + } + + logError(errMsg); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg); + return createErrorResponse(statusCode, errMsg, rt); + } + + httpResponse = null; + + method.reset(); + method = null; + + LOGGER.info(MessageEnum.RA_RESPONSE_FROM_SDNC, responseContent, "SDNC", ""); + return createResponseFromContent(statusCode, statusMessage, responseContent, rt); + + } catch (SocketTimeoutException e) { + String errMsg = "Request to SDNC timed out"; + logError(errMsg, e); + return createErrorResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg, rt); + + } catch (ConnectTimeoutException e) { + String errMsg = "Request to SDNC timed out"; + logError(errMsg, e); + return createErrorResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg, rt); + + } catch (Exception e) { + String errMsg = "Error processing request to SDNC"; + logError(errMsg, e); + return createErrorResponse(HttpURLConnection.HTTP_INTERNAL_ERROR, errMsg, rt); + + } finally { + if (httpResponse != null) { + try { + EntityUtils.consume(httpResponse.getEntity()); + } catch (Exception e) { + // Ignore + } + } + + if (method != null) { + try { + method.reset(); + } catch (Exception e) { + // Ignore + } + } + } + } + + protected void logError(String errMsg) { + LOGGER.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", + MsoLogger.ErrorCode.AvailabilityError, errMsg); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg); + } + + protected void logError(String errMsg, Throwable t) { + LOGGER.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", + MsoLogger.ErrorCode.AvailabilityError, errMsg, t); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg); + } + + /** + * Generates a response object from content received from SDNC. The response + * object may be a success response object or an error response object. This + * method must be overridden by the subclass to return the correct object type. + * @param statusCode the response status code from SDNC (e.g. 200) + * @param statusMessage the response status message from SDNC (e.g. "OK") + * @param responseContent the body of the response from SDNC (possibly null) + * @param rt request tunables + * @return a response object + */ + protected abstract SDNCResponseCommon createResponseFromContent(int statusCode, + String statusMessage, String responseContent, TypedRequestTunables rt); + + /** + * Generates an error response object. This method must be overridden by the + * subclass to return the correct object type. + * @param statusCode the response status code (from SDNC, or internally generated) + * @param errMsg the error message (normally a verbose explanation of the error) + * @param rt request tunables + * @return an error response object + */ + protected abstract SDNCErrorCommon createErrorResponse(int statusCode, + String errMsg, TypedRequestTunables rt); + + /** + * Called by the send() method to analyze errors that may be encoded in the + * content of non-2XX responses. By default, this method tries to parse the + * content as a restconf error. + * <pre> + * xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf" + * </pre> + * If an error (or errors) can be obtained from the content, then the result + * is a string in this format: + * <pre> + * [error-type:TYPE, error-tag:TAG, error-message:MESSAGE] ... + * </pre> + * If no error could be obtained from the content, then the result is null. + * <p> + * The subclass can override this method to provide another implementation. + */ + protected String analyzeErrors(String content) { + if (content == null || content.isEmpty()) { + return null; + } + + // Confirmed with Andrew Shen on 11/1/16 that SDNC will send content like + // this in error responses (non-2XX response codes) to "agnostic" service + // requests. + // + // <errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf"> + // <error> + // <error-type>protocol</error-type> + // <error-tag>malformed-message</error-tag> + // <error-message>Error parsing input: The element type "input" must be terminated by the matching end-tag "</input>".</error-message> + // </error> + // </errors> + + String output = null; + + try { + XPathFactory xpathFactory = XPathFactory.newInstance(); + XPath xpath = xpathFactory.newXPath(); + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); + InputSource source = new InputSource(new StringReader(content)); + Document doc = documentBuilderFactory.newDocumentBuilder().parse(source); + 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 info = ""; + + try { + String errorType = xpath.evaluate("error-type", error); + info += "error-type:" + errorType; + } catch (XPathExpressionException e) { + LOGGER.error(MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-type", error.toString(), "SDNC", "", + MsoLogger.ErrorCode.DataError, "XPath Exception", e); + } + + try { + String errorTag = xpath.evaluate( "error-tag", error); + if (!info.isEmpty()) { + info += ", "; + } + info += "error-tag:" + errorTag; + } catch (XPathExpressionException e) { + LOGGER.error(MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-tag", error.toString(), "SDNC", "", + MsoLogger.ErrorCode.DataError, "XPath Exception", e); + } + + try { + String errorMessage = xpath.evaluate("error-message", error); + if (!info.isEmpty()) { + info += ", "; + } + info += "error-message:" + errorMessage; + } catch (Exception e) { + LOGGER.error(MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-message", error.toString(), "SDNC", "", + MsoLogger.ErrorCode.DataError, "XPath Exception", e); + } + + if (!info.isEmpty()) { + if (output == null) { + output = "[" + info + "]"; + } else { + output += " [" + info + "]"; + } + } + } + } catch (Exception e) { + LOGGER.error (MessageEnum.RA_ANALYZE_ERROR_EXC, "SDNC", "", + MsoLogger.ErrorCode.DataError, "Exception while analyzing errors", e); + } + + return output; + } +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCEventParser.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCEventParser.java new file mode 100644 index 0000000000..9808f48e7e --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCEventParser.java @@ -0,0 +1,156 @@ +/*- + * ============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.sdncrest; + +import org.openecomp.mso.adapters.sdncrest.SDNCEvent; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.InputSource; + +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.StringReader; +import java.text.ParseException; + +/** + * SDNCConnector for "agnostic" API services. + */ +public class SDNCEventParser { + /** + * Parses SDNC event XML. If the content can be parsed and contains all required + * elements, then an object is returned. Otherwise, a ParseException is thrown. + * This method performs no logging or alarming. + * @throws ParseException on error + */ + public static SDNCEvent parse(String content) throws ParseException { + try { + // Note: this document builder is not namespace-aware, so namespaces are ignored. + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); + InputSource source = new InputSource(new StringReader(content)); + Document doc = documentBuilderFactory.newDocumentBuilder().parse(source); + + // Find the configuration-event child under the root element. + // The root element is expected to be an "output" element, but we don't really care. + + Element root = doc.getDocumentElement(); + Element configurationEvent = null; + + for (Element child : SDNCAdapterUtils.childElements(root)) { + if ("configuration-event".equals(child.getNodeName())) { + configurationEvent = child; + break; + } + } + + if (configurationEvent == null) { + throw new ParseException("No configuration-event element in SDNC event", 0); + } + + // Process the children of configuration-event + + String eventType = null; + String eventCorrelatorType = null; + String eventCorrelator = null; + Element eventParameters = null; + + for (Element child : SDNCAdapterUtils.childElements(configurationEvent)) { + if ("event-type".equals(child.getNodeName())) { + eventType = child.getTextContent(); + } else if ("event-correlator-type".equals(child.getNodeName())) { + eventCorrelatorType = child.getTextContent(); + } else if ("event-correlator".equals(child.getNodeName())) { + eventCorrelator = child.getTextContent(); + } else if ("event-parameters".equals(child.getNodeName())) { + eventParameters = (Element) child; + } + } + + // event-type is mandatory. + + if (eventType == null || eventType.isEmpty()) { + throw new ParseException("No event-type in SDNC event", 0); + } + + // event-correlator-type is mandatory. + + if (eventCorrelatorType == null || eventCorrelatorType.isEmpty()) { + throw new ParseException("No event-correlator-type in SDNC event", 0); + } + + // event-correlator is mandatory. + + if (eventCorrelator == null || eventCorrelator.isEmpty()) { + throw new ParseException("No event-correlator in SDNC event", 0); + } + + // Create an event object. + + SDNCEvent event = new SDNCEvent(eventType, eventCorrelatorType, eventCorrelator); + + // event-parameters is an optional container element. If present, + // process its children, adding values to the event object. + + if (eventParameters != null) { + for (Element element : SDNCAdapterUtils.childElements(eventParameters)) { + if (!"event-parameter".equals(element.getNodeName())) { + continue; + } + + String tagName = null; + String tagValue = null; + + for (Element child : SDNCAdapterUtils.childElements(element)) { + if ("tag-name".equals(child.getNodeName())) { + tagName = child.getTextContent(); + } else if ("tag-value".equals(child.getNodeName())) { + tagValue = child.getTextContent(); + } + } + + // tag-name is mandatory + + if (tagName == null) { + throw new ParseException("Missing tag-name in SDNC event parameter", 0); + } + + // tag-value is optional. If absent, make it an empty string so we don't + // end up with null values in the parameter map. + + if (tagValue == null) { + tagValue = ""; + } + + event.addParam(tagName, tagValue); + } + } + + return event; + } catch (ParseException e) { + throw e; + } catch (Exception e) { + throw new ParseException("Failed to parse SDNC event", 0); + } + } + + // Instantiation is not allowed. + private SDNCEventParser() { + } +}
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java new file mode 100644 index 0000000000..bd864d085a --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java @@ -0,0 +1,194 @@ +/*- + * ============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.sdncrest; + +import org.openecomp.mso.adapters.sdncrest.SDNCErrorCommon; +import org.openecomp.mso.adapters.sdncrest.SDNCResponseCommon; +import org.openecomp.mso.adapters.sdncrest.SDNCServiceError; +import org.openecomp.mso.adapters.sdncrest.SDNCServiceResponse; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.InputSource; + +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.StringReader; +import java.net.HttpURLConnection; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.List; + +/** + * SDNCConnector for "agnostic" API services. + */ +public class SDNCServiceRequestConnector extends SDNCConnector { + + @Override + protected SDNCResponseCommon createResponseFromContent(int statusCode, String statusMessage, + String responseContent, TypedRequestTunables rt) { + try { + return parseResponseContent(responseContent); + } catch (ParseException e) { + logError(e.getMessage()); + return createErrorResponse(HttpURLConnection.HTTP_INTERNAL_ERROR, e.getMessage(), rt); + } + } + + @Override + protected SDNCErrorCommon createErrorResponse(int statusCode, String errMsg, + TypedRequestTunables rt) { + return new SDNCServiceError(rt.getReqId(), String.valueOf(statusCode), errMsg, "Y"); + } + + /** + * Parses SDNC synchronous service response content or service notification content. + * If the content can be parsed and contains all required elements, then an object + * is returned. The type of the returned object depends on the response code + * contained in the content. For 2XX response codes, an SDNCServiceResponse is + * returned. Otherwise, an SDNCServiceError is returned. If the content cannot + * be parsed, or if the content does not contain all required elements, a parse + * exception is thrown. This method performs no logging or alarming. + * @throws ParseException on error + */ + public static SDNCResponseCommon parseResponseContent(String responseContent) + throws ParseException { + try { + // Note: this document builder is not namespace-aware, so namespaces are ignored. + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); + InputSource source = new InputSource(new StringReader(responseContent)); + Document doc = documentBuilderFactory.newDocumentBuilder().parse(source); + + // Find the configuration-response-common child under the root element. + // The root element is expected to be an "output" element, but we don't really care. + + Element root = doc.getDocumentElement(); + Element configurationResponseCommon = null; + + for (Element child : SDNCAdapterUtils.childElements(root)) { + if ("configuration-response-common".equals(child.getNodeName())) { + configurationResponseCommon = child; + break; + } + } + + if (configurationResponseCommon == null) { + throw new ParseException("No configuration-response-common element in SDNC response", 0); + } + + // Process the children of configuration-response-common. + + String responseCode = null; + String responseMessage = null; + String svcRequestId = null; + String ackFinalIndicator = null; + List<Element> responseParameters = new ArrayList<Element>(); + + for (Element child : SDNCAdapterUtils.childElements(configurationResponseCommon)) { + if ("response-code".equals(child.getNodeName())) { + responseCode = child.getTextContent(); + } else if ("response-message".equals(child.getNodeName())) { + responseMessage = child.getTextContent(); + } else if ("svc-request-id".equals(child.getNodeName())) { + svcRequestId = child.getTextContent(); + } else if ("ack-final-indicator".equals(child.getNodeName())) { + ackFinalIndicator = child.getTextContent(); + } else if ("response-parameters".equals(child.getNodeName())) { + responseParameters.add((Element) child); + } + } + + // svc-request-id is mandatory. + + if (svcRequestId == null || svcRequestId.isEmpty()) { + throw new ParseException("No svc-request-id in SDNC response", 0); + } + + // response-code is mandatory. + + if (responseCode == null || responseCode.isEmpty()) { + throw new ParseException("No response-code in SDNC response", 0); + } + + // ack-final-indicator is optional: default to "Y". + + if (ackFinalIndicator == null) { + ackFinalIndicator = "Y"; + } + + if (!ackFinalIndicator.equals("Y") && !ackFinalIndicator.equals("N")) { + throw new ParseException("Invalid ack-final-indicator in SDNC response: '" + ackFinalIndicator + "'", 0); + } + + // response-message is optional. If the value is empty, omit it from the response object. + + if (responseMessage != null && responseMessage.isEmpty()) { + responseMessage = null; + } + + // If the response code in the message from SDNC was not 2XX, return SDNCServiceError. + + if (!responseCode.matches("2[0-9][0-9]")) { + // Not a 2XX response. Return SDNCServiceError. + return new SDNCServiceError(svcRequestId, responseCode, responseMessage, ackFinalIndicator); + } + + // Create a success response object. + + SDNCServiceResponse response = new SDNCServiceResponse(svcRequestId, + responseCode, responseMessage, ackFinalIndicator); + + // Process any response-parameters that might be present. + + for (Element element : responseParameters) { + String tagName = null; + String tagValue = null; + + for (Element child : SDNCAdapterUtils.childElements(element)) { + if ("tag-name".equals(child.getNodeName())) { + tagName = child.getTextContent(); + } else if ("tag-value".equals(child.getNodeName())) { + tagValue = child.getTextContent(); + } + } + + // tag-name is mandatory + + if (tagName == null) { + throw new ParseException("Missing tag-name in SDNC response parameter", 0); + } + + // tag-value is optional. If absent, make it an empty string so we don't + // end up with null values in the parameter map. + + if (tagValue == null) { + tagValue = ""; + } + + response.addParam(tagName, tagValue); + } + return response; + } catch (ParseException e) { + throw e; + } catch (Exception e) { + throw new ParseException("Failed to parse SDNC response", 0); + } + } +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java new file mode 100644 index 0000000000..e52a426b4d --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCServiceRequestTask.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.sdnc.sdncrest; + +import org.openecomp.mso.adapters.sdncrest.SDNCErrorCommon; +import org.openecomp.mso.adapters.sdncrest.SDNCResponseCommon; +import org.openecomp.mso.adapters.sdncrest.SDNCServiceError; +import org.openecomp.mso.adapters.sdncrest.SDNCServiceRequest; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.apache.http.HttpStatus; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import java.io.StringWriter; + +public class SDNCServiceRequestTask implements Runnable { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + + private final SDNCServiceRequest request; + private final String msoRequestId; + private final String msoServiceInstanceId; + private final String myUrlSuffix; + + public SDNCServiceRequestTask(SDNCServiceRequest request, + String msoRequestId, String msoServiceInstanceId, + String myUrlSuffix) { + this.request = request; + this.msoRequestId = msoRequestId; + this.msoServiceInstanceId = msoServiceInstanceId; + this.myUrlSuffix = myUrlSuffix; + } + + @Override + public void run() + { + MsoLogger.setLogContext(msoRequestId, msoServiceInstanceId); + MsoLogger.setServiceName(getClass().getSimpleName()); + + LOGGER.debug(getClass().getSimpleName() + ".run()" + + " entered with request: " + request.toJson()); + + String sdncRequestId = request.getSDNCRequestId(); + String sdncService = request.getSDNCService(); + String sdncOperation = request.getSDNCOperation(); + + TypedRequestTunables rt = new TypedRequestTunables(sdncRequestId, myUrlSuffix); + rt.setServiceKey(sdncService, sdncOperation); + + if (!rt.setTunables()) { + // Note that the error was logged and alarmed by setTunables() + SDNCServiceError error = new SDNCServiceError(request.getSDNCRequestId(), + String.valueOf(HttpStatus.SC_INTERNAL_SERVER_ERROR), rt.getError(), "Y"); + BPRestCallback callback = new BPRestCallback(); + callback.send(request.getBPNotificationUrl(), error.toJson()); + return; + } + + String xml = genSdncReq(request, rt); + + long sdncStartTime = System.currentTimeMillis(); + SDNCConnector connector = new SDNCServiceRequestConnector(); + SDNCResponseCommon response = connector.send(xml, rt); + + if (response instanceof SDNCErrorCommon) { + LOGGER.recordMetricEvent(sdncStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + "Received success response from SDNC", "SDNC", sdncService + "." + sdncOperation, null); + } else { + LOGGER.recordMetricEvent(sdncStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + "Received error response from SDNC", "SDNC", sdncService + "." + sdncOperation, null); + } + + long bpStartTime = System.currentTimeMillis(); + BPRestCallback callback = new BPRestCallback(); + boolean callbackSuccess = callback.send(request.getBPNotificationUrl(), response.toJson()); + + if (callbackSuccess) { + LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + "Sent notification", "BPMN", request.getBPNotificationUrl(), null); + } else { + LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + "Failed to send notification", "BPMN", request.getBPNotificationUrl(), null); + } + } + + private Element addChild(Element parent, String tag) { + Element child = parent.getOwnerDocument().createElement(tag); + parent.appendChild(child); + return child; + } + + private void addTextChild(Element parent, String tag, String text) { + if (text != null) { + Element child = parent.getOwnerDocument().createElement(tag); + child.setTextContent(text); + parent.appendChild(child); + } + } + + private String genSdncReq(SDNCServiceRequest request, TypedRequestTunables rt) { + Document doc; + + try { + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); + + doc = documentBuilder.newDocument(); + Element root = doc.createElementNS(rt.getNamespace(), "input"); + doc.appendChild(root); + + Element hdr = addChild(root, rt.getHeaderName()); + addTextChild(hdr, "svc-request-id", rt.getReqId()); + addTextChild(hdr, "svc-notification-url", rt.getMyUrl()); + + Element requestInformation = addChild(root, "request-information"); + addTextChild(requestInformation, "request-id", request.getRequestInformation().getRequestId()); + addTextChild(requestInformation, "source", request.getRequestInformation().getSource()); + addTextChild(requestInformation, "notification-url", request.getRequestInformation().getNotificationUrl()); + + Element serviceInformation = addChild(root, "service-information"); + addTextChild(serviceInformation, "service-type", request.getServiceInformation().getServiceType()); + addTextChild(serviceInformation, "service-instance-id", request.getServiceInformation().getServiceInstanceId()); + addTextChild(serviceInformation, "subscriber-name", request.getServiceInformation().getSubscriberName()); + addTextChild(serviceInformation, "subscriber-global-id", request.getServiceInformation().getSubscriberGlobalId()); + + Element agnosticServiceInformation = addChild(root, "agnostic-service-information"); + addTextChild(agnosticServiceInformation, "operation", request.getSDNCOperation()); + addTextChild(agnosticServiceInformation, "service", request.getSDNCService()); + + // anydata is mandatory in the SDNC schema, so if the data we got is null, + // set use an empty string instead to ensure we generate an empty element. + + String anydata = request.getSDNCServiceData(); + if (anydata == null) { + anydata = ""; + } + + // content-type is also mandatory. + + String contentType = request.getSDNCServiceDataType(); + + if (contentType == null || contentType.isEmpty()) { + if (anydata.isEmpty()) { + contentType = "XML"; + } else { + if (anydata.startsWith("<")) { + contentType = "XML"; + } else { + contentType = "JSON"; + } + } + } + + addTextChild(agnosticServiceInformation, "content-type", contentType); + addTextChild(agnosticServiceInformation, "anydata", anydata); + } catch (Exception e) { + LOGGER.error(MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST, "SDNC", "", + MsoLogger.ErrorCode.BusinessProcesssError, "Exception in genSdncReq", e); + return null; + } + + String xml; + + try { + StringWriter writer = new StringWriter(); + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); + transformer.transform(new DOMSource(doc), new StreamResult(writer)); + xml = writer.toString(); + } catch (Exception e) { + LOGGER.error(MessageEnum.RA_ERROR_CONVERT_XML2STR, "", "", + MsoLogger.ErrorCode.DataError, "Exception - domToStr", e); + return(null); + } + + LOGGER.debug("Formatted SDNC service request XML:\n" + xml); + return xml; + } +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SNIROResponse.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SNIROResponse.java new file mode 100644 index 0000000000..2045b8c353 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SNIROResponse.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.sdnc.sdncrest; + +import org.openecomp.mso.adapters.sdnc.impl.Constants; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; + +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +/** + * A temporary interface to support notifications from SNIRO to BPMN. + * We added this to the SDNC adapter because we didn't have time to + * develop a SNIRO adapter in 1702. + */ +@Path("/") +public class SNIROResponse { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger(); + + @POST + @Path("/SDNCNotify/SNIROResponse/{correlator}") + @Consumes("*/*") + @Produces({MediaType.TEXT_PLAIN}) + public Response serviceNotification(@PathParam("correlator") String correlator, String content) { + LOGGER.info(MessageEnum.RA_RECEIVE_SDNC_NOTIF, content, "SDNC", "SDNCNotify/SNIROResponse"); + + long startTime = System.currentTimeMillis(); + + String bpUrl = SDNCAdapterProperties.getProperty(Constants.BPEL_REST_URL_PROP, null); + + if (bpUrl == null) { + String error = "Missing configuration for: " + Constants.BPEL_REST_URL_PROP; + LOGGER.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, Constants.BPEL_REST_URL_PROP, "SDNC", "", + MsoLogger.ErrorCode.DataError, "Missing config param"); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(error).build(); + } + + long bpStartTime = System.currentTimeMillis(); + BPRestCallback callback = new BPRestCallback(); + boolean callbackSuccess = callback.send(bpUrl, "SNIROResponse", correlator, content); + + if (callbackSuccess) { + LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + "Sent notification", "BPMN", bpUrl, null); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + } else { + LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + "Failed to send notification", "BPMN", bpUrl, null); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + "Failed to send notification"); + } + + return Response.status(204).build(); + } +}
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/TypedRequestTunables.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/TypedRequestTunables.java new file mode 100644 index 0000000000..4c270cee60 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/TypedRequestTunables.java @@ -0,0 +1,224 @@ +/*- + * ============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.sdncrest; + +import org.openecomp.mso.adapters.sdnc.impl.Constants; +import org.openecomp.mso.logger.MessageEnum; +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; + +/** + * Typed Request Tunables. Each entry is identified by a TYPE in the property name. + * Different types can have different keys. + * <p> + * General format: + * <pre> + * org.openecomp.mso.adapters.sdnc.TYPE.KEY1[.KEY2...]=METHOD|TIMEOUT|URL|HEADER|NAMESPACE + * </pre> + * Currently supported type(s): service + * <pre> + * org.openecomp.mso.adapters.sdnc.service.SERVICE.OPERATION=METHOD|TIMEOUT|URL|HEADER|NAMESPACE + * </pre> + */ +public class TypedRequestTunables { + + private static final String MSO_PROPERTIES_ID = "MSO_PROP_SDNC_ADAPTER"; + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger(); + + private final MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + + private final String reqId; + private final String myUrlSuffix; + private String key = null; + private String error = null; + + // tunables (all are required) + private String reqMethod = null; + private String timeout = null; + private String sdncUrl = null; + private String headerName = null; + private String namespace = null; + private String myUrl = null; + + public TypedRequestTunables(String reqId, String myUrlSuffix) { + this.reqId = reqId; + this.myUrlSuffix = myUrlSuffix; + } + + /** + * Sets the key for a service request: + * <pre> + * org.openecomp.mso.adapters.sdnc.service.SERVICE.OPERATION + * </pre> + * @param service the sdncService + * @param operation the sdncOperation + */ + public void setServiceKey(String service, String operation) { + key = Constants.REQUEST_TUNABLES + ".service." + service + "." + operation; + LOGGER.debug("Generated " + getClass().getSimpleName() + " key: " + key); + } + + /** + * Gets the SDNC request ID. + */ + public String getReqId() { + return reqId; + } + + /** + * Gets the generated key. + */ + public String getKey() { + return key; + } + + /** + * Gets the most recent error, or null if there was no error. + */ + public String getError() { + return error; + } + + public String getReqMethod() { + return reqMethod; + } + + public String getTimeout() { + return timeout; + } + + public String getSdncUrl() { + return sdncUrl; + } + + public String getHeaderName() { + return headerName; + } + + public String getNamespace() { + return namespace; + } + + /** + * Gets the SDNC adapter notification URL, trimmed of trailing '/' characters. + */ + public String getMyUrl() { + return myUrl; + } + + /** + * Returns true if successful. If there is an error, it is logged and alarmed. + * The error description may be retrieved by calling getError(). + */ + public boolean setTunables() { + error = null; + MsoJavaProperties properties; + + try { + properties = msoPropertiesFactory.getMsoJavaProperties(MSO_PROPERTIES_ID); + } catch (MsoPropertiesException e) { + error = "Mso Properties ID not found in cache: " + MSO_PROPERTIES_ID; + LOGGER.error(MessageEnum.LOAD_PROPERTIES_FAIL, "Unknown. " + error, "SDNC", "", + MsoLogger.ErrorCode.DataError, "Exception - Mso Properties ID not found in cache", e); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + return false; + } + + String value = properties.getProperty(key, ""); + + if (value.equals("")) { + error = "Missing configuration for: " + key; + LOGGER.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, key, "SDNC", "", MsoLogger.ErrorCode.DataError, "Missing config param"); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + return false; + } + + String[] parts = value.split("\\|"); + + if (parts.length != 5) { + error = "Invalid configuration for: " + key; + LOGGER.error(MessageEnum.RA_SDNC_INVALID_CONFIG, key, value, "SDNC", "", MsoLogger.ErrorCode.DataError, "Invalid config"); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + return false; + } + + reqMethod = parts[0]; + LOGGER.debug("Request Method is set to: " + reqMethod); + + timeout = parts[1]; + LOGGER.debug("Timeout is set to: " + timeout); + + String urlPropKey = Constants.REQUEST_TUNABLES + "." + parts[2]; + sdncUrl = properties.getProperty(urlPropKey, ""); + + if (sdncUrl.equals("")) { + error = "Missing configuration for: " + urlPropKey; + LOGGER.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, urlPropKey, "SDNC", "", MsoLogger.ErrorCode.DataError, "Missing config param"); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + return false; + } + + LOGGER.debug("SDNC Url is set to: " + sdncUrl); + + headerName = parts[3]; + LOGGER.debug("Header Name is set to: " + headerName); + + namespace = parts[4]; + LOGGER.debug("Namespace is set to: " + namespace); + + myUrl = properties.getProperty(Constants.MY_URL_PROP, ""); + + if (myUrl.equals("")) { + error = "Missing configuration for: " + Constants.MY_URL_PROP; + LOGGER.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, Constants.MY_URL_PROP, "SDNC", "", + MsoLogger.ErrorCode.DataError, "Missing config param"); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + return false; + } + + while (myUrl.endsWith("/")) { + myUrl = myUrl.substring(0, myUrl.length()-1); + } + + myUrl += myUrlSuffix; + + LOGGER.debug(toString()); + return true; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "[" + + "reqId=" + reqId + + (key == null ? "" : ", key=" + key) + + (reqMethod == null ? "" : ", reqMethod=" + reqMethod) + + (sdncUrl == null ? "" : ", sdncUrl=" + sdncUrl) + + (timeout == null ? "" : ", timeout=" + timeout) + + (headerName == null ? "" : ", headerName=" + headerName) + + (namespace == null ? "" : ", namespace=" + namespace) + + (myUrl == null ? "" : ", myUrl=" + myUrl) + + "]"; + } +}
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/resources/SDNCAdapter.wsdl b/adapters/mso-sdnc-adapter/src/main/resources/SDNCAdapter.wsdl index 2f4c5ad5eb..7a66cd418b 100644 --- a/adapters/mso-sdnc-adapter/src/main/resources/SDNCAdapter.wsdl +++ b/adapters/mso-sdnc-adapter/src/main/resources/SDNCAdapter.wsdl @@ -1,16 +1,16 @@ <?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:sdncadaptersc="http://org.openecomp/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:tns="http://org.openecomp/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"> + targetNamespace="http://org.openecomp/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" + targetNamespace="http://org.openecomp/workflow/sdnc/adapter/wsdl/v1"> + <import namespace="http://org.openecomp/workflow/sdnc/adapter/schema/v1" schemaLocation="SDNCAdapterSchema.xsd" /> </schema> </types> diff --git a/adapters/mso-sdnc-adapter/src/main/resources/SDNCAdapterSchema.xsd b/adapters/mso-sdnc-adapter/src/main/resources/SDNCAdapterSchema.xsd index f0e4435771..ed904d4a2e 100644 --- a/adapters/mso-sdnc-adapter/src/main/resources/SDNCAdapterSchema.xsd +++ b/adapters/mso-sdnc-adapter/src/main/resources/SDNCAdapterSchema.xsd @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<schema targetNamespace="http://domain2.att.com/workflow/sdnc/adapter/schema/v1" +<schema targetNamespace="http://org.openecomp/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" + xmlns:tns="http://org.openecomp/workflow/sdnc/adapter/schema/v1" + xmlns:sdncadaptersc="http://org.openecomp/workflow/sdnc/adapter/schema/v1" elementFormDefault="qualified"> diff --git a/adapters/mso-sdnc-adapter/src/main/resources/SDNCCallbackAdapter.wsdl b/adapters/mso-sdnc-adapter/src/main/resources/SDNCCallbackAdapter.wsdl index 1429b5f1c7..0a106752fb 100644 --- a/adapters/mso-sdnc-adapter/src/main/resources/SDNCCallbackAdapter.wsdl +++ b/adapters/mso-sdnc-adapter/src/main/resources/SDNCCallbackAdapter.wsdl @@ -1,16 +1,16 @@ <?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:sdncadaptersc="http://org.openecomp/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:tns="http://org.openecomp/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"> + targetNamespace="http://org.openecomp/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" + targetNamespace="http://org.openecomp/workflow/sdnc/adapter/wsdl/v1"> + <import namespace="http://org.openecomp/workflow/sdnc/adapter/schema/v1" schemaLocation="SDNCAdapterSchema.xsd" /> </schema> </types> diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/sdncrest/ObjectMappingTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/sdncrest/ObjectMappingTest.java new file mode 100644 index 0000000000..39090158b3 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/sdncrest/ObjectMappingTest.java @@ -0,0 +1,477 @@ +/*- + * ============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.sdncrest; + +import org.openecomp.mso.adapters.sdncrest.SDNCEvent; +import org.openecomp.mso.adapters.sdncrest.SDNCServiceError; +import org.openecomp.mso.adapters.sdncrest.SDNCServiceRequest; +import org.openecomp.mso.adapters.sdncrest.SDNCServiceResponse; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; +import org.junit.Test; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.Arrays; + +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + + + +/** + * JSON object mapping tests. + */ +public class ObjectMappingTest { + private static final String EOL = "\n"; + + private final String SDNC_SERVICE_REQUEST = + "{" + EOL + + " \"SDNCServiceRequest\": {" + EOL + + " \"requestInformation\": {" + EOL + + " \"requestId\": \"413658f4-7f42-482e-b834-23a5c15657da\"," + EOL + + " \"source\": \"CCD\"," + EOL + + " \"notificationUrl\": \"https://ccd-host:8080/notifications\"" + EOL + + " }," + EOL + + " \"serviceInformation\": {" + EOL + + " \"serviceType\": \"vHNFaaS\"," + EOL + + " \"serviceInstanceId\": \"74e65b2b637441bca078e63e44bb511b\"," + EOL + + " \"subscriberName\": \"IST_SG_0902_3003\"," + EOL + + " \"subscriberGlobalId\": \"IST15_0902_3003\"" + EOL + + " }," + EOL + + " \"bpNotificationUrl\": \"http://localhost:8080/mso/SDNCAdapterCallbackService\"," + EOL + + "((BP-TIMEOUT))" + + " \"sdncRequestId\": \"413658f4-7f42-482e-b834-23a5c15657da-1474471336781\"," + EOL + + " \"sdncService\": \"vhnf\"," + EOL + + " \"sdncOperation\": \"service-topology-cust-assign-operation\"," + EOL + + " \"sdncServiceDataType\": \"XML\"," + EOL + + " \"sdncServiceData\": \"<vhnf-cust-stage-information><dhv-service-instance-id>c26dfed652164d60a17461734422b085</dhv-service-instance-id><hnportal-primary-vnf-host-name>HOSTNAME</hnportal-primary-vnf-host-name></vhnf-cust-stage-information>\"" + EOL + + " }" + EOL + + "}" + EOL; + + private final String SDNC_SERVICE_RESPONSE = + "{" + EOL + + " \"SDNCServiceResponse\": {" + EOL + + " \"sdncRequestId\": \"413658f4-7f42-482e-b834-23a5c15657da-1474471336781\"," + EOL + + " \"responseCode\": \"200\"," + EOL + + "((RESPONSE-MESSAGE))" + + " \"ackFinalIndicator\": \"Y\"" + EOL + + "((RESPONSE-PARAMS))" + + " }" + EOL + + "}" + EOL; + + private final String SDNC_SERVICE_ERROR = + "{" + EOL + + " \"SDNCServiceError\": {" + EOL + + " \"sdncRequestId\": \"413658f4-7f42-482e-b834-23a5c15657da-1474471336781\"," + EOL + + " \"responseCode\": \"500\"," + EOL + + "((RESPONSE-MESSAGE))" + + " \"ackFinalIndicator\": \"Y\"" + EOL + + " }" + EOL + + "}" + EOL; + + private final String SDNC_EVENT = + "{" + EOL + + " \"SDNCEvent\": {" + EOL + + " \"eventType\": \"ACTIVATION\"," + EOL + + " \"eventCorrelatorType\": \"HOST-NAME\"," + EOL + + " \"eventCorrelator\": \"USOSTCDALTX0101UJZZ31\"" + EOL + + "((EVENT-PARAMS))" + + " }" + EOL + + "}" + EOL; + + private final String PARAMS = + "{\"entry\":[{\"key\":\"P1\",\"value\":\"V1\"},{\"key\":\"P2\",\"value\":\"V2\"},{\"key\":\"P3\",\"value\":\"V3\"}]}"; + + @Test + public final void jsonToSDNCServiceRequest() throws Exception { + logTest(); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + + String json = SDNC_SERVICE_REQUEST; + json = json.replace("((BP-TIMEOUT))", "\"bpTimeout\": \"" + "PT5M" + "\"," + EOL); + + SDNCServiceRequest object = mapper.readValue(json, SDNCServiceRequest.class); + assertEquals("413658f4-7f42-482e-b834-23a5c15657da", object.getRequestInformation().getRequestId()); + assertEquals("CCD", object.getRequestInformation().getSource()); + assertEquals("https://ccd-host:8080/notifications", object.getRequestInformation().getNotificationUrl()); + assertEquals("vHNFaaS", object.getServiceInformation().getServiceType()); + assertEquals("74e65b2b637441bca078e63e44bb511b", object.getServiceInformation().getServiceInstanceId()); + assertEquals("IST_SG_0902_3003", object.getServiceInformation().getSubscriberName()); + assertEquals("IST15_0902_3003", object.getServiceInformation().getSubscriberGlobalId()); + assertEquals("http://localhost:8080/mso/SDNCAdapterCallbackService", object.getBPNotificationUrl()); + assertEquals("PT5M", object.getBPTimeout()); + assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSDNCRequestId()); + assertEquals("vhnf", object.getSDNCService()); + assertEquals("service-topology-cust-assign-operation", object.getSDNCOperation()); + assertEquals("XML", object.getSDNCServiceDataType()); + assertTrue(object.getSDNCServiceData().startsWith("<vhnf-cust-stage-information>")); + } + + @Test + public final void jsonToSDNCServiceRequestWithoutOptionalFields() throws Exception { + logTest(); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + + // bpTimeout is optional. + String json = SDNC_SERVICE_REQUEST; + json = json.replace("((BP-TIMEOUT))", ""); + + SDNCServiceRequest object = mapper.readValue(json, SDNCServiceRequest.class); + assertEquals("413658f4-7f42-482e-b834-23a5c15657da", object.getRequestInformation().getRequestId()); + assertEquals("CCD", object.getRequestInformation().getSource()); + assertEquals("https://ccd-host:8080/notifications", object.getRequestInformation().getNotificationUrl()); + assertEquals("vHNFaaS", object.getServiceInformation().getServiceType()); + assertEquals("74e65b2b637441bca078e63e44bb511b", object.getServiceInformation().getServiceInstanceId()); + assertEquals("IST_SG_0902_3003", object.getServiceInformation().getSubscriberName()); + assertEquals("IST15_0902_3003", object.getServiceInformation().getSubscriberGlobalId()); + assertEquals("http://localhost:8080/mso/SDNCAdapterCallbackService", object.getBPNotificationUrl()); + assertNull(object.getBPTimeout()); + assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSDNCRequestId()); + assertEquals("vhnf", object.getSDNCService()); + assertEquals("service-topology-cust-assign-operation", object.getSDNCOperation()); + assertEquals("XML", object.getSDNCServiceDataType()); + assertTrue(object.getSDNCServiceData().startsWith("<vhnf-cust-stage-information>")); + } + + @Test + public final void jsonFromSDNCServiceRequest() throws Exception { + logTest(); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + + // Convert source json string to object. + String json1 = SDNC_SERVICE_REQUEST; + json1 = json1.replace("((BP-TIMEOUT))", "\"bpTimeout\": \"" + "PT5M" + "\"," + EOL); + SDNCServiceRequest object1 = mapper.readValue(json1, SDNCServiceRequest.class); + + // Convert resulting object back to json. + String json2 = object1.toJson(); + System.out.println("Generated JSON for " + object1.getClass().getSimpleName() + + ":" + System.lineSeparator() + json2); + assertTrue(json2.replaceAll("\\s+","").startsWith("{\"SDNCServiceRequest\":{")); + + // Convert generated json string to another object. + SDNCServiceRequest object2 = mapper.readValue(json2, SDNCServiceRequest.class); + + // Compare the first object to the second object. + assertTrue(serializedEquals(object1, object2)); + } + + @Test + public final void jsonFromSDNCServiceRequestWithoutOptionalFields() throws Exception { + logTest(); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + + // Convert source json string to object. + String json1 = SDNC_SERVICE_REQUEST; + json1 = json1.replace("((BP-TIMEOUT))", ""); + SDNCServiceRequest object1 = mapper.readValue(json1, SDNCServiceRequest.class); + + // Convert resulting object back to json. + String json2 = object1.toJson(); + System.out.println("Generated JSON for " + object1.getClass().getSimpleName() + + ":" + System.lineSeparator() + json2); + assertTrue(json2.replaceAll("\\s+","").startsWith("{\"SDNCServiceRequest\":{")); + + // Convert generated json string to another object. + SDNCServiceRequest object2 = mapper.readValue(json2, SDNCServiceRequest.class); + + // Compare the first object to the second object. + assertTrue(serializedEquals(object1, object2)); + } + + @Test + public final void jsonToSDNCServiceResponse() throws Exception { + logTest(); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + + String json = SDNC_SERVICE_RESPONSE; + json = json.replace("((RESPONSE-MESSAGE))", " \"responseMessage\": \"" + "OK" + "\"," + EOL); + json = json.replace(EOL + "((RESPONSE-PARAMS))", "," + EOL + " \"params\": " + PARAMS + EOL); + + SDNCServiceResponse object = mapper.readValue(json, SDNCServiceResponse.class); + assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSDNCRequestId()); + assertEquals("200", object.getResponseCode()); + assertEquals("OK", object.getResponseMessage()); + assertEquals("Y", object.getAckFinalIndicator()); + assertEquals("V1", object.getParams().get("P1")); + assertEquals("V2", object.getParams().get("P2")); + assertEquals("V3", object.getParams().get("P3")); + } + + @Test + public final void jsonToSDNCServiceResponseWithoutOptionalFields() throws Exception { + logTest(); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + + // responseMessage is optional. + String json = SDNC_SERVICE_RESPONSE; + json = json.replace("((RESPONSE-MESSAGE))", ""); + json = json.replace("((RESPONSE-PARAMS))", ""); + + SDNCServiceResponse object = mapper.readValue(json, SDNCServiceResponse.class); + assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSDNCRequestId()); + assertEquals("200", object.getResponseCode()); + assertNull(object.getResponseMessage()); + assertEquals("Y", object.getAckFinalIndicator()); + assertNull(object.getParams()); + } + + @Test + public final void jsonFromSDNCServiceResponse() throws Exception { + logTest(); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + + // Convert source json string to object. + String json1 = SDNC_SERVICE_RESPONSE; + json1 = json1.replace("((RESPONSE-MESSAGE))", "\"responseMessage\": \"" + "OK" + "\"," + EOL); + json1 = json1.replace(EOL + "((RESPONSE-PARAMS))", "," + EOL + " \"params\": " + PARAMS + EOL); + SDNCServiceResponse object1 = mapper.readValue(json1, SDNCServiceResponse.class); + + // Convert resulting object back to json. + String json2 = object1.toJson(); + System.out.println("Generated JSON for " + object1.getClass().getSimpleName() + + ":" + System.lineSeparator() + json2); + assertTrue(json2.replaceAll("\\s+","").startsWith("{\"SDNCServiceResponse\":{")); + + // Convert generated json string to another object. + SDNCServiceResponse object2 = mapper.readValue(json2, SDNCServiceResponse.class); + + // Compare the first object to the second object. + assertTrue(serializedEquals(object1, object2)); + } + + @Test + public final void jsonFromSDNCServiceResponseWithoutOptionalFields() throws Exception { + logTest(); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + + // Convert source json string to object. + String json1 = SDNC_SERVICE_RESPONSE; + json1 = json1.replace("((RESPONSE-MESSAGE))", ""); + json1 = json1.replace("((RESPONSE-PARAMS))", ""); + SDNCServiceResponse object1 = mapper.readValue(json1, SDNCServiceResponse.class); + + // Convert resulting object back to json. + String json2 = object1.toJson(); + System.out.println("Generated JSON for " + object1.getClass().getSimpleName() + + ":" + System.lineSeparator() + json2); + assertTrue(json2.replaceAll("\\s+","").startsWith("{\"SDNCServiceResponse\":{")); + + // Convert generated json string to another object. + SDNCServiceResponse object2 = mapper.readValue(json2, SDNCServiceResponse.class); + + // Compare the first object to the second object. + assertTrue(serializedEquals(object1, object2)); + } + + @Test + public final void jsonToSDNCServiceError() throws Exception { + logTest(); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + + String json = SDNC_SERVICE_ERROR; + json = json.replace("((RESPONSE-MESSAGE))", "\"responseMessage\": \"" + "SOMETHING BAD" + "\"," + EOL); + + SDNCServiceError object = mapper.readValue(json, SDNCServiceError.class); + assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSDNCRequestId()); + assertEquals("500", object.getResponseCode()); + assertEquals("SOMETHING BAD", object.getResponseMessage()); + assertEquals("Y", object.getAckFinalIndicator()); + } + + @Test + public final void jsonToSDNCServiceErrorWithoutOptionalFields() throws Exception { + logTest(); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + + // responseMessage is optional. + String json = SDNC_SERVICE_ERROR; + json = json.replace("((RESPONSE-MESSAGE))", ""); + + SDNCServiceError object = mapper.readValue(json, SDNCServiceError.class); + assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSDNCRequestId()); + assertEquals("500", object.getResponseCode()); + assertNull(object.getResponseMessage()); + assertEquals("Y", object.getAckFinalIndicator()); + } + + @Test + public final void jsonFromSDNCServiceError() throws Exception { + logTest(); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + + // Convert source json string to object. + String json1 = SDNC_SERVICE_ERROR; + json1 = json1.replace("((RESPONSE-MESSAGE))", "\"responseMessage\": \"" + "OK" + "\"," + EOL); + SDNCServiceError object1 = mapper.readValue(json1, SDNCServiceError.class); + + // Convert resulting object back to json. + String json2 = object1.toJson(); + System.out.println("Generated JSON for " + object1.getClass().getSimpleName() + + ":" + System.lineSeparator() + json2); + assertTrue(json2.replaceAll("\\s+","").startsWith("{\"SDNCServiceError\":{")); + + // Convert generated json string to another object. + SDNCServiceError object2 = mapper.readValue(json2, SDNCServiceError.class); + + // Compare the first object to the second object. + assertTrue(serializedEquals(object1, object2)); + } + + @Test + public final void jsonFromSDNCServiceErrorWithoutOptionalFields() throws Exception { + logTest(); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + + // Convert source json string to object. + String json1 = SDNC_SERVICE_ERROR; + json1 = json1.replace("((RESPONSE-MESSAGE))", ""); + SDNCServiceError object1 = mapper.readValue(json1, SDNCServiceError.class); + + // Convert resulting object back to json. + String json2 = object1.toJson(); + System.out.println("Generated JSON for " + object1.getClass().getSimpleName() + + ":" + System.lineSeparator() + json2); + assertTrue(json2.replaceAll("\\s+","").startsWith("{\"SDNCServiceError\":{")); + + // Convert generated json string to another object. + SDNCServiceError object2 = mapper.readValue(json2, SDNCServiceError.class); + + // Compare the first object to the second object. + assertTrue(serializedEquals(object1, object2)); + } + + @Test + public final void jsonToSDNCEvent() throws Exception { + logTest(); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + + String json = SDNC_EVENT; + json = json.replace(EOL + "((EVENT-PARAMS))", "," + EOL + " \"params\": " + PARAMS + EOL); + + SDNCEvent object = mapper.readValue(json, SDNCEvent.class); + assertEquals("ACTIVATION", object.getEventType()); + assertEquals("HOST-NAME", object.getEventCorrelatorType()); + assertEquals("USOSTCDALTX0101UJZZ31", object.getEventCorrelator()); + assertEquals("V1", object.getParams().get("P1")); + assertEquals("V2", object.getParams().get("P2")); + assertEquals("V3", object.getParams().get("P3")); + } + + @Test + public final void jsonToSDNCEventWithoutOptionalFields() throws Exception { + logTest(); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + + // params are optional. + String json = SDNC_EVENT; + json = json.replace("((EVENT-PARAMS))", ""); + + SDNCEvent object = mapper.readValue(json, SDNCEvent.class); + assertEquals("ACTIVATION", object.getEventType()); + assertEquals("HOST-NAME", object.getEventCorrelatorType()); + assertEquals("USOSTCDALTX0101UJZZ31", object.getEventCorrelator()); + assertNull(object.getParams()); + } + + @Test + public final void jsonFromSDNCEvent() throws Exception { + logTest(); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + + // Convert source json string to object. + String json1 = SDNC_EVENT; + json1 = json1.replace(EOL + "((EVENT-PARAMS))", "," + EOL + " \"params\": " + PARAMS + EOL); + SDNCEvent object1 = mapper.readValue(json1, SDNCEvent.class); + + // Convert resulting object back to json. + String json2 = object1.toJson(); + System.out.println("Generated JSON for " + object1.getClass().getSimpleName() + + ":" + System.lineSeparator() + json2); + assertTrue(json2.replaceAll("\\s+","").startsWith("{\"SDNCEvent\":{")); + + // Convert generated json string to another object. + SDNCEvent object2 = mapper.readValue(json2, SDNCEvent.class); + + // Compare the first object to the second object. + assertTrue(serializedEquals(object1, object2)); + } + + /** + * Tests equality of two objects by comparing their serialized form. + * WARNING: this works pretty well as long as the objects don't contain + * collections like maps and sets that are semantically equal, but have + * different internal ordering of elements. + */ + private boolean serializedEquals(Serializable object1, Serializable object2) throws IOException { + ByteArrayOutputStream byteStream1 = new ByteArrayOutputStream(); + ObjectOutputStream objectStream1 = new ObjectOutputStream(byteStream1); + objectStream1.writeObject(object1); + objectStream1.close(); + + ByteArrayOutputStream byteStream2 = new ByteArrayOutputStream(); + ObjectOutputStream objectStream2 = new ObjectOutputStream(byteStream2); + objectStream2.writeObject(object2); + objectStream2.close(); + + return Arrays.equals(byteStream1.toByteArray(), byteStream2.toByteArray()); + } + + private void logTest() { + StackTraceElement[] st = Thread.currentThread().getStackTrace(); + String method = st[2].getMethodName(); + System.out.println("RUNNING TEST: " + method); + } +} diff --git a/adapters/mso-sdnc-adapter/src/test/resources/mso.properties b/adapters/mso-sdnc-adapter/src/test/resources/mso.properties index 5384285306..2428b512b1 100644 --- a/adapters/mso-sdnc-adapter/src/test/resources/mso.properties +++ b/adapters/mso-sdnc-adapter/src/test/resources/mso.properties @@ -23,26 +23,16 @@ #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 diff --git a/adapters/mso-tenant-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-tenant-adapter/WebContent/WEB-INF/web.xml index 9118bba5a8..780bdd08ee 100644 --- a/adapters/mso-tenant-adapter/WebContent/WEB-INF/web.xml +++ b/adapters/mso-tenant-adapter/WebContent/WEB-INF/web.xml @@ -44,7 +44,7 @@ <filter> <filter-name>LogFilter</filter-name> - <filter-class>org.openecomp.mso.logger.LogFilter</filter-class> + <filter-class>org.openecomp.mso.logger.LogFilter</filter-class> </filter> <filter-mapping> <filter-name>LogFilter</filter-name> @@ -89,6 +89,19 @@ <role-name>BPEL-Client</role-name> </auth-constraint> </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>MSO internal Requests</web-resource-name> + <description>Internal Requests</description> + <url-pattern>/rest/logging/*</url-pattern> + <url-pattern>/rest/properties/*</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> <login-config> <auth-method>BASIC</auth-method> <realm-name>ApplicationRealm</realm-name> @@ -99,5 +112,8 @@ <security-role> <role-name>SiteControl-Client</role-name> </security-role> + <security-role> + <role-name>MSO-Client</role-name> + </security-role> </web-app> 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 index a86c93828f..9e874bcc00 100644 --- 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 @@ -35,7 +35,7 @@ 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") +@WebService (name="TenantAdapter", targetNamespace="http://org.openecomp.mso/tenant") public interface MsoTenantAdapter { /** 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 index 040c682b3d..c90308394e 100644 --- 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 @@ -41,7 +41,7 @@ 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") +@WebService(serviceName = "TenantAdapter", endpointInterface = "org.openecomp.mso.adapters.tenant.MsoTenantAdapter", targetNamespace = "http://org.openecomp.mso/tenant") public class MsoTenantAdapterImpl implements MsoTenantAdapter { MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); 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 index cc80b949dd..e5de100348 100644 --- 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 @@ -34,7 +34,7 @@ import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; * * */ -@WebFault (name="TenantAlreadyExists", faultBean="org.openecomp.mso.adapters.tenant.exceptions.TenantExceptionBean", targetNamespace="http://com.att.mso/tenant") +@WebFault (name="TenantAlreadyExists", faultBean="org.openecomp.mso.adapters.tenant.exceptions.TenantExceptionBean", targetNamespace="http://org.openecomp.mso/tenant") public class TenantAlreadyExists extends TenantException { private static final long serialVersionUID = 1L; 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 index f68b0fa65b..f6f1e68bda 100644 --- 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 @@ -34,7 +34,7 @@ import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; * * */ -@WebFault (name="TenantException", faultBean="org.openecomp.mso.adapters.tenant.exceptions.TenantExceptionBean", targetNamespace="http://com.att.mso/tenant") +@WebFault (name="TenantException", faultBean="org.openecomp.mso.adapters.tenant.exceptions.TenantExceptionBean", targetNamespace="http://org.openecomp.mso/tenant") public class TenantException extends Exception { private static final long serialVersionUID = 1L; diff --git a/adapters/mso-vnf-adapter-async-client/pom.xml b/adapters/mso-vnf-adapter-async-client/pom.xml index 1ae4b16e05..27e555b815 100644 --- a/adapters/mso-vnf-adapter-async-client/pom.xml +++ b/adapters/mso-vnf-adapter-async-client/pom.xml @@ -1,90 +1,91 @@ -<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> +<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>1.1.0-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> + </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 index aecef0dd03..951d702467 100644 --- a/adapters/mso-vnf-adapter-async-client/src/main/resources/VnfAdapterNotify.wsdl +++ b/adapters/mso-vnf-adapter-async-client/src/main/resources/VnfAdapterNotify.wsdl @@ -1,8 +1,8 @@ <?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"> +<definitions targetNamespace="http://org.openecomp.mso/vnfNotify" name="vnfAdapterNotify" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:tns="http://org.openecomp.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:schema version="1.0" targetNamespace="http://org.openecomp.mso/vnfNotify" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="createVnfNotification" type="tns:createVnfNotification"/> @@ -161,19 +161,19 @@ </message> <portType name="vnfAdapterNotify"> <operation name="rollbackVnfNotification"> - <input wsam:Action="http://com.att.mso/notify/adapterNotify/rollbackVnfNotificationRequest" message="tns:rollbackVnfNotification"/> + <input wsam:Action="http://org.openecomp.mso/notify/adapterNotify/rollbackVnfNotificationRequest" message="tns:rollbackVnfNotification"/> </operation> <operation name="queryVnfNotification"> - <input wsam:Action="http://com.att.mso/notify/adapterNotify/queryVnfNotificationRequest" message="tns:queryVnfNotification"/> + <input wsam:Action="http://org.openecomp.mso/notify/adapterNotify/queryVnfNotificationRequest" message="tns:queryVnfNotification"/> </operation> <operation name="createVnfNotification"> - <input wsam:Action="http://com.att.mso/notify/adapterNotify/createVnfNotificationRequest" message="tns:createVnfNotification"/> + <input wsam:Action="http://org.openecomp.mso/notify/adapterNotify/createVnfNotificationRequest" message="tns:createVnfNotification"/> </operation> <operation name="updateVnfNotification"> - <input wsam:Action="http://com.att.mso/notify/adapterNotify/updateVnfNotificationRequest" message="tns:updateVnfNotification"/> + <input wsam:Action="http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest" message="tns:updateVnfNotification"/> </operation> <operation name="deleteVnfNotification"> - <input wsam:Action="http://com.att.mso/notify/adapterNotify/deleteVnfNotificationRequest" message="tns:deleteVnfNotification"/> + <input wsam:Action="http://org.openecomp.mso/notify/adapterNotify/deleteVnfNotificationRequest" message="tns:deleteVnfNotification"/> </operation> </portType> <binding name="MsoVnfAdapterAsyncImplPortBinding" type="tns:vnfAdapterNotify"> diff --git a/adapters/mso-vnf-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-vnf-adapter/WebContent/WEB-INF/web.xml index 3a50781b22..e69486e1fd 100644 --- a/adapters/mso-vnf-adapter/WebContent/WEB-INF/web.xml +++ b/adapters/mso-vnf-adapter/WebContent/WEB-INF/web.xml @@ -79,6 +79,19 @@ <role-name>SiteControl-Client</role-name> </auth-constraint> </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>MSO internal Requests</web-resource-name> + <description>Internal Requests</description> + <url-pattern>/rest/logging/*</url-pattern> + <url-pattern>/rest/properties/*</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> <login-config> <auth-method>BASIC</auth-method> <realm-name>ApplicationRealm</realm-name> @@ -89,6 +102,9 @@ <security-role> <role-name>SiteControl-Client</role-name> </security-role> + <security-role> + <role-name>MSO-Client</role-name> + </security-role> <filter> <filter-name>LogFilter</filter-name> diff --git a/adapters/mso-vnf-adapter/pom.xml b/adapters/mso-vnf-adapter/pom.xml index bc32498b20..ced5c3ae6e 100644 --- a/adapters/mso-vnf-adapter/pom.xml +++ b/adapters/mso-vnf-adapter/pom.xml @@ -1,159 +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> +<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>1.1.0-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> + </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 index e76aa40304..2f734f2e6c 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -239,6 +239,9 @@ public class BpelRestClient { LOGGER.debug("Sending to BPEL server: "+bpelUrl); LOGGER.debug("Content is: "+toBpelStr); + //Client 4.3+ + CloseableHttpClient client = HttpClients.createDefault(); + //POST HttpPost post = new HttpPost(bpelUrl); if (credentials != null && !credentials.isEmpty()) @@ -258,8 +261,8 @@ public class BpelRestClient { //Client 4.3+ //Execute & GetResponse - try (CloseableHttpClient client = HttpClients.createDefault(); - CloseableHttpResponse response = client.execute(post)) { + try { + CloseableHttpResponse response = client.execute(post); if (response != null) { lastResponseCode = response.getStatusLine().getStatusCode(); HttpEntity entity = response.getEntity(); @@ -273,32 +276,15 @@ public class BpelRestClient { LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, error, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Error sending Bpel notification", e); lastResponseCode = 900; lastResponse = ""; + } finally { + try { + client.close(); + } catch (IOException e) { + // ignore + } } 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/MsoVnfAdapter.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapter.java index 95d8ee23a0..d1646bf9ea 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -36,7 +36,7 @@ import org.openecomp.mso.entity.MsoRequest; import java.util.Map; -@WebService (name="VnfAdapter", targetNamespace="http://com.att.mso/vnf") +@WebService (name="VnfAdapter", targetNamespace="http://org.openecomp.mso/vnf") public interface MsoVnfAdapter { /** @@ -58,7 +58,7 @@ public interface MsoVnfAdapter @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, @@ -72,7 +72,7 @@ public interface MsoVnfAdapter @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, @@ -83,19 +83,19 @@ public interface MsoVnfAdapter @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, @@ -105,6 +105,7 @@ public interface MsoVnfAdapter @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 = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid, @WebParam(name="inputs") Map<String,String> inputs, @WebParam(name="failIfExists") Boolean failIfExists, @WebParam(name="backout") Boolean backout, @@ -113,14 +114,15 @@ public interface MsoVnfAdapter @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) + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name = "vfModuleOutputs", mode = Mode.OUT) Holder<Map<String, String>> vfModuleOutputs) throws VnfException; - + @WebMethod public void updateVfModule (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, @@ -131,12 +133,13 @@ public interface MsoVnfAdapter @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 = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid, @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 index d58e9ee6a8..fcd78069d3 100644 --- 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 @@ -37,7 +37,7 @@ import java.util.Map; * (by the client service WSDL). * */ -@WebService (name="VnfAdapterAsync", targetNamespace="http://com.att.mso/vnfA") +@WebService (name="VnfAdapterAsync", targetNamespace="http://org.openecomp.mso/vnfA") public interface MsoVnfAdapterAsync { /** 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 index c192eb6063..d2b1699116 100644 --- 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 @@ -50,7 +50,7 @@ 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") +@WebService(serviceName = "VnfAdapterAsync", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapterAsync", targetNamespace = "http://org.openecomp.mso/vnfA") public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); @@ -611,7 +611,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { } VnfAdapterNotify_Service notifySvc = new VnfAdapterNotify_Service (warWsdlLoc, - new QName ("http://com.att.mso/vnfNotify", + new QName ("http://org.openecomp.mso/vnfNotify", "vnfAdapterNotify")); VnfAdapterNotify notifyPort = notifySvc.getMsoVnfAdapterAsyncImplPort (); 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 index 757f875128..e998fe8afe 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -68,7 +68,7 @@ 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") +@WebService(serviceName = "VnfAdapter", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapter", targetNamespace = "http://org.openecomp.mso/vnf") public class MsoVnfAdapterImpl implements MsoVnfAdapter { CloudConfigFactory cloudConfigFactory = new CloudConfigFactory(); @@ -84,6 +84,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { 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"; + private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); /** * Health Check web method. Does nothing but return to show the adapter is deployed. @@ -178,24 +179,25 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // 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, + this.createVfModule(cloudSiteId, + tenantId, + vnfType, + vnfVersion, + vnfName, + newRequestType, + vfVolGroupHeatStackId, + vfBaseHeatStackId, + null, + 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 = ""; @@ -203,20 +205,21 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (requestType != null) { newRequestTypeSb.append(requestType); } - this.createVfModule(cloudSiteId, - tenantId, - vnfType, - vnfVersion, - vnfName, - newRequestTypeSb.toString(), - vfVolGroupHeatStackId, - vfBaseHeatStackId, - inputs, - failIfExists, - backout, - msoRequest, - vnfId, - outputs, + this.createVfModule(cloudSiteId, + tenantId, + vnfType, + vnfVersion, + vnfName, + newRequestTypeSb.toString(), + vfVolGroupHeatStackId, + vfBaseHeatStackId, + null, + inputs, + failIfExists, + backout, + msoRequest, + vnfId, + outputs, rollback); return; // End createVf shortcut @@ -290,7 +293,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { 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 (); @@ -319,14 +322,18 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug("Found nested heat stack - copying values to inputs"); this.sendMapToDebug(inputs); - heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); + heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); this.sendMapToDebug(inputs); } } // Ready to deploy the new VNF - try(CatalogDatabase db = new CatalogDatabase ()) { + // Get a handle to the Catalog Database + CatalogDatabase db = new CatalogDatabase (); + + // Make sure DB session is closed + try { // Retrieve the VNF definition VnfResource vnf; if (vnfVersion != null && !vnfVersion.isEmpty ()) { @@ -351,8 +358,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); throw new VnfException (error, MsoExceptionCategory.INTERNAL); } - - //1604 - Need to handle an updateVolume request. + + //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()); @@ -398,7 +405,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ()); - + // Add check for any Environment variable HeatEnvironment heatEnvironment = null; String heatEnvironmentString = null; @@ -425,7 +432,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } 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) { @@ -451,8 +458,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } // End 1604 - - + + LOGGER.debug ("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId=" + heatTemplate.getId ()); Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getId ()); @@ -565,8 +572,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { 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 + } + // 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 () @@ -596,9 +603,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug ("No missing parameters found - ok to proceed"); } - + // Here - modify heatEnvironmentString - StringBuilder parsedEnvironmentString = null; + StringBuilder parsedEnvironmentString = null; String newEnvironmentString = null; if (mhee != null) { LOGGER.debug("Environment before:\n" + heatEnvironmentString); @@ -648,6 +655,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); throw new VnfException (me); } + } finally { + // Make sure DB session is closed + db.close (); } // Reach this point if updateStack is successful. @@ -929,7 +939,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } return string; } - + private void sendMapToDebug(Map<String, String> inputs) { int i = 0; StringBuilder sb = new StringBuilder("inputs:"); @@ -947,6 +957,63 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { return; } + 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]"; + } + + private Map<String, String> convertMapStringObjectToStringString(Map<String, Object> objectMap) { + if (objectMap == null) { + return null; + } + Map<String, String> stringMap = new HashMap<String, String>(); + for (String key : objectMap.keySet()) { + if (!stringMap.containsKey(key)) { + Object obj = objectMap.get(key); + if (obj instanceof String) { + stringMap.put(key, (String) objectMap.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); + stringMap.put(key, str); + } catch (Exception e) { + LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for "+ key); + //okay in this instance - only string values (fqdn) are expected to be needed + } + } 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); + stringMap.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; + stringMap.put(key, str); + } catch (Exception e) { + LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for "+ key); + //okay here - only expecting fqdn's + } + } + } + } + + return stringMap; + } + public void createVfModule(String cloudSiteId, String tenantId, String vnfType, @@ -955,6 +1022,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String requestType, String volumeGroupHeatStackId, String baseVfHeatStackId, + String modelCustomizationUuid, Map <String, String> inputs, Boolean failIfExists, Boolean backout, @@ -965,6 +1033,18 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String vfModuleName = vnfName; String vfModuleType = vnfType; String vfVersion = vnfVersion; + String mcu = modelCustomizationUuid; + boolean useMCUuid = false; + if (mcu != null && !mcu.isEmpty()) { + if (mcu.equalsIgnoreCase("null")) { + LOGGER.debug("modelCustomizationUuid: passed in as the string 'null' - will ignore: " + modelCustomizationUuid); + useMCUuid = false; + mcu = ""; + } else { + LOGGER.debug("Found modelCustomizationUuid! Will use that: " + mcu); + useMCUuid = true; + } + } MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName ("CreateVfModule"); String requestTypeString = ""; @@ -983,7 +1063,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { nestedBaseStackId = baseVfHeatStackId; } } - + if (inputs == null) { // Create an empty set of inputs inputs = new HashMap<String,String>(); @@ -998,13 +1078,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { 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 @@ -1019,7 +1099,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vfRollback.setVolumeGroupHeatStackId(volumeGroupHeatStackId); vfRollback.setBaseGroupHeatStackId(baseVfHeatStackId); vfRollback.setIsBase(isBaseRequest); - + vfRollback.setModelCustomizationUuid(mcu); + // First, look up to see if the VF already exists. MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); @@ -1038,7 +1119,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { 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 + // 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(); @@ -1054,22 +1135,22 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { 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 ()); + 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 ()); + throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); } if (status == HeatStatus.CREATED) { - // fail - it exists + // 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 ()); + throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); } else { LOGGER.debug ("Found Existing stack, status=" + heatStack.getStatus ()); // Populate the outputs from the existing stack. @@ -1080,9 +1161,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } 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 (); @@ -1111,11 +1192,11 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug("Found nested volume heat stack - copying values to inputs"); this.sendMapToDebug(inputs); - heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); + 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 (); @@ -1144,19 +1225,43 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug("Found nested base heat stack - copying values to inputs"); this.sendMapToDebug(inputs); - heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false); + heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false); this.sendMapToDebug(inputs); } } - + // Ready to deploy the new VNF - - try (CatalogDatabase db = new CatalogDatabase()) { - // Retrieve the VF + + CatalogDatabase db = new CatalogDatabase(); + + try { + // Retrieve the VF VfModule vf = null; VnfResource vnfResource = null; LOGGER.debug("version: " + vfVersion); - if (!oldWay) { + if (useMCUuid) { + // 1702 - this will be the new way going forward. We find the vf by mcu - otherwise, code is the same. + vf = db.getVfModuleByModelCustomizationUuid(mcu); + if (vf == null) { + LOGGER.debug("Unable to find vfModule with modelCustomizationUuid=" + mcu); + String error = "Create vfModule error: Unable to find vfModule with modelCustomizationUuid=" + mcu; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, + "VF Module ModelCustomizationUuid", modelCustomizationUuid, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Unable to find vfModule with modelCustomizationUuid=" + mcu); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); + } else { + LOGGER.debug("Found vfModule entry in table! " + 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 (!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); @@ -1222,14 +1327,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // 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) { + 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) { @@ -1281,10 +1386,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // 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. + // with VNF_RESOURCE - we use the old methods. Integer heatTemplateId = null; Integer heatEnvtId = null; - + if (!oldWay) { if (isVolumeRequest) { heatTemplateId = vf.getVolTemplateId(); @@ -1334,7 +1439,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { throw new VnfException(error, MsoExceptionCategory.INTERNAL); } LOGGER.debug("Got HEAT Template from DB"); - + HeatEnvironment heatEnvironment = null; String heatEnvironmentString = null; @@ -1359,7 +1464,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } 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 ()); @@ -1579,8 +1684,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { 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 + } + // 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 () @@ -1609,9 +1714,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug ("No missing parameters found - ok to proceed"); } - + // Here - modify heatEnvironmentString - StringBuilder parsedEnvironmentString = null; + StringBuilder parsedEnvironmentString = null; String newEnvironmentString = null; if (mhee != null) { LOGGER.debug("Environment before:\n" + heatEnvironmentString); @@ -1715,7 +1820,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } catch (Exception e) { LOGGER.debug("unhandled exception in create VF"); throw new VnfException("Exception during create VF " + e.getMessage()); - + + } finally { + // Make sure DB session is closed + db.close (); } // Reach this point if createStack is successful. @@ -1731,13 +1839,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { 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 { + MsoRequest msoRequest, + Holder <Map <String, String>> outputs) throws VnfException { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName ("DeleteVf"); LOGGER.debug ("Deleting VF " + vnfName + " in " + cloudSiteId + "/" + tenantId); @@ -1746,6 +1855,24 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + // 1702 capture the output parameters on a delete + // so we'll need to query first + Map<String, Object> stackOutputs = null; + try { + stackOutputs = heat.queryStackForOutputs(cloudSiteId, tenantId, vnfName); + } catch (MsoException me) { + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + me.addContext ("DeleteVFModule"); + String error = "Delete VFModule: Query to get outputs: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me; + LOGGER.recordMetricEvent (startTime, 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 - QueryStack", me); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + throw new VnfException (me); + } + // call method which handles the conversion from Map<String,Object> to Map<String,String> for our expected Object types + outputs.value = this.convertMapStringObjectToStringString(stackOutputs); + // 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 @@ -1780,6 +1907,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String volumeGroupHeatStackId, String baseVfHeatStackId, String vfModuleStackId, + String modelCustomizationUuid, Map <String, String> inputs, MsoRequest msoRequest, Holder <Map <String, String>> outputs, @@ -1792,6 +1920,19 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName; MsoLogger.setServiceName (serviceName); + String mcu = modelCustomizationUuid; + boolean useMCUuid = false; + if (mcu != null && !mcu.isEmpty()) { + if (mcu.equalsIgnoreCase("null")) { + LOGGER.debug("modelCustomizationUuid: passed in as the string 'null' - will ignore: " + modelCustomizationUuid); + useMCUuid = false; + mcu = ""; + } else { + LOGGER.debug("Found modelCustomizationUuid! Will use that: " + mcu); + useMCUuid = true; + } + } + String requestTypeString = ""; if (requestType != null && !requestType.equals("")) { requestTypeString = requestType; @@ -1843,6 +1984,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vfRollback.setBaseGroupHeatStackId(baseVfHeatStackId); vfRollback.setIsBase(isBaseRequest); vfRollback.setVfModuleStackId(vfModuleStackId); + vfRollback.setModelCustomizationUuid(mcu); // First, look up to see if the VNF already exists. MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); @@ -1947,12 +2089,21 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } // Ready to deploy the new VNF + // Get a handle to the Catalog Database + CatalogDatabase db = new CatalogDatabase (); - try (CatalogDatabase db = new CatalogDatabase ()) { + // Make sure DB session is closed + try { // Retrieve the VF definition //VnfResource vnf; VfModule vf = null; - if (vfVersion != null && !vfVersion.isEmpty ()) { + if (useMCUuid) { + vf = db.getVfModuleByModelCustomizationUuid(mcu); + if (vf == null) { + LOGGER.debug("Unable to find a vfModule matching modelCustomizationUuid=" + mcu); + } + } + else 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"); @@ -1972,16 +2123,21 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } if (vf == null) { - String error = "Update VFModule: Unknown VF Module Type: " + vfModuleType; - if (vfVersion != null && !vfVersion.isEmpty()) { - error += " with version = " + vfVersion; + String error; + if (!useMCUuid) { + error = "Update VFModule: Unknown VF Module Type: " + vfModuleType; + if (vfVersion != null && !vfVersion.isEmpty()) { + error += " with version = " + vfVersion; + } + } else { + error = "Update VfModule: unable to find vfModule with modelCustomizationUuid=" + mcu; } 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; @@ -2167,7 +2323,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // 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=" @@ -2348,7 +2504,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { 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"); @@ -2358,6 +2514,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); throw new VnfException (me); } + } finally { + // Make sure DB session is closed + db.close (); } // Reach this point if updateStack is successful. @@ -2377,7 +2536,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (vfModuleStackId == null) return null; int index = vfModuleStackId.lastIndexOf('/'); - if (index <= 0) + if (index <= 0) return null; String vfModuleName = null; try { 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 index 6906f816a7..3efab60409 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -173,11 +173,12 @@ public class VnfAdapterRest { public void run() { try { String cloudsite = req.getCloudSiteId(); + Holder<Map<String, String>> outputs = new Holder <Map <String, String>> (); 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()); + vnfAdapter.deleteVfModule (req.getCloudSiteId(), req.getTenantId(), req.getVfModuleStackId(), req.getMsoRequest(), outputs); } - response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE, req.getMessageId()); + response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE, req.getMessageId(), outputs.value); } 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()); @@ -365,7 +366,7 @@ public class VnfAdapterRest { } vnfRollback.value = new VnfRollback(req.getVnfId(), tenant, cloudsite, true, false, new MsoRequest("reqid", "svcid"), - req.getVolumeGroupId(), req.getVolumeGroupId(), req.getRequestType()); + req.getVolumeGroupId(), req.getVolumeGroupId(), req.getRequestType(), req.getModelCustomizationUuid()); vfModuleStackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484"; outputs.value = VolumeAdapterRest.testMap(); } else { @@ -392,6 +393,7 @@ public class VnfAdapterRest { req.getRequestType(), req.getVolumeGroupStackId(), req.getBaseVfModuleStackId(), + req.getModelCustomizationUuid(), req.getVfModuleParams(), req.getFailIfExists(), req.getBackout(), @@ -496,7 +498,7 @@ public class VnfAdapterRest { updateReq.getVfModuleParams(), updateReq.getMsoRequest(), outputs, - vnfRollback); + vnfRollback); */ vnfAdapter.updateVfModule (req.getCloudSiteId(), req.getTenantId(), @@ -508,10 +510,11 @@ public class VnfAdapterRest { req.getVolumeGroupStackId(), req.getBaseVfModuleId(), req.getVfModuleStackId(), + req.getModelCustomizationUuid(), req.getVfModuleParams(), req.getMsoRequest(), outputs, - vnfRollback); + vnfRollback); response = new UpdateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), vfModuleStackId.value, outputs.value, req.getMessageId()); @@ -610,7 +613,7 @@ public class VnfAdapterRest { VfModuleRollback vmr = req.getVfModuleRollback(); VnfRollback vrb = new VnfRollback( vmr.getVfModuleStackId(), vmr.getTenantId(), vmr.getCloudSiteId(), true, true, - vmr.getMsoRequest(), null, null, null); + vmr.getMsoRequest(), null, null, null, null); vnfAdapter.rollbackVnf (vrb); response = new RollbackVfModuleResponse(Boolean.TRUE, req.getMessageId()); } catch (VnfException e) { 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 index 8fa1552bb0..5514c27a46 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -166,21 +166,22 @@ public class VolumeAdapterRest { // outputs, // vnfRollback); vnfAdapter.createVfModule( - req.getCloudSiteId(), //cloudSiteId, - req.getTenantId(), //tenantId, - //req.getVnfType(), //vnfType, + 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, + req.getVnfVersion(), //vnfVersion, + req.getVolumeGroupName(), //vnfName, + "VOLUME", //requestType, + null, //volumeGroupHeatStackId, + null, //baseVfHeatStackId, + req.getModelCustomizationUuid(), + req.getVolumeGroupParams(), //inputs, + req.getFailIfExists(), //failIfExists, + req.getSuppressBackout(), //backout, + req.getMsoRequest(), // msoRequest, + stackId, + outputs, vnfRollback); } VolumeGroupRollback rb = new VolumeGroupRollback( @@ -370,7 +371,7 @@ public class VolumeAdapterRest { VolumeGroupRollback vgr = req.getVolumeGroupRollback(); VnfRollback vrb = new VnfRollback( vgr.getVolumeGroupStackId(), vgr.getTenantId(), vgr.getCloudSiteId(), true, true, - vgr.getMsoRequest(), null, null, null); + vgr.getMsoRequest(), null, null, null, null); vnfAdapter.rollbackVnf(vrb); response = new RollbackVolumeGroupResponse(true, req.getMessageId()); } catch (VnfException e) { @@ -383,6 +384,7 @@ public class VolumeAdapterRest { } LOGGER.debug("DeleteVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); } + } @PUT @@ -487,10 +489,11 @@ public class VolumeAdapterRest { null, null, req.getVolumeGroupStackId(), + req.getModelCustomizationUuid(), req.getVolumeGroupParams(), req.getMsoRequest(), outputs, - vnfRollback); + vnfRollback); } response = new UpdateVolumeGroupResponse( req.getVolumeGroupId(), req.getVolumeGroupStackId(), 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 index 7cec0cd99e..149192cbac 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -28,15 +28,15 @@ 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") +@WebFault (name="VnfAlreadyExists", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://org.openecomp.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); + super("Resource " + 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 index ceef76b468..f25b1d7f47 100644 --- 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 @@ -33,7 +33,7 @@ import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; * * */ -@WebFault (name="VnfException", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://com.att.mso/vnf") +@WebFault (name="VnfException", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://org.openecomp.mso/vnf") public class VnfException extends Exception { private static final long serialVersionUID = 1L; 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 index 15918eabb8..022f651b01 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -39,7 +39,8 @@ public class VnfExceptionBean implements Serializable { public VnfExceptionBean () {} public VnfExceptionBean (String message) { - this.message = message; + // Create a default category to prevent null pointer exceptions + this(message, MsoExceptionCategory.INTERNAL); } public VnfExceptionBean (String message, MsoExceptionCategory category) { 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 index 3c27d03daa..3f6a65a551 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -29,15 +29,15 @@ 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") +@WebFault (name="VnfNotFound", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://org.openecomp.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); + super("Resource " + vnfName + " not found in cloud/tenant " + cloudId + "/" + tenantId); } } diff --git a/adapters/mso-workflow-message-adapter/WebContent/META-INF/MANIFEST.MF b/adapters/mso-workflow-message-adapter/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..bbf7aa0cf9 --- /dev/null +++ b/adapters/mso-workflow-message-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-workflow-message-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml b/adapters/mso-workflow-message-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 0000000000..9a24bfc509 --- /dev/null +++ b/adapters/mso-workflow-message-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-workflow-message-adapter/WebContent/WEB-INF/jboss-web.xml b/adapters/mso-workflow-message-adapter/WebContent/WEB-INF/jboss-web.xml new file mode 100644 index 0000000000..a6ab6790c1 --- /dev/null +++ b/adapters/mso-workflow-message-adapter/WebContent/WEB-INF/jboss-web.xml @@ -0,0 +1,3 @@ +<jboss-web> + <context-root>workflows/messages</context-root> +</jboss-web>
\ No newline at end of file diff --git a/adapters/mso-workflow-message-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-workflow-message-adapter/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000000..2adea83c4e --- /dev/null +++ b/adapters/mso-workflow-message-adapter/WebContent/WEB-INF/web.xml @@ -0,0 +1,80 @@ +<?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-workflow-message-adapter</display-name> + <welcome-file-list> + <welcome-file>check.html</welcome-file> + </welcome-file-list> + <context-param> + <param-name>log.configuration</param-name> + <param-value>logback.workflow-message-adapter.xml</param-value> + </context-param> + <context-param> + <param-name>mso.configuration</param-name> + <param-value>MSO_PROP_WORKFLOW_MESSAGE_ADAPTER=mso.workflow-message-adapter.properties,MSO_PROP_TOPOLOGY=topology.properties,MSO_PROP_AAF=cadi.properties</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.workflowmessage.WMAdapterRest + </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>com.att.ecomp.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>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>MSO internal Requests</web-resource-name> + <description>Internal Requests</description> + <url-pattern>/rest/logging/*</url-pattern> + <url-pattern>/rest/properties/*</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> + <login-config> + <auth-method>BASIC</auth-method> + <realm-name>ApplicationRealm</realm-name> + </login-config> + <security-role> + <role-name>SiteControl-Client</role-name> + </security-role> + <security-role> + <role-name>MSO-Client</role-name> + </security-role> +</web-app> diff --git a/adapters/mso-workflow-message-adapter/WebContent/check.html b/adapters/mso-workflow-message-adapter/WebContent/check.html new file mode 100644 index 0000000000..454997901e --- /dev/null +++ b/adapters/mso-workflow-message-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-workflow-message-adapter/pom.xml b/adapters/mso-workflow-message-adapter/pom.xml new file mode 100644 index 0000000000..bde619f509 --- /dev/null +++ b/adapters/mso-workflow-message-adapter/pom.xml @@ -0,0 +1,76 @@ +<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>1.1.0-SNAPSHOT</version> + </parent> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-workflow-message-adapter</artifactId> + <packaging>war</packaging> + <name>mso-workflow-message-adapter</name> + <description>mso workflow message 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> + </configuration> + </plugin> + </plugins> + </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.1_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>1.1.1</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>4.5.2</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>status-control</artifactId> + <version>${project.version}</version> + </dependency> + <!-- For UriUtils which does URL encoding according to RFC 3986 Section 2 --> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>4.3.2.RELEASE</version> + </dependency> + </dependencies> +</project> diff --git a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallback.java b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallback.java new file mode 100644 index 0000000000..cb3aea62c7 --- /dev/null +++ b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallback.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.workflowmessage; + +import javax.xml.bind.DatatypeConverter; + +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.config.RequestConfig; +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.HttpClientBuilder; +import org.apache.http.util.EntityUtils; + +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; + +/** + * Sends asynchronous messages to the BPMN WorkflowMessage service. + */ +public class BPRestCallback { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger(); + + /** + * Sends a message to the BPMN workflow message service. The URL path is + * constructed using the specified message type and correlator. + * @param workflowMessageUrl the base BPMN WorkflowMessage URL + * @param messageType the message type + * @param correlator the message correlator + * @param contentType the value for the HTTP Content-Type header (possibly null) + * @param message the content (possibly null) + * @return true if the message was consumed successfully by the endpoint + */ + public boolean send(String workflowMessageUrl, String messageType, + String correlator, ContentType contentType, String message) { + LOGGER.debug(getClass().getSimpleName() + ".send(" + + "workflowMessageUrl=" + workflowMessageUrl + + " messageType=" + messageType + + " correlator=" + correlator + + " contentType=" + contentType + + " message=" + message + + ")"); + + while (workflowMessageUrl.endsWith("/")) { + workflowMessageUrl = workflowMessageUrl.substring(0, workflowMessageUrl.length()-1); + } + + String endpoint = workflowMessageUrl + "/" + WMAdapterUtils.encodeURLPathSegment(messageType) + + "/" + WMAdapterUtils.encodeURLPathSegment(correlator); + + return send(endpoint, contentType, message); + } + + /** + * Sends a message to the BPMN workflow message service. The specified URL + * must have the message type and correlator already embedded in it. + * @param url the endpoint URL + * @param message the content (possibly null) + * @param contentType the value for the HTTP Content-Type header (possibly null) + * @return true if the message was consumed successfully by the endpoint + */ + public boolean send(String url, ContentType contentType, String message) { + LOGGER.debug(getClass().getSimpleName() + ".send(" + + "url=" + url + + " contentType=" + contentType + + " message=" + message + + ")"); + + LOGGER.info(MessageEnum.RA_CALLBACK_BPEL, message == null ? "[no content]" : message, "Camunda", ""); + + HttpPost method = null; + HttpResponse httpResponse = null; + + try { + // TODO: configurable timeout? + int timeout = 60 * 1000; + + RequestConfig requestConfig = RequestConfig.custom() + .setSocketTimeout(timeout) + .setConnectTimeout(timeout) + .setConnectionRequestTimeout(timeout) + .build(); + + HttpClient client = HttpClientBuilder.create().build(); + method = new HttpPost(url); + method.setConfig(requestConfig); + + if (message != null) { + method.setEntity(new StringEntity(message, contentType)); + } + + boolean error = false; + + try { + // AAF Integration, disabled for now due to the constrains from other party + // String userCredentials = CredentialConstants.getDecryptedCredential(WMAdapterConstants.DEFAULT_BPEL_AUTH); + // Once AAF enabled, the credential shall be get by triggering the CredentialConstants.getDecryptedCredential -- remove line + String userCredentials = WMAdapterProperties.getEncryptedProperty(WMAdapterConstants.BPEL_AUTH_PROP, + WMAdapterConstants.DEFAULT_BPEL_AUTH, WMAdapterConstants.ENCRYPTION_KEY); + String authorization = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); + method.setHeader("Authorization", authorization); + } catch (Exception e) { + LOGGER.error(MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, + "Unable to set authorization in callback request", e); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, + "Unable to set authorization in callback request: " + e.getMessage()); + error = true; + } + + if (!error) { + httpResponse = client.execute(method); + + @SuppressWarnings("unused") + String responseContent = null; + + if (httpResponse.getEntity() != null) { + responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); + } + + if (httpResponse.getStatusLine().getStatusCode() >= 300) { + String msg = "Received error response to callback request: " + httpResponse.getStatusLine(); + LOGGER.error(MessageEnum.RA_CALLBACK_BPEL_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, msg); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, msg); + } + + httpResponse = null; + } + + method.reset(); + method = null; + return true; + } catch (Exception e) { + LOGGER.error(MessageEnum.RA_CALLBACK_BPEL_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, + "Error sending callback request", e); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, + "Error sending callback request: " + e.getMessage()); + return false; + } finally { + if (httpResponse != null) { + try { + EntityUtils.consume(httpResponse.getEntity()); + } catch (Exception e) { + // Ignore + } + } + + if (method != null) { + try { + method.reset(); + } catch (Exception e) { + // Ignore + } + } + + LOGGER.info(MessageEnum.RA_CALLBACK_BPEL_COMPLETE, "Camunda", ""); + } + } +}
\ No newline at end of file diff --git a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterConstants.java b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterConstants.java new file mode 100644 index 0000000000..a92051da12 --- /dev/null +++ b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterConstants.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.adapters.workflowmessage; + +public interface WMAdapterConstants { + public static final String MSO_PROPERTIES_ID = "MSO_PROP_WORKFLOW_MESSAGE_ADAPTER"; + public static final String BPEL_URL_PROP = "org.openecomp.mso.adapters.workflow.message.bpelurl"; + + // Once AAF enabled, the credential shall be get by triggering the CredentialConstants.getEncryptedPropValue + public static final String BPEL_AUTH_PROP = "org.openecomp.mso.adapters.workflow.message.bpelauth"; + public static final String DEFAULT_BPEL_AUTH = "05FDA034C27D1CA51AAB8FAE512EDE45241E16FC8C137D292AA3A964431C82DB"; + public static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; +}
\ No newline at end of file diff --git a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterProperties.java b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterProperties.java new file mode 100644 index 0000000000..e63c404024 --- /dev/null +++ b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterProperties.java @@ -0,0 +1,89 @@ +/*- + * ============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.workflowmessage; + +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; + +/** + * Static methods to access Workflow Message Adapter properties. + */ +public final class WMAdapterProperties { + private static final MsoPropertiesFactory MSO_PROPERTIES_FACTORY = new MsoPropertiesFactory(); + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + + /** + * Gets the value of a Workflow Message Adapter property. + * @param key the property key + * @param defaultValue the default value to use if the property does not + * exist or if an error occurs + */ + public static String getProperty(String key, String defaultValue) { + MsoJavaProperties properties; + + try { + properties = MSO_PROPERTIES_FACTORY.getMsoJavaProperties(WMAdapterConstants.MSO_PROPERTIES_ID); + } catch (MsoPropertiesException e) { + LOGGER.error (MessageEnum.NO_PROPERTIES, + "Unknown. MSO Properties ID not found in cache: " + WMAdapterConstants.MSO_PROPERTIES_ID, + "WorkflowMessageAdatper", "", MsoLogger.ErrorCode.DataError, + "Exception - MSO Properties ID not found in cache", e); + return defaultValue; + } + + String value = properties.getProperty(key, defaultValue); + LOGGER.debug("Config read for " + WMAdapterConstants.MSO_PROPERTIES_ID + + " - key:" + key + " value:" + value); + return value; + } + + /** + * Gets the value of an Workflow Message Adapter property. + * @param key the property key + * @param defaultValue the default value to use if the property does not + * exist or if an error occurs + */ + public static String getEncryptedProperty(String key, String defaultValue, String encryptionKey) { + MsoJavaProperties properties; + + try { + properties = MSO_PROPERTIES_FACTORY.getMsoJavaProperties(WMAdapterConstants.MSO_PROPERTIES_ID); + } catch (MsoPropertiesException e) { + LOGGER.error (MessageEnum.NO_PROPERTIES, + "Unknown. MSO Properties ID not found in cache: " + WMAdapterConstants.MSO_PROPERTIES_ID, + "WorkflowMessageAdatper", "", MsoLogger.ErrorCode.DataError, + "Exception - MSO Properties ID not found in cache", e); + return defaultValue; + } + + String value = properties.getEncryptedProperty(key, defaultValue, encryptionKey); + LOGGER.debug("Config read for " + WMAdapterConstants.MSO_PROPERTIES_ID + " - key:" + key); + return value; + } + + /** + * Instantiation is not allowed. + */ + private WMAdapterProperties() { + } +}
\ No newline at end of file diff --git a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterRest.java b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterRest.java new file mode 100644 index 0000000000..db7e47f00e --- /dev/null +++ b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterRest.java @@ -0,0 +1,140 @@ +/*- + * ============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.workflowmessage; + +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.http.entity.ContentType; + +import org.openecomp.mso.HealthCheckUtils; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.utils.UUIDChecker; + +/** + * Workflow Message Adapter interface added in 1707. Supports delivery of + * callbacks from external systems to waiting BPMN workflows. + */ +@Path("/") +public class WMAdapterRest { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger(); + + @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, LOGGER); + HealthCheckUtils healthCheck = new HealthCheckUtils(); + + if (!healthCheck.siteStatusCheck(LOGGER, startTime)) { + return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; + } + + if (!healthCheck.configFileCheck(LOGGER, startTime, WMAdapterConstants.MSO_PROPERTIES_ID)) { + return HealthCheckUtils.NOT_STARTED_RESPONSE; + } + + LOGGER.debug("healthcheck - Successful"); + return HealthCheckUtils.HEALTH_CHECK_RESPONSE; + } + + /** + * Receives a message from a remote system. + * @param content the message content + */ + @POST + @Path("/message/{messageType}/{correlator}") + @Consumes("*/*") + @Produces({MediaType.TEXT_PLAIN}) + public Response receiveWorkflowMessage( + @HeaderParam("Content-Type") String contentTypeHeader, + @PathParam("messageType") String messageType, + @PathParam("correlator") String correlator, + String content) { + + String path= "workflow/" + messageType + "/" + correlator; + LOGGER.info(MessageEnum.RA_RECEIVE_WORKFLOW_MESSAGE, content, "WorkflowMessageAdapter", path); + + long startTime = System.currentTimeMillis(); + + ContentType contentType = null; + + if (contentTypeHeader != null) { + try { + contentType = ContentType.parse(contentTypeHeader); + } catch (Exception e) { + // If we don't get a valid one, we handle it below. + } + } + + if (contentType == null && content != null) { + String error = "Missing or Invalid Content-Type"; + LOGGER.error(MessageEnum.RA_PARSING_REQUEST_ERROR, error, "WorkflowMessageAdapter", path, + MsoLogger.ErrorCode.DataError, "Bad Request"); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + return Response.status(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE).entity(error).build(); + } + + String bpUrl = WMAdapterProperties.getProperty(WMAdapterConstants.BPEL_URL_PROP, null); + + if (bpUrl == null) { + String error = "Missing configuration for: " + WMAdapterConstants.BPEL_URL_PROP; + LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "WorkflowMessageAdapter", path, + MsoLogger.ErrorCode.DataError, "Configuration Error"); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(error).build(); + } + + long bpStartTime = System.currentTimeMillis(); + BPRestCallback callback = new BPRestCallback(); + boolean callbackSuccess = callback.send(bpUrl, messageType, correlator, contentType, content); + + if (callbackSuccess) { + LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + "Sent notification", "BPMN", bpUrl, null); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + } else { + LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + "Failed to send notification", "BPMN", bpUrl, null); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + "Failed to send notification"); + } + + return Response.status(204).build(); + } +} diff --git a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterUtils.java b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterUtils.java new file mode 100644 index 0000000000..b371d2dd9b --- /dev/null +++ b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterUtils.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.workflowmessage; + +import java.io.UnsupportedEncodingException; + +import org.springframework.web.util.UriUtils; + +/** + * Utility methods used by WMAdapterRest. + */ +public final class WMAdapterUtils { + /** + * Encodes a URL path segment according to RFC 3986 Section 2. + * @param pathSegment the path segment to encode + * @return the encoded path segment + */ + public static String encodeURLPathSegment(String pathSegment) { + try { + return UriUtils.encodePathSegment(pathSegment, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("UTF-8 encoding is not supported"); + } + } + + /** + * Instantiation is not allowed. + */ + private WMAdapterUtils() { + } +}
\ No newline at end of file diff --git a/adapters/mso-workflow-message-adapter/src/test/resources/logback-test.xml b/adapters/mso-workflow-message-adapter/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..bc3d7f36b6 --- /dev/null +++ b/adapters/mso-workflow-message-adapter/src/test/resources/logback-test.xml @@ -0,0 +1,25 @@ +<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>
\ No newline at end of file diff --git a/adapters/pom.xml b/adapters/pom.xml index 8ccd8cdc71..a96b04aed9 100644 --- a/adapters/pom.xml +++ b/adapters/pom.xml @@ -24,9 +24,17 @@ <module>mso-vnf-adapter</module> <module>mso-vnf-adapter-async-client</module> <module>mso-requests-db-adapter</module> + <module>mso-catalog-db-adapter</module> + <module>mso-workflow-message-adapter</module> </modules> <dependencies> + <dependency> + <groupId>org.evosuite</groupId> + <artifactId>evosuite-standalone-runtime</artifactId> + <version>${evosuiteVersion}</version> + <scope>test</scope> + </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> |