diff options
author | 2017-06-07 23:53:59 -0400 | |
---|---|---|
committer | 2017-06-07 23:56:55 -0400 | |
commit | 8ed8d2f6cacc55263470af007d7ecec23666bbfc (patch) | |
tree | 99387e19e54acb770ec2c798b75fb0e396354f63 /aai-resources/src/test/java | |
parent | 57c589b4026f09daf02cf6d3d73b8ce672de1b0b (diff) |
[AAI-ONAP] Get latest changes from develop sync
Change-Id: I2bf80b4af4e3db84cf61fd98bc0ad6efb5e0551b
Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-resources/src/test/java')
4 files changed, 0 insertions, 651 deletions
diff --git a/aai-resources/src/test/java/org/openecomp/aai/dbgen/DbMethTest.java b/aai-resources/src/test/java/org/openecomp/aai/dbgen/DbMethTest.java deleted file mode 100644 index 420daa7..0000000 --- a/aai-resources/src/test/java/org/openecomp/aai/dbgen/DbMethTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * org.openecomp.aai - * ================================================================================ - * Copyright (C) 2017 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========================================================= - */ - -package org.openecomp.aai.dbgen; - -import static org.junit.Assert.assertEquals; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import org.openecomp.aai.exceptions.AAIException; - -public class DbMethTest { - - @Rule - public ExpectedException expectedEx = ExpectedException.none(); - - @Test - public void testGetEdgeTagPropPutHash() throws AAIException { - Map<String, String> expectedMap = new HashMap<>(); - expectedMap.put("usesResource", "false"); - expectedMap.put("isParent", "false"); - expectedMap.put("SVC-INFRA", "true"); - expectedMap.put("hasDelTarget", "false"); - - assertEquals(expectedMap, DbMeth.getEdgeTagPropPutHash("", "", "pserver|complex").get("locatedIn").getEdgeProperties()); - } - - @Test - public void testGetEdgeTagPropPutHash2() throws AAIException { - Map<String, String> expectedMap = new HashMap<>(); - expectedMap.put("usesResource", "false"); - expectedMap.put("isParent", "false"); - expectedMap.put("SVC-INFRA", "false"); - expectedMap.put("hasDelTarget", "false"); - - assertEquals(expectedMap, DbMeth.getEdgeTagPropPutHash("", "", "service-instance|allotted-resource").get("uses").getEdgeProperties()); - } - - @Test - public void testGetEdgeTagPropPutHash3() throws AAIException { - Map<String, String> expectedMap = new HashMap<>(); - expectedMap.put("usesResource", "false"); - expectedMap.put("isParent", "true"); - expectedMap.put("SVC-INFRA", "false"); - expectedMap.put("hasDelTarget", "false"); - - assertEquals(expectedMap, DbMeth.getEdgeTagPropPutHash("", "", "service-instance|allotted-resource").get("has").getEdgeProperties()); - } - - @Ignore - @Test - public void getGetEdgeTagPropPutHashThrowsExceptionWhenNoRuleExists() throws Exception { - expectedEx.expect(AAIException.class); - expectedEx.expectMessage("AAI_6120"); - DbMeth.getEdgeTagPropPutHash("", "", "complex|pserver"); - } - - @Ignore - @Test - public void getGetEdgeTagPropPutHashThrowsExceptionWhenNoRuleExists1() throws Exception { - expectedEx.expect(AAIException.class); - expectedEx.expectMessage("AAI_6120"); - DbMeth.getEdgeTagPropPutHash("", "", "complex"); - } - - -} diff --git a/aai-resources/src/test/java/org/openecomp/aai/dbgen/DbRunTest.java b/aai-resources/src/test/java/org/openecomp/aai/dbgen/DbRunTest.java deleted file mode 100644 index cef8019..0000000 --- a/aai-resources/src/test/java/org/openecomp/aai/dbgen/DbRunTest.java +++ /dev/null @@ -1,341 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * org.openecomp.aai - * ================================================================================ - * Copyright (C) 2017 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========================================================= - */ - -package org.openecomp.aai.dbgen; - -import java.nio.file.attribute.FileTime; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.HashMap; -import java.util.Iterator; - -import org.openecomp.aai.dbmap.AAIGraph; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.logging.ErrorLogHelper; -import org.openecomp.aai.util.AAIConfig; -import org.openecomp.aai.util.DbTestGetFileTime; -import com.thinkaurelius.titan.core.TitanTransaction; -import com.thinkaurelius.titan.core.TitanVertex; - -public class DbRunTest { - - /** - * The main method. - * - * @param args the arguments - */ - public static void main(String[] args) { - - String testid = "NA"; - TitanTransaction graph = null; - - boolean runIt = false; - try { - AAIConfig.init(); - ErrorLogHelper.loadProperties(); - if (args.length > 0) { - System.out.println( "DbRunTest called with " + args.length + " arguments"); - - - } else { - System.out.print("usage: DbRunTest <testid> <processDelay milliseconds> <processName> <loopcnt>\n"); - return; - } - } catch (AAIException e) { - System.out.print("Threw a AAIException -- \n"); - System.out.println(e.getMessage()); - } catch (Exception ex) { - System.out.print("Threw a regular ole Exception \n"); - System.out.println(ex.getMessage()); - } - - - - //System.out.println("skipping Titan graph for now..."); - //TitanGraph graph = null; - - - String processName = "NA"; - if ( args.length > 1 ) - processName = args[2].trim(); - - try { - System.out.println(processName + " ---- NOTE --- about to open graph (takes a little while)--------\n"); - - graph = AAIGraph.getInstance().getGraph().newTransaction(); - - if( graph == null ){ - System.out.println(processName + "Error creating Titan graph. \n"); - return; - } - } catch( Exception ex ){ - System.out.println( processName + " ERROR: caught this exception: " + ex ); - return; - } - - testid = args[0].trim(); - runIt = true; - Integer processDelay = new Integer(args[1].trim() ); // delay of write - Integer loopCnt = new Integer(args[3].trim() ); // delay of write - - String path = "NA"; - try { - - path = AAIConfig.get("dbruntest.path" ); // uses file create-timestamp - Integer writeDelay = new Integer(AAIConfig.get("dbruntest.delay" )); // delay seconds from create-timestamp - Integer loopDelay = new Integer(AAIConfig.get("dbruntest.loopdelay" )); // delay seconds from create-timestamp for next loop - - DbTestGetFileTime getFileTime = new DbTestGetFileTime(); - FileTime fileTime = getFileTime.createFileReturnTime( path ); - long createMillis = fileTime.toMillis(); - System.out.println(processName + " delays to use " + writeDelay + " processDelay " + processDelay); - System.out.println(processName + " test control file " + path + " creation time :" - + new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:SSS") - .format(fileTime.toMillis())); - - long delayMillis = writeDelay * 60 * 1000; - long loopMillis = loopDelay * 60 * 1000; - - int loops = loopCnt.intValue(); - - long sleepTime; - for ( int i = 0; i < loops; ++i ) { - - if ( i > 0 ) - delayMillis = loopMillis * i; // to find the time the write will be done - delayMillis += processDelay.intValue(); - - System.out.println(processName + " test control file " + path + " write time :" - + new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:SSS") - .format(createMillis + delayMillis)); - - Calendar now = Calendar.getInstance(); - long myMillis = now.getTimeInMillis(); - System.out.println(processName + " test control file " + path + " current time :" - + new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:SSS") - .format(myMillis)); - // total sleep based on current time, time file was created, and any delay per process - - if ( i == 0 ) - sleepTime = createMillis + delayMillis - myMillis; // + processDelay.intValue() - else - sleepTime = createMillis + ( loopMillis * i ) - myMillis; - sleepTime += processDelay.intValue(); - System.out.println(processName + " sleep " + sleepTime + " current time :" - + new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:SSS") - .format(myMillis)); - Thread.sleep(sleepTime); - - System.out.println(processName + " out of sleep for loop count " + i); - - if (runIt) { - // include loop in unique-id string - runMultiLevelTest(graph, testid + i + "-", processName); - } - - } // end loop - - - } catch ( Exception io ) { - System.out.println( processName + " Exception getting creation time " + path + " message " + io.getMessage()); - io.printStackTrace(); - } - - - - - - if( graph != null && graph.isOpen() ){ - System.out.println(processName + "About to call graph.shutdown()"); - graph.tx().close(); - System.out.println(processName + " -- AFTER call graph.shutdown()"); - } - - System.out.println(processName + " -- Boom!"); - System.exit(0); - - }// end of main() - - - - /** - * Run multi level test. - * - * @param graph the graph - * @param testIdentifier the test identifier - * @param processName the process name - */ - private static void runMultiLevelTest(TitanTransaction graph, String testIdentifier, String processName) { - - try { - String useRollback = AAIConfig.get("dbruntest.rollback"); - - // l3-interface-ipv6-address-list -> vlan -> l-interface -> vnic -> vserver -> tenant - - HashMap<String, Object> propHash7 = new HashMap<String, Object>(); - propHash7.put("tenant-name", testIdentifier + "tenantName"); - propHash7.put("tenant-id", testIdentifier + "tenantId"); - TitanVertex tenantVtx = DbMeth.persistAaiNode("junkTransId", - "testApp", graph, "tenant", propHash7, true, null); - - - HashMap<String, Object> propHash8 = new HashMap<String, Object>(); - propHash8.put("vserver-selflink", testIdentifier + "vserverSelfThing"); - propHash8.put("vserver-id", testIdentifier + "vserverID"); - propHash8.put("vserver-name", testIdentifier + "vserverName"); - propHash8.put("vserver-name2", testIdentifier + "vserverName2"); - TitanVertex vserverVtx = DbMeth.persistAaiNode("junkTransId", - "testApp", graph, "vserver", propHash8, true, tenantVtx); - - HashMap<String, Object> propHash10 = new HashMap<String, Object>(); - propHash10.put("interface-name", testIdentifier + "logIntfOnVpe"); - TitanVertex logIntfVtx = DbMeth.persistAaiNode("junkTransId", - "testApp", graph, "l-interface", propHash10, true, vserverVtx); - - HashMap<String, Object> propHash11 = new HashMap<String, Object>(); - propHash11.put("vlan-interface", testIdentifier + "vlanIntf"); - TitanVertex vlanVtx = DbMeth.persistAaiNode("junkTransId", - "testApp", graph, "vlan", propHash11, true, logIntfVtx); - - HashMap<String, Object> propHash12 = new HashMap<String, Object>(); - propHash12.put("l3-interface-ipv6-address", testIdentifier + "v6 pool"); - TitanVertex l3PoolVtx = DbMeth.persistAaiNode("junkTransId", - "testApp", graph, "l3-interface-ipv6-address-list", propHash12, true, vlanVtx); - - System.out.println(processName + " ---- did the persist on all the nodes -- "); - - DbMeth.persistAaiEdge("junkTransId", "junkApp", graph, vserverVtx, tenantVtx); - DbMeth.persistAaiEdge("junkTransId", "junkApp", graph, logIntfVtx, vserverVtx); - DbMeth.persistAaiEdge("junkTransId", "junkApp", graph, vlanVtx, logIntfVtx); - DbMeth.persistAaiEdge("junkTransId", "junkApp", graph, l3PoolVtx, vlanVtx); - - System.out.println(processName + " ---- persisted all the edges -- "); - - if ( useRollback.toUpperCase().equals("Y")) { - System.out.print(processName + " using rollback for unittesting\n"); - if (graph != null) { - graph.tx().rollback(); - } - } else { - graph.tx().commit(); - System.out.println(processName + " ---- Ran graph.commit() -- "); - } - HashMap<String, Object> propHash0 = new HashMap<String, Object>(); - propHash0.put("l3-interface-ipv6-address-list.l3-interface-ipv6-address", testIdentifier + "v6 pool"); - propHash0.put("tenant.tenant-name", testIdentifier + "tenantName"); - propHash0.put("tenant.tenant-id", testIdentifier + "tenantId"); - propHash0.put("vserver.vserver-selflink", testIdentifier + "vserverSelfThing"); - propHash0.put("vserver.vserver-id", testIdentifier + "vserverID"); - propHash0.put("vserver.vserver-name", testIdentifier + "vserverName"); - propHash0.put("vserver.vserver-name2", testIdentifier + "vserverName2"); - propHash0.put("l-interface.interface-name", testIdentifier + "logIntfOnVpe"); - propHash0.put("vlan.vlan-interface", testIdentifier + "vlanIntf"); - - - System.out.println(processName + " ---- First try the getUniqueNodeWithDepParams trail: "); - - TitanVertex poolV = DbMeth.getUniqueNodeWithDepParams("junkTransId", "junkAppId", graph, "l3-interface-ipv6-address-list", propHash0, null); - - ArrayList <String> retArr = DbMeth.showPropertiesForNode("junkTransId", "junkFromAppId", poolV); - for( String info : retArr ){ System.out.println(info); } - -/* - * RelationshipUtils replaced with RelationshipGraph - * System.out.println(processName + " ---- Next try the figureRelData trail: "); - List <RelationshipData> relDatList = RelationshipUtils.figureRelData("junkTransId", "junkAppId", graph, poolV, ""); - System.out.println(processName + " ---- Looks like it worked ----------"); - Iterator<RelationshipData> iterDat = relDatList.iterator(); - while (iterDat.hasNext()) { - RelationshipData relDat = iterDat.next(); - System.out.println(processName + " relData: key = [" - + relDat.getRelationshipKey() + "], val = [" - + relDat.getRelationshipValue() + "]"); - }*/ - - - HashMap<String, Object> propHash = new HashMap<String, Object>(); - ArrayList<TitanVertex> vertList; - - propHash.put("tenant-id", testIdentifier + "tenantId"); - vertList = DbMeth.getNodes("junkTransId", - "testApp", graph, "tenant", propHash, false, null, true); - - Iterator<TitanVertex> iter = vertList.iterator(); - - int vertexCnt = 0; - while( iter.hasNext() ) { - ++vertexCnt; - TitanVertex tvx = iter.next(); - System.out.println(processName + " Found tenant " + vertexCnt ); - DbMeth.showPropertiesForNode( "junkId", "junkApp", tvx ); - } - if ( vertexCnt == 0 ) - System.out.println(processName + " no tenant found" ); - - propHash = new HashMap<String, Object>(); - - propHash.put("vserver-id", testIdentifier + "vserverID"); - vertList = DbMeth.getNodes("junkTransId", - "testApp", graph, "vserver", propHash, false, null, true); - - iter = vertList.iterator(); - - vertexCnt = 0; - while( iter.hasNext() ) { - ++vertexCnt; - TitanVertex tvx = iter.next(); - System.out.println(processName + " Found vserver " + vertexCnt ); - DbMeth.showPropertiesForNode( "junkId", "junkApp", tvx ); - } - if ( vertexCnt == 0 ) - System.out.println(processName + " no vserver found" ); - - if ( useRollback.toUpperCase().equals("Y")) { - System.out.print(processName + " using rollback for unittesting\n"); - if (graph != null) { - graph.tx().rollback(); - } - } - - } - catch (AAIException e) { - System.out.print(processName + " Threw an AAIException -- calling graph.rollback()\n"); - System.out.println("exMsg = [" + e.getMessage() + "]"); - if (graph != null) { - graph.tx().rollback(); - } - } - catch (Exception ex) { - System.out.print(processName + " Threw a regular ole Exception calling graph.rollback()\n"); - System.out.println(ex.getMessage()); - System.out.println(ex.toString()); - if (graph != null) { - graph.tx().rollback(); - } - } - - - - return; - } - - -} diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/AAIUtilsTest.java b/aai-resources/src/test/java/org/openecomp/aai/util/AAIUtilsTest.java deleted file mode 100644 index 0bba892..0000000 --- a/aai-resources/src/test/java/org/openecomp/aai/util/AAIUtilsTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * org.openecomp.aai - * ================================================================================ - * Copyright (C) 2017 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========================================================= - */ - -package org.openecomp.aai.util; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.TimeZone; -import java.util.concurrent.TimeUnit; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.powermock.modules.agent.PowerMockAgent; -import org.powermock.modules.junit4.rule.PowerMockRule; - -public class AAIUtilsTest { - - @Rule - public PowerMockRule rule = new PowerMockRule(); - - static { - PowerMockAgent.initializeIfNeeded(); - } - - - AAIUtils testObj; - - /** - * Initialize. - */ - @Before - public void initialize(){ - testObj = new AAIUtils(); - } - - /** - * Test nullCheck with null. - */ - @Test - public void testNullCheck_withNull(){ - List<String> newList = null; - assertNotNull("method nullCheck should not return null", AAIUtils.nullCheck(newList)); - } - - /** - * Test nullCheck with a List. - */ - @Test - public void testNullCheck_withList(){ - List<String> newList = new ArrayList<String>(); - newList.add("testString"); - assertNotNull("method nullCheck failed for a List", AAIUtils.nullCheck(newList)); - } - - /** - * Test genDate using a past and a future date. - */ - @Test - public void testGenDate(){ - - Date d1 = new Date(0); - - DateFormat formatter = new SimpleDateFormat("YYMMdd-HH:mm:ss:SSS"); - formatter.setTimeZone(TimeZone.getTimeZone("GMT")); - formatter.setLenient(false); - - Date d2 = null; - - try { - d2 = formatter.parse(AAIUtils.genDate()); - } catch (ParseException e) { - fail("Date parsing exception"); - e.printStackTrace(); - } - - try { - TimeUnit.SECONDS.sleep(1); - } catch (InterruptedException e1) {} - - Date d3 = new Date(); - - assertTrue("Generated date is not after a past date", d2.after(d1)); - assertTrue("Generated date is not before a future date", d2.before(d3)); - } - -} diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/DeleteResourceTest.java b/aai-resources/src/test/java/org/openecomp/aai/util/DeleteResourceTest.java deleted file mode 100644 index 1522e80..0000000 --- a/aai-resources/src/test/java/org/openecomp/aai/util/DeleteResourceTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * org.openecomp.aai - * ================================================================================ - * Copyright (C) 2017 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========================================================= - */ - -package org.openecomp.aai.util; - - - -import static org.junit.Assert.assertEquals; - -import static org.junit.Assert.assertFalse; - -import static org.junit.Assert.assertTrue; - -import static org.junit.Assert.fail; - -import org.junit.Test; - - - -import org.openecomp.aai.domain.yang.PhysicalLink; - - - -public class DeleteResourceTest { - - - - /** - * Test getInstance. - */ - - @Test - - public void testGetInstance(){ - - Object obj = null; - - try { - - obj = DeleteResource.getInstance(DeleteResource.class); - - } catch (IllegalAccessException | InstantiationException e) { - - e.printStackTrace(); - - } - - assertTrue("Didn't get right instance", obj instanceof DeleteResource); - - } - - - - /** - * Test GetResourceVersion. - */ - - @Test - - public void testGetResourceVersion(){ - - String version = "aVersion"; - - PhysicalLink plink = new PhysicalLink(); - - plink.setResourceVersion(version); - - assertEquals("Versions didn't match", version, DeleteResource.GetResourceVersion(plink)); - - } - - - - /** - * Test null in GetResourceVersion. - */ - - @Test - - public void testGetResourceVersion_withNull(){ - - PhysicalLink plink = new PhysicalLink(); - - assertEquals("Versions didn't match", null, DeleteResource.GetResourceVersion(plink)); - - } - - - -} - |