2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package jtest.org.onap.ccsdk.sli.adaptors.ra;
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.onap.ccsdk.sli.adaptors.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;
38 @RunWith(SpringJUnit4ClassRunner.class)
39 @ContextConfiguration(locations = { "classpath:test-context.xml" })
40 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
41 public class TestQuery {
43 private static final Logger log = LoggerFactory.getLogger(TestQuery.class);
45 @Autowired(required = true)
46 private ResourceAllocator resourceAllocator;
48 @Autowired(required = true)
49 private DataSetup dataSetup;
52 public void test001() throws Exception {
54 log.info("============== query " + t + " ================================");
55 log.info("=== Test reading assigned resources (subinterface-id, vlan-id-inner)");
57 String service1 = "ICOREPVC" + t + "-1";
60 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
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");
72 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
74 Assert.assertTrue(st == QueryStatus.SUCCESS);
75 Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "VPE-Cust", "Pending", 1, 300000));
77 st = resourceAllocator.query("NetworkCapacity", true, null, service1, "end-point", null, ctx);
79 Assert.assertTrue(st == QueryStatus.SUCCESS);
80 Assert.assertEquals(ctx.getAttribute("end-point.subinterface-id"), "100");
81 Assert.assertEquals(ctx.getAttribute("end-point.vlan-id-inner"), "2");
82 Assert.assertEquals(ctx.getAttribute("end-point.vpe-name"), "mtanjrsv126");
83 Assert.assertEquals(ctx.getAttribute("end-point.affinity-link"), "1");