summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VnfCommand.kt7
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/view-models/creationDialog.htm94
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/view-models/msoCommit.htm98
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/VnfCommandTest.kt19
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java4
-rw-r--r--vid-automation/conf/users15
-rw-r--r--vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/UserCredentials.java4
-rw-r--r--vid-automation/src/main/java/vid/automation/test/Constants.java2
-rw-r--r--vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java3
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java2
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/BaseApiAaiTest.java25
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/PropertyControllerApiTest.java62
12 files changed, 208 insertions, 127 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/VnfCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/VnfCommand.kt
index b008c1306..cada6055d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/VnfCommand.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/VnfCommand.kt
@@ -12,7 +12,6 @@ import org.onap.vid.model.serviceInstantiation.Vnf
import org.onap.vid.mso.RestMsoImplementation
import org.onap.vid.properties.Features
import org.onap.vid.services.AsyncInstantiationBusinessLogic
-import org.onap.vid.utils.isNotActive
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
@@ -77,7 +76,7 @@ class VnfCommand @Autowired constructor(
.map { childVfModuleWithVnfRegionAndTenant(it) }
internal fun childVfModuleWithVnfRegionAndTenant(vfModule: VfModule): VfModule {
- if (featureManager.isNotActive(Features.FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF)) {
+ if (!shouldEntailRegionAndTenantToVfModule(vfModule)) {
return vfModule
}
@@ -86,6 +85,10 @@ class VnfCommand @Autowired constructor(
return vfModule.cloneWith(vnfLcpCloudRegionId, vnfTenantId)
}
+ private fun shouldEntailRegionAndTenantToVfModule(vfModule: VfModule) =
+ vfModule.action == Action.Create
+ && featureManager.isActive(Features.FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF)
+
private fun filterModuleByNeedToCreateBase(vfModule: VfModule): Boolean {
return needToCreateBaseModule ==
commandUtils.isVfModuleBaseModule(
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/creationDialog.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/creationDialog.htm
index 42fe083ab..9b0d99f1b 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/creationDialog.htm
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/creationDialog.htm
@@ -1,47 +1,47 @@
-<div ng-controller="creationDialogController">
- <div ng-show="isDialogVisible">
- <iframe class="popup" scrolling="no" ng-if="!shouldShowOldPopup()" id="iframe_callback" ng-src={{url}}></iframe>
- <div ng-if="shouldShowOldPopup()">
- <div class="titleLine">
- <img src="app/vid/images/spinner.gif"
- ngx-visible="{{isSpinnerVisible}}"></img>
- <h3 data-tests-id="create-modal-title">Create {{componentName}} -- {{createType}}</h3>
- </div>
-
- <div class="error" ng-show="isErrorVisible">
- <button class="btn-danger" att-button size="small" ng-click="showReportWindow()">Create report</button>
- <img src="app/vid/images/error.png"></img>
- {{error}} <br>
- </div>
-
- <div ngx-visible="{{isDataVisible}}">
- <parameter-block control="summaryControl"></parameter-block>
- <h4>
- User Provided Data (<img class="requiredIndicator"
- src="app/vid/images/asterisk.png" height='10' width='10'></img> indicates required field)
- </h4>
- <parameter-block control="userProvidedControl"
- callback="userParameterChanged(id);" editable></parameter-block>
- <div class="prompt">
- <p>
- Enter Data and <span>Confirm</span> to<br />Create <span>{{componentName}}</span>
- </p>
- <p>
- <span>Cancel</span> to Return to Previous Page.<br />Data entered
- will be lost
- </p>
- </div>
-
- </div>
- <div class="buttonRow">
- <button data-tests-id="confirmButton" ngx-enabled="{{isConfirmEnabled}}" att-button size="small"
- ng-click="confirm();">Confirm</button>
- <button type="button" data-tests-id="cancelButton" ng-click="cancel();" att-button
- btn-type="primary" size="small">Cancel</button>
- </div>
- </div>
- </div>
-
- <div ng-include="'app/vid/scripts/view-models/msoCommit.htm'"></div>
-
-</div>
+<div ng-controller="creationDialogController">
+ <div ng-show="isDialogVisible">
+ <iframe class="popup" scrolling="no" ng-if="!shouldShowOldPopup()" id="iframe_callback" ng-src={{url}}></iframe>
+ <div ng-if="shouldShowOldPopup()">
+ <div class="titleLine">
+ <img src="app/vid/images/spinner.gif"
+ ngx-visible="{{isSpinnerVisible}}"></img>
+ <h3 data-tests-id="create-modal-title">Create {{componentName}} -- {{createType}}</h3>
+ </div>
+
+ <div class="error" ng-show="isErrorVisible">
+ <button class="btn-danger" att-button size="small" ng-click="showReportWindow()" ng-if="isShowErrorReport()">Create report</button>
+ <img src="app/vid/images/error.png"></img>
+ {{error}} <br>
+ </div>
+
+ <div ngx-visible="{{isDataVisible}}">
+ <parameter-block control="summaryControl"></parameter-block>
+ <h4>
+ User Provided Data (<img class="requiredIndicator"
+ src="app/vid/images/asterisk.png" height='10' width='10'></img> indicates required field)
+ </h4>
+ <parameter-block control="userProvidedControl"
+ callback="userParameterChanged(id);" editable></parameter-block>
+ <div class="prompt">
+ <p>
+ Enter Data and <span>Confirm</span> to<br />Create <span>{{componentName}}</span>
+ </p>
+ <p>
+ <span>Cancel</span> to Return to Previous Page.<br />Data entered
+ will be lost
+ </p>
+ </div>
+
+ </div>
+ <div class="buttonRow">
+ <button data-tests-id="confirmButton" ngx-enabled="{{isConfirmEnabled}}" att-button size="small"
+ ng-click="confirm();">Confirm</button>
+ <button type="button" data-tests-id="cancelButton" ng-click="cancel();" att-button
+ btn-type="primary" size="small">Cancel</button>
+ </div>
+ </div>
+ </div>
+
+ <div ng-include="'app/vid/scripts/view-models/msoCommit.htm'"></div>
+
+</div>
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/msoCommit.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/msoCommit.htm
index 7cd0ab3b2..11ef3338e 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/msoCommit.htm
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/msoCommit.htm
@@ -1,50 +1,50 @@
-<!--
- ============LICENSE_START=======================================================
- VID
- ================================================================================
- Copyright (C) 2017 - 2019 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=========================================================
- -->
-
-<div ng-controller="msoCommitController" ng-show="isViewVisible" >
-<div ng-if="isViewVisible">
- <div class="statusLine">
- <img src="app/vid/images/spinner.gif"
- ngx-visible="{{isSpinnerVisible}}"> </img> <label>Status:</label><span
- class="status">{{status}}</span>
- </div>
-
- <div class="feedback">
-
- <div progress-bar control="progressBarControl"
- value="{{percentProgress}}" increases-only="true"
- ngx-show="{{isProgressVisible}}"></div>
-
- <div class="error" ng-show="!isProgressVisible">
- <button class="btn-danger" att-button size="small" ng-click="showReportWindow()">Create report</button>
- <img src="app/vid/images/error.png"></img>
- {{error}}
- </div>
-
- </div>
-
- <pre class="log">{{log}}</pre>
-
- <div class="buttonRow">
- <button data-tests-id="msoCommitDialogCloseButton" ngx-enabled="{{isCloseEnabled}}" att-button size="small"
- ng-click="close();">Close</button>
- </div>
-</div>
+<!--
+ ============LICENSE_START=======================================================
+ VID
+ ================================================================================
+ Copyright (C) 2017 - 2019 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=========================================================
+ -->
+
+<div ng-controller="msoCommitController" ng-show="isViewVisible" >
+<div ng-if="isViewVisible">
+ <div class="statusLine">
+ <img src="app/vid/images/spinner.gif"
+ ngx-visible="{{isSpinnerVisible}}"> </img> <label>Status:</label><span
+ class="status">{{status}}</span>
+ </div>
+
+ <div class="feedback">
+
+ <div progress-bar control="progressBarControl"
+ value="{{percentProgress}}" increases-only="true"
+ ngx-show="{{isProgressVisible}}"></div>
+
+ <div class="error" ng-show="!isProgressVisible">
+ <button class="btn-danger" att-button size="small" ng-click="showReportWindow()" ng-if="isShowErrorReport()">Create report</button>
+ <img src="app/vid/images/error.png"></img>
+ {{error}}
+ </div>
+
+ </div>
+
+ <pre class="log">{{log}}</pre>
+
+ <div class="buttonRow">
+ <button data-tests-id="msoCommitDialogCloseButton" ngx-enabled="{{isCloseEnabled}}" att-button size="small"
+ ng-click="close();">Close</button>
+ </div>
+</div>
</div> \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/VnfCommandTest.kt b/vid-app-common/src/test/java/org/onap/vid/job/command/VnfCommandTest.kt
index 660abe4d2..977966271 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/VnfCommandTest.kt
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/VnfCommandTest.kt
@@ -37,6 +37,7 @@ import org.onap.vid.services.AsyncInstantiationBusinessLogic
import org.onap.vid.testUtils.TestUtils
import org.onap.vid.testUtils.TestUtils.initMockitoMocks
import org.testng.annotations.BeforeMethod
+import org.testng.annotations.DataProvider
import org.testng.annotations.Test
import org.togglz.core.manager.FeatureManager
import org.mockito.Mockito.`when` as _when
@@ -65,8 +66,22 @@ class VnfCommandTest {
@Test(dataProvider = "trueAndFalse", dataProviderClass = TestUtils::class)
fun `childVfModuleWithVnfRegionAndTenant -- given vfmodule -- tenant and region are copied from vnf`(featureToggleOn: Boolean) {
+ runChildVfModuleWithVnfRegionAndTenant(featureToggleOn, Action.Create, featureToggleOn)
+ }
+
+ @DataProvider
+ fun allPossibleActions(): Array<Array<out Any?>> {
+ return Action.values().map { arrayOf(it) }.toTypedArray()
+ }
+
+ @Test(dataProvider = "allPossibleActions")
+ fun `childVfModuleWithVnfRegionAndTenant -- given vfmodule in different actions -- only "action_Create" copies tenant and region from vnf`(vfModuleAction: Action) {
+ runChildVfModuleWithVnfRegionAndTenant(true, vfModuleAction, vfModuleAction == Action.Create)
+ }
+
+ private fun runChildVfModuleWithVnfRegionAndTenant(featureToggleOn: Boolean, vfModuleAction: Action, isCopyVnfToVfmoduleExpected: Boolean) {
- val vfModule = FakeResourceCreator.createVfModule(Action.Create)
+ val vfModule = FakeResourceCreator.createVfModule(vfModuleAction)
.cloneWith("vfmodule-lcp-cloud-region-id", "vfmodule-tenant-id")
_when(featureManager.isActive(Features.FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF)).thenReturn(featureToggleOn)
@@ -77,7 +92,7 @@ class VnfCommandTest {
vnfCommand.init(jobSharedData, mapOf())
- val expectedSource = if (featureToggleOn) "vnf" else "vfmodule"
+ val expectedSource = if (isCopyVnfToVfmoduleExpected) "vnf" else "vfmodule"
assertThat(vnfCommand.childVfModuleWithVnfRegionAndTenant(vfModule),
allOf(
diff --git a/vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java b/vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java
index 5f4fc7861..ed7f82a45 100644
--- a/vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java
@@ -201,9 +201,7 @@ public class RoleProviderTest {
private String owningEntityId() {
- // while translateOwningEntityNameToOwningEntityId does nothing, no translation happens.
- // this will be changed later.
- return SAMPLE_SUBSCRIBER;
+ return EXISTING_OWNING_ENTITY_ID;
}
private void setSubscribers() {
diff --git a/vid-automation/conf/users b/vid-automation/conf/users
index 648b661a5..b4b632748 100644
--- a/vid-automation/conf/users
+++ b/vid-automation/conf/users
@@ -14,7 +14,7 @@
"password": "1"
},
"roles": [
- "d61e6f2d-12fa-4cc2-91df-7c244011d6fc___LOB", "Melissa___LOB", "aaa1___LOB",
+ "WayneHolland___LOB", "Melissa___LOB", "aaa1___LOB",
"SILVIA ROBBINS___TYLER SILVIA", "SILVIA ROBBINS___DARREN MCGEE", "CAR_2020_ER___DARREN MCGEE", "CAR_2020_ER___MSO-dev-service-type", "CAR_2020_ER___TYLER SILVIA","READ___LOGS___PERMITTED","Emanuel___mySubType", "global-customer-id___service-instance-type"
],
"subscriberNames": ["SILVIA ROBBINS", "CAR_2020_ER", "Emanuel", "global-customer-id"],
@@ -27,7 +27,7 @@
"password": "3"
},
"roles": [
- "d61e6f2d-12fa-4cc2-91df-7c244011d6fc___LOB", "Melissa___LOB", "aaa1___LOB",
+ "WayneHolland___LOB", "Melissa___LOB", "aaa1___LOB",
"Emanuel___Emanuel"
],
"subscriberNames": ["Emanuel"],
@@ -40,7 +40,7 @@
"password": "667"
},
"roles": [
- "d61e6f2d-12fa-4cc2-91df-7c244011d6fc___LOB", "Melissa___LOB", "aaa1___LOB",
+ "WayneHolland___LOB", "Melissa___LOB", "aaa1___LOB",
"CRAIG/ROBERTS___AIM Transport"
],
"subscriberNames": ["CRAIG/ROBERTS"],
@@ -53,7 +53,7 @@
"password": "4"
},
"roles": [
- "d61e6f2d-12fa-4cc2-91df-7c244011d6fc___LOB", "Melissa___LOB", "aaa1___LOB",
+ "WayneHolland___LOB", "Melissa___LOB", "aaa1___LOB",
"Emanuel___vWINIFRED", "Emanuel___vRichardson"
],
"subscriberNames": ["Emanuel"],
@@ -66,10 +66,9 @@
"password": "822"
},
"roles": [
- "d61e6f2d-12fa-4cc2-91df-7c244011d6fc___LOB", "Melissa___LOB", "aaa1___LOB",
+ "WayneHolland___LOB",
"JULIO ERICKSON___Emanuel",
"JULIO ERICKSON___vRichardson"
-
],
"subscriberNames": ["JULIO ERICKSON"],
"serviceTypes": ["Emanuel", "vRichardson"],
@@ -81,7 +80,7 @@
"password": "312"
},
"roles": [
- "d61e6f2d-12fa-4cc2-91df-7c244011d6fc___LOB", "Melissa___LOB", "aaa1___LOB",
+ "WayneHolland___LOB", "Melissa___LOB", "aaa1___LOB",
"Emanuel___vRichardson"
],
"subscriberNames": ["Emanuel"],
@@ -94,7 +93,7 @@
"password": "312"
},
"roles": [
- "d61e6f2d-12fa-4cc2-91df-7c244011d6fc___LOB", "Melissa___LOB", "aaa1___LOB",
+ "WayneHolland___LOB", "Melissa___LOB", "aaa1___LOB",
"Emanuel___vWINIFRED___test-hvf6-09"
],
"subscriberNames": ["Emanuel"],
diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/UserCredentials.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/UserCredentials.java
index 5dec39541..88b2a280d 100644
--- a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/UserCredentials.java
+++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/UserCredentials.java
@@ -42,6 +42,10 @@ public class UserCredentials extends User {
this.copyData(user);
}
+ public UserCredentials(vid.automation.test.model.User user) {
+ this(user.credentials.userId, user.credentials.password, "", "", "");
+ }
+
public String getPassword() {
return password;
}
diff --git a/vid-automation/src/main/java/vid/automation/test/Constants.java b/vid-automation/src/main/java/vid/automation/test/Constants.java
index 7256f0a2e..e639ee0a2 100644
--- a/vid-automation/src/main/java/vid/automation/test/Constants.java
+++ b/vid-automation/src/main/java/vid/automation/test/Constants.java
@@ -516,7 +516,7 @@ public class Constants {
public static final String EMANUEL_EMANUEL = "emanuelEmanuel";
public static final String CRAIG_ROBERTS_AIM_TRANSPORT = "FIREWALL_AIM_Trans";
public static final String EMANUEL_vWINIFRED = "emanuelvWINIFRED";
- public static final String SUPRE_USER = "su";
+ public static final String PORFIRIO_GERHARDT = "Porfirio Gerhardt";
}
public class RegisterToSimulator {
diff --git a/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java b/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java
index 3caf59ef6..5590c0acd 100644
--- a/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java
+++ b/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java
@@ -19,6 +19,7 @@ import static vid.automation.test.infra.Features.FLAG_1908_INFRASTRUCTURE_VPN;
import static vid.automation.test.infra.Features.FLAG_1908_MACRO_NOT_TRANSPORT_NEW_VIEW_EDIT;
import static vid.automation.test.infra.Features.FLAG_1908_TRANSPORT_SERVICE_NEW_INSTANTIATION_UI;
import static vid.automation.test.infra.Features.FLAG_2002_ANY_ALACARTE_BESIDES_EXCLUDED_NEW_INSTANTIATION_UI;
+import static vid.automation.test.infra.Features.FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF;
import static vid.automation.test.infra.Features.FLAG_5G_IN_NEW_INSTANTIATION_UI;
import static vid.automation.test.infra.Features.FLAG_ENABLE_WEBPACK_MODERN_UI;
import static vid.automation.test.infra.ModelInfo.aLaCarteNetworkProvider5G;
@@ -1329,7 +1330,7 @@ public class NewServiceInstanceTest extends ModernUITestBase {
Assert.assertEquals(Get.byTestId("model-item-value-serviceName").getText(), serviceInstanceName, "Service name should be shown in vf module");
}
- if (serviceData.isALaCarte) {
+ if (serviceData.isALaCarte && !FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF.isActive()) {
String lcpRegion = "hvf6";
Wait.waitByClassAndText("lcpRegionOption", lcpRegion, 30);
viewEditPage.selectLcpRegion(lcpRegion, AIC);
diff --git a/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java
index 54300c22a..958ba87d1 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java
@@ -907,7 +907,7 @@ public class AaiApiTest extends BaseApiAaiTest {
public void searchServiceInstancesBySubscriber_serviceInstanceOfAnotherSubscriber_authIsFollowingFeatureToggle() {
String craigRobertsSubscriberId = "31739f3e-526b-11e6-beb8-9e71128cae77";
String aServiceOwningEntityId = "f160c875-ddd1-4ef5-84d8-d098784daa3a";
- String currentUserAuthorizedOwningEntityId = "SILVIA ROBBINS"; // this will need to change with translateOwningEntityNameToOwningEntityId
+ String currentUserAuthorizedOwningEntityId = "d61e6f2d-12fa-4cc2-91df-7c244011d6fc";
SimulatorApi.registerExpectation(GET_SUBSCRIBERS_FOR_CUSTOMER_CRAIG_ROBERTS,
ImmutableMap.of(aServiceOwningEntityId, currentUserAuthorizedOwningEntityId), CLEAR_THEN_SET);
diff --git a/vid-automation/src/test/java/org/onap/vid/api/BaseApiAaiTest.java b/vid-automation/src/test/java/org/onap/vid/api/BaseApiAaiTest.java
index 4ac38a0e7..32586afac 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/BaseApiAaiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/BaseApiAaiTest.java
@@ -1,6 +1,15 @@
package org.onap.vid.api;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonStringEquals;
+import static org.hamcrest.Matchers.either;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import static vid.automation.test.services.SimulatorApi.registerExpectation;
+
import com.google.common.collect.ImmutableMap;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import org.springframework.http.HttpMethod;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
@@ -8,23 +17,13 @@ import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.client.HttpStatusCodeException;
import org.testng.annotations.BeforeClass;
+import vid.automation.test.services.CategoryParamsService;
import vid.automation.test.services.SimulatorApi;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import static net.javacrumbs.jsonunit.JsonMatchers.jsonStringEquals;
-import static org.hamcrest.Matchers.either;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-import static vid.automation.test.services.SimulatorApi.registerExpectation;
-
-/**
- * Created by Oren on 11/1/17.
- */
public class BaseApiAaiTest extends BaseApiTest {
+ protected final CategoryParamsService categoryParamsService = new CategoryParamsService();
+
@BeforeClass
public void login() {
super.login();
diff --git a/vid-automation/src/test/java/org/onap/vid/api/PropertyControllerApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/PropertyControllerApiTest.java
new file mode 100644
index 000000000..b12adbe46
--- /dev/null
+++ b/vid-automation/src/test/java/org/onap/vid/api/PropertyControllerApiTest.java
@@ -0,0 +1,62 @@
+package org.onap.vid.api;
+
+import static java.util.stream.Collectors.toList;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonPartEquals;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static vid.automation.test.infra.Features.FLAG_2006_LIMIT_OWNING_ENTITY_SELECTION_BY_ROLES;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.ImmutableMap;
+import java.util.List;
+import java.util.function.Function;
+import java.util.stream.Stream;
+import org.onap.sdc.ci.tests.datatypes.UserCredentials;
+import org.testng.annotations.Test;
+import vid.automation.test.Constants.Users;
+import vid.automation.test.infra.FeatureTogglingTest;
+
+public class PropertyControllerApiTest extends BaseApiTest {
+
+ private final List<Object> allOwningEntities = toOwningEntitiesList(Stream.of("aaa1", "Melissa", "WayneHolland"));
+
+ private final List<Object> singleOwningEntity = toOwningEntitiesList(Stream.of("WayneHolland"));
+
+ @Test
+ public void categoryParameter_whenUserFullyAllowed_allOwningEntitiesRetrieved() {
+ categoryParameters_loginAndAssertOwningEntities(Users.SILVIA_ROBBINS_TYLER_SILVIA, allOwningEntities);
+ }
+
+ @Test
+ @FeatureTogglingTest(FLAG_2006_LIMIT_OWNING_ENTITY_SELECTION_BY_ROLES)
+ public void categoryParameter_whenUserNotFullyAllowed_onlySomeOwningEntitiesRetrieved() {
+ categoryParameters_loginAndAssertOwningEntities(Users.PORFIRIO_GERHARDT, singleOwningEntity);
+ }
+
+ @Test
+ @FeatureTogglingTest(value = FLAG_2006_LIMIT_OWNING_ENTITY_SELECTION_BY_ROLES, flagActive = false)
+ public void categoryParameter_whenUserNotFullyAllowed_stillAllOwningEntitiesRetrieved() {
+ categoryParameters_loginAndAssertOwningEntities(Users.PORFIRIO_GERHARDT, allOwningEntities);
+ }
+
+
+
+ public void categoryParameters_loginAndAssertOwningEntities(String user, List<Object> singleOwningEntities) {
+ login(new UserCredentials(usersService.getUser(user)));
+
+ String url = uri.toASCIIString() + "/category_parameter?familyName=PARAMETER_STANDARDIZATION";
+
+ assertThat(restTemplate.getForObject(url, JsonNode.class),
+ jsonPartEquals("categoryParameters.owningEntity", singleOwningEntities));
+ }
+
+ private List<Object> toOwningEntitiesList(Stream<String> owningEntitiesNames) {
+ return owningEntitiesNames.map(it -> ImmutableMap.of(
+ "name", it,
+ "id", expectedIdByName.apply(it))
+ ).collect(toList());
+ }
+
+ static private final Function<String, String> expectedIdByName = it ->
+ "WayneHolland".equals(it) ? "d61e6f2d-12fa-4cc2-91df-7c244011d6fc" : it;
+
+}