[CCSDK-6] Populate seed code
[ccsdk/sli/adaptors.git] / resource-assignment / provider / src / test / java / jtest / org / openecomp / sdnc / ra / TestReserve2.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2017 ONAP Intellectual Property. All rights
6  *                                              reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package jtest.org.openecomp.sdnc.ra;
23
24 import org.junit.Assert;
25 import org.junit.FixMethodOrder;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.junit.runners.MethodSorters;
29 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
30 import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
31 import org.openecomp.sdnc.ra.ResourceAllocator;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34 import org.springframework.beans.factory.annotation.Autowired;
35 import org.springframework.test.context.ContextConfiguration;
36 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
37
38 @RunWith(SpringJUnit4ClassRunner.class)
39 @ContextConfiguration(locations = { "classpath:test-context.xml" })
40 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
41 public class TestReserve2 {
42
43         private static final Logger log = LoggerFactory.getLogger(TestReserve2.class);
44
45         @Autowired(required = true)
46         private ResourceAllocator resourceAllocator;
47
48         @Autowired(required = true)
49         private DataSetup dataSetup;
50
51         @Test
52         public void test001() throws Exception {
53                 String t = "001";
54                 log.info("============== reserve " + t + " ================================");
55                 log.info("=== Test successful response - new start - all resources available");
56
57                 String service1 = "ICOREPVC" + t + "-1";
58
59                 dataSetup.cleanup();
60                 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
61
62                 SvcLogicContext ctx = new SvcLogicContext();
63                 ctx.setAttribute("tmp.resource-allocator.request-type", "New");
64                 ctx.setAttribute("tmp.resource-allocator.service-model", "L3AVPN-EVC");
65                 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
66                 ctx.setAttribute("tmp.resource-allocator.speed", "300");
67                 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
68                 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
69                 ctx.setAttribute("tmp.resource-allocator.vpn-id", "123");
70                 ctx.setAttribute("tmp.resource-allocator.vrf-required", "false");
71
72                 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
73
74                 Assert.assertTrue(st == QueryStatus.SUCCESS);
75                 Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "VPE-Cust", "Pending", 1, 300000));
76         }
77 }