2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.vid.model.serviceInstantiation;
23 import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
24 import static org.hamcrest.CoreMatchers.equalTo;
25 import static org.hamcrest.MatcherAssert.assertThat;
26 import static org.hamcrest.beans.HasPropertyWithValue.hasProperty;
27 import static org.hamcrest.core.AllOf.allOf;
28 import static org.onap.vid.testUtils.TestUtils.setStringsInStringProperties;
30 import org.onap.vid.mso.model.ModelInfo;
31 import org.testng.annotations.Test;
33 public class VfModuleTest {
36 public void cloneWithLcpCloudRegionIdAndTenantId() {
37 String targetLcpCloudRegionId = "dictated lcpCloudRegionId";
38 String targetTenantId = "dictated tenantId";
40 VfModule originVfModule = createVfModule();
42 assertThat(originVfModule.cloneWith(targetLcpCloudRegionId, targetTenantId), allOf(
43 hasProperty("lcpCloudRegionId", equalTo(targetLcpCloudRegionId)),
44 hasProperty("tenantId", equalTo(targetTenantId)),
45 jsonEquals(originVfModule).whenIgnoringPaths("lcpCloudRegionId", "tenantId")
48 // verify vfModule did not mutate
49 assertThat(originVfModule, jsonEquals(createVfModule()));
52 private VfModule createVfModule() {
53 VfModule vfModule = new VfModule(
54 setStringsInStringProperties(new ModelInfo()),
55 null, null, null, null, null,
56 null, null, null, true, true,
57 null, null, true, null, true,
60 return setStringsInStringProperties(vfModule);