* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
* =============================================================================
* 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.
- *
+ *
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
public class TestAAIResourceNode {
-
+
//Removed for ONAP integration
private static final EELFLogger log = EELFManager.getInstance().getLogger(TestAAIResourceNode.class);
-
+
@Test
public void sortVServer() throws Exception{
-
+
//log.info("Test");
-
+
ArrayList<Map<String, String>> vservers = new ArrayList<Map<String, String>>();
HashMap<String, String> vserverMap = new HashMap<String, String>();
vserverMap.put("vserver-id", "vserverId9");
return o1.get("vserver-name").compareTo(o2.get("vserver-name"));
}
});
-
+
SvcLogicContext ctx = new SvcLogicContext();
AAIResourceNode aai = new AAIResourceNode();
aai.populateContext(vservers, ctx, "vserver.");
@Test
public void testAllVServer() throws Exception{
-
+
MockAAIResourceNode mrn = new MockAAIResourceNode();
SvcLogicContext ctx = new SvcLogicContext();
populateAllVServerInfo(ctx, "tmp.vnfInfo");
assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-name"), "vserverName2");
assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vf-module-id"), "vfModule2");
//assertNull(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-name"));
-
+
// VM2
assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vserver-id"), "ibcxvm0001id");
assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].tenant-id"), "tenantid1");
ctx.setAttribute(prefix+ ".vm[1].tenant-id", "tenantid1");
ctx.setAttribute(prefix+ ".vm[1].cloud-owner", "cloudOwner1");
ctx.setAttribute(prefix+ ".vm[1].cloud-region-id", "cloudRegionId1");
-
+
}
-
+
public static class MockAAIResourceNode extends AAIResourceNode {
private static final EELFLogger log = EELFManager.getInstance().getLogger(MockAAIResourceNode.class);
private AAIClient aaiClient;
-
+
public AaiService getAaiService() {
log.info("In MockAAI");
return new MockAaiService(aaiClient);
@Test
public void testPopulateContext() throws Exception{
-
+
ArrayList<Map<String, String>> vservers = new ArrayList<Map<String, String>>();
HashMap<String, String> vserverMap = new HashMap<String, String>();
vserverMap = new HashMap<String, String>();
assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-id"), "vserverId1");
assertEquals(ctx.getAttribute("vm-name"), "vServerName3");
}
-
+
@Test
public final void testGetVnfInfo() {
SvcLogicContext ctx = new SvcLogicContext();
} catch (SvcLogicException e) {
e.printStackTrace();
}
-
+
}
@Test
public final void testaddVnfcs()
} catch (SvcLogicException e) {
e.printStackTrace();
}
-
+
}
@Test
public final void testupdateVnfAndVServerStatus(){
SvcLogicContext ctx = new SvcLogicContext();
AAIResourceNode aai = new AAIResourceNode();
Map<String, String> inParams =new HashMap<String, String>();
-
+
inParams.put("responsePrefix", "tmp.vnfInfo");
try {
aai.updateVnfAndVServerStatus(inParams, ctx);
e.printStackTrace();
}
}
+
+ @Test
+ public void testgetVfModduleModelInfo() throws Exception{
+ SvcLogicContext ctx = new SvcLogicContext();
+ AAIResourceNode aai = new AAIResourceNode();
+ AAIClient aaic=null;
+ MockAaiService aaiService=new MockAaiService(aaic);
+ Map<String, String> inParams =new HashMap<String, String>();
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+ aai.processForVfModuleModelInfo(aaiService,inParams, ctx);
+ assertEquals(ctx.getAttribute("template-model-id"),"model0001");
+
+ }
+ @Test
+ public final void testSetVmParams() {
+ SvcLogicContext ctx = new SvcLogicContext();
+ String vServerId = "vserver02";
+ ctx.setAttribute("tmp.vnfInfo.vm-count","3");
+ ctx.setAttribute("tmp.vnfInfo.vm[0].vserver-id","vserver01");
+ ctx.setAttribute("tmp.vnfInfo.vm[1].vserver-id","vserver02");
+ ctx.setAttribute("tmp.vnfInfo.vm[1].tenant-id","ten01");
+ ctx.setAttribute("tmp.vnfInfo.vm[1].cloud-region-id","cr01");
+ ctx.setAttribute("tmp.vnfInfo.vm[1].cloud-owner","co01");
+ AAIResourceNode aairn= new AAIResourceNode();
+ Map <String, String> params = aairn.setVmParams(ctx, vServerId);
+ assertNotNull(params);
+ }
+ @Test
+ public final void testGetVnfcInformationForVserver() throws Exception{
+ MockAAIResourceNode aairn = new MockAAIResourceNode();
+ SvcLogicContext ctx = new SvcLogicContext();
+ SvcLogicContext newVnfcCtx = new SvcLogicContext();
+ Map<String,String> inParams = new HashMap<String, String>();
+ Map<String,String> vnfcParams = new HashMap<String, String>();
+ String responsePrefix="test.";
+ inParams.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX, "test");
+ vnfcParams.put("vnfcName", "vnfcName2");
+ aairn.getVnfcInformationForVserver(vnfcParams, newVnfcCtx, inParams, ctx, aairn.getAaiService(), responsePrefix);
+ assertEquals(ctx.getAttribute("test.vm.vnfc.vnfc-name"),"vnfcName2");
+ assertEquals(ctx.getAttribute("test.vm.vnfc.vnfc-type"), "vnfcType2");
+ assertEquals(ctx.getAttribute("test.vm.vnfc.vnfc-function-code"), "vnfcFuncCode2");
+ assertEquals(ctx.getAttribute("test.vm.vnfc.vnfc-group-notation"), "vnfcGrpNot2");
+ }
}