summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8.1__AddColumnAdminProjectDomainName.sql3
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncUpgradePreCheckPnfBBTest.java88
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java102
-rw-r--r--graph-inventory/aai-client/pom.xml2
-rw-r--r--graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java22
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java35
7 files changed, 243 insertions, 11 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
index ab0239057a..c1c7ed5fd6 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
@@ -100,7 +100,7 @@ public final class AuthenticationMethodFactory {
Project project = new Project();
Project.Domain projectDomain = new Project.Domain();
userDomain.setName(cloudIdentity.getUserDomainName());
- projectDomain.setName(cloudIdentity.getProjectDomainName());
+ projectDomain.setName(cloudIdentity.getAdminProjectDomainName());
user.setName(cloudIdentity.getMsoId());
user.setPassword(CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass()));
user.setDomain(userDomain);
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8.1__AddColumnAdminProjectDomainName.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8.1__AddColumnAdminProjectDomainName.sql
new file mode 100644
index 0000000000..a883466515
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8.1__AddColumnAdminProjectDomainName.sql
@@ -0,0 +1,3 @@
+use catalogdb;
+
+ALTER TABLE identity_services ADD COLUMN ADMIN_PROJECT_DOMAIN_NAME varchar(255) DEFAULT 'Default'; \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncUpgradePreCheckPnfBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncUpgradePreCheckPnfBBTest.java
new file mode 100644
index 0000000000..0ba1e27f5e
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncUpgradePreCheckPnfBBTest.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.controller.sdnc.prepare;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+
+public class PrepareSdncUpgradePreCheckPnfBBTest {
+
+ private PrepareSdncUpgradePreCheckPnfBB testedObject;
+
+ @Before
+ public void setup() {
+ testedObject = new PrepareSdncUpgradePreCheckPnfBB();
+ }
+
+ @Test
+ public void understandTrue() {
+ ControllerContext<BuildingBlockExecution> controllerContext =
+ createControllerContext("sdnc", "UpgradePreCheck", "pnf");
+ boolean result = testedObject.understand(controllerContext);
+ assertThat(result).isTrue();
+ }
+
+ @Test
+ public void understandFalse() {
+ ControllerContext<BuildingBlockExecution> controllerContext =
+ createControllerContext("actor1", "action1", "scope1");
+ boolean result = testedObject.understand(controllerContext);
+ assertThat(result).isFalse();
+ }
+
+ @Test
+ public void prepare_jsonWithoutActionPayload() {
+ String payloadWithoutActionArray = "{\"json name\": \"test1\"}";
+ ControllerContext<BuildingBlockExecution> controllerContext =
+ createControllerContext(payloadWithoutActionArray);
+ testedObject.prepare(controllerContext);
+
+ assertThat((String) controllerContext.getExecution().getVariable("payload"))
+ .isEqualTo(payloadWithoutActionArray);
+ }
+
+ private ControllerContext<BuildingBlockExecution> createControllerContext(String actor, String action,
+ String scope) {
+ ControllerContext<BuildingBlockExecution> controllerContext = new ControllerContext<>();
+ controllerContext.setControllerActor(actor);
+ controllerContext.setControllerAction(action);
+ controllerContext.setControllerScope(scope);
+ return controllerContext;
+ }
+
+ private ControllerContext<BuildingBlockExecution> createControllerContext(String payload) {
+ ControllerContext<BuildingBlockExecution> controllerContext = new ControllerContext<>();
+ controllerContext.setExecution(prepareBuildingBlockExecution(payload));
+ return controllerContext;
+ }
+
+ private BuildingBlockExecution prepareBuildingBlockExecution(String payload) {
+ DelegateExecution execution = new DelegateExecutionFake();
+ execution.setVariable("payload", payload);
+ return new DelegateExecutionImpl(execution);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java
new file mode 100644
index 0000000000..35a5bfefd7
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java
@@ -0,0 +1,102 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in 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.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.aai.domain.yang.VpnBinding;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
+import org.onap.aaiclient.client.aai.entities.Relationships;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAISimpleUri;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
+import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
+
+@RunWith(MockitoJUnitRunner.class)
+public class WorkflowActionExtractResourcesAAITest {
+
+ private static final String CONFIGURATION_ID = "configTestId";
+ private static final String VPN_ID = "vpnTestId";
+
+ @Mock
+ private BBInputSetupUtils bbInputSetupUtils;
+ @InjectMocks
+ private WorkflowActionExtractResourcesAAI testedObject;
+
+ @Test
+ public void extractRelationshipsConfigurationSuccess() {
+ // given
+ Relationships relationships = mock(Relationships.class);
+ when(relationships.getByType(Types.CONFIGURATION)).thenReturn(getConfigurationList());
+ // when
+ Optional<Configuration> resultOpt = testedObject.extractRelationshipsConfiguration(relationships);
+ // then
+ assertThat(resultOpt).isNotEmpty();
+ assertThat(resultOpt.get().getConfigurationId()).isEqualTo(CONFIGURATION_ID);
+ }
+
+ @Test
+ public void extractRelationshipsConfiguration_notFound() {
+ // given
+ Relationships relationships = mock(Relationships.class);
+ when(relationships.getByType(Types.CONFIGURATION)).thenReturn(Collections.emptyList());
+ // when
+ Optional<Configuration> resultOpt = testedObject.extractRelationshipsConfiguration(relationships);
+ // then
+ assertThat(resultOpt).isEmpty();
+ }
+
+ @Test
+ public void extractRelationshipsVpnBindingSuccess() {
+ // given
+ Relationships relationships = mock(Relationships.class);
+ AAIResourceUri aaiResourceUri = mock(AAISimpleUri.class);
+ List<AAIResourceUri> aaiResourceUriList = new ArrayList<>();
+ aaiResourceUriList.add(aaiResourceUri);
+ when(relationships.getRelatedUris(Types.VPN_BINDING)).thenReturn(aaiResourceUriList);
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper("{\"vpn-id\" : \"" + VPN_ID + "\"}");
+ when(bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri)).thenReturn(aaiResultWrapper);
+ // when
+ Optional<VpnBinding> resultOpt = testedObject.extractRelationshipsVpnBinding(relationships);
+ // then
+ assertThat(resultOpt).isNotEmpty();
+ assertThat(resultOpt.get().getVpnId()).isEqualTo(VPN_ID);
+ }
+
+ private List<AAIResultWrapper> getConfigurationList() {
+ List<AAIResultWrapper> configurations = new ArrayList<>();
+ AAIResultWrapper aaiResultWrapper =
+ new AAIResultWrapper("{\"configuration-id\" : \"" + CONFIGURATION_ID + "\"}");
+ configurations.add(aaiResultWrapper);
+ return configurations;
+ }
+}
diff --git a/graph-inventory/aai-client/pom.xml b/graph-inventory/aai-client/pom.xml
index d1c9742cea..d532103c40 100644
--- a/graph-inventory/aai-client/pom.xml
+++ b/graph-inventory/aai-client/pom.xml
@@ -93,7 +93,7 @@
<destination>${project.build.directory}/generated-sources</destination>
<destinationClasspath>org.onap.aaiclient.client.generated.fluentbuilders</destinationClasspath>
<builderName>AAIFluentTypeBuilder</builderName>
- <swaggerLocation>${project.build.directory}/swagger/onap/aai_swagger_yaml/aai_swagger_v21.yaml</swaggerLocation>
+ <swaggerLocation>${project.build.directory}/swagger/onap/aai_swagger_yaml/aai_swagger_LATEST.yaml</swaggerLocation>
<singularBuilderClass>org.onap.aaiclient.client.aai.entities.uri.AAIFluentSingleType</singularBuilderClass>
<pluralBuilderClass>org.onap.aaiclient.client.aai.entities.uri.AAIFluentPluralType</pluralBuilderClass>
<topLevelBuilderClass>org.onap.aaiclient.client.aai.entities.uri.AAIFluentTopLevelType</topLevelBuilderClass>
diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java
index ec09af8a4e..fc42d9ca0d 100644
--- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java
+++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java
@@ -1,6 +1,10 @@
package org.onap.graphinventory.generate;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -26,6 +30,9 @@ public class SwaggerConverter {
}
public Map<String, ObjectType> getDoc(String swaggerLocation) throws JsonProcessingException {
+
+
+ swaggerLocation = processLocation(swaggerLocation);
Swagger swagger = new SwaggerParser().read(swaggerLocation);
Map<String, Path> paths = swagger.getPaths().entrySet().stream()
@@ -168,4 +175,19 @@ public class SwaggerConverter {
return output;
}
+
+ private String processLocation(String swaggerLocation) {
+
+ java.nio.file.Path path = Paths.get(swaggerLocation);
+ try {
+ return Files.list(path.getParent())
+ .filter(it -> it.getFileName().toString()
+ .matches(path.getFileName().toString().replaceFirst("LATEST", "v\\\\\\d+")))
+ .sorted(Comparator.reverseOrder()).map(it -> it.toString()).findFirst().orElseGet(null);
+ } catch (IOException e) {
+ log.error(e);
+ }
+
+ return null;
+ }
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java
index 61b0b11445..63ee35cd9c 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java
@@ -20,13 +20,7 @@
package org.onap.so.db.catalog.beans;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.openpojo.business.annotation.BusinessKey;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
import java.util.Date;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
@@ -36,6 +30,12 @@ import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.openpojo.business.annotation.BusinessKey;
import uk.co.blackpepper.bowman.annotation.RemoteResource;
/**
@@ -74,6 +74,11 @@ public class CloudIdentity {
@Column(name = "PROJECT_DOMAIN_NAME")
private String projectDomainName;
+ @JsonProperty("admin_project_domain_name ")
+ @BusinessKey
+ @Column(name = "ADMIN_PROJECT_DOMAIN_NAME")
+ private String adminProjectDomainName;
+
@JsonProperty("user_domain_name")
@BusinessKey
@Column(name = "USER_DOMAIN_NAME")
@@ -245,6 +250,14 @@ public class CloudIdentity {
this.projectDomainName = projectDomainName;
}
+ public String getAdminProjectDomainName() {
+ return adminProjectDomainName;
+ }
+
+ public void setAdminProjectDomainName(String adminProjectDomainName) {
+ this.adminProjectDomainName = adminProjectDomainName;
+ }
+
public String getUserDomainName() {
return userDomainName;
}
@@ -267,6 +280,7 @@ public class CloudIdentity {
cloudIdentityCopy.identityServerType = this.identityServerType;
cloudIdentityCopy.identityAuthenticationType = this.identityAuthenticationType;
cloudIdentityCopy.projectDomainName = this.projectDomainName;
+ cloudIdentityCopy.adminProjectDomainName = this.adminProjectDomainName;
cloudIdentityCopy.userDomainName = this.userDomainName;
return cloudIdentityCopy;
@@ -279,7 +293,8 @@ public class CloudIdentity {
.append("projectDomain", getProjectDomainName()).append("userDomain", getUserDomainName())
.append("adminTenant", getAdminTenant()).append("memberRole", getMemberRole())
.append("tenantMetadata", getTenantMetadata()).append("identityServerType", getIdentityServerType())
- .append("identityAuthenticationType", getIdentityAuthenticationType()).toString();
+ .append("identityAuthenticationType", getIdentityAuthenticationType())
+ .append("adminProjectDomainName", getAdminProjectDomainName()).toString();
}
@Override
@@ -299,7 +314,8 @@ public class CloudIdentity {
.append(getMemberRole(), castOther.getMemberRole())
.append(getTenantMetadata(), castOther.getTenantMetadata())
.append(getIdentityServerType(), castOther.getIdentityServerType())
- .append(getIdentityAuthenticationType(), castOther.getIdentityAuthenticationType()).isEquals();
+ .append(getIdentityAuthenticationType(), castOther.getIdentityAuthenticationType())
+ .append(getAdminProjectDomainName(), castOther.getAdminProjectDomainName()).isEquals();
}
@Override
@@ -307,6 +323,7 @@ public class CloudIdentity {
return new HashCodeBuilder(1, 31).append(getId()).append(getIdentityUrl()).append(getMsoId())
.append(getMsoPass()).append(getProjectDomainName()).append(getUserDomainName())
.append(getAdminTenant()).append(getMemberRole()).append(getTenantMetadata())
- .append(getIdentityServerType()).append(getIdentityAuthenticationType()).toHashCode();
+ .append(getIdentityServerType()).append(getIdentityAuthenticationType())
+ .append(getAdminProjectDomainName()).toHashCode();
}
}