diff options
Diffstat (limited to 'aai-traversal/src/test')
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java) | 1967 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java) | 1083 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/dbgraphmap/SearchGraphTest.java) | 755 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSInInterceptorTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptorTest.java) | 13 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSOutInterceptorTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/interceptors/AAILogJAXRSOutInterceptorTest.java) | 13 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptorTest.java) | 15 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/interceptors/PreAaiAjscInterceptorTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/interceptors/PreAaiAjscInterceptorTest.java) | 13 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/ExceptionHandlerTest.java) | 13 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeQueryTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromNfTypeQueryTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeVendorVersionTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromNfTypeVendorVersionTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeVendorVersion_withOptionalTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromNfTypeVendorVersion_withOptionalTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromVnfTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromVnfTest.java) | 27 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionfromCountryCloudRegionVersionQueryTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionfromCountryCloudRegionVersionQueryTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionfromCountryQueryTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionfromCountryQueryTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/FirstNetTopology_LineOfBusinessTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/FirstNetTopology_LineOfBusinessTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/FirstNetTopology_ServiceInstanceTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/FirstNetTopology_ServiceInstanceTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/GremlinServerImplTest.java) | 327 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/GroovyShellImplTest.java) | 315 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/ImageFromCloudRegionNfTypeTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/ImageFromCloudRegionNfTypeTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java) | 27 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_NewvceVserverTest.java) | 27 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java) | 27 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/LocationNetTypeNetRolefromCloudRegionQueryTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/LocationNetTypeNetRolefromCloudRegionQueryTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/ModelAndNamedQueryRestProviderTest.java) | 37 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/MsoRequestVfModuleTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/MsoRequestVfModuleTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java) | 27 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/NfTypefromCloudRegionQueryTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/NfTypefromCloudRegionQueryTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/OwningEntityfromServiceInstance.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/OwningEntityfromServiceInstance.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/PendingTopologyDetailTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/PendingTopologyDetailTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationTest.java) | 15 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/PserversFromVnfQueryTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserversFromVnfQueryTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryTest.java) | 37 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryVnfFromModelByRegionTest.java) | 27 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/SearchProviderTest.java) | 37 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/ServiceFromPserverAndSubsNameTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/SimpleFormatTest.java) | 47 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyDetailFromVserverQueryTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyDetailsQueryTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromCloudRegionIdAndServiceIdTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyFromCloudRegionIdAndServiceIdTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/VnfInstancesFromServiceInstancebyModelVersionTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfInstancesFromServiceInstancebyModelVersionTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfTopologyFromServiceInstanceTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVfModuleTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfTopologyFromVfModuleTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVnfTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfTopologyFromVnfTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsFromPserverQueryTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfsFromPserverQueryTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsFromServiceInstanceTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfsFromServiceInstanceTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromVnfQueryTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/VserverFromVnfQueryTest.java) | 27 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/VserverLogicallinkFromPServerTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/search/VserverLogicallinkFromPServerTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/util/EchoResponseTest.java) | 13 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/util/LogFormatToolsTest.java) | 71 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java) | 17 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/retiredcustomer/JaxrsUserServiceTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/JaxrsUserServiceTest.java) | 221 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/retiredcustomer/RetiredConsumerTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/RetiredConsumerTest.java) | 257 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V3ThroughV7ConsumerTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/V3ThroughV7ConsumerTest.java) | 67 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V7V8NamedQueriesTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/V7V8NamedQueriesTest.java) | 67 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/transforms/JoltTestUtil.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/transforms/JoltTestUtil.java) | 17 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/transforms/LowerHyphenToLowerCamelConverterTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/transforms/LowerHyphenToLowerCamelConverterTest.java) | 17 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/transforms/MapTraverserTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/transforms/MapTraverserTest.java) | 21 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java (renamed from aai-traversal/src/test/java/org/openecomp/aai/util/AAIAppServletContextListenerTest.java) | 355 | ||||
-rw-r--r-- | aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties | 16 | ||||
-rw-r--r-- | aai-traversal/src/test/resources/config/etc/titan-cached.properties | 16 | ||||
-rw-r--r-- | aai-traversal/src/test/resources/config/etc/titan-realtime.properties | 16 | ||||
-rw-r--r-- | aai-traversal/src/test/resources/inmemory_titan.properties | 16 | ||||
-rw-r--r-- | aai-traversal/src/test/resources/logback.xml | 45 | ||||
-rw-r--r-- | aai-traversal/src/test/resources/test_aaiconfig.properties | 16 |
66 files changed, 3453 insertions, 3238 deletions
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java index b255916..bd3705e 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java @@ -1,983 +1,984 @@ -/*-
- * ============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.dbgraphgen;
-
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyMap;
-import static org.mockito.Matchers.anyMapOf;
-import static org.mockito.Mockito.*;
-
-import com.bazaarvoice.jolt.modifier.DataType;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.LinkedListMultimap;
-import com.google.common.collect.Multimap;
-import com.thinkaurelius.titan.graphdb.olap.computer.VertexMapJob;
-import com.thinkaurelius.titan.graphdb.types.VertexLabelVertex;
-import com.thinkaurelius.titan.graphdb.types.system.BaseVertexLabel;
-import com.thinkaurelius.titan.graphdb.types.system.EmptyVertex;
-import com.thinkaurelius.titan.graphdb.types.vertices.EdgeLabelVertex;
-import com.thinkaurelius.titan.graphdb.types.vertices.PropertyKeyVertex;
-import org.apache.commons.lang.ObjectUtils;
-import org.apache.openjpa.kernel.exps.Exp;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.*;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.openecomp.aai.db.DbMethHelper;
-import org.openecomp.aai.db.props.AAIProperties;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
-import org.openecomp.aai.serialization.db.DBSerializer;
-import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-
-import javax.inject.Inject;
-import java.util.*;
-@RunWith(MockitoJUnitRunner.class)
-public class ModelBasedProcessingInvalidDataTest {
-
- @Mock
- private static TransactionalGraphEngine dbEngine;
- private static Loader loader;
- @Mock
- private static DBSerializer serializer;
- ModelBasedProcessing processor;
-
- @Mock
- private ModelBasedProcessing mockProcessor;
-
-
- @Mock
- private DbMethHelper dbMethHelper;
-
- @BeforeClass
- public static void configure() throws Exception {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
- loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
-
-
- }
-
- @Before
- public void init() {
- MockitoAnnotations.initMocks(this);
- processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- dbMethHelper = new DbMethHelper(loader, dbEngine);
-
- }
-
- @Test
- public void getStartNodesAndModVersionIdsTest() throws AAIException {
-
-
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("test", new Object());
- startNodeFilterArrayOfHashes.add(map);
- Map<String, String> result=new HashMap<>();
-
- Map<String, String> result1 = mockProcessor.getStartNodesAndModVersionIds("test", "test",
- "test", "test", "test",
- "test", startNodeFilterArrayOfHashes,
- "test");
- assertNotNull(result);
-
- }
-
-
- @Test(expected = NullPointerException.class)
- public void getStartNodesAndModVersionIdsTest2() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("test", new Object());
- startNodeFilterArrayOfHashes.add(map);
- Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
- "", "test", "test",
- "test", startNodeFilterArrayOfHashes,
- "test");
- assertNotNull(result1);
- }
-
-
- @Test(expected = NullPointerException.class)
- public void getStartNodesAndModVersionIdsTest3() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("test", new Object());
- startNodeFilterArrayOfHashes.add(map);
- Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
- "", "", "test",
- "test", startNodeFilterArrayOfHashes,
- "test");
- assertNotNull(result1);
- }
-
-
- @Test(expected = AAIException.class)
- public void getStartNodesAndModVersionIdsTest4() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("test", new Object());
- startNodeFilterArrayOfHashes.add(map);
- Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
- "", "", "",
- "test", startNodeFilterArrayOfHashes,
- "test");
- assertNotNull(result1);
- }
-
-
- @Test(expected = AAIException.class)
- public void getStartNodesAndModVersionIdsTest5() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("test", new Object());
- startNodeFilterArrayOfHashes.add(map);
- Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
- "", "", "",
- "", startNodeFilterArrayOfHashes,
- "test");
- assertNotNull(result1);
- }
-
-
- @Test(expected = AAIException.class)
- public void getStartNodesAndModVersionIdsNullTest() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
-
- Map<String, String> result = null;
- result = processor.getStartNodesAndModVersionIds("test", "test",
- "", "", "",
- "", startNodeFilterArrayOfHashes,
- "test");
-
- assertNotNull(result);
- }
-
-
- @Test(expected = NullPointerException.class)
- public void getStartNodesAndModVersionIdsNullTest1() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
-
- Map<String, String> result = null;
- result = processor.getStartNodesAndModVersionIds("test", "test",
- "Test", "", "",
- "", startNodeFilterArrayOfHashes,
- "test");
-
- assertNotNull(result);
- }
-
- @Test(expected = NullPointerException.class)
- public void getStartNodesAndModVersionIdsNullTest2() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
-
- Map<String, String> result = null;
- result = processor.getStartNodesAndModVersionIds("test", "test",
- "", "test", "",
- "", startNodeFilterArrayOfHashes,
- "test");
- assertNotNull(result);
- }
-
-
- @Test(expected = NullPointerException.class)
- public void getStartNodesAndModVersionIdsNullTest3() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
-
- Map<String, String> result = null;
- result = processor.getStartNodesAndModVersionIds("test", "test",
- "", "", "test",
- "", startNodeFilterArrayOfHashes,
- "test");
- assertNotNull(result);
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelVerTopWidgetTypeTest() throws AAIException {
- Vertex vertex = new EmptyVertex();
- //Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(Vertex.class), Mockito.any(String.class))).thenReturn("Sucess");
- String result = processor.getModelVerTopWidgetType(vertex, "test");
- assertEquals("result has -local tacked on the end as it should", "Sucess", result
- );
-
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelVerTopWidgetType() throws AAIException {
- /*Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(String.class),
- Mockito.any(String.class), Mockito.any(String.class),
- Mockito.any(String.class), Mockito.any(String.class))
- ).thenReturn("Sucess");*/
- String result = processor.getModelVerTopWidgetType("test", "test", "test", "Test", "test");
- assertEquals("result has -local tacked on the end as it should", "Sucess", result
- );
-
- }
-
- @Test(expected = AAIException.class)
- public void queryByModel() throws AAIException {
- /*Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(String.class),
- Mockito.any(String.class), Mockito.any(String.class),
- Mockito.any(String.class), Mockito.any(String.class))
- ).thenReturn("Sucess");*/
- List<ResultSet> result = processor.queryByModel("test", "test",
- "test", "test", "test",
- "generic-vnf", null,
- "test");
- assertEquals("result has -local tacked on the end as it should", 0, result.size());
-
-
- }
-
-
- @Test(expected = NullPointerException.class)
- public void queryByModel_Timed() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("test", new Object());
- startNodeFilterArrayOfHashes.add(map);
- List<ResultSet> result = processor.queryByModel_Timed("test", "test",
- "test", "test", "test",
- "test", startNodeFilterArrayOfHashes,
- "test");
- assertEquals("result has -local tacked on the end as it should", 0, result.size());
-
-
- }
-
- @Mock
- Map<String, Object> startNodeFilterHash;
-
- @Test(expected = NullPointerException.class)
- public void runDeleteByModel() throws AAIException {
- Map<String, String> resultMock = new HashMap<String, String>();
-
- // when(mockProcessor.getNodeUsingUniqueId(any(String.class),any(String.class),any(String.class),any(String.class),any(String.class))).thenReturn(vertex);
- when(mockProcessor.runDeleteByModel(any(String.class),
- any(String.class), any(String.class),
- any(String.class), anyMapOf(String.class, Object.class), any(String.class), any(String.class))
- ).thenReturn(resultMock);
- Map<String, String> result = processor.runDeleteByModel("test", "test",
- "test", "test", startNodeFilterHash,
- "test",
- "test");
- assertEquals("result has -local tacked on the end as it should", result.size(), resultMock.size());
-
-
- }
-
- Optional<Vertex> vertext = Optional.empty();
-
- @Test(expected = AAIException.class)
- public void runDeleteByModelWithNullParams() throws AAIException {
- Map<String, String> resultMock = new HashMap<String, String>();
-
-
- Map<String, String> result = processor.runDeleteByModel("test", "test",
- null, null, null,
- "test",
- "test");
-
- assertNotNull(result);
-
- }
-
- @Test(expected = NullPointerException.class)
- public void runDeleteByModelWithNullParams1() throws AAIException {
-
- Map<String, String> result1 = processor.runDeleteByModel("test", "test",
- null, "unknown", null,
- "test",
- "test");
- assertNotNull(result1);
-
- }
-
-
- @Test(expected = NullPointerException.class)
- public void runDeleteByModelWithNullParams2() throws AAIException {
-
- Map<String, String> result1 = processor.runDeleteByModel("test", "test",
- null, "unknown", null,
- "test",
- "test");
- assertNotNull(result1);
-
- }
-
- @Test(expected = AAIException.class)
- public void queryByNamedQuery() throws AAIException{
- String transId="test";
- String fromAppId="test";
- String namedQueryUuid="test";
- ArrayList <Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<Map<String,Object>>();
- String apiVer="test";
- List<ResultSet> result=processor.queryByNamedQuery(transId,fromAppId,namedQueryUuid,startNodeFilterArrayOfHashes,apiVer);
- assertNotNull(result);
- }
-
- @Test(expected = AAIException.class)
- public void queryByNamedQuery1() throws AAIException{
- String transId="teet";
- String fromAppId="test";
- String namedQueryUuid="test";
- String secondaryFilterCutPoint="test";
- List <Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<Map<String,Object>>();
- String apiVer="test";
- Map<String,Object> secondaryFilterHash=new HashMap<String,Object>();
- List<ResultSet> result=processor.queryByNamedQuery(transId,fromAppId,namedQueryUuid,startNodeFilterArrayOfHashes,apiVer,secondaryFilterCutPoint,secondaryFilterHash);
- assertNotNull(result);
- }
-
- @Test
- public void deleteAsNeededFromResultSet() throws AAIException {
- Vertex vert = new BaseVertexLabel("Test");
- Map<String, String> resultMock = new HashMap<String, String>();
- ResultSet resultSet = new ResultSet();
- resultSet.setVert(null);
-
- Map<String, String> result = processor.deleteAsNeededFromResultSet("test", "test",
- resultSet, "test", "test",
- "test",
- resultMock);
-
- assertEquals(result.size(), 0);
-
- resultSet.setVert(vert);
-
- Map<String, String> result1 = processor.deleteAsNeededFromResultSet("test", "test",
- resultSet, "test", "test",
- "test",
- resultMock);
-
- assertEquals(result.size(), 0);
-
-
- }
-
- @Test(expected = NullPointerException.class)
- public void pruneResultSetTest() throws AAIException {
- ResultSet rs = new ResultSet();
- Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
- rs.setVert(v);
- List<ResultSet> rsList = new ArrayList<ResultSet>();
- ResultSet rs1 = new ResultSet();
- rsList.add(rs1);
- rs.setSubResultSet(rsList);
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("test", new Object());
- ResultSet resultSet = processor.pruneResultSet(rs, "testr", map);
- assertNotNull(resultSet);
-
- }
-
- @Test(expected = NullPointerException.class)
- public void satisfiesFiltersTest() throws AAIException {
- ResultSet rs = new ResultSet();
- Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
- rs.setVert(v);
- rs.getVert().property(AAIProperties.NODE_TYPE);
- List<ResultSet> rsList = new ArrayList<ResultSet>();
- ResultSet rs1 = new ResultSet();
- rsList.add(rs1);
- rs.setSubResultSet(rsList);
- Map<String, Object> map = new HashMap<String, Object>();
-
- map.put("modern.vertex-id", new Object());
-
- boolean result = processor.satisfiesFilters(rs, map);
- assertEquals(result, true);
- }
-
- @Test
- public void satisfiesFiltersTest1() throws AAIException {
- ResultSet rs = new ResultSet();
- Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
- rs.setVert(v);
- List<ResultSet> rsList = new ArrayList<ResultSet>();
- ResultSet rs1 = new ResultSet();
- rsList.add(rs1);
- rs.setSubResultSet(rsList);
- Map<String, Object> map = new HashMap<String, Object>();
- //map.put("test.filter",new Object());
-
- boolean result = processor.satisfiesFilters(rs, map);
- assertEquals(result, false);
- }
-
- @Test(expected = AAIException.class)
- public void satisfiesFiltersTest2() throws AAIException {
- ResultSet rs = new ResultSet();
- Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
- rs.setVert(v);
- List<ResultSet> rsList = new ArrayList<ResultSet>();
- ResultSet rs1 = new ResultSet();
- rsList.add(rs1);
- rs.setSubResultSet(rsList);
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("testfilter", new Object());
-
- boolean result = processor.satisfiesFilters(rs, map);
- assertEquals(result, false);
- }
-
- @Test
- public void collapseForDoNotOutputTest() throws AAIException {
- ResultSet rs = new ResultSet();
- rs.setDoNotOutputFlag("true");
- List<ResultSet> rsList = new ArrayList<ResultSet>();
- ResultSet rs1 = new ResultSet();
- rsList.add(rs1);
- rs.setSubResultSet(rsList);
- List<ResultSet> result = processor.collapseForDoNotOutput(rs);
- assertEquals(result.size(), 1);
- }
-
- @Test(expected = NullPointerException.class)
- public void collectInstanceDataTest() throws AAIException {
-
- BaseVertexLabel bs = new BaseVertexLabel("test");
- //bs.setId(80);
- EmptyVertex ev = new EmptyVertex();
- //ev.setId(50l);
- Vertex thisLevelElemVtx = ev;
-
-
- Multimap<String, String> thisMap = ArrayListMultimap.create();
- List<String> vidsTraversed = new ArrayList<String>();
- // only applies when collecting data using the default model for delete
- Multimap<String, String> validNextStepMap = ArrayListMultimap.create();
- Map<String, String> namedQueryElementHash = new HashMap<String, String>();
- namedQueryElementHash.put("test", "test");
- Map<String, String> delKeyHash = new HashMap<String, String>();
-
- ResultSet rs = processor.collectInstanceData("test", "test", thisLevelElemVtx, "test", validNextStepMap, vidsTraversed, 1, delKeyHash, namedQueryElementHash, "test");
- }
-
- @Test(expected = NullPointerException.class)
- public void genTopoMap4ModelVerTest() throws
- AAIException {
- Vertex vertext = new EmptyVertex();
- Multimap<String, String> map = processor.genTopoMap4ModelVer("test", "test", vertext, "test");
- assertNotEquals(map, null);
- }
-
- @Test(expected = AAIException.class)
- public void genTopoMap4ModelVerTestNull() throws
- AAIException {
- Vertex vertext = null;
- Multimap<String, String> map = processor.genTopoMap4ModelVer("test", "test", vertext, "test");
- assertNotEquals(map, null);
- }
-
- @Test
- public void makeSureItsAnArrayListTest() {
- String input = "model-versionId,modelTestID,modelTestid2;";
- List<String> result = processor.makeSureItsAnArrayList(input);
- assertTrue(result.size() > 0);
- }
-
- @Test(expected = AAIException.class)
- public void getModConstraintHashTest() throws AAIException {
- Vertex modelElementVtx = new EmptyVertex();
- //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
- Vertex modelElementVtx1 = new EmptyVertex();
- Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
- currentHash.put("constraint", modelElementVtx1);
- Map<String, Vertex> result = processor.getModConstraintHash(modelElementVtx, currentHash);
- assertTrue(result.size() > 0);
- }
-
- @Test(expected = AAIException.class)
- public void getModConstraintHashTestNull() throws AAIException {
- Vertex modelElementVtx = null;
- //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
- Vertex modelElementVtx1 =null;
- Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
- currentHash.put("constraint", modelElementVtx1);
- Map<String, Vertex> result = processor.getModConstraintHash(modelElementVtx, currentHash);
- assertTrue(result.size() > 0);
- }
-
- @Test(expected = NullPointerException.class)
- public void getTopElementForSvcOrResModelVerTest() throws AAIException {
- Vertex modelElementVtx = new EmptyVertex();
- //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
- Vertex modelElementVtx1 = new EmptyVertex();
- Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
- currentHash.put("constraint", modelElementVtx1);
- Vertex result = processor.getTopElementForSvcOrResModelVer(modelElementVtx, "test");
- assertNotEquals(result, null);
- }
-
- @Test
- public void getNamedQueryPropOverRideTest() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex namedQueryElementVertex = new EmptyVertex();
- Vertex instanceVertex = new EmptyVertex();
- String apiVer = "test";
-
- namedQueryElementVertex.properties("property-collect-list", "");
-
- Map<String, Object> result = processor.getNamedQueryPropOverRide(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
- assertNotEquals(result, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getNamedQueryPropOverRideTestNull() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex namedQueryElementVertex = null;
- Vertex instanceVertex = new EmptyVertex();
- String apiVer = "test";
-
- namedQueryElementVertex.properties("property-collect-list", "");
-
- Map<String, Object> result = processor.getNamedQueryPropOverRide(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
- assertNotEquals(result, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void namedQueryConstraintSaysStopTest() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex namedQueryElementVertex = new EmptyVertex();
- Vertex instanceVertex = new EmptyVertex();
- String apiVer = "test";
-
- namedQueryElementVertex.properties("property-collect-list", "");
-
- boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
- assertTrue(result);
- }
-
- @Test(expected = NullPointerException.class)
- public void namedQueryConstraintSaysStopTestNull() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex namedQueryElementVertex = null;
- Vertex instanceVertex = new EmptyVertex();
- String apiVer = "test";
-
- namedQueryElementVertex.properties("property-collect-list", "");
-
- boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
- assertTrue(result);
- }
-
- @Test(expected = AAIException.class)
- public void namedQuerynamedQueryElementVertexNullTest() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex namedQueryElementVertex = null;
- Vertex instanceVertex = null;
- String apiVer = "test";
-
-
- boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
- assertTrue(result);
- }
-
- @Test(expected = NullPointerException.class)
-
- public void getNamedQueryExtraDataLookupTest() throws Exception {
-
- String transId = "test";
- String fromAppId = "test";
- Vertex namedQueryElementVertex = new EmptyVertex();
- Vertex instanceVertex = new EmptyVertex();
- String apiVer = "test";
-
- namedQueryElementVertex.properties("property-collect-list", "");
-
- Map<String, Object> result = processor.getNamedQueryExtraDataLookup(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
-
- assertTrue(result.size() > 0);
- }
-
- @Test(expected = NullPointerException.class)
- public void collectNQElementHash() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- Map<String, String> currentHash = new HashMap<String, String>();
- ArrayList<String> vidsTraversed = new ArrayList<String>();
- int levelCounter = 1;
-
- Map<String, String> result = processor.collectNQElementHash(transId, fromAppId,
- thisLevelElemVtx, incomingTrail, currentHash,
- vidsTraversed, levelCounter);
-
- assertNotEquals(result, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void collectDeleteKeyHash() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- Map<String, String> currentHash = new HashMap<String, String>();
- ArrayList<String> vidsTraversed = new ArrayList<String>();
- int levelCounter = 1;
- Map<String, Vertex> modConstraintHash = new HashMap<String, Vertex>();
- String overRideModelId = "test";
- String overRideModelVersionId = "test";
-
- Map<String, String> result = processor.collectDeleteKeyHash(transId, fromAppId,
- thisLevelElemVtx, incomingTrail, currentHash,
- vidsTraversed, levelCounter, modConstraintHash, overRideModelId, overRideModelVersionId);
-
- assertNotEquals(result, null);
- }
-
- @Test
- public void getLinkageConnectNodeTypesTest() throws AAIException {
- List<String> linkagePtList = new ArrayList<String>();
- linkagePtList.add("modern\\|testdata\\|");
- Set<String> result = processor.getLinkageConnectNodeTypes(linkagePtList);
- assertNotEquals(result, null);
-
- }
-
- @Test(expected = AAIException.class)
- public void getLinkageConnectNodeTypesTest1() throws AAIException {
-
- Set<String> result1 = processor.getLinkageConnectNodeTypes(null);
- assertNotEquals(result1, null);
-
- List<String> linkagePtList = new ArrayList<String>();
- linkagePtList.add("moderntestdata");
- Set<String> result = processor.getLinkageConnectNodeTypes(linkagePtList);
- assertNotEquals(result, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void collectTopology4ModelVerTest() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Multimap<String, String> thisMap = ArrayListMultimap.create();
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
- List<String> vidsTraversed = new ArrayList<String>();
- int levelCounter = 1;
-
- Multimap<String, String> result = processor.collectTopology4ModelVer(transId, fromAppId,
- thisLevelElemVtx, incomingTrail, thisMap, vidsTraversed, levelCounter, currentHash
- , "test", "test");
-
- assertNotEquals(result, null);
- }
-
- @Test(expected = AAIException.class)
- public void check4EdgeRuleTest() throws AAIException {
- processor.check4EdgeRule("test", "test");
- }
-
- @Test(expected = AAIException.class)
- public void collectTopology4LinkagePointTest() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- String linkagePointStrVal = "test";
- String incomingTrail = "test";
- Multimap<String, String> currentMap = ArrayListMultimap.create();
-
- Multimap<String, String> result = processor.collectTopology4LinkagePoint(transId, fromAppId, linkagePointStrVal, incomingTrail, currentMap);
- assertNotEquals(result, null);
-
- }
-
- @Test(expected = AAIException.class)
- public void getNextStepElementsFromSet() throws AAIException {
- Vertex constrElemSetVtx = new EmptyVertex();
- constrElemSetVtx.<String>property(AAIProperties.NODE_TYPE);
- Map<String, Object> result = processor.getNextStepElementsFromSet(constrElemSetVtx);
- assertNotEquals(result, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void genTopoMap4NamedQTest() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex queryVertex = new EmptyVertex();
- String namedQueryUuid = "E44533334343";
- Multimap<String, String> result = processor.genTopoMap4NamedQ(transId, fromAppId, queryVertex, namedQueryUuid);
- assertNotEquals(result, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void collectTopology4NamedQTest() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Multimap<String, String> thisMap = ArrayListMultimap.create();
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
- List<String> vidsTraversed = new ArrayList<String>();
- int levelCounter = 1;
-
- Multimap<String, String> result = processor.collectTopology4NamedQ(transId, fromAppId,
- thisLevelElemVtx, incomingTrail, thisMap, vidsTraversed, levelCounter);
- assertNotEquals(result, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelThatNqElementRepresentsTest() throws AAIException {
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- Vertex vertex = processor.getModelThatNqElementRepresents(thisLevelElemVtx, incomingTrail);
- assertNotEquals(vertex, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelGivenModelVer() throws AAIException {
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- Vertex vertex = processor.getModelGivenModelVer(thisLevelElemVtx, incomingTrail);
- assertNotEquals(vertex, null);
- }
-
- @Test(expected = AAIException.class)
- public void getModelTypeFromModel() throws AAIException {
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- String vertex = processor.getModelTypeFromModel(thisLevelElemVtx, incomingTrail);
- assertNotEquals(vertex, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelTypeFromModelVer() throws AAIException {
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- String vertex = processor.getModelTypeFromModelVer(thisLevelElemVtx, incomingTrail);
- assertNotEquals(vertex, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelElementStepName() throws AAIException {
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- String vertex = processor.getModelElementStepName(thisLevelElemVtx, incomingTrail);
- assertNotEquals(vertex, null);
- }
-
- @Test(expected = AAIException.class)
- public void nodeTypeSupportsPersona() throws AAIException {
- String incomingTrail = "";
- boolean vertex = processor.nodeTypeSupportsPersona(incomingTrail);
- assertFalse(vertex);
-
-
- incomingTrail = "test";
- boolean vertex1 = processor.nodeTypeSupportsPersona(incomingTrail);
- assertTrue(vertex1);
- }
-
- @Test(expected = NullPointerException.class)
- public void getNqElementWidgetType() throws AAIException{
- String appId="test";
- String transID="test";
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- String vertex1 = processor.getNqElementWidgetType(appId,transID,thisLevelElemVtx,incomingTrail);
- assertNotEquals(vertex1,null);
- }
-
-
- @Test(expected = NullPointerException.class)
- public void getModElementWidgetType() throws AAIException{
- String appId="test";
- String transID="test";
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- String vertex1 = processor.getModElementWidgetType(thisLevelElemVtx,incomingTrail);
- assertNotEquals(vertex1,null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getNodeUsingUniqueId() throws AAIException{
- String appId="test";
- String transID="test";
- String nodeType = "generic-vnf";
- String idPropertyName = "test";
- String uniqueIdVal="test";
- Vertex vertex1 = processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
- assertNotEquals(vertex1,null);
- }
-
-
- @Test(expected = AAIException.class)
- public void getNodeUsingUniqueIdNull() throws AAIException{
- String appId="test";
- String transID="test";
- String nodeType = "generic-vnf";
- String idPropertyName = "test";
- String uniqueIdVal="";
- Vertex vertex1 = null;
- vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
- assertNotEquals(vertex1,null);
-
- }
-
-
- @Test(expected = AAIException.class)
- public void getNodeUsingUniqueIdNull1() throws AAIException{
- String appId="test";
- String transID="test";
- String nodeType = "generic-vnf";
- String idPropertyName="";
- String uniqueIdVal="test";
- Vertex vertex1 = null;
- vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
- assertNotEquals(vertex1,null);
-
-
- }
-
-
- @Test(expected = AAIException.class)
- public void getNodeUsingUniqueIdNull2() throws AAIException{
- String appId="test";
- String transID="test";
- String nodeType = "";
- String idPropertyName="test";
- String uniqueIdVal="test";
- Vertex vertex1 = null;
- vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
- assertNotEquals(vertex1,null);
-
-
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelVersUsingName() throws AAIException{
- String appId="test";
- String transID="test";
- String modelName = "test";
-
- List<Vertex> result= processor.getModelVersUsingName(transID,appId,modelName);
- assertNotEquals(result,null);
- }
-
-
- @Test(expected = AAIException.class)
- public void getModelVersUsingNameNull() throws AAIException{
- String appId="test";
- String transID="test";
- String modelName = "";
-
- List<Vertex> result= processor.getModelVersUsingName(transID,appId,modelName);
- assertNotEquals(result,null);
- }
-
-
- @Test(expected = NullPointerException.class)
- public void getModVersUsingModelInvId() throws AAIException{
- String appId="test";
- String transID="test";
- String modelName = "test";
-
- Iterator<Vertex> result= processor.getModVersUsingModelInvId(transID,appId,modelName);
- assertNotEquals(result,null);
- }
-
- @Test(expected = AAIException.class)
- public void getModVersUsingModelInvIdNull() throws AAIException{
- String appId="test";
- String transID="test";
- String modelName = "";
-
- Iterator<Vertex> result= processor.getModVersUsingModelInvId(transID,appId,modelName);
- assertNotEquals(result,null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getModVersUsingModel() throws AAIException{
- String appId="test";
- String transID="test";
- String modelName = "test";
- Vertex thisLevelElemVtx = new EmptyVertex();
- List<Vertex> result= processor.getModVersUsingModel(transID,appId,thisLevelElemVtx);
- assertNotEquals(result,null);
- }
-
- @Test(expected = AAIException.class)
- public void getModVersUsingModel1() throws AAIException{
- String appId="test";
- String transID="test";
-
- Vertex thisLevelElemVtx = null;
- List<Vertex> result= processor.getModVersUsingModel(transID,appId,thisLevelElemVtx);
- assertNotEquals(result,null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelVerIdsUsingName() throws AAIException{
- String appId="test";
- String transID="test";
-
- String modelName= "test";
- List<String> result= processor.getModelVerIdsUsingName(transID,appId,modelName);
- assertNotEquals(result,null);
- }
-
- @Test(expected = AAIException.class)
- public void getModelVerIdsUsingName1() throws AAIException{
- String appId="test";
- String transID="test";
-
- String modelName= "";
- List<String> result= processor.getModelVerIdsUsingName(transID,appId,modelName);
- assertNotEquals(result,null);
- }
-
- @Test(expected =NullPointerException.class)
- public void validateModel() throws AAIException{
- String appId="test";
- String transID="test";
-
- String modelVersionId= "test";
- String modelInvId= "test";
- String modelName= "test";
- processor.validateModel(transID,appId,modelName,modelVersionId);
-
-
- }
-
-
-
-}
-
+/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.dbgraphgen; + +import static org.junit.Assert.*; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyMap; +import static org.mockito.Matchers.anyMapOf; +import static org.mockito.Mockito.*; + +import com.bazaarvoice.jolt.modifier.DataType; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.LinkedListMultimap; +import com.google.common.collect.Multimap; +import com.thinkaurelius.titan.graphdb.olap.computer.VertexMapJob; +import com.thinkaurelius.titan.graphdb.types.VertexLabelVertex; +import com.thinkaurelius.titan.graphdb.types.system.BaseVertexLabel; +import com.thinkaurelius.titan.graphdb.types.system.EmptyVertex; +import com.thinkaurelius.titan.graphdb.types.vertices.EdgeLabelVertex; +import com.thinkaurelius.titan.graphdb.types.vertices.PropertyKeyVertex; +import org.apache.commons.lang.ObjectUtils; +import org.apache.openjpa.kernel.exps.Exp; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.structure.T; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.structure.VertexProperty; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.*; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.aai.db.DbMethHelper; +import org.onap.aai.db.props.AAIProperties; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.introspection.Loader; +import org.onap.aai.introspection.LoaderFactory; +import org.onap.aai.introspection.ModelType; +import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; +import org.onap.aai.serialization.db.DBSerializer; +import org.onap.aai.serialization.engines.TransactionalGraphEngine; + +import javax.inject.Inject; +import java.util.*; +@RunWith(MockitoJUnitRunner.class) +public class ModelBasedProcessingInvalidDataTest { + + @Mock + private static TransactionalGraphEngine dbEngine; + private static Loader loader; + @Mock + private static DBSerializer serializer; + ModelBasedProcessing processor; + + @Mock + private ModelBasedProcessing mockProcessor; + + + @Mock + private DbMethHelper dbMethHelper; + + @BeforeClass + public static void configure() throws Exception { + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST); + + + } + + @Before + public void init() { + MockitoAnnotations.initMocks(this); + processor = new ModelBasedProcessing(loader, dbEngine, serializer); + + dbMethHelper = new DbMethHelper(loader, dbEngine); + + } + + @Test + public void getStartNodesAndModVersionIdsTest() throws AAIException { + + + List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>(); + Map<String, Object> map = new HashMap<String, Object>(); + map.put("test", new Object()); + startNodeFilterArrayOfHashes.add(map); + Map<String, String> result=new HashMap<>(); + + Map<String, String> result1 = mockProcessor.getStartNodesAndModVersionIds("test", "test", + "test", "test", "test", + "test", startNodeFilterArrayOfHashes, + "test"); + assertNotNull(result); + + } + + + @Test(expected = NullPointerException.class) + public void getStartNodesAndModVersionIdsTest2() throws AAIException { + List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>(); + Map<String, Object> map = new HashMap<String, Object>(); + map.put("test", new Object()); + startNodeFilterArrayOfHashes.add(map); + Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test", + "", "test", "test", + "test", startNodeFilterArrayOfHashes, + "test"); + assertNotNull(result1); + } + + + @Test(expected = NullPointerException.class) + public void getStartNodesAndModVersionIdsTest3() throws AAIException { + List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>(); + Map<String, Object> map = new HashMap<String, Object>(); + map.put("test", new Object()); + startNodeFilterArrayOfHashes.add(map); + Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test", + "", "", "test", + "test", startNodeFilterArrayOfHashes, + "test"); + assertNotNull(result1); + } + + + @Test(expected = AAIException.class) + public void getStartNodesAndModVersionIdsTest4() throws AAIException { + List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>(); + Map<String, Object> map = new HashMap<String, Object>(); + map.put("test", new Object()); + startNodeFilterArrayOfHashes.add(map); + Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test", + "", "", "", + "test", startNodeFilterArrayOfHashes, + "test"); + assertNotNull(result1); + } + + + @Test(expected = AAIException.class) + public void getStartNodesAndModVersionIdsTest5() throws AAIException { + List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>(); + Map<String, Object> map = new HashMap<String, Object>(); + map.put("test", new Object()); + startNodeFilterArrayOfHashes.add(map); + Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test", + "", "", "", + "", startNodeFilterArrayOfHashes, + "test"); + assertNotNull(result1); + } + + + @Test(expected = AAIException.class) + public void getStartNodesAndModVersionIdsNullTest() throws AAIException { + List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>(); + + Map<String, String> result = null; + result = processor.getStartNodesAndModVersionIds("test", "test", + "", "", "", + "", startNodeFilterArrayOfHashes, + "test"); + + assertNotNull(result); + } + + + @Test(expected = NullPointerException.class) + public void getStartNodesAndModVersionIdsNullTest1() throws AAIException { + List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>(); + + Map<String, String> result = null; + result = processor.getStartNodesAndModVersionIds("test", "test", + "Test", "", "", + "", startNodeFilterArrayOfHashes, + "test"); + + assertNotNull(result); + } + + @Test(expected = NullPointerException.class) + public void getStartNodesAndModVersionIdsNullTest2() throws AAIException { + List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>(); + + Map<String, String> result = null; + result = processor.getStartNodesAndModVersionIds("test", "test", + "", "test", "", + "", startNodeFilterArrayOfHashes, + "test"); + assertNotNull(result); + } + + + @Test(expected = NullPointerException.class) + public void getStartNodesAndModVersionIdsNullTest3() throws AAIException { + List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>(); + + Map<String, String> result = null; + result = processor.getStartNodesAndModVersionIds("test", "test", + "", "", "test", + "", startNodeFilterArrayOfHashes, + "test"); + assertNotNull(result); + } + + @Test(expected = NullPointerException.class) + public void getModelVerTopWidgetTypeTest() throws AAIException { + Vertex vertex = new EmptyVertex(); + //Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(Vertex.class), Mockito.any(String.class))).thenReturn("Sucess"); + String result = processor.getModelVerTopWidgetType(vertex, "test"); + assertEquals("result has -local tacked on the end as it should", "Sucess", result + ); + + } + + @Test(expected = NullPointerException.class) + public void getModelVerTopWidgetType() throws AAIException { + /*Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(String.class), + Mockito.any(String.class), Mockito.any(String.class), + Mockito.any(String.class), Mockito.any(String.class)) + ).thenReturn("Sucess");*/ + String result = processor.getModelVerTopWidgetType("test", "test", "test", "Test", "test"); + assertEquals("result has -local tacked on the end as it should", "Sucess", result + ); + + } + + @Test(expected = AAIException.class) + public void queryByModel() throws AAIException { + /*Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(String.class), + Mockito.any(String.class), Mockito.any(String.class), + Mockito.any(String.class), Mockito.any(String.class)) + ).thenReturn("Sucess");*/ + List<ResultSet> result = processor.queryByModel("test", "test", + "test", "test", "test", + "generic-vnf", null, + "test"); + assertEquals("result has -local tacked on the end as it should", 0, result.size()); + + + } + + + @Test(expected = NullPointerException.class) + public void queryByModel_Timed() throws AAIException { + List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>(); + Map<String, Object> map = new HashMap<String, Object>(); + map.put("test", new Object()); + startNodeFilterArrayOfHashes.add(map); + List<ResultSet> result = processor.queryByModel_Timed("test", "test", + "test", "test", "test", + "test", startNodeFilterArrayOfHashes, + "test"); + assertEquals("result has -local tacked on the end as it should", 0, result.size()); + + + } + + @Mock + Map<String, Object> startNodeFilterHash; + + @Test(expected = NullPointerException.class) + public void runDeleteByModel() throws AAIException { + Map<String, String> resultMock = new HashMap<String, String>(); + + // when(mockProcessor.getNodeUsingUniqueId(any(String.class),any(String.class),any(String.class),any(String.class),any(String.class))).thenReturn(vertex); + when(mockProcessor.runDeleteByModel(any(String.class), + any(String.class), any(String.class), + any(String.class), anyMapOf(String.class, Object.class), any(String.class), any(String.class)) + ).thenReturn(resultMock); + Map<String, String> result = processor.runDeleteByModel("test", "test", + "test", "test", startNodeFilterHash, + "test", + "test"); + assertEquals("result has -local tacked on the end as it should", result.size(), resultMock.size()); + + + } + + Optional<Vertex> vertext = Optional.empty(); + + @Test(expected = AAIException.class) + public void runDeleteByModelWithNullParams() throws AAIException { + Map<String, String> resultMock = new HashMap<String, String>(); + + + Map<String, String> result = processor.runDeleteByModel("test", "test", + null, null, null, + "test", + "test"); + + assertNotNull(result); + + } + + @Test(expected = NullPointerException.class) + public void runDeleteByModelWithNullParams1() throws AAIException { + + Map<String, String> result1 = processor.runDeleteByModel("test", "test", + null, "unknown", null, + "test", + "test"); + assertNotNull(result1); + + } + + + @Test(expected = NullPointerException.class) + public void runDeleteByModelWithNullParams2() throws AAIException { + + Map<String, String> result1 = processor.runDeleteByModel("test", "test", + null, "unknown", null, + "test", + "test"); + assertNotNull(result1); + + } + + @Test(expected = AAIException.class) + public void queryByNamedQuery() throws AAIException{ + String transId="test"; + String fromAppId="test"; + String namedQueryUuid="test"; + ArrayList <Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<Map<String,Object>>(); + String apiVer="test"; + List<ResultSet> result=processor.queryByNamedQuery(transId,fromAppId,namedQueryUuid,startNodeFilterArrayOfHashes,apiVer); + assertNotNull(result); + } + + @Test(expected = AAIException.class) + public void queryByNamedQuery1() throws AAIException{ + String transId="teet"; + String fromAppId="test"; + String namedQueryUuid="test"; + String secondaryFilterCutPoint="test"; + List <Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<Map<String,Object>>(); + String apiVer="test"; + Map<String,Object> secondaryFilterHash=new HashMap<String,Object>(); + List<ResultSet> result=processor.queryByNamedQuery(transId,fromAppId,namedQueryUuid,startNodeFilterArrayOfHashes,apiVer,secondaryFilterCutPoint,secondaryFilterHash); + assertNotNull(result); + } + + @Test + public void deleteAsNeededFromResultSet() throws AAIException { + Vertex vert = new BaseVertexLabel("Test"); + Map<String, String> resultMock = new HashMap<String, String>(); + ResultSet resultSet = new ResultSet(); + resultSet.setVert(null); + + Map<String, String> result = processor.deleteAsNeededFromResultSet("test", "test", + resultSet, "test", "test", + "test", + resultMock); + + assertEquals(result.size(), 0); + + resultSet.setVert(vert); + + Map<String, String> result1 = processor.deleteAsNeededFromResultSet("test", "test", + resultSet, "test", "test", + "test", + resultMock); + + assertEquals(result.size(), 0); + + + } + + @Test(expected = NullPointerException.class) + public void pruneResultSetTest() throws AAIException { + ResultSet rs = new ResultSet(); + Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE); + rs.setVert(v); + List<ResultSet> rsList = new ArrayList<ResultSet>(); + ResultSet rs1 = new ResultSet(); + rsList.add(rs1); + rs.setSubResultSet(rsList); + Map<String, Object> map = new HashMap<String, Object>(); + map.put("test", new Object()); + ResultSet resultSet = processor.pruneResultSet(rs, "testr", map); + assertNotNull(resultSet); + + } + + @Test(expected = NullPointerException.class) + public void satisfiesFiltersTest() throws AAIException { + ResultSet rs = new ResultSet(); + Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE); + rs.setVert(v); + rs.getVert().property(AAIProperties.NODE_TYPE); + List<ResultSet> rsList = new ArrayList<ResultSet>(); + ResultSet rs1 = new ResultSet(); + rsList.add(rs1); + rs.setSubResultSet(rsList); + Map<String, Object> map = new HashMap<String, Object>(); + + map.put("modern.vertex-id", new Object()); + + boolean result = processor.satisfiesFilters(rs, map); + assertEquals(result, true); + } + + @Test + public void satisfiesFiltersTest1() throws AAIException { + ResultSet rs = new ResultSet(); + Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE); + rs.setVert(v); + List<ResultSet> rsList = new ArrayList<ResultSet>(); + ResultSet rs1 = new ResultSet(); + rsList.add(rs1); + rs.setSubResultSet(rsList); + Map<String, Object> map = new HashMap<String, Object>(); + //map.put("test.filter",new Object()); + + boolean result = processor.satisfiesFilters(rs, map); + assertEquals(result, false); + } + + @Test(expected = AAIException.class) + public void satisfiesFiltersTest2() throws AAIException { + ResultSet rs = new ResultSet(); + Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE); + rs.setVert(v); + List<ResultSet> rsList = new ArrayList<ResultSet>(); + ResultSet rs1 = new ResultSet(); + rsList.add(rs1); + rs.setSubResultSet(rsList); + Map<String, Object> map = new HashMap<String, Object>(); + map.put("testfilter", new Object()); + + boolean result = processor.satisfiesFilters(rs, map); + assertEquals(result, false); + } + + @Test + public void collapseForDoNotOutputTest() throws AAIException { + ResultSet rs = new ResultSet(); + rs.setDoNotOutputFlag("true"); + List<ResultSet> rsList = new ArrayList<ResultSet>(); + ResultSet rs1 = new ResultSet(); + rsList.add(rs1); + rs.setSubResultSet(rsList); + List<ResultSet> result = processor.collapseForDoNotOutput(rs); + assertEquals(result.size(), 1); + } + + @Test(expected = NullPointerException.class) + public void collectInstanceDataTest() throws AAIException { + + BaseVertexLabel bs = new BaseVertexLabel("test"); + //bs.setId(80); + EmptyVertex ev = new EmptyVertex(); + //ev.setId(50l); + Vertex thisLevelElemVtx = ev; + + + Multimap<String, String> thisMap = ArrayListMultimap.create(); + List<String> vidsTraversed = new ArrayList<String>(); + // only applies when collecting data using the default model for delete + Multimap<String, String> validNextStepMap = ArrayListMultimap.create(); + Map<String, String> namedQueryElementHash = new HashMap<String, String>(); + namedQueryElementHash.put("test", "test"); + Map<String, String> delKeyHash = new HashMap<String, String>(); + + ResultSet rs = processor.collectInstanceData("test", "test", thisLevelElemVtx, "test", validNextStepMap, vidsTraversed, 1, delKeyHash, namedQueryElementHash, "test"); + } + + @Test(expected = NullPointerException.class) + public void genTopoMap4ModelVerTest() throws + AAIException { + Vertex vertext = new EmptyVertex(); + Multimap<String, String> map = processor.genTopoMap4ModelVer("test", "test", vertext, "test"); + assertNotEquals(map, null); + } + + @Test(expected = AAIException.class) + public void genTopoMap4ModelVerTestNull() throws + AAIException { + Vertex vertext = null; + Multimap<String, String> map = processor.genTopoMap4ModelVer("test", "test", vertext, "test"); + assertNotEquals(map, null); + } + + @Test + public void makeSureItsAnArrayListTest() { + String input = "model-versionId,modelTestID,modelTestid2;"; + List<String> result = processor.makeSureItsAnArrayList(input); + assertTrue(result.size() > 0); + } + + @Test(expected = AAIException.class) + public void getModConstraintHashTest() throws AAIException { + Vertex modelElementVtx = new EmptyVertex(); + //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model"); + Vertex modelElementVtx1 = new EmptyVertex(); + Map<String, Vertex> currentHash = new HashMap<String, Vertex>(); + currentHash.put("constraint", modelElementVtx1); + Map<String, Vertex> result = processor.getModConstraintHash(modelElementVtx, currentHash); + assertTrue(result.size() > 0); + } + + @Test(expected = AAIException.class) + public void getModConstraintHashTestNull() throws AAIException { + Vertex modelElementVtx = null; + //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model"); + Vertex modelElementVtx1 =null; + Map<String, Vertex> currentHash = new HashMap<String, Vertex>(); + currentHash.put("constraint", modelElementVtx1); + Map<String, Vertex> result = processor.getModConstraintHash(modelElementVtx, currentHash); + assertTrue(result.size() > 0); + } + + @Test(expected = NullPointerException.class) + public void getTopElementForSvcOrResModelVerTest() throws AAIException { + Vertex modelElementVtx = new EmptyVertex(); + //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model"); + Vertex modelElementVtx1 = new EmptyVertex(); + Map<String, Vertex> currentHash = new HashMap<String, Vertex>(); + currentHash.put("constraint", modelElementVtx1); + Vertex result = processor.getTopElementForSvcOrResModelVer(modelElementVtx, "test"); + assertNotEquals(result, null); + } + + @Test + public void getNamedQueryPropOverRideTest() throws AAIException { + String transId = "test"; + String fromAppId = "test"; + Vertex namedQueryElementVertex = new EmptyVertex(); + Vertex instanceVertex = new EmptyVertex(); + String apiVer = "test"; + + namedQueryElementVertex.properties("property-collect-list", ""); + + Map<String, Object> result = processor.getNamedQueryPropOverRide(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer); + assertNotEquals(result, null); + } + + @Test(expected = NullPointerException.class) + public void getNamedQueryPropOverRideTestNull() throws AAIException { + String transId = "test"; + String fromAppId = "test"; + Vertex namedQueryElementVertex = null; + Vertex instanceVertex = new EmptyVertex(); + String apiVer = "test"; + + namedQueryElementVertex.properties("property-collect-list", ""); + + Map<String, Object> result = processor.getNamedQueryPropOverRide(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer); + assertNotEquals(result, null); + } + + @Test(expected = NullPointerException.class) + public void namedQueryConstraintSaysStopTest() throws AAIException { + String transId = "test"; + String fromAppId = "test"; + Vertex namedQueryElementVertex = new EmptyVertex(); + Vertex instanceVertex = new EmptyVertex(); + String apiVer = "test"; + + namedQueryElementVertex.properties("property-collect-list", ""); + + boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer); + assertTrue(result); + } + + @Test(expected = NullPointerException.class) + public void namedQueryConstraintSaysStopTestNull() throws AAIException { + String transId = "test"; + String fromAppId = "test"; + Vertex namedQueryElementVertex = null; + Vertex instanceVertex = new EmptyVertex(); + String apiVer = "test"; + + namedQueryElementVertex.properties("property-collect-list", ""); + + boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer); + assertTrue(result); + } + + @Test(expected = AAIException.class) + public void namedQuerynamedQueryElementVertexNullTest() throws AAIException { + String transId = "test"; + String fromAppId = "test"; + Vertex namedQueryElementVertex = null; + Vertex instanceVertex = null; + String apiVer = "test"; + + + boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer); + assertTrue(result); + } + + @Test(expected = NullPointerException.class) + + public void getNamedQueryExtraDataLookupTest() throws Exception { + + String transId = "test"; + String fromAppId = "test"; + Vertex namedQueryElementVertex = new EmptyVertex(); + Vertex instanceVertex = new EmptyVertex(); + String apiVer = "test"; + + namedQueryElementVertex.properties("property-collect-list", ""); + + Map<String, Object> result = processor.getNamedQueryExtraDataLookup(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer); + + assertTrue(result.size() > 0); + } + + @Test(expected = NullPointerException.class) + public void collectNQElementHash() throws AAIException { + String transId = "test"; + String fromAppId = "test"; + Vertex thisLevelElemVtx = new EmptyVertex(); + String incomingTrail = "test"; + Map<String, String> currentHash = new HashMap<String, String>(); + ArrayList<String> vidsTraversed = new ArrayList<String>(); + int levelCounter = 1; + + Map<String, String> result = processor.collectNQElementHash(transId, fromAppId, + thisLevelElemVtx, incomingTrail, currentHash, + vidsTraversed, levelCounter); + + assertNotEquals(result, null); + } + + @Test(expected = NullPointerException.class) + public void collectDeleteKeyHash() throws AAIException { + String transId = "test"; + String fromAppId = "test"; + Vertex thisLevelElemVtx = new EmptyVertex(); + String incomingTrail = "test"; + Map<String, String> currentHash = new HashMap<String, String>(); + ArrayList<String> vidsTraversed = new ArrayList<String>(); + int levelCounter = 1; + Map<String, Vertex> modConstraintHash = new HashMap<String, Vertex>(); + String overRideModelId = "test"; + String overRideModelVersionId = "test"; + + Map<String, String> result = processor.collectDeleteKeyHash(transId, fromAppId, + thisLevelElemVtx, incomingTrail, currentHash, + vidsTraversed, levelCounter, modConstraintHash, overRideModelId, overRideModelVersionId); + + assertNotEquals(result, null); + } + + @Test + public void getLinkageConnectNodeTypesTest() throws AAIException { + List<String> linkagePtList = new ArrayList<String>(); + linkagePtList.add("modern\\|testdata\\|"); + Set<String> result = processor.getLinkageConnectNodeTypes(linkagePtList); + assertNotEquals(result, null); + + } + + @Test(expected = AAIException.class) + public void getLinkageConnectNodeTypesTest1() throws AAIException { + + Set<String> result1 = processor.getLinkageConnectNodeTypes(null); + assertNotEquals(result1, null); + + List<String> linkagePtList = new ArrayList<String>(); + linkagePtList.add("moderntestdata"); + Set<String> result = processor.getLinkageConnectNodeTypes(linkagePtList); + assertNotEquals(result, null); + } + + @Test(expected = NullPointerException.class) + public void collectTopology4ModelVerTest() throws AAIException { + String transId = "test"; + String fromAppId = "test"; + Multimap<String, String> thisMap = ArrayListMultimap.create(); + Vertex thisLevelElemVtx = new EmptyVertex(); + String incomingTrail = "test"; + Map<String, Vertex> currentHash = new HashMap<String, Vertex>(); + List<String> vidsTraversed = new ArrayList<String>(); + int levelCounter = 1; + + Multimap<String, String> result = processor.collectTopology4ModelVer(transId, fromAppId, + thisLevelElemVtx, incomingTrail, thisMap, vidsTraversed, levelCounter, currentHash + , "test", "test"); + + assertNotEquals(result, null); + } + + @Test(expected = AAIException.class) + public void check4EdgeRuleTest() throws AAIException { + processor.check4EdgeRule("test", "test"); + } + + @Test(expected = AAIException.class) + public void collectTopology4LinkagePointTest() throws AAIException { + String transId = "test"; + String fromAppId = "test"; + String linkagePointStrVal = "test"; + String incomingTrail = "test"; + Multimap<String, String> currentMap = ArrayListMultimap.create(); + + Multimap<String, String> result = processor.collectTopology4LinkagePoint(transId, fromAppId, linkagePointStrVal, incomingTrail, currentMap); + assertNotEquals(result, null); + + } + + @Test(expected = AAIException.class) + public void getNextStepElementsFromSet() throws AAIException { + Vertex constrElemSetVtx = new EmptyVertex(); + constrElemSetVtx.<String>property(AAIProperties.NODE_TYPE); + Map<String, Object> result = processor.getNextStepElementsFromSet(constrElemSetVtx); + assertNotEquals(result, null); + } + + @Test(expected = NullPointerException.class) + public void genTopoMap4NamedQTest() throws AAIException { + String transId = "test"; + String fromAppId = "test"; + Vertex queryVertex = new EmptyVertex(); + String namedQueryUuid = "E44533334343"; + Multimap<String, String> result = processor.genTopoMap4NamedQ(transId, fromAppId, queryVertex, namedQueryUuid); + assertNotEquals(result, null); + } + + @Test(expected = NullPointerException.class) + public void collectTopology4NamedQTest() throws AAIException { + String transId = "test"; + String fromAppId = "test"; + Multimap<String, String> thisMap = ArrayListMultimap.create(); + Vertex thisLevelElemVtx = new EmptyVertex(); + String incomingTrail = "test"; + Map<String, Vertex> currentHash = new HashMap<String, Vertex>(); + List<String> vidsTraversed = new ArrayList<String>(); + int levelCounter = 1; + + Multimap<String, String> result = processor.collectTopology4NamedQ(transId, fromAppId, + thisLevelElemVtx, incomingTrail, thisMap, vidsTraversed, levelCounter); + assertNotEquals(result, null); + } + + @Test(expected = NullPointerException.class) + public void getModelThatNqElementRepresentsTest() throws AAIException { + Vertex thisLevelElemVtx = new EmptyVertex(); + String incomingTrail = "test"; + Vertex vertex = processor.getModelThatNqElementRepresents(thisLevelElemVtx, incomingTrail); + assertNotEquals(vertex, null); + } + + @Test(expected = NullPointerException.class) + public void getModelGivenModelVer() throws AAIException { + Vertex thisLevelElemVtx = new EmptyVertex(); + String incomingTrail = "test"; + Vertex vertex = processor.getModelGivenModelVer(thisLevelElemVtx, incomingTrail); + assertNotEquals(vertex, null); + } + + @Test(expected = AAIException.class) + public void getModelTypeFromModel() throws AAIException { + Vertex thisLevelElemVtx = new EmptyVertex(); + String incomingTrail = "test"; + String vertex = processor.getModelTypeFromModel(thisLevelElemVtx, incomingTrail); + assertNotEquals(vertex, null); + } + + @Test(expected = NullPointerException.class) + public void getModelTypeFromModelVer() throws AAIException { + Vertex thisLevelElemVtx = new EmptyVertex(); + String incomingTrail = "test"; + String vertex = processor.getModelTypeFromModelVer(thisLevelElemVtx, incomingTrail); + assertNotEquals(vertex, null); + } + + @Test(expected = NullPointerException.class) + public void getModelElementStepName() throws AAIException { + Vertex thisLevelElemVtx = new EmptyVertex(); + String incomingTrail = "test"; + String vertex = processor.getModelElementStepName(thisLevelElemVtx, incomingTrail); + assertNotEquals(vertex, null); + } + + @Test(expected = AAIException.class) + public void nodeTypeSupportsPersona() throws AAIException { + String incomingTrail = ""; + boolean vertex = processor.nodeTypeSupportsPersona(incomingTrail); + assertFalse(vertex); + + + incomingTrail = "test"; + boolean vertex1 = processor.nodeTypeSupportsPersona(incomingTrail); + assertTrue(vertex1); + } + + @Test(expected = NullPointerException.class) + public void getNqElementWidgetType() throws AAIException{ + String appId="test"; + String transID="test"; + Vertex thisLevelElemVtx = new EmptyVertex(); + String incomingTrail = "test"; + String vertex1 = processor.getNqElementWidgetType(appId,transID,thisLevelElemVtx,incomingTrail); + assertNotEquals(vertex1,null); + } + + + @Test(expected = NullPointerException.class) + public void getModElementWidgetType() throws AAIException{ + String appId="test"; + String transID="test"; + Vertex thisLevelElemVtx = new EmptyVertex(); + String incomingTrail = "test"; + String vertex1 = processor.getModElementWidgetType(thisLevelElemVtx,incomingTrail); + assertNotEquals(vertex1,null); + } + + @Test(expected = NullPointerException.class) + public void getNodeUsingUniqueId() throws AAIException{ + String appId="test"; + String transID="test"; + String nodeType = "generic-vnf"; + String idPropertyName = "test"; + String uniqueIdVal="test"; + Vertex vertex1 = processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal); + assertNotEquals(vertex1,null); + } + + + @Test(expected = AAIException.class) + public void getNodeUsingUniqueIdNull() throws AAIException{ + String appId="test"; + String transID="test"; + String nodeType = "generic-vnf"; + String idPropertyName = "test"; + String uniqueIdVal=""; + Vertex vertex1 = null; + vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal); + assertNotEquals(vertex1,null); + + } + + + @Test(expected = AAIException.class) + public void getNodeUsingUniqueIdNull1() throws AAIException{ + String appId="test"; + String transID="test"; + String nodeType = "generic-vnf"; + String idPropertyName=""; + String uniqueIdVal="test"; + Vertex vertex1 = null; + vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal); + assertNotEquals(vertex1,null); + + + } + + + @Test(expected = AAIException.class) + public void getNodeUsingUniqueIdNull2() throws AAIException{ + String appId="test"; + String transID="test"; + String nodeType = ""; + String idPropertyName="test"; + String uniqueIdVal="test"; + Vertex vertex1 = null; + vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal); + assertNotEquals(vertex1,null); + + + } + + @Test(expected = NullPointerException.class) + public void getModelVersUsingName() throws AAIException{ + String appId="test"; + String transID="test"; + String modelName = "test"; + + List<Vertex> result= processor.getModelVersUsingName(transID,appId,modelName); + assertNotEquals(result,null); + } + + + @Test(expected = AAIException.class) + public void getModelVersUsingNameNull() throws AAIException{ + String appId="test"; + String transID="test"; + String modelName = ""; + + List<Vertex> result= processor.getModelVersUsingName(transID,appId,modelName); + assertNotEquals(result,null); + } + + + @Test(expected = NullPointerException.class) + public void getModVersUsingModelInvId() throws AAIException{ + String appId="test"; + String transID="test"; + String modelName = "test"; + + Iterator<Vertex> result= processor.getModVersUsingModelInvId(transID,appId,modelName); + assertNotEquals(result,null); + } + + @Test(expected = AAIException.class) + public void getModVersUsingModelInvIdNull() throws AAIException{ + String appId="test"; + String transID="test"; + String modelName = ""; + + Iterator<Vertex> result= processor.getModVersUsingModelInvId(transID,appId,modelName); + assertNotEquals(result,null); + } + + @Test(expected = NullPointerException.class) + public void getModVersUsingModel() throws AAIException{ + String appId="test"; + String transID="test"; + String modelName = "test"; + Vertex thisLevelElemVtx = new EmptyVertex(); + List<Vertex> result= processor.getModVersUsingModel(transID,appId,thisLevelElemVtx); + assertNotEquals(result,null); + } + + @Test(expected = AAIException.class) + public void getModVersUsingModel1() throws AAIException{ + String appId="test"; + String transID="test"; + + Vertex thisLevelElemVtx = null; + List<Vertex> result= processor.getModVersUsingModel(transID,appId,thisLevelElemVtx); + assertNotEquals(result,null); + } + + @Test(expected = NullPointerException.class) + public void getModelVerIdsUsingName() throws AAIException{ + String appId="test"; + String transID="test"; + + String modelName= "test"; + List<String> result= processor.getModelVerIdsUsingName(transID,appId,modelName); + assertNotEquals(result,null); + } + + @Test(expected = AAIException.class) + public void getModelVerIdsUsingName1() throws AAIException{ + String appId="test"; + String transID="test"; + + String modelName= ""; + List<String> result= processor.getModelVerIdsUsingName(transID,appId,modelName); + assertNotEquals(result,null); + } + + @Test(expected =NullPointerException.class) + public void validateModel() throws AAIException{ + String appId="test"; + String transID="test"; + + String modelVersionId= "test"; + String modelInvId= "test"; + String modelName= "test"; + processor.validateModel(transID,appId,modelName,modelVersionId); + + + } + + + +} + diff --git a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java index 64e723b..406d122 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java @@ -1,541 +1,542 @@ -/*-
- * ============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.dbgraphgen;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import com.bazaarvoice.jolt.modifier.DataType;
-import com.google.common.collect.Multimap;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.*;
-import org.mockito.internal.exceptions.MockitoLimitations;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.openecomp.aai.db.DbMethHelper;
-import org.openecomp.aai.db.props.AAIProperties;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Introspector;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
-import org.openecomp.aai.parsers.exceptions.AAIIdentityMapParseException;
-import org.openecomp.aai.query.builder.GraphTraversalBuilder;
-import org.openecomp.aai.query.builder.QueryBuilder;
-import org.openecomp.aai.query.builder.TraversalQuery;
-import org.openecomp.aai.schema.enums.PropertyMetadata;
-import org.openecomp.aai.serialization.db.DBSerializer;
-import org.openecomp.aai.serialization.db.EdgeType;
-import org.openecomp.aai.serialization.engines.QueryStyle;
-import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-import org.powermock.modules.junit4.PowerMockRunner;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import java.util.*;
-
-@RunWith(MockitoJUnitRunner.class)
-public class ModelBasedProcessingTest {
-
- @Mock private static TransactionalGraphEngine dbEngine;
- private static Loader loader;
- @Mock private static DBSerializer serializer;
- @Mock private static TransactionalGraphEngine.Admin admin;
- ModelBasedProcessing mockProcessor;
- @Mock
- private DbMethHelper dbMethHelper;
-
- @BeforeClass
- public static void configure() throws Exception {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
- loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
-
-
- }
-
- @Before
- public void init() {
- mockProcessor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testPropNameChange1() throws AAIUnknownObjectException {
- String result;
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
- result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "model-invariant-id");
- assertEquals("result has -local tacked on the end as it should", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX, result);
- result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "vnf-id");
- assertEquals("result does NOT have -local tacked on the end as it should", "vnf-id", result);
- result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX);
- assertEquals("property not modified because it already includes the right suffix", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX, result);
- }
-
- @Mock
- GraphTraversal<Vertex, Vertex> v;
- @Mock
- GraphTraversal<Vertex, Vertex> graphTraversal;
- @Mock
- GraphTraversalSource graphTraversalSource;
- @Mock Iterable <?> uniqVerts;
- List<Vertex> vertexList=new ArrayList<>();
- @Mock Vertex vertex;
- @Mock Vertex vertex1;
- @Mock
- QueryBuilder<Vertex> queryBuilder;
-
- EdgeType treeType;
- @Test(expected = NullPointerException.class)
- public void getStartNodesAndModVersionIds() throws AAIException{
-
- vertex.property("model-ver","model-version-id");
- vertex1.property(AAIProperties.NODE_TYPE,"model-ver");
- graphTraversal.addV(vertex);
- v.addV(vertex1);
- vertexList.add(vertex);
- //vertexList.add(vertex1);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
- Mockito.when(graphTraversalSource.V()).thenReturn(v);
- Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-ver")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.has("model-ver","model-version-id")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
- //this.engine.getQueryBuilder(startV).createEdgeTraversal(treeType, startV, loader.introspectorFromName(connectedNodeType));
-
- queryBuilder.toList().add(vertex);
- Mockito.when(dbEngine.getQueryBuilder(vertex)).thenReturn(queryBuilder);
-
- Introspector obj=loader.introspectorFromName("model-ver");
-
- Mockito.when(queryBuilder.createEdgeTraversal(EdgeType.TREE,vertex,obj)).thenReturn(queryBuilder);
- //Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","model-ver","model-version-id","vnf-id-1");
-
-
- List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
-
- Map<String,String> result1=processor.getStartNodesAndModVersionIds("9999","postmen","vnf-id-1","vnf-id-1",
- "vnf-id","generic-vnf",startNodeFilterArrayOfHashes,"");
- }
-
-
- @Test(expected = AAIException.class)
- public void getStartNodesAndModVersionIds1() throws AAIException{
-
- vertex.property("model-version-id","vnf-id-1");
- vertex1.property(AAIProperties.NODE_TYPE,"model-ver");
- graphTraversal.addV(vertex);
- v.addV(vertex1);
- vertexList.add(vertex);
- //vertexList.add(vertex1);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
- Mockito.when(graphTraversalSource.V()).thenReturn(v);
- Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-ver")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.has("model-version-id","vnf-id-1")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
- //this.engine.getQueryBuilder(startV).createEdgeTraversal(treeType, startV, loader.introspectorFromName(connectedNodeType));
-
- queryBuilder.toList().add(vertex);
- Mockito.when(dbEngine.getQueryBuilder(vertex)).thenReturn(queryBuilder);
-
- Introspector obj=loader.introspectorFromName("generic-vnf");
- Mockito.when(queryBuilder.createEdgeTraversal(EdgeType.TREE,vertex,obj)).thenReturn(queryBuilder);
- //Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","model-ver","model-version-id","vnf-id-1");
-
-
- List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
-
- Map<String,String> result1=processor.getStartNodesAndModVersionIds("9999","postmen","vnf-id-1","vnf-id-1",
- "vnf-id","generic-vnf",startNodeFilterArrayOfHashes,"");
- }
-
- @Test
- public void getNodeUsingUniqueIdTest() throws AAIException{
- vertex.property("vnf-id","vnf-id-1");
- vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
- graphTraversal.addV(vertex);
- v.addV(vertex1);
- vertexList.add(vertex);
- //vertexList.add(vertex1);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
- Mockito.when(graphTraversalSource.V()).thenReturn(v);
- Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
-
- assertNotNull(result);
- }
-
- @Test
- public void getNodeUsingUniqueIdTest1() throws AAIException{
- vertex.property("named-query-uui","vnf-id-1");
- vertex1.property(AAIProperties.NODE_TYPE,"named-query");
- graphTraversal.addV(vertex);
- v.addV(vertex1);
- vertexList.add(vertex);
- //vertexList.add(vertex1);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
- Mockito.when(graphTraversalSource.V()).thenReturn(v);
- Mockito.when(v.has(AAIProperties.NODE_TYPE,"named-query")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.has("named-query-uui","vnf-id-1")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","named-query","named-query-uui","vnf-id-1");
-
- assertNotNull(result);
- }
-
- @Test(expected = AAIException.class)
- public void getModelVersUsingNameTest() throws AAIException{
-
- vertex.property(AAIProperties.NODE_TYPE,"generic-vnf");
- vertex1.property("generic-vnf","generic-vnf");
- graphTraversal.addV(vertex1);
- v.addV(vertex1);
- vertexList.add(vertex);
- vertexList.add(vertex1);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
- Mockito.when(graphTraversalSource.V()).thenReturn(v);
- Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-ver")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.has("model-name","generic-vnf")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
- //Mockito.when(vertexList.listIterator().hasNext()).thenReturn(true);
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- List<Vertex> result=processor.getModelVersUsingName("9999","postment","generic-vnf");
-
- assertTrue(result.size()>0);
- }
-
- //uniqueIdVal Null Expecting AAI Excpetion
- @Test(expected = AAIException.class)
- public void getNodeUsingUniqueIdTestNull() throws AAIException{
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
- Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","");
-
-
- }
-
- //idPropertyName Null Expecting AAI Excpetion
- @Test(expected = AAIException.class)
- public void getNodeUsingUniqueIdTestNull1() throws AAIException{
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
- Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","","vnf-id-1");
-
-
- }
-
- //idPropertyName Null Expecting AAI Excpetion
- @Test(expected = AAIException.class)
- public void getNodeUsingUniqueIdTestNull2() throws AAIException{
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
- Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","","vnf-id","vnf-id-1");
-
-
- }
-
- @Test(expected = AAIException.class)
- public void getNodeUsingUniqueIdTestTwoVertex() throws AAIException{
- vertex.property("vnf-id","vnf-id-1");
- vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
- graphTraversal.addV(vertex);
- v.addV(vertex1);
- vertexList.add(vertex);
- vertexList.add(vertex1);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
- Mockito.when(graphTraversalSource.V()).thenReturn(v);
- Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
-
- assertNotNull(result);
- }
-
- //uniqVerts Null Expection AAI Exception
- @Test(expected = AAIException.class)
- public void getNodeUsingUniqueIdTestVertexNull() throws AAIException{
- vertex.property("vnf-id","vnf-id-1");
- vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
- graphTraversal.addV(vertex);
- v.addV(vertex1);
- vertexList.add(vertex);
- //vertexList.add(vertex1);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
- Mockito.when(graphTraversalSource.V()).thenReturn(v);
- Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.toList()).thenReturn(null);
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
-
- assertNotNull(result);
- }
-
- //uniqVerts Null Expection AAI Exception
- @Test(expected = AAIException.class)
- public void getNodeUsingUniqueIdTestVertexHasNot() throws AAIException{
- vertex.property("vnf-id","vnf-id-1");
- vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf");
- graphTraversal.addV(vertex);
- v.addV(vertex1);
- //vertexList.add(vertex);
- //vertexList.add(vertex1);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
- Mockito.when(graphTraversalSource.V()).thenReturn(v);
- Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1");
-
- assertNotNull(result);
- }
-
- @Test(expected = AAIIdentityMapParseException.class)
- public void runDeleteByModelTest() throws AAIException{
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
- Optional<Vertex> vertex=Optional.empty();
- Map<String,Object> startNodeFilterHash=new HashMap<>();
- startNodeFilterHash.put("related-link.data","relationshipdata");
- startNodeFilterHash.put("generic-vnf.d","relationshipdata");
- Mockito.when(dbMethHelper.searchVertexByIdentityMap("relationship-data",startNodeFilterHash)).thenReturn(vertex);
- Map<String,String> re =processor.runDeleteByModel("9999","postmen","","relationship-data",startNodeFilterHash,"vnf-id","vnf-id");
- assertNotNull(re);
-
-
- }
-
- @Test(expected = AAIException.class)
- public void getModelGivenModelVerTest() throws AAIException{
- vertex.property("named-query-uuid","vnf-id-1");
- vertex1.property(AAIProperties.NODE_TYPE,"named-query");
- graphTraversal.addV(vertex);
- v.addV(vertex1);
- vertexList.add(vertex);
- //vertexList.add(vertex1);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
- Mockito.when(graphTraversalSource.V()).thenReturn(v);
- Mockito.when(v.has(AAIProperties.NODE_TYPE,"named-query")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.has("named-query-uuid","vnf-id-1")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
-
- QueryBuilder qub=Mockito.mock(QueryBuilder.class);
- qub.toList().addAll(vertexList);
- Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
-
- Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
-
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- Vertex result=processor.getModelGivenModelVer(vertex,"");
- assertNotNull(result);
-
- }
-
- @Test(expected = AAIException.class)
- public void queryByNamedQuery_TimedTest() throws AAIException{
- vertex.property("named-query-uuid","named-query-element");
- vertex1.property(AAIProperties.NODE_TYPE,"named-query");
- graphTraversal.addV(vertex);
- v.addV(vertex1);
- vertexList.add(vertex);
- //vertexList.add(vertex1);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
- Mockito.when(graphTraversalSource.V()).thenReturn(v);
- Mockito.when(v.has(AAIProperties.NODE_TYPE,"named-query")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.has("named-query-uuid","named-query-element")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
-
- QueryBuilder qub=Mockito.mock(QueryBuilder.class);
- qub.toList().addAll(vertexList);
- Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
-
- Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
-
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- Map<String,Object> secondaryFilterHash=new HashMap<>();
-
- List<ResultSet> res=processor.queryByNamedQuery_Timed("99999","postmen","named-query-element",startNodeFilterArrayOfHashes,"vnf","vnf",
- secondaryFilterHash);
-
-
- }
-
- @Test(expected = AAIException.class)
- public void genTopoMap4NamedQTest() throws AAIException{
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- vertex.property("named-query-uuid","named-query-element");
- vertex1.property(AAIProperties.NODE_TYPE,"named-query-element");
- graphTraversal.addV(vertex);
- v.addV(vertex1);
- vertexList.add(vertex);
- QueryBuilder qub=Mockito.mock(QueryBuilder.class);
- qub.toList().addAll(vertexList);
- Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
-
- Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
-
- Multimap<String, String> map =processor.genTopoMap4NamedQ("9999","postmen",vertex,"named-query-element");
- }
-
- @Test(expected = AAIException.class)
- public void genTopoMap4NamedQTest1() throws AAIException{
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- vertex.property("named-query-uuid","named-query-element");
- vertex1.property(AAIProperties.NODE_TYPE,"named-query-element");
- graphTraversal.addV(vertex);
- v.addV(vertex1);
- vertexList.add(vertex);
- QueryBuilder qub=Mockito.mock(QueryBuilder.class);
- qub.toList().addAll(vertexList);
- Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
-
- Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
-
- Multimap<String, String> map =processor.genTopoMap4NamedQ("9999","postmen",null,"named-query-element");
- }
-
- @Test(expected = AAIException.class)
- public void getModelThatNqElementRepresentsTest() throws AAIException{
- vertex.property("model-ver","named-query-element");
- vertex1.property(AAIProperties.NODE_TYPE,"named-query-element");
- graphTraversal.addV(vertex);
- v.addV(vertex1);
- vertexList.add(vertex);
- QueryBuilder qub=Mockito.mock(QueryBuilder.class);
- qub.toList().addAll(vertexList);
- Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder);
-
- Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub);
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
- Vertex v=processor.getModelThatNqElementRepresents(vertex,"g");
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelTypeFromModel() throws AAIException{
- Vertex vt=Mockito.mock(Vertex.class);
- vt.property("model-type","named-query-element");
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
- String v=processor.getModelTypeFromModel(vt,"g");
- }
-
- @Test(expected = AAIException.class)
- public void getModelTypeFromModel1() throws AAIException{
- Vertex vt=Mockito.mock(Vertex.class);
- vt.property("model-type","named-query-element");
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
- String v=processor.getModelTypeFromModel(null,"g");
- }
-
- @Test(expected = NullPointerException.class)
- public void getModVersUsingModelInvId() throws AAIException{
-
- vertex.property(AAIProperties.NODE_TYPE,"model-invariant-id");
- vertex1.property("model","model-invariant-id");
- graphTraversal.addV(vertex1);
- v.addV(vertex1);
- vertexList.add(vertex);
- vertexList.add(vertex1);
- Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
- Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource);
- Mockito.when(graphTraversalSource.V()).thenReturn(v);
- Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-invariant-id")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.has("model","model-invariant-id")).thenReturn(graphTraversal);
- Mockito.when(graphTraversal.toList()).thenReturn(vertexList);
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- Iterator<Vertex> result=processor.getModVersUsingModelInvId("9999","postment","model");
- }
-
- @Test(expected = AAIException.class)
- public void getNamedQueryExtraDataLookupTest() throws AAIException{
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- Map<String,Object> re=processor.getNamedQueryExtraDataLookup("","",null,vertex,
- "");
- }
-
- @Test(expected = AAIException.class)
- public void getNamedQueryExtraDataLookupTest1() throws AAIException{
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- Map<String,Object> re=processor.getNamedQueryExtraDataLookup("","",vertex,null,
- "");
- }
-
- @Test(expected = NullPointerException.class)
- public void showResultSet() throws AAIException{
- vertex.property("model-ver","model-versionId");
- vertex.property("aai","model-versionId");
-
-
- ResultSet rs= Mockito.mock(ResultSet.class);
- Mockito.when(rs.getVert()).thenReturn(vertex);
-
- List<VertexProperty<String>> vb=new ArrayList<>();
- VertexProperty<String> v=Mockito.mock(VertexProperty.class);
- v.property("model-ver","1");
- vb.add(v);
- v.property("aai","5");
- vb.add(v);
- v.property("source-of-truth","6");
- vb.add(v);
-
- vertex.properties("model-ver","aai");
- Mockito.when(vertex.<String>property(AAIProperties.NODE_TYPE)).thenReturn(v);
- //Mockito.when(vertex.properties()).thenReturn(Mockito.any());
- ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
- processor.showResultSet(rs,8);
-
- }
-}
+/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.dbgraphgen; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import com.bazaarvoice.jolt.modifier.DataType; +import com.google.common.collect.Multimap; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.structure.VertexProperty; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.*; +import org.mockito.internal.exceptions.MockitoLimitations; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.aai.db.DbMethHelper; +import org.onap.aai.db.props.AAIProperties; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.introspection.Introspector; +import org.onap.aai.introspection.Loader; +import org.onap.aai.introspection.LoaderFactory; +import org.onap.aai.introspection.ModelType; +import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; +import org.onap.aai.parsers.exceptions.AAIIdentityMapParseException; +import org.onap.aai.query.builder.GraphTraversalBuilder; +import org.onap.aai.query.builder.QueryBuilder; +import org.onap.aai.query.builder.TraversalQuery; +import org.onap.aai.schema.enums.PropertyMetadata; +import org.onap.aai.serialization.db.DBSerializer; +import org.onap.aai.serialization.db.EdgeType; +import org.onap.aai.serialization.engines.QueryStyle; +import org.onap.aai.serialization.engines.TransactionalGraphEngine; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.*; + +@RunWith(MockitoJUnitRunner.class) +public class ModelBasedProcessingTest { + + @Mock private static TransactionalGraphEngine dbEngine; + private static Loader loader; + @Mock private static DBSerializer serializer; + @Mock private static TransactionalGraphEngine.Admin admin; + ModelBasedProcessing mockProcessor; + @Mock + private DbMethHelper dbMethHelper; + + @BeforeClass + public static void configure() throws Exception { + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST); + + + } + + @Before + public void init() { + mockProcessor = new ModelBasedProcessing(loader, dbEngine, serializer); + + MockitoAnnotations.initMocks(this); + } + + @Test + public void testPropNameChange1() throws AAIUnknownObjectException { + String result; + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "model-invariant-id"); + assertEquals("result has -local tacked on the end as it should", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX, result); + result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "vnf-id"); + assertEquals("result does NOT have -local tacked on the end as it should", "vnf-id", result); + result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX); + assertEquals("property not modified because it already includes the right suffix", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX, result); + } + + @Mock + GraphTraversal<Vertex, Vertex> v; + @Mock + GraphTraversal<Vertex, Vertex> graphTraversal; + @Mock + GraphTraversalSource graphTraversalSource; + @Mock Iterable <?> uniqVerts; + List<Vertex> vertexList=new ArrayList<>(); + @Mock Vertex vertex; + @Mock Vertex vertex1; + @Mock + QueryBuilder<Vertex> queryBuilder; + + EdgeType treeType; + @Test(expected = NullPointerException.class) + public void getStartNodesAndModVersionIds() throws AAIException{ + + vertex.property("model-ver","model-version-id"); + vertex1.property(AAIProperties.NODE_TYPE,"model-ver"); + graphTraversal.addV(vertex); + v.addV(vertex1); + vertexList.add(vertex); + //vertexList.add(vertex1); + Mockito.when(dbEngine.asAdmin()).thenReturn(admin); + Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource); + Mockito.when(graphTraversalSource.V()).thenReturn(v); + Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-ver")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.has("model-ver","model-version-id")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.toList()).thenReturn(vertexList); + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + //this.engine.getQueryBuilder(startV).createEdgeTraversal(treeType, startV, loader.introspectorFromName(connectedNodeType)); + + queryBuilder.toList().add(vertex); + Mockito.when(dbEngine.getQueryBuilder(vertex)).thenReturn(queryBuilder); + + Introspector obj=loader.introspectorFromName("model-ver"); + + Mockito.when(queryBuilder.createEdgeTraversal(EdgeType.TREE,vertex,obj)).thenReturn(queryBuilder); + //Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","model-ver","model-version-id","vnf-id-1"); + + + List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>(); + + Map<String,String> result1=processor.getStartNodesAndModVersionIds("9999","postmen","vnf-id-1","vnf-id-1", + "vnf-id","generic-vnf",startNodeFilterArrayOfHashes,""); + } + + + @Test(expected = AAIException.class) + public void getStartNodesAndModVersionIds1() throws AAIException{ + + vertex.property("model-version-id","vnf-id-1"); + vertex1.property(AAIProperties.NODE_TYPE,"model-ver"); + graphTraversal.addV(vertex); + v.addV(vertex1); + vertexList.add(vertex); + //vertexList.add(vertex1); + Mockito.when(dbEngine.asAdmin()).thenReturn(admin); + Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource); + Mockito.when(graphTraversalSource.V()).thenReturn(v); + Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-ver")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.has("model-version-id","vnf-id-1")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.toList()).thenReturn(vertexList); + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + //this.engine.getQueryBuilder(startV).createEdgeTraversal(treeType, startV, loader.introspectorFromName(connectedNodeType)); + + queryBuilder.toList().add(vertex); + Mockito.when(dbEngine.getQueryBuilder(vertex)).thenReturn(queryBuilder); + + Introspector obj=loader.introspectorFromName("generic-vnf"); + Mockito.when(queryBuilder.createEdgeTraversal(EdgeType.TREE,vertex,obj)).thenReturn(queryBuilder); + //Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","model-ver","model-version-id","vnf-id-1"); + + + List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>(); + + Map<String,String> result1=processor.getStartNodesAndModVersionIds("9999","postmen","vnf-id-1","vnf-id-1", + "vnf-id","generic-vnf",startNodeFilterArrayOfHashes,""); + } + + @Test + public void getNodeUsingUniqueIdTest() throws AAIException{ + vertex.property("vnf-id","vnf-id-1"); + vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf"); + graphTraversal.addV(vertex); + v.addV(vertex1); + vertexList.add(vertex); + //vertexList.add(vertex1); + Mockito.when(dbEngine.asAdmin()).thenReturn(admin); + Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource); + Mockito.when(graphTraversalSource.V()).thenReturn(v); + Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.toList()).thenReturn(vertexList); + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + + Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1"); + + assertNotNull(result); + } + + @Test + public void getNodeUsingUniqueIdTest1() throws AAIException{ + vertex.property("named-query-uui","vnf-id-1"); + vertex1.property(AAIProperties.NODE_TYPE,"named-query"); + graphTraversal.addV(vertex); + v.addV(vertex1); + vertexList.add(vertex); + //vertexList.add(vertex1); + Mockito.when(dbEngine.asAdmin()).thenReturn(admin); + Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource); + Mockito.when(graphTraversalSource.V()).thenReturn(v); + Mockito.when(v.has(AAIProperties.NODE_TYPE,"named-query")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.has("named-query-uui","vnf-id-1")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.toList()).thenReturn(vertexList); + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + + Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","named-query","named-query-uui","vnf-id-1"); + + assertNotNull(result); + } + + @Test(expected = AAIException.class) + public void getModelVersUsingNameTest() throws AAIException{ + + vertex.property(AAIProperties.NODE_TYPE,"generic-vnf"); + vertex1.property("generic-vnf","generic-vnf"); + graphTraversal.addV(vertex1); + v.addV(vertex1); + vertexList.add(vertex); + vertexList.add(vertex1); + Mockito.when(dbEngine.asAdmin()).thenReturn(admin); + Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource); + Mockito.when(graphTraversalSource.V()).thenReturn(v); + Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-ver")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.has("model-name","generic-vnf")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.toList()).thenReturn(vertexList); + //Mockito.when(vertexList.listIterator().hasNext()).thenReturn(true); + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + + List<Vertex> result=processor.getModelVersUsingName("9999","postment","generic-vnf"); + + assertTrue(result.size()>0); + } + + //uniqueIdVal Null Expecting AAI Excpetion + @Test(expected = AAIException.class) + public void getNodeUsingUniqueIdTestNull() throws AAIException{ + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id",""); + + + } + + //idPropertyName Null Expecting AAI Excpetion + @Test(expected = AAIException.class) + public void getNodeUsingUniqueIdTestNull1() throws AAIException{ + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","","vnf-id-1"); + + + } + + //idPropertyName Null Expecting AAI Excpetion + @Test(expected = AAIException.class) + public void getNodeUsingUniqueIdTestNull2() throws AAIException{ + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","","vnf-id","vnf-id-1"); + + + } + + @Test(expected = AAIException.class) + public void getNodeUsingUniqueIdTestTwoVertex() throws AAIException{ + vertex.property("vnf-id","vnf-id-1"); + vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf"); + graphTraversal.addV(vertex); + v.addV(vertex1); + vertexList.add(vertex); + vertexList.add(vertex1); + Mockito.when(dbEngine.asAdmin()).thenReturn(admin); + Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource); + Mockito.when(graphTraversalSource.V()).thenReturn(v); + Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.toList()).thenReturn(vertexList); + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + + Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1"); + + assertNotNull(result); + } + + //uniqVerts Null Expection AAI Exception + @Test(expected = AAIException.class) + public void getNodeUsingUniqueIdTestVertexNull() throws AAIException{ + vertex.property("vnf-id","vnf-id-1"); + vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf"); + graphTraversal.addV(vertex); + v.addV(vertex1); + vertexList.add(vertex); + //vertexList.add(vertex1); + Mockito.when(dbEngine.asAdmin()).thenReturn(admin); + Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource); + Mockito.when(graphTraversalSource.V()).thenReturn(v); + Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.toList()).thenReturn(null); + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + + Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1"); + + assertNotNull(result); + } + + //uniqVerts Null Expection AAI Exception + @Test(expected = AAIException.class) + public void getNodeUsingUniqueIdTestVertexHasNot() throws AAIException{ + vertex.property("vnf-id","vnf-id-1"); + vertex1.property(AAIProperties.NODE_TYPE,"generic-vnf"); + graphTraversal.addV(vertex); + v.addV(vertex1); + //vertexList.add(vertex); + //vertexList.add(vertex1); + Mockito.when(dbEngine.asAdmin()).thenReturn(admin); + Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource); + Mockito.when(graphTraversalSource.V()).thenReturn(v); + Mockito.when(v.has(AAIProperties.NODE_TYPE,"generic-vnf")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.has("vnf-id","vnf-id-1")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.toList()).thenReturn(vertexList); + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + + Vertex result=processor.getNodeUsingUniqueId("9999", "postmen","generic-vnf","vnf-id","vnf-id-1"); + + assertNotNull(result); + } + + @Test(expected = AAIIdentityMapParseException.class) + public void runDeleteByModelTest() throws AAIException{ + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + Optional<Vertex> vertex=Optional.empty(); + Map<String,Object> startNodeFilterHash=new HashMap<>(); + startNodeFilterHash.put("related-link.data","relationshipdata"); + startNodeFilterHash.put("generic-vnf.d","relationshipdata"); + Mockito.when(dbMethHelper.searchVertexByIdentityMap("relationship-data",startNodeFilterHash)).thenReturn(vertex); + Map<String,String> re =processor.runDeleteByModel("9999","postmen","","relationship-data",startNodeFilterHash,"vnf-id","vnf-id"); + assertNotNull(re); + + + } + + @Test(expected = AAIException.class) + public void getModelGivenModelVerTest() throws AAIException{ + vertex.property("named-query-uuid","vnf-id-1"); + vertex1.property(AAIProperties.NODE_TYPE,"named-query"); + graphTraversal.addV(vertex); + v.addV(vertex1); + vertexList.add(vertex); + //vertexList.add(vertex1); + Mockito.when(dbEngine.asAdmin()).thenReturn(admin); + Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource); + Mockito.when(graphTraversalSource.V()).thenReturn(v); + Mockito.when(v.has(AAIProperties.NODE_TYPE,"named-query")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.has("named-query-uuid","vnf-id-1")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.toList()).thenReturn(vertexList); + + QueryBuilder qub=Mockito.mock(QueryBuilder.class); + qub.toList().addAll(vertexList); + Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder); + + Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub); + + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + + Vertex result=processor.getModelGivenModelVer(vertex,""); + assertNotNull(result); + + } + + @Test(expected = AAIException.class) + public void queryByNamedQuery_TimedTest() throws AAIException{ + vertex.property("named-query-uuid","named-query-element"); + vertex1.property(AAIProperties.NODE_TYPE,"named-query"); + graphTraversal.addV(vertex); + v.addV(vertex1); + vertexList.add(vertex); + //vertexList.add(vertex1); + Mockito.when(dbEngine.asAdmin()).thenReturn(admin); + Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource); + Mockito.when(graphTraversalSource.V()).thenReturn(v); + Mockito.when(v.has(AAIProperties.NODE_TYPE,"named-query")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.has("named-query-uuid","named-query-element")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.toList()).thenReturn(vertexList); + + QueryBuilder qub=Mockito.mock(QueryBuilder.class); + qub.toList().addAll(vertexList); + Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder); + + Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub); + + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + + List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>(); + Map<String,Object> secondaryFilterHash=new HashMap<>(); + + List<ResultSet> res=processor.queryByNamedQuery_Timed("99999","postmen","named-query-element",startNodeFilterArrayOfHashes,"vnf","vnf", + secondaryFilterHash); + + + } + + @Test(expected = AAIException.class) + public void genTopoMap4NamedQTest() throws AAIException{ + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + + vertex.property("named-query-uuid","named-query-element"); + vertex1.property(AAIProperties.NODE_TYPE,"named-query-element"); + graphTraversal.addV(vertex); + v.addV(vertex1); + vertexList.add(vertex); + QueryBuilder qub=Mockito.mock(QueryBuilder.class); + qub.toList().addAll(vertexList); + Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder); + + Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub); + + Multimap<String, String> map =processor.genTopoMap4NamedQ("9999","postmen",vertex,"named-query-element"); + } + + @Test(expected = AAIException.class) + public void genTopoMap4NamedQTest1() throws AAIException{ + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + + vertex.property("named-query-uuid","named-query-element"); + vertex1.property(AAIProperties.NODE_TYPE,"named-query-element"); + graphTraversal.addV(vertex); + v.addV(vertex1); + vertexList.add(vertex); + QueryBuilder qub=Mockito.mock(QueryBuilder.class); + qub.toList().addAll(vertexList); + Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder); + + Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub); + + Multimap<String, String> map =processor.genTopoMap4NamedQ("9999","postmen",null,"named-query-element"); + } + + @Test(expected = AAIException.class) + public void getModelThatNqElementRepresentsTest() throws AAIException{ + vertex.property("model-ver","named-query-element"); + vertex1.property(AAIProperties.NODE_TYPE,"named-query-element"); + graphTraversal.addV(vertex); + v.addV(vertex1); + vertexList.add(vertex); + QueryBuilder qub=Mockito.mock(QueryBuilder.class); + qub.toList().addAll(vertexList); + Mockito.when(dbEngine.getQueryBuilder(Mockito.any(Vertex.class))).thenReturn(queryBuilder); + + Mockito.when(queryBuilder.createEdgeTraversal(Mockito.any(EdgeType.class),Mockito.any(Vertex.class),Mockito.any(Introspector.class))).thenReturn(qub); + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + Vertex v=processor.getModelThatNqElementRepresents(vertex,"g"); + } + + @Test(expected = NullPointerException.class) + public void getModelTypeFromModel() throws AAIException{ + Vertex vt=Mockito.mock(Vertex.class); + vt.property("model-type","named-query-element"); + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + String v=processor.getModelTypeFromModel(vt,"g"); + } + + @Test(expected = AAIException.class) + public void getModelTypeFromModel1() throws AAIException{ + Vertex vt=Mockito.mock(Vertex.class); + vt.property("model-type","named-query-element"); + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + String v=processor.getModelTypeFromModel(null,"g"); + } + + @Test(expected = NullPointerException.class) + public void getModVersUsingModelInvId() throws AAIException{ + + vertex.property(AAIProperties.NODE_TYPE,"model-invariant-id"); + vertex1.property("model","model-invariant-id"); + graphTraversal.addV(vertex1); + v.addV(vertex1); + vertexList.add(vertex); + vertexList.add(vertex1); + Mockito.when(dbEngine.asAdmin()).thenReturn(admin); + Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(graphTraversalSource); + Mockito.when(graphTraversalSource.V()).thenReturn(v); + Mockito.when(v.has(AAIProperties.NODE_TYPE,"model-invariant-id")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.has("model","model-invariant-id")).thenReturn(graphTraversal); + Mockito.when(graphTraversal.toList()).thenReturn(vertexList); + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + + Iterator<Vertex> result=processor.getModVersUsingModelInvId("9999","postment","model"); + } + + @Test(expected = AAIException.class) + public void getNamedQueryExtraDataLookupTest() throws AAIException{ + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + + Map<String,Object> re=processor.getNamedQueryExtraDataLookup("","",null,vertex, + ""); + } + + @Test(expected = AAIException.class) + public void getNamedQueryExtraDataLookupTest1() throws AAIException{ + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + + Map<String,Object> re=processor.getNamedQueryExtraDataLookup("","",vertex,null, + ""); + } + + @Test(expected = NullPointerException.class) + public void showResultSet() throws AAIException{ + vertex.property("model-ver","model-versionId"); + vertex.property("aai","model-versionId"); + + + ResultSet rs= Mockito.mock(ResultSet.class); + Mockito.when(rs.getVert()).thenReturn(vertex); + + List<VertexProperty<String>> vb=new ArrayList<>(); + VertexProperty<String> v=Mockito.mock(VertexProperty.class); + v.property("model-ver","1"); + vb.add(v); + v.property("aai","5"); + vb.add(v); + v.property("source-of-truth","6"); + vb.add(v); + + vertex.properties("model-ver","aai"); + Mockito.when(vertex.<String>property(AAIProperties.NODE_TYPE)).thenReturn(v); + //Mockito.when(vertex.properties()).thenReturn(Mockito.any()); + ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + processor.showResultSet(rs,8); + + } +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphmap/SearchGraphTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java index 49ad810..f624828 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphmap/SearchGraphTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java @@ -1,378 +1,379 @@ -/*-
- * ============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.dbgraphmap;
-
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.graphdb.types.system.EmptyVertex;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.velocity.util.ArrayListWrapper;
-import org.eclipse.persistence.dynamic.DynamicEntity;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.openecomp.aai.dbgraphgen.ModelBasedProcessing;
-import org.openecomp.aai.dbmap.DBConnectionType;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.extensions.AAIExtensionMap;
-import org.openecomp.aai.introspection.*;
-import org.openecomp.aai.parsers.relationship.RelationshipToURI;
-import org.openecomp.aai.serialization.db.DBSerializer;
-import org.openecomp.aai.serialization.engines.QueryStyle;
-import org.openecomp.aai.serialization.engines.TitanDBEngine;
-import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder;
-
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.*;
-import java.net.URI;
-import java.sql.ResultSet;
-import java.util.*;
-import java.util.stream.Stream;
-
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.*;
-
-public class SearchGraphTest {
-
- private SearchGraph searchGraph;
-
- protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
-
- private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
-
- private final static Version version = Version.getLatest();
- private final static ModelType introspectorFactoryType = ModelType.MOXY;
- private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private final static DBConnectionType type = DBConnectionType.REALTIME;
-
- static {
- VALID_HTTP_STATUS_CODES.add(200);
- VALID_HTTP_STATUS_CODES.add(201);
- VALID_HTTP_STATUS_CODES.add(204);
- }
-
- private HttpHeaders httpHeaders;
-
- private UriInfo uriInfo;
-
- private MultivaluedMap<String, String> headersMultiMap;
- private MultivaluedMap<String, String> queryParameters;
-
- private List<String> aaiRequestContextList;
-
- private List<MediaType> outputMediaTypes;
-
- private Loader loader;
- private TitanGraph graph;
-
- private Graph tx;
-
- private GraphTraversalSource g;
- private TransactionalGraphEngine dbEngine;
-
- @Before
- public void setup(){
-
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
-
- searchGraph = new SearchGraph();
-
- httpHeaders = mock(HttpHeaders.class);
- uriInfo = mock(UriInfo.class);
-
- headersMultiMap = new MultivaluedHashMap<>();
- queryParameters = Mockito.spy(new MultivaluedHashMap<>());
-
- headersMultiMap.add("X-FromAppId", "JUNIT");
- headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
- headersMultiMap.add("Real-Time", "true");
- headersMultiMap.add("Accept", "application/json");
- headersMultiMap.add("aai-request-context", "");
-
- outputMediaTypes = new ArrayList<>();
- outputMediaTypes.add(APPLICATION_JSON);
-
- aaiRequestContextList = new ArrayList<>();
- aaiRequestContextList.add("");
-
- when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
- when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
- when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Arrays.asList("JUNIT"));
- when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Arrays.asList("JUNIT"));
-
- when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
-
-
- when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
- when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
-
- // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
- Mockito.doReturn(null).when(queryParameters).remove(anyObject());
-
- when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new TitanDBEngine(
- queryStyle,
- type,
- loader);
- }
-
-@Test(expected = AAIException.class)
- public void runNodesQuery() throws AAIException{
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
- searchGraph.runNodesQuery(httpHeaders,"",null,
- null,dbEngine,loader,urlBuilder);
- }
- @Test(expected = AAIException.class)
- public void runNodesQueryNull() throws AAIException{
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
- searchGraph.runNodesQuery(httpHeaders,"nnn",null,
- null,dbEngine,loader,urlBuilder);
- }
- @Test(expected = AAIException.class)
- public void testRunGenericQueryFailWhenInvalidRelationshipList() throws AAIException {
-
- List<String> keys = new ArrayList<>();
- keys.add("cloud-region.cloud-owner:test-aic");
-
- List<String> includeStrings = new ArrayList<>();
- includeStrings.add("cloud-region");
-
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
- Response response = searchGraph.runGenericQuery(httpHeaders, "service-instance", keys, includeStrings, 1, dbEngine, loader, urlBuilder);
- System.out.println(response);
- }
-
-
- @Test(expected = AAIException.class)
- public void testRunGenericQueryFailWhenInvalidRelationshipList1() throws AAIException {
-
- List<String> keys = new ArrayList<>();
- keys.add("cloud-region.cloud-owner:test-aic");
-
- List<String> includeStrings = new ArrayList<>();
- includeStrings.add("cloud-region");
-
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
- Response response = searchGraph.runGenericQuery(httpHeaders, null, keys, includeStrings, 1, dbEngine, loader, urlBuilder);
- System.out.println(response);
- }
-
- @Test(expected = AAIException.class)
- public void testRunGenericQueryFailWhenInvalidRelationshipList2() throws AAIException {
-
- List<String> keys = new ArrayList<>();
- keys.add("cloud-region.cloud-owner:test-aic");
-
- List<String> includeStrings = new ArrayList<>();
- includeStrings.add("cloud-region");
-
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
- Response response = searchGraph.runGenericQuery(httpHeaders, "", null, includeStrings, 1, dbEngine, loader, urlBuilder);
- System.out.println(response);
- }
-
- @Test(expected = AAIException.class)
- public void testRunGenericQueryFailWhenInvalidRelationshipList3() throws AAIException {
-
- List<String> keys = new ArrayList<>();
- keys.add("cloud-region.cloud-owner:test-aic");
-
- List<String> includeStrings = new ArrayList<>();
- includeStrings.add("cloud-region");
-
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
- Response response = searchGraph.runGenericQuery(httpHeaders, "", keys, null, 1, dbEngine, loader, urlBuilder);
- System.out.println(response);
- }
-
-
- /*@Test(expected = NullPointerException.class)
- public void createSearchResults() throws AAIException {
-
- List<Vertex> keys = new ArrayList<>();
- Vertex vertex=new EmptyVertex();
- keys.add(vertex);
-
-
-
- List<String> includeStrings = new ArrayList<>();
- includeStrings.add("cloud-region");
-
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
- Introspector response = searchGraph.createSearchResults(loader, urlBuilder, keys);
- System.out.println(response);
- }*/
- @Test
- public void createSearchResults1() throws Exception {
-
- List<Vertex> keys = new ArrayList<>();
- Vertex vertex=new EmptyVertex();
- keys.add(vertex);
- DBSerializer ds=mock(DBSerializer.class);
- UrlBuilder urlBuilder=mock(UrlBuilder.class);
- when(urlBuilder.pathed(vertex)).thenReturn("cloud-region");
- Stream<Vertex> stream=mock(Stream.class);
- when(stream.isParallel()).thenReturn(true);
- List<String> includeStrings = new ArrayList<>();
- includeStrings.add("cloud-region");
- RelationshipToURI relationshipToURI=mock(RelationshipToURI.class);
- URI uri =new URI("");
- when(relationshipToURI.getUri()).thenReturn(uri);
-
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- // UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
- Introspector response = searchGraph.createSearchResults(loader, urlBuilder, keys);
- System.out.println(response);
- }
- @Test(expected = AAIException.class)
- public void executeModelOperationTest() throws Exception{
- Vertex vertex=new EmptyVertex();
- vertex.property("model-name");
- Map<String,Object> mapObj=new HashMap<String,Object>();
- mapObj.put("modle-version",vertex);
- List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- startNodeFilterArrayOfHashes.add(mapObj);
- List<org.openecomp.aai.dbgraphgen.ResultSet> resultSet=new ArrayList<org.openecomp.aai.dbgraphgen.ResultSet>();
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- // ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
- AAIExtensionMap map=mock(AAIExtensionMap.class);
- HttpServletRequest servletRequest=mock(HttpServletRequest.class);
-
- when(map.getHttpServletRequest()).thenReturn(servletRequest);
- when(servletRequest.getContentType()).thenReturn("application/json");
- DynamicEntity modelAndNamedQuerySearch=mock(DynamicEntity.class);
- when(modelAndNamedQuerySearch.isSet("topNodeType")).thenReturn(true);
-
-
-/* when(processor.queryByModel("9999","model-ver","model-version-id",
- "model-inv-id","modelname","aai",
- startNodeFilterArrayOfHashes,"aai-ver")).thenReturn(resultSet);*/
-
- searchGraph.executeModelOperation("","","",type,true,
- map);
- }
-
- @Test(expected = AAIException.class)
- public void executeModelOperationXMLTest() throws Exception{
- Vertex vertex=new EmptyVertex();
- vertex.property("model-name");
- Map<String,Object> mapObj=new HashMap<String,Object>();
- mapObj.put("modle-version",vertex);
- List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- startNodeFilterArrayOfHashes.add(mapObj);
- List<org.openecomp.aai.dbgraphgen.ResultSet> resultSet=new ArrayList<org.openecomp.aai.dbgraphgen.ResultSet>();
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- // ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
- AAIExtensionMap map=mock(AAIExtensionMap.class);
- HttpServletRequest servletRequest=mock(HttpServletRequest.class);
-
- when(map.getHttpServletRequest()).thenReturn(servletRequest);
- when(servletRequest.getContentType()).thenReturn("application/xml");
-
- DynamicEntity modelAndNamedQuerySearch=mock(DynamicEntity.class);
- when(modelAndNamedQuerySearch.isSet("queryParameters")).thenReturn(true);
-/* when(processor.queryByModel("9999","model-ver","model-version-id",
- "model-inv-id","modelname","aai",
- startNodeFilterArrayOfHashes,"aai-ver")).thenReturn(resultSet);*/
-
- searchGraph.executeModelOperation("","","",type,true,
- map);
- }
- @Test
- public void runNodesQueryTest() throws AAIException{
- UrlBuilder urlBuilder=mock(UrlBuilder.class);
- List<String> filter=new ArrayList<String>();
- filter.add("model:EQUALS:DOES-NOT-EXIST:AAI");
- List<String> edgeFilter=new ArrayList<String>();
- edgeFilter.add("model:DOES-NOT-EXIST:DOES-NOT-EXIST:AAI");
- Response response= searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter,
- filter,dbEngine,loader,urlBuilder);
- Assert.assertNotNull(response);
- }
-
- @Test
- public void runNodesQueryExistsTest() throws AAIException{
- UrlBuilder urlBuilder=mock(UrlBuilder.class);
- List<String> filter=new ArrayList<String>();
- filter.add("model:EQUALS:DOES-NOT-EXIST:AAI");
- List<String> edgeFilter=new ArrayList<String>();
- edgeFilter.add("model:EXISTS:DOES-NOT-EXIST:AAI");
- Response response= searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter,
- filter,dbEngine,loader,urlBuilder);
- Assert.assertNotNull(response);
- }
-
- @Test
- public void runNodesQueryTestDOESNOTEQUAL() throws AAIException{
- UrlBuilder urlBuilder=mock(UrlBuilder.class);
- List<String> filter=new ArrayList<String>();
- filter.add("model:DOES-NOT-EQUAL:DOES-NOT-EXIST");
- List<String> edgeFilter=new ArrayList<String>();
- searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter,
- filter,dbEngine,loader,urlBuilder);
- }
-
- @Test
- public void runNodesQueryTestGreaterThan3() throws AAIException{
- UrlBuilder urlBuilder=mock(UrlBuilder.class);
- List<String> filter=new ArrayList<String>();
- filter.add("model:DOES-NOT-EQUAL:DOES-NOT-EXIST:AAI");
- List<String> edgeFilter=new ArrayList<String>();
- searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter,
- filter,dbEngine,loader,urlBuilder);
- }
-
- @Test
- public void runNodesQueryTestGreaterThanExists() throws AAIException{
- UrlBuilder urlBuilder=mock(UrlBuilder.class);
- List<String> filter=new ArrayList<String>();
- filter.add("model:EXISTS:DOES-NOT-EXIST:AAI");
- List<String> edgeFilter=new ArrayList<String>();
- searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter,
- filter,dbEngine,loader,urlBuilder);
- }
-
- @Test(expected = AAIException.class)
- public void runNodesQueryTestGreaterThanDoesNotExists() throws AAIException{
- UrlBuilder urlBuilder=mock(UrlBuilder.class);
- List<String> filter=new ArrayList<String>();
- filter.add("model:DOES_NOT_EXIST:DOES-NOT-EXIST:AAI");
- List<String> edgeFilter=new ArrayList<String>();
- searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter,
- filter,dbEngine,loader,urlBuilder);
- }
+/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.dbgraphmap; + +import com.thinkaurelius.titan.core.TitanGraph; +import com.thinkaurelius.titan.graphdb.types.system.EmptyVertex; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.structure.VertexProperty; +import org.apache.velocity.util.ArrayListWrapper; +import org.eclipse.persistence.dynamic.DynamicEntity; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aai.dbgraphgen.ModelBasedProcessing; +import org.onap.aai.dbmap.DBConnectionType; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.extensions.AAIExtensionMap; +import org.onap.aai.introspection.*; +import org.onap.aai.parsers.relationship.RelationshipToURI; +import org.onap.aai.serialization.db.DBSerializer; +import org.onap.aai.serialization.engines.QueryStyle; +import org.onap.aai.serialization.engines.TitanDBEngine; +import org.onap.aai.serialization.engines.TransactionalGraphEngine; +import org.onap.aai.serialization.queryformats.utils.UrlBuilder; + + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.*; +import java.net.URI; +import java.sql.ResultSet; +import java.util.*; +import java.util.stream.Stream; + +import static org.mockito.Matchers.anyObject; +import static org.mockito.Mockito.*; + +public class SearchGraphTest { + + private SearchGraph searchGraph; + + protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json"); + + private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>(); + + private final static Version version = Version.getLatest(); + private final static ModelType introspectorFactoryType = ModelType.MOXY; + private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL; + private final static DBConnectionType type = DBConnectionType.REALTIME; + + static { + VALID_HTTP_STATUS_CODES.add(200); + VALID_HTTP_STATUS_CODES.add(201); + VALID_HTTP_STATUS_CODES.add(204); + } + + private HttpHeaders httpHeaders; + + private UriInfo uriInfo; + + private MultivaluedMap<String, String> headersMultiMap; + private MultivaluedMap<String, String> queryParameters; + + private List<String> aaiRequestContextList; + + private List<MediaType> outputMediaTypes; + + private Loader loader; + private TitanGraph graph; + + private Graph tx; + + private GraphTraversalSource g; + private TransactionalGraphEngine dbEngine; + + @Before + public void setup(){ + + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + + searchGraph = new SearchGraph(); + + httpHeaders = mock(HttpHeaders.class); + uriInfo = mock(UriInfo.class); + + headersMultiMap = new MultivaluedHashMap<>(); + queryParameters = Mockito.spy(new MultivaluedHashMap<>()); + + headersMultiMap.add("X-FromAppId", "JUNIT"); + headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString()); + headersMultiMap.add("Real-Time", "true"); + headersMultiMap.add("Accept", "application/json"); + headersMultiMap.add("aai-request-context", ""); + + outputMediaTypes = new ArrayList<>(); + outputMediaTypes.add(APPLICATION_JSON); + + aaiRequestContextList = new ArrayList<>(); + aaiRequestContextList.add(""); + + when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes); + when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap); + when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Arrays.asList("JUNIT")); + when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Arrays.asList("JUNIT")); + + when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList); + + + when(uriInfo.getQueryParameters()).thenReturn(queryParameters); + when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters); + + // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable + Mockito.doReturn(null).when(queryParameters).remove(anyObject()); + + when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON); + loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); + dbEngine = new TitanDBEngine( + queryStyle, + type, + loader); + } + +@Test(expected = AAIException.class) + public void runNodesQuery() throws AAIException{ + DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT"); + UrlBuilder urlBuilder = new UrlBuilder(version, serializer); + searchGraph.runNodesQuery(httpHeaders,"",null, + null,dbEngine,loader,urlBuilder); + } + @Test(expected = AAIException.class) + public void runNodesQueryNull() throws AAIException{ + DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT"); + UrlBuilder urlBuilder = new UrlBuilder(version, serializer); + searchGraph.runNodesQuery(httpHeaders,"nnn",null, + null,dbEngine,loader,urlBuilder); + } + @Test(expected = AAIException.class) + public void testRunGenericQueryFailWhenInvalidRelationshipList() throws AAIException { + + List<String> keys = new ArrayList<>(); + keys.add("cloud-region.cloud-owner:test-aic"); + + List<String> includeStrings = new ArrayList<>(); + includeStrings.add("cloud-region"); + + DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT"); + UrlBuilder urlBuilder = new UrlBuilder(version, serializer); + Response response = searchGraph.runGenericQuery(httpHeaders, "service-instance", keys, includeStrings, 1, dbEngine, loader, urlBuilder); + System.out.println(response); + } + + + @Test(expected = AAIException.class) + public void testRunGenericQueryFailWhenInvalidRelationshipList1() throws AAIException { + + List<String> keys = new ArrayList<>(); + keys.add("cloud-region.cloud-owner:test-aic"); + + List<String> includeStrings = new ArrayList<>(); + includeStrings.add("cloud-region"); + + DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT"); + UrlBuilder urlBuilder = new UrlBuilder(version, serializer); + Response response = searchGraph.runGenericQuery(httpHeaders, null, keys, includeStrings, 1, dbEngine, loader, urlBuilder); + System.out.println(response); + } + + @Test(expected = AAIException.class) + public void testRunGenericQueryFailWhenInvalidRelationshipList2() throws AAIException { + + List<String> keys = new ArrayList<>(); + keys.add("cloud-region.cloud-owner:test-aic"); + + List<String> includeStrings = new ArrayList<>(); + includeStrings.add("cloud-region"); + + DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT"); + UrlBuilder urlBuilder = new UrlBuilder(version, serializer); + Response response = searchGraph.runGenericQuery(httpHeaders, "", null, includeStrings, 1, dbEngine, loader, urlBuilder); + System.out.println(response); + } + + @Test(expected = AAIException.class) + public void testRunGenericQueryFailWhenInvalidRelationshipList3() throws AAIException { + + List<String> keys = new ArrayList<>(); + keys.add("cloud-region.cloud-owner:test-aic"); + + List<String> includeStrings = new ArrayList<>(); + includeStrings.add("cloud-region"); + + DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT"); + UrlBuilder urlBuilder = new UrlBuilder(version, serializer); + Response response = searchGraph.runGenericQuery(httpHeaders, "", keys, null, 1, dbEngine, loader, urlBuilder); + System.out.println(response); + } + + + /*@Test(expected = NullPointerException.class) + public void createSearchResults() throws AAIException { + + List<Vertex> keys = new ArrayList<>(); + Vertex vertex=new EmptyVertex(); + keys.add(vertex); + + + + List<String> includeStrings = new ArrayList<>(); + includeStrings.add("cloud-region"); + + DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT"); + UrlBuilder urlBuilder = new UrlBuilder(version, serializer); + Introspector response = searchGraph.createSearchResults(loader, urlBuilder, keys); + System.out.println(response); + }*/ + @Test + public void createSearchResults1() throws Exception { + + List<Vertex> keys = new ArrayList<>(); + Vertex vertex=new EmptyVertex(); + keys.add(vertex); + DBSerializer ds=mock(DBSerializer.class); + UrlBuilder urlBuilder=mock(UrlBuilder.class); + when(urlBuilder.pathed(vertex)).thenReturn("cloud-region"); + Stream<Vertex> stream=mock(Stream.class); + when(stream.isParallel()).thenReturn(true); + List<String> includeStrings = new ArrayList<>(); + includeStrings.add("cloud-region"); + RelationshipToURI relationshipToURI=mock(RelationshipToURI.class); + URI uri =new URI(""); + when(relationshipToURI.getUri()).thenReturn(uri); + + DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT"); + // UrlBuilder urlBuilder = new UrlBuilder(version, serializer); + Introspector response = searchGraph.createSearchResults(loader, urlBuilder, keys); + System.out.println(response); + } + @Test(expected = AAIException.class) + public void executeModelOperationTest() throws Exception{ + Vertex vertex=new EmptyVertex(); + vertex.property("model-name"); + Map<String,Object> mapObj=new HashMap<String,Object>(); + mapObj.put("modle-version",vertex); + List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>(); + startNodeFilterArrayOfHashes.add(mapObj); + List<org.onap.aai.dbgraphgen.ResultSet> resultSet=new ArrayList<org.onap.aai.dbgraphgen.ResultSet>(); + DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT"); + // ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + AAIExtensionMap map=mock(AAIExtensionMap.class); + HttpServletRequest servletRequest=mock(HttpServletRequest.class); + + when(map.getHttpServletRequest()).thenReturn(servletRequest); + when(servletRequest.getContentType()).thenReturn("application/json"); + DynamicEntity modelAndNamedQuerySearch=mock(DynamicEntity.class); + when(modelAndNamedQuerySearch.isSet("topNodeType")).thenReturn(true); + + +/* when(processor.queryByModel("9999","model-ver","model-version-id", + "model-inv-id","modelname","aai", + startNodeFilterArrayOfHashes,"aai-ver")).thenReturn(resultSet);*/ + + searchGraph.executeModelOperation("","","",type,true, + map); + } + + @Test(expected = AAIException.class) + public void executeModelOperationXMLTest() throws Exception{ + Vertex vertex=new EmptyVertex(); + vertex.property("model-name"); + Map<String,Object> mapObj=new HashMap<String,Object>(); + mapObj.put("modle-version",vertex); + List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>(); + startNodeFilterArrayOfHashes.add(mapObj); + List<org.onap.aai.dbgraphgen.ResultSet> resultSet=new ArrayList<org.onap.aai.dbgraphgen.ResultSet>(); + DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT"); + // ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer); + AAIExtensionMap map=mock(AAIExtensionMap.class); + HttpServletRequest servletRequest=mock(HttpServletRequest.class); + + when(map.getHttpServletRequest()).thenReturn(servletRequest); + when(servletRequest.getContentType()).thenReturn("application/xml"); + + DynamicEntity modelAndNamedQuerySearch=mock(DynamicEntity.class); + when(modelAndNamedQuerySearch.isSet("queryParameters")).thenReturn(true); +/* when(processor.queryByModel("9999","model-ver","model-version-id", + "model-inv-id","modelname","aai", + startNodeFilterArrayOfHashes,"aai-ver")).thenReturn(resultSet);*/ + + searchGraph.executeModelOperation("","","",type,true, + map); + } + @Test + public void runNodesQueryTest() throws AAIException{ + UrlBuilder urlBuilder=mock(UrlBuilder.class); + List<String> filter=new ArrayList<String>(); + filter.add("model:EQUALS:DOES-NOT-EXIST:AAI"); + List<String> edgeFilter=new ArrayList<String>(); + edgeFilter.add("model:DOES-NOT-EXIST:DOES-NOT-EXIST:AAI"); + Response response= searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter, + filter,dbEngine,loader,urlBuilder); + Assert.assertNotNull(response); + } + + @Test + public void runNodesQueryExistsTest() throws AAIException{ + UrlBuilder urlBuilder=mock(UrlBuilder.class); + List<String> filter=new ArrayList<String>(); + filter.add("model:EQUALS:DOES-NOT-EXIST:AAI"); + List<String> edgeFilter=new ArrayList<String>(); + edgeFilter.add("model:EXISTS:DOES-NOT-EXIST:AAI"); + Response response= searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter, + filter,dbEngine,loader,urlBuilder); + Assert.assertNotNull(response); + } + + @Test + public void runNodesQueryTestDOESNOTEQUAL() throws AAIException{ + UrlBuilder urlBuilder=mock(UrlBuilder.class); + List<String> filter=new ArrayList<String>(); + filter.add("model:DOES-NOT-EQUAL:DOES-NOT-EXIST"); + List<String> edgeFilter=new ArrayList<String>(); + searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter, + filter,dbEngine,loader,urlBuilder); + } + + @Test + public void runNodesQueryTestGreaterThan3() throws AAIException{ + UrlBuilder urlBuilder=mock(UrlBuilder.class); + List<String> filter=new ArrayList<String>(); + filter.add("model:DOES-NOT-EQUAL:DOES-NOT-EXIST:AAI"); + List<String> edgeFilter=new ArrayList<String>(); + searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter, + filter,dbEngine,loader,urlBuilder); + } + + @Test + public void runNodesQueryTestGreaterThanExists() throws AAIException{ + UrlBuilder urlBuilder=mock(UrlBuilder.class); + List<String> filter=new ArrayList<String>(); + filter.add("model:EXISTS:DOES-NOT-EXIST:AAI"); + List<String> edgeFilter=new ArrayList<String>(); + searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter, + filter,dbEngine,loader,urlBuilder); + } + + @Test(expected = AAIException.class) + public void runNodesQueryTestGreaterThanDoesNotExists() throws AAIException{ + UrlBuilder urlBuilder=mock(UrlBuilder.class); + List<String> filter=new ArrayList<String>(); + filter.add("model:DOES_NOT_EXIST:DOES-NOT-EXIST:AAI"); + List<String> edgeFilter=new ArrayList<String>(); + searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter, + filter,dbEngine,loader,urlBuilder); + } }
\ No newline at end of file diff --git a/aai-traversal/src/test/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptorTest.java b/aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSInInterceptorTest.java index d265299..40de5a9 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptorTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSInInterceptorTest.java @@ -1,14 +1,14 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 + * 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, @@ -16,9 +16,10 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.interceptors; +package org.onap.aai.interceptors; import org.apache.cxf.message.Exchange; import org.apache.cxf.message.ExchangeImpl; diff --git a/aai-traversal/src/test/java/org/openecomp/aai/interceptors/AAILogJAXRSOutInterceptorTest.java b/aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSOutInterceptorTest.java index df2feec..52c6a42 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/interceptors/AAILogJAXRSOutInterceptorTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSOutInterceptorTest.java @@ -1,14 +1,14 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 + * 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, @@ -16,9 +16,10 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.interceptors; +package org.onap.aai.interceptors; import org.apache.cxf.io.CacheAndWriteOutputStream; import org.apache.cxf.message.Exchange; diff --git a/aai-traversal/src/test/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptorTest.java b/aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java index 3aa2aa9..6efb0d1 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptorTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java @@ -1,14 +1,14 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 + * 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, @@ -16,14 +16,15 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.interceptors; +package org.onap.aai.interceptors; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; -import org.openecomp.aai.logging.LoggingContext; +import org.onap.aai.logging.LoggingContext; import javax.servlet.http.HttpServletRequest; diff --git a/aai-traversal/src/test/java/org/openecomp/aai/interceptors/PreAaiAjscInterceptorTest.java b/aai-traversal/src/test/java/org/onap/aai/interceptors/PreAaiAjscInterceptorTest.java index 9162019..35651c3 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/interceptors/PreAaiAjscInterceptorTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/interceptors/PreAaiAjscInterceptorTest.java @@ -1,14 +1,14 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 + * 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, @@ -16,9 +16,10 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.interceptors; +package org.onap.aai.interceptors; import org.junit.Before; import org.junit.Test; diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/ExceptionHandlerTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java index 8e2bb94..eaf9e55 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/ExceptionHandlerTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java @@ -1,14 +1,14 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 + * 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, @@ -16,9 +16,10 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest; +package org.onap.aai.rest; import com.fasterxml.jackson.core.JsonLocation; import com.fasterxml.jackson.core.JsonParseException; diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromNfTypeQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeQueryTest.java index f2a1a3e..1c93230 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromNfTypeQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeQueryTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -28,8 +29,8 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class CloudRegionFromNfTypeQueryTest extends QueryTest { public CloudRegionFromNfTypeQueryTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromNfTypeVendorVersionTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeVendorVersionTest.java index 5a39f12..ae04734 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromNfTypeVendorVersionTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeVendorVersionTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -27,8 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class CloudRegionFromNfTypeVendorVersionTest extends QueryTest { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromNfTypeVendorVersion_withOptionalTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeVendorVersion_withOptionalTest.java index 08a24a9..59b0d0a 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromNfTypeVendorVersion_withOptionalTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromNfTypeVendorVersion_withOptionalTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -27,8 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class CloudRegionFromNfTypeVendorVersion_withOptionalTest extends QueryTest { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromVnfTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromVnfTest.java index 5e0ecd5..f828558 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionFromVnfTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromVnfTest.java @@ -1,4 +1,25 @@ -package org.openecomp.aai.rest.search; +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.rest.search; import static org.junit.Assert.*; @@ -9,8 +30,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class CloudRegionFromVnfTest extends QueryTest { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionfromCountryCloudRegionVersionQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionfromCountryCloudRegionVersionQueryTest.java index 0bf58fb..08c62af 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionfromCountryCloudRegionVersionQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionfromCountryCloudRegionVersionQueryTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -28,8 +29,8 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class CloudRegionfromCountryCloudRegionVersionQueryTest extends QueryTest { public CloudRegionfromCountryCloudRegionVersionQueryTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionfromCountryQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionfromCountryQueryTest.java index 4a5991d..4106939 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/CloudRegionfromCountryQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionfromCountryQueryTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -28,8 +29,8 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class CloudRegionfromCountryQueryTest extends QueryTest { public CloudRegionfromCountryQueryTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/FirstNetTopology_LineOfBusinessTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/FirstNetTopology_LineOfBusinessTest.java index ce739c8..88831bd 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/FirstNetTopology_LineOfBusinessTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/FirstNetTopology_LineOfBusinessTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -27,8 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class FirstNetTopology_LineOfBusinessTest extends QueryTest { public FirstNetTopology_LineOfBusinessTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/FirstNetTopology_ServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/FirstNetTopology_ServiceInstanceTest.java index a6352ec..a53ca0c 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/FirstNetTopology_ServiceInstanceTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/FirstNetTopology_ServiceInstanceTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -27,8 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class FirstNetTopology_ServiceInstanceTest extends QueryTest { public FirstNetTopology_ServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/GremlinServerImplTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java index deea903..5c6a45f 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/GremlinServerImplTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java @@ -1,163 +1,164 @@ -/*-
- * ============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.rest.search;
-
-import com.thinkaurelius.titan.core.TitanGraph;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.aai.dbmap.DBConnectionType;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.Version;
-import org.openecomp.aai.serialization.engines.QueryStyle;
-import org.openecomp.aai.serialization.engines.TitanDBEngine;
-import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-import org.openecomp.aai.serialization.queryformats.SubGraphStyle;
-
-import javax.ws.rs.core.*;
-import java.net.URI;
-import java.util.*;
-
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class GremlinServerImplTest {
-
- GremlinServerImpl gremlinServerImpl;
-
- protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
-
- private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
-
- private final static Version version = Version.getLatest();
- private final static ModelType introspectorFactoryType = ModelType.MOXY;
- private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private final static DBConnectionType type = DBConnectionType.REALTIME;
-
- static {
- VALID_HTTP_STATUS_CODES.add(200);
- VALID_HTTP_STATUS_CODES.add(201);
- VALID_HTTP_STATUS_CODES.add(204);
- }
-
- private GenericQueryProcessor genericQueryProcessor;
- private HttpHeaders httpHeaders;
-
- private UriInfo uriInfo;
-
- private MultivaluedMap<String, String> headersMultiMap;
- private MultivaluedMap<String, String> queryParameters;
-
- private List<String> aaiRequestContextList;
-
- private List<MediaType> outputMediaTypes;
-
- private Loader loader;
- private TitanGraph graph;
-
- private Graph tx;
-
- private GraphTraversalSource g;
- private TransactionalGraphEngine dbEngine;
-
-
-
-@Before
- public void setup()throws AAIException{
-
- httpHeaders = mock(HttpHeaders.class);
- uriInfo = mock(UriInfo.class);
-
- headersMultiMap = new MultivaluedHashMap<>();
- queryParameters = Mockito.spy(new MultivaluedHashMap<>());
-
- headersMultiMap.add("X-FromAppId", "JUNIT");
- headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
- headersMultiMap.add("Real-Time", "true");
- headersMultiMap.add("Accept", "application/json");
- headersMultiMap.add("aai-request-context", "");
-
- outputMediaTypes = new ArrayList<>();
- outputMediaTypes.add(APPLICATION_JSON);
-
- aaiRequestContextList = new ArrayList<>();
- aaiRequestContextList.add("");
-
- when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
- when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
- when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Arrays.asList("JUNIT"));
- when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Arrays.asList("JUNIT"));
-
- when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
-
-
- when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
- when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
-
- // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
- Mockito.doReturn(null).when(queryParameters).remove(anyObject());
-
- when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new TitanDBEngine(
- queryStyle,
- type,
- loader);
- GenericQueryProcessor.Builder builder=new GenericQueryProcessor.Builder(dbEngine);
-builder.queryFrom(URI.create("te"));
-builder.queryFrom("te");
-builder.create();
-builder.processWith(QueryProcessorType.GREMLIN_SERVER);
- builder.processWith(QueryProcessorType.LOCAL_GROOVY);
-
- gremlinServerImpl= new GremlinServerImpl(builder);
- }
-
- @Test(expected = NullPointerException.class)
- public void processSubGraphTest() throws Exception{
- GraphTraversal<Vertex, Vertex> g=Mockito.mock(GraphTraversal.class);
- g.has("cloud-region-id", "cloud-region-id-1");
- gremlinServerImpl.processSubGraph(SubGraphStyle.prune,g);
-}
-
- @Test(expected = RuntimeException.class)
- public void executeTest() throws Exception{
- GraphTraversal<Vertex, Vertex> g=Mockito.mock(GraphTraversal.class);
- g.has("cloud-region-id", "cloud-region-id-1");
- //Mockito.when(etPath()).thenReturn("testpath");
- List<Object> re= gremlinServerImpl.execute(SubGraphStyle.prune);
- Assert.assertNotNull(re);
- }
-
-
-
-}
+/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.aai.rest.search; + +import com.thinkaurelius.titan.core.TitanGraph; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.structure.T; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.aai.dbmap.DBConnectionType; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.introspection.Loader; +import org.onap.aai.introspection.LoaderFactory; +import org.onap.aai.introspection.ModelType; +import org.onap.aai.introspection.Version; +import org.onap.aai.serialization.engines.QueryStyle; +import org.onap.aai.serialization.engines.TitanDBEngine; +import org.onap.aai.serialization.engines.TransactionalGraphEngine; +import org.onap.aai.serialization.queryformats.SubGraphStyle; + +import javax.ws.rs.core.*; +import java.net.URI; +import java.util.*; + +import static org.mockito.Matchers.anyObject; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class GremlinServerImplTest { + + GremlinServerImpl gremlinServerImpl; + + protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json"); + + private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>(); + + private final static Version version = Version.getLatest(); + private final static ModelType introspectorFactoryType = ModelType.MOXY; + private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL; + private final static DBConnectionType type = DBConnectionType.REALTIME; + + static { + VALID_HTTP_STATUS_CODES.add(200); + VALID_HTTP_STATUS_CODES.add(201); + VALID_HTTP_STATUS_CODES.add(204); + } + + private GenericQueryProcessor genericQueryProcessor; + private HttpHeaders httpHeaders; + + private UriInfo uriInfo; + + private MultivaluedMap<String, String> headersMultiMap; + private MultivaluedMap<String, String> queryParameters; + + private List<String> aaiRequestContextList; + + private List<MediaType> outputMediaTypes; + + private Loader loader; + private TitanGraph graph; + + private Graph tx; + + private GraphTraversalSource g; + private TransactionalGraphEngine dbEngine; + + + +@Before + public void setup()throws AAIException{ + + httpHeaders = mock(HttpHeaders.class); + uriInfo = mock(UriInfo.class); + + headersMultiMap = new MultivaluedHashMap<>(); + queryParameters = Mockito.spy(new MultivaluedHashMap<>()); + + headersMultiMap.add("X-FromAppId", "JUNIT"); + headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString()); + headersMultiMap.add("Real-Time", "true"); + headersMultiMap.add("Accept", "application/json"); + headersMultiMap.add("aai-request-context", ""); + + outputMediaTypes = new ArrayList<>(); + outputMediaTypes.add(APPLICATION_JSON); + + aaiRequestContextList = new ArrayList<>(); + aaiRequestContextList.add(""); + + when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes); + when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap); + when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Arrays.asList("JUNIT")); + when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Arrays.asList("JUNIT")); + + when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList); + + + when(uriInfo.getQueryParameters()).thenReturn(queryParameters); + when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters); + + // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable + Mockito.doReturn(null).when(queryParameters).remove(anyObject()); + + when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON); + loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); + dbEngine = new TitanDBEngine( + queryStyle, + type, + loader); + GenericQueryProcessor.Builder builder=new GenericQueryProcessor.Builder(dbEngine); +builder.queryFrom(URI.create("te")); +builder.queryFrom("te"); +builder.create(); +builder.processWith(QueryProcessorType.GREMLIN_SERVER); + builder.processWith(QueryProcessorType.LOCAL_GROOVY); + + gremlinServerImpl= new GremlinServerImpl(builder); + } + + @Test(expected = NullPointerException.class) + public void processSubGraphTest() throws Exception{ + GraphTraversal<Vertex, Vertex> g=Mockito.mock(GraphTraversal.class); + g.has("cloud-region-id", "cloud-region-id-1"); + gremlinServerImpl.processSubGraph(SubGraphStyle.prune,g); +} + + @Test(expected = RuntimeException.class) + public void executeTest() throws Exception{ + GraphTraversal<Vertex, Vertex> g=Mockito.mock(GraphTraversal.class); + g.has("cloud-region-id", "cloud-region-id-1"); + //Mockito.when(etPath()).thenReturn("testpath"); + List<Object> re= gremlinServerImpl.execute(SubGraphStyle.prune); + Assert.assertNotNull(re); + } + + + +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/GroovyShellImplTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java index 723e30d..3735e97 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/GroovyShellImplTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java @@ -1,157 +1,158 @@ -/*-
- * ============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.rest.search;
-
-import com.thinkaurelius.titan.core.TitanGraph;
-import groovy.lang.MissingPropertyException;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.aai.dbmap.DBConnectionType;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.Version;
-import org.openecomp.aai.serialization.engines.QueryStyle;
-import org.openecomp.aai.serialization.engines.TitanDBEngine;
-import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-import org.openecomp.aai.serialization.queryformats.SubGraphStyle;
-
-import javax.ws.rs.core.*;
-import java.net.URI;
-import java.util.*;
-
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class GroovyShellImplTest {
-
- GroovyShellImpl groovyShellImpl ;
-
- protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
-
- private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
-
- private final static Version version = Version.getLatest();
- private final static ModelType introspectorFactoryType = ModelType.MOXY;
- private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private final static DBConnectionType type = DBConnectionType.REALTIME;
-
- static {
- VALID_HTTP_STATUS_CODES.add(200);
- VALID_HTTP_STATUS_CODES.add(201);
- VALID_HTTP_STATUS_CODES.add(204);
- }
-
- private GenericQueryProcessor genericQueryProcessor;
- private HttpHeaders httpHeaders;
-
- private UriInfo uriInfo;
-
- private MultivaluedMap<String, String> headersMultiMap;
- private MultivaluedMap<String, String> queryParameters;
-
- private List<String> aaiRequestContextList;
-
- private List<MediaType> outputMediaTypes;
-
- private Loader loader;
- private TitanGraph graph;
-
- private Graph tx;
-
- private GraphTraversalSource g;
- private TransactionalGraphEngine dbEngine;
-
-
-
-@Before
- public void setup()throws AAIException{
-
- httpHeaders = mock(HttpHeaders.class);
- uriInfo = mock(UriInfo.class);
-
- headersMultiMap = new MultivaluedHashMap<>();
- queryParameters = Mockito.spy(new MultivaluedHashMap<>());
-
- headersMultiMap.add("X-FromAppId", "JUNIT");
- headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
- headersMultiMap.add("Real-Time", "true");
- headersMultiMap.add("Accept", "application/json");
- headersMultiMap.add("aai-request-context", "");
-
- outputMediaTypes = new ArrayList<>();
- outputMediaTypes.add(APPLICATION_JSON);
-
- aaiRequestContextList = new ArrayList<>();
- aaiRequestContextList.add("");
-
- when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
- when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
- when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Arrays.asList("JUNIT"));
- when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Arrays.asList("JUNIT"));
-
- when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
-
-
- when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
- when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
-
- // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
- Mockito.doReturn(null).when(queryParameters).remove(anyObject());
-
- when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new TitanDBEngine(
- queryStyle,
- type,
- loader);
- GenericQueryProcessor.Builder builder=new GenericQueryProcessor.Builder(dbEngine);
-builder.queryFrom(URI.create("te"));
-builder.queryFrom("te");
-builder.create();
-builder.processWith(QueryProcessorType.GREMLIN_SERVER);
- builder.processWith(QueryProcessorType.LOCAL_GROOVY);
-
- groovyShellImpl= new GroovyShellImpl(builder);
- }
-
- @Test(expected = MissingPropertyException.class)
- public void processSubGraphTest() throws Exception{
- GraphTraversal<Vertex, Vertex> g=Mockito.mock(GraphTraversal.class);
- g.has("cloud-region-id", "cloud-region-id-1");
- Map<String, Object> params = new HashMap<>();
- groovyShellImpl.runQuery("vnfs-fromServiceInstance",params);
-}
-
-
-
-
-
-}
+/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.aai.rest.search; + +import com.thinkaurelius.titan.core.TitanGraph; +import groovy.lang.MissingPropertyException; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.aai.dbmap.DBConnectionType; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.introspection.Loader; +import org.onap.aai.introspection.LoaderFactory; +import org.onap.aai.introspection.ModelType; +import org.onap.aai.introspection.Version; +import org.onap.aai.serialization.engines.QueryStyle; +import org.onap.aai.serialization.engines.TitanDBEngine; +import org.onap.aai.serialization.engines.TransactionalGraphEngine; +import org.onap.aai.serialization.queryformats.SubGraphStyle; + +import javax.ws.rs.core.*; +import java.net.URI; +import java.util.*; + +import static org.mockito.Matchers.anyObject; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class GroovyShellImplTest { + + GroovyShellImpl groovyShellImpl ; + + protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json"); + + private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>(); + + private final static Version version = Version.getLatest(); + private final static ModelType introspectorFactoryType = ModelType.MOXY; + private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL; + private final static DBConnectionType type = DBConnectionType.REALTIME; + + static { + VALID_HTTP_STATUS_CODES.add(200); + VALID_HTTP_STATUS_CODES.add(201); + VALID_HTTP_STATUS_CODES.add(204); + } + + private GenericQueryProcessor genericQueryProcessor; + private HttpHeaders httpHeaders; + + private UriInfo uriInfo; + + private MultivaluedMap<String, String> headersMultiMap; + private MultivaluedMap<String, String> queryParameters; + + private List<String> aaiRequestContextList; + + private List<MediaType> outputMediaTypes; + + private Loader loader; + private TitanGraph graph; + + private Graph tx; + + private GraphTraversalSource g; + private TransactionalGraphEngine dbEngine; + + + +@Before + public void setup()throws AAIException{ + + httpHeaders = mock(HttpHeaders.class); + uriInfo = mock(UriInfo.class); + + headersMultiMap = new MultivaluedHashMap<>(); + queryParameters = Mockito.spy(new MultivaluedHashMap<>()); + + headersMultiMap.add("X-FromAppId", "JUNIT"); + headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString()); + headersMultiMap.add("Real-Time", "true"); + headersMultiMap.add("Accept", "application/json"); + headersMultiMap.add("aai-request-context", ""); + + outputMediaTypes = new ArrayList<>(); + outputMediaTypes.add(APPLICATION_JSON); + + aaiRequestContextList = new ArrayList<>(); + aaiRequestContextList.add(""); + + when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes); + when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap); + when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Arrays.asList("JUNIT")); + when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Arrays.asList("JUNIT")); + + when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList); + + + when(uriInfo.getQueryParameters()).thenReturn(queryParameters); + when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters); + + // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable + Mockito.doReturn(null).when(queryParameters).remove(anyObject()); + + when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON); + loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); + dbEngine = new TitanDBEngine( + queryStyle, + type, + loader); + GenericQueryProcessor.Builder builder=new GenericQueryProcessor.Builder(dbEngine); +builder.queryFrom(URI.create("te")); +builder.queryFrom("te"); +builder.create(); +builder.processWith(QueryProcessorType.GREMLIN_SERVER); + builder.processWith(QueryProcessorType.LOCAL_GROOVY); + + groovyShellImpl= new GroovyShellImpl(builder); + } + + @Test(expected = MissingPropertyException.class) + public void processSubGraphTest() throws Exception{ + GraphTraversal<Vertex, Vertex> g=Mockito.mock(GraphTraversal.class); + g.has("cloud-region-id", "cloud-region-id-1"); + Map<String, Object> params = new HashMap<>(); + groovyShellImpl.runQuery("vnfs-fromServiceInstance",params); +} + + + + + +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/ImageFromCloudRegionNfTypeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ImageFromCloudRegionNfTypeTest.java index d93f183..02f7162 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/ImageFromCloudRegionNfTypeTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ImageFromCloudRegionNfTypeTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -27,8 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class ImageFromCloudRegionNfTypeTest extends QueryTest { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java index 656cd44..c4b90bf 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java @@ -1,4 +1,25 @@ -package org.openecomp.aai.rest.search; +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.rest.search; import java.util.Map; @@ -7,8 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class LinkedDevices_ComplicatedGVtoGV extends QueryTest { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_NewvceVserverTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java index e37bb5a..dcc3d32 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_NewvceVserverTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java @@ -1,4 +1,25 @@ -package org.openecomp.aai.rest.search; +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.rest.search; import static org.junit.Assert.*; @@ -11,8 +32,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class LinkedDevices_NewvceVserverTest extends QueryTest { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java index 435878e..399b60a 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java @@ -1,4 +1,25 @@ -package org.openecomp.aai.rest.search; +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.rest.search; import java.util.Map; @@ -7,8 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class LinkedDevices_SimpleGVtoGVQueryTest extends QueryTest { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LocationNetTypeNetRolefromCloudRegionQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/LocationNetTypeNetRolefromCloudRegionQueryTest.java index e8aec8b..6dcb071 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LocationNetTypeNetRolefromCloudRegionQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/LocationNetTypeNetRolefromCloudRegionQueryTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -28,8 +29,8 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class LocationNetTypeNetRolefromCloudRegionQueryTest extends QueryTest { public LocationNetTypeNetRolefromCloudRegionQueryTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/ModelAndNamedQueryRestProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java index 5813ef1..ea5bc85 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/ModelAndNamedQueryRestProviderTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @@ -26,16 +27,16 @@ import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; -import org.openecomp.aai.dbmap.DBConnectionType; -import org.openecomp.aai.introspection.Loader; -import org.openecomp.aai.introspection.LoaderFactory; -import org.openecomp.aai.introspection.ModelType; -import org.openecomp.aai.introspection.Version; -import org.openecomp.aai.serialization.db.DBSerializer; -import org.openecomp.aai.serialization.engines.QueryStyle; -import org.openecomp.aai.serialization.engines.TitanDBEngine; -import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; -import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder; +import org.onap.aai.dbmap.DBConnectionType; +import org.onap.aai.introspection.Loader; +import org.onap.aai.introspection.LoaderFactory; +import org.onap.aai.introspection.ModelType; +import org.onap.aai.introspection.Version; +import org.onap.aai.serialization.db.DBSerializer; +import org.onap.aai.serialization.engines.QueryStyle; +import org.onap.aai.serialization.engines.TitanDBEngine; +import org.onap.aai.serialization.engines.TransactionalGraphEngine; +import org.onap.aai.serialization.queryformats.utils.UrlBuilder; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.*; diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/MsoRequestVfModuleTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/MsoRequestVfModuleTest.java index 1038eb3..225d45f 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/MsoRequestVfModuleTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/MsoRequestVfModuleTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -27,8 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class MsoRequestVfModuleTest extends QueryTest { public MsoRequestVfModuleTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java index ce88b01..83b6d2f 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/NetworkNameFromNetworkRoleQueryTest.java @@ -1,4 +1,25 @@ -package org.openecomp.aai.rest.search; +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.rest.search; import static org.junit.Assert.*; @@ -9,8 +30,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class NetworkNameFromNetworkRoleQueryTest extends QueryTest { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/NfTypefromCloudRegionQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/NfTypefromCloudRegionQueryTest.java index 9451a86..4b667d0 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/NfTypefromCloudRegionQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/NfTypefromCloudRegionQueryTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -27,8 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class NfTypefromCloudRegionQueryTest extends QueryTest { public NfTypefromCloudRegionQueryTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/OwningEntityfromServiceInstance.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/OwningEntityfromServiceInstance.java index d6704fa..d0fd1b1 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/OwningEntityfromServiceInstance.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/OwningEntityfromServiceInstance.java @@ -1,32 +1,33 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; import java.util.Map; diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PendingTopologyDetailTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PendingTopologyDetailTest.java index 22a60ce..d282164 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PendingTopologyDetailTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PendingTopologyDetailTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -28,8 +29,8 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class PendingTopologyDetailTest extends QueryTest { public PendingTopologyDetailTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java index 2dc023b..9a427ca 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -28,8 +29,8 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class PserverfromConfigurationFilterInterfaceIdTest extends QueryTest { public PserverfromConfigurationFilterInterfaceIdTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java index fd23bc4..9638cfd 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserverfromConfigurationTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java @@ -1,14 +1,14 @@ -/*- +/** * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 + * 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, @@ -16,9 +16,10 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -28,8 +29,8 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class PserverfromConfigurationTest extends QueryTest { public PserverfromConfigurationTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserversFromVnfQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserversFromVnfQueryTest.java index f8bcb7d..e6abee6 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/PserversFromVnfQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserversFromVnfQueryTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -28,8 +29,8 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class PserversFromVnfQueryTest extends QueryTest { public PserversFromVnfQueryTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java index 2d40484..5457937 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; @@ -35,16 +36,16 @@ import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.introspection.Loader; -import org.openecomp.aai.introspection.LoaderFactory; -import org.openecomp.aai.introspection.ModelType; -import org.openecomp.aai.introspection.Version; -import org.openecomp.aai.query.builder.GremlinTraversal; -import org.openecomp.aai.serialization.db.EdgeRules; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; -import org.openecomp.aai.serialization.engines.QueryStyle; -import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.introspection.Loader; +import org.onap.aai.introspection.LoaderFactory; +import org.onap.aai.introspection.ModelType; +import org.onap.aai.introspection.Version; +import org.onap.aai.query.builder.GremlinTraversal; +import org.onap.aai.serialization.db.EdgeRules; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.serialization.engines.QueryStyle; +import org.onap.aai.serialization.engines.TransactionalGraphEngine; public abstract class QueryTest { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryVnfFromModelByRegionTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java index 6fe7872..67f7d11 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryVnfFromModelByRegionTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryVnfFromModelByRegionTest.java @@ -1,12 +1,33 @@ -package org.openecomp.aai.rest.search; +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.rest.search; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; import java.util.Map; diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/SearchProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java index 6b922bf..8633cb4 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/SearchProviderTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java @@ -1,40 +1,41 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; -import org.openecomp.aai.dbmap.DBConnectionType; -import org.openecomp.aai.introspection.Loader; -import org.openecomp.aai.introspection.LoaderFactory; -import org.openecomp.aai.introspection.ModelType; -import org.openecomp.aai.introspection.Version; -import org.openecomp.aai.serialization.db.DBSerializer; -import org.openecomp.aai.serialization.engines.QueryStyle; -import org.openecomp.aai.serialization.engines.TitanDBEngine; -import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; -import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder; +import org.onap.aai.dbmap.DBConnectionType; +import org.onap.aai.introspection.Loader; +import org.onap.aai.introspection.LoaderFactory; +import org.onap.aai.introspection.ModelType; +import org.onap.aai.introspection.Version; +import org.onap.aai.serialization.db.DBSerializer; +import org.onap.aai.serialization.engines.QueryStyle; +import org.onap.aai.serialization.engines.TitanDBEngine; +import org.onap.aai.serialization.engines.TransactionalGraphEngine; +import org.onap.aai.serialization.queryformats.utils.UrlBuilder; import javax.ws.rs.core.*; import java.util.*; diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/ServiceFromPserverAndSubsNameTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java index 264e462..3be5b34 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/ServiceFromPserverAndSubsNameTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceFromPserverAndSubsNameTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -28,8 +29,8 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class ServiceFromPserverAndSubsNameTest extends QueryTest { public ServiceFromPserverAndSubsNameTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/SimpleFormatTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java index eedcd69..17ddfc5 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/SimpleFormatTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -35,21 +36,21 @@ import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.openecomp.aai.dbmap.DBConnectionType; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.introspection.Loader; -import org.openecomp.aai.introspection.LoaderFactory; -import org.openecomp.aai.introspection.ModelType; -import org.openecomp.aai.introspection.Version; -import org.openecomp.aai.serialization.db.DBSerializer; -import org.openecomp.aai.serialization.db.EdgeRules; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; -import org.openecomp.aai.serialization.engines.QueryStyle; -import org.openecomp.aai.serialization.engines.TitanDBEngine; -import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; -import org.openecomp.aai.serialization.queryformats.RawFormat; -import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException; -import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder; +import org.onap.aai.dbmap.DBConnectionType; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.introspection.Loader; +import org.onap.aai.introspection.LoaderFactory; +import org.onap.aai.introspection.ModelType; +import org.onap.aai.introspection.Version; +import org.onap.aai.serialization.db.DBSerializer; +import org.onap.aai.serialization.db.EdgeRules; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.serialization.engines.QueryStyle; +import org.onap.aai.serialization.engines.TitanDBEngine; +import org.onap.aai.serialization.engines.TransactionalGraphEngine; +import org.onap.aai.serialization.queryformats.RawFormat; +import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException; +import org.onap.aai.serialization.queryformats.utils.UrlBuilder; import com.google.gson.JsonObject; diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyDetailFromVserverQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java index 758b113..a99fa8f 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyDetailFromVserverQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -28,8 +29,8 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class TopologyDetailFromVserverQueryTest extends QueryTest { public TopologyDetailFromVserverQueryTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyDetailsQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java index 1dd4db2..1891914 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyDetailsQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailsQueryTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -27,8 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class TopologyDetailsQueryTest extends QueryTest { public TopologyDetailsQueryTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyFromCloudRegionIdAndServiceIdTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromCloudRegionIdAndServiceIdTest.java index d53f51d..8068c31 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyFromCloudRegionIdAndServiceIdTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromCloudRegionIdAndServiceIdTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -28,8 +29,8 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class TopologyFromCloudRegionIdAndServiceIdTest extends QueryTest { public TopologyFromCloudRegionIdAndServiceIdTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java index b200e9b..b10abf3 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -32,8 +33,8 @@ import com.att.eelf.configuration.EELFManager; import com.google.common.base.CaseFormat; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class TopologyFromSubscriberNameAndServiceTypeTest extends QueryTest { private static final EELFLogger LOGGER = EELFManager.getInstance() diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfInstancesFromServiceInstancebyModelVersionTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfInstancesFromServiceInstancebyModelVersionTest.java index 56ddaaf..ecf30b3 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfInstancesFromServiceInstancebyModelVersionTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfInstancesFromServiceInstancebyModelVersionTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -27,8 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class VnfInstancesFromServiceInstancebyModelVersionTest extends QueryTest { public VnfInstancesFromServiceInstancebyModelVersionTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfTopologyFromServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java index 2963c2f..b426ee1 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfTopologyFromServiceInstanceTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -27,8 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class VnfTopologyFromServiceInstanceTest extends QueryTest { public VnfTopologyFromServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfTopologyFromVfModuleTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVfModuleTest.java index 07e3894..7fbc175 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfTopologyFromVfModuleTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVfModuleTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -28,8 +29,8 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class VnfTopologyFromVfModuleTest extends QueryTest { public VnfTopologyFromVfModuleTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfTopologyFromVnfTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVnfTest.java index c678be5..af935f7 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfTopologyFromVnfTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVnfTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -28,8 +29,8 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class VnfTopologyFromVnfTest extends QueryTest { public VnfTopologyFromVnfTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfsFromPserverQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsFromPserverQueryTest.java index fde3729..a3f9c97 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfsFromPserverQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsFromPserverQueryTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -28,8 +29,8 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class VnfsFromPserverQueryTest extends QueryTest { public VnfsFromPserverQueryTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfsFromServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsFromServiceInstanceTest.java index 2a33d7d..6e4f923 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfsFromServiceInstanceTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsFromServiceInstanceTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import java.util.Map; @@ -27,8 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class VnfsFromServiceInstanceTest extends QueryTest { public VnfsFromServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VserverFromVnfQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromVnfQueryTest.java index 9d6ad2e..acec2e7 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VserverFromVnfQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromVnfQueryTest.java @@ -1,4 +1,25 @@ -package org.openecomp.aai.rest.search; +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.rest.search; import static org.junit.Assert.*; @@ -9,8 +30,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class VserverFromVnfQueryTest extends QueryTest { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VserverLogicallinkFromPServerTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverLogicallinkFromPServerTest.java index 5d022ff..8901de2 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VserverLogicallinkFromPServerTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverLogicallinkFromPServerTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.search; +package org.onap.aai.rest.search; import static org.junit.Assert.*; @@ -29,8 +30,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; public class VserverLogicallinkFromPServerTest extends QueryTest { diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/util/EchoResponseTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java index 44d38be..d06c8b7 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/util/EchoResponseTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java @@ -1,14 +1,14 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 + * 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, @@ -16,9 +16,10 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.util; +package org.onap.aai.rest.util; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/util/LogFormatToolsTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java index 3a1ddc1..c4cc211 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/util/LogFormatToolsTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java @@ -1,35 +1,36 @@ -/*-
- * ============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.rest.util;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertNotNull;
-
-public class LogFormatToolsTest {
-
- @Test
- public void testLogFormatTools(){
-
- String dateTime = new LogFormatTools().getCurrentDateTime();
- assertNotNull(dateTime);
- }
-}
+/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.rest.util; + +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +public class LogFormatToolsTest { + + @Test + public void testLogFormatTools(){ + + String dateTime = new LogFormatTools().getCurrentDateTime(); + assertNotNull(dateTime); + } +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java index 8c6450d..fa6480f 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.rest.util; +package org.onap.aai.rest.util; import static org.junit.Assert.*; diff --git a/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/JaxrsUserServiceTest.java b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/JaxrsUserServiceTest.java index 9a9ae8d..3e323dd 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/JaxrsUserServiceTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/JaxrsUserServiceTest.java @@ -1,110 +1,111 @@ -/*-
- * ============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.retiredcustomer;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.aai.ajsc_aai.JaxrsUserService;
-import org.openecomp.aai.introspection.Version;
-import org.openecomp.aai.rest.retired.RetiredConsumer;
-
-import javax.ws.rs.core.*;
-import java.util.*;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.when;
-
-public class JaxrsUserServiceTest {
-
-
- protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
-
- private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
-
- static {
- VALID_HTTP_STATUS_CODES.add(200);
- VALID_HTTP_STATUS_CODES.add(201);
- VALID_HTTP_STATUS_CODES.add(204);
- }
-
- protected JaxrsUserService jaxrsUserService;
- protected HttpHeaders httpHeaders;
- protected UriInfo uriInfo;
-
- private MultivaluedMap<String, String> headersMultiMap;
- private MultivaluedMap<String, String> queryParameters;
-
- private List<String> aaiRequestContextList;
-
- private List<MediaType> outputMediaTypes;
-
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(RetiredConsumer.class.getName());
-
- @Before
- public void setup(){
- logger.info("Starting the setup for the integration tests of Rest Endpoints");
-
- jaxrsUserService = new JaxrsUserService();
- httpHeaders = Mockito.mock(HttpHeaders.class);
- uriInfo = Mockito.mock(UriInfo.class);
-
- headersMultiMap = new MultivaluedHashMap<>();
- queryParameters = Mockito.spy(new MultivaluedHashMap<>());
-
- headersMultiMap.add("X-FromAppId", "JUNIT");
- headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
- headersMultiMap.add("Real-Time", "true");
- headersMultiMap.add("Accept", "application/json");
- headersMultiMap.add("aai-request-context", "");
-
- outputMediaTypes = new ArrayList<>();
- outputMediaTypes.add(APPLICATION_JSON);
-
- aaiRequestContextList = new ArrayList<>();
- aaiRequestContextList.add("");
-
- when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
- when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
-
- when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
-
-
- when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
- when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
-
- // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
- Mockito.doReturn(null).when(queryParameters).remove(anyObject());
-
- when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
- }
- @Test
- public void lookUpUserTest(){
- when(uriInfo.getPath()).thenReturn("/user?userID1");
- String response = jaxrsUserService.lookupUser("userID1");
- assertNotNull(response);
-
-
- }
-}
+/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.retiredcustomer; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.aai.ajsc_aai.JaxrsUserService; +import org.onap.aai.introspection.Version; +import org.onap.aai.rest.retired.RetiredConsumer; + +import javax.ws.rs.core.*; +import java.util.*; + +import static org.junit.Assert.assertNotNull; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Mockito.when; + +public class JaxrsUserServiceTest { + + + protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json"); + + private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>(); + + static { + VALID_HTTP_STATUS_CODES.add(200); + VALID_HTTP_STATUS_CODES.add(201); + VALID_HTTP_STATUS_CODES.add(204); + } + + protected JaxrsUserService jaxrsUserService; + protected HttpHeaders httpHeaders; + protected UriInfo uriInfo; + + private MultivaluedMap<String, String> headersMultiMap; + private MultivaluedMap<String, String> queryParameters; + + private List<String> aaiRequestContextList; + + private List<MediaType> outputMediaTypes; + + private static final EELFLogger logger = EELFManager.getInstance().getLogger(RetiredConsumer.class.getName()); + + @Before + public void setup(){ + logger.info("Starting the setup for the integration tests of Rest Endpoints"); + + jaxrsUserService = new JaxrsUserService(); + httpHeaders = Mockito.mock(HttpHeaders.class); + uriInfo = Mockito.mock(UriInfo.class); + + headersMultiMap = new MultivaluedHashMap<>(); + queryParameters = Mockito.spy(new MultivaluedHashMap<>()); + + headersMultiMap.add("X-FromAppId", "JUNIT"); + headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString()); + headersMultiMap.add("Real-Time", "true"); + headersMultiMap.add("Accept", "application/json"); + headersMultiMap.add("aai-request-context", ""); + + outputMediaTypes = new ArrayList<>(); + outputMediaTypes.add(APPLICATION_JSON); + + aaiRequestContextList = new ArrayList<>(); + aaiRequestContextList.add(""); + + when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes); + when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap); + + when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList); + + + when(uriInfo.getQueryParameters()).thenReturn(queryParameters); + when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters); + + // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable + Mockito.doReturn(null).when(queryParameters).remove(anyObject()); + + when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON); + } + @Test + public void lookUpUserTest(){ + when(uriInfo.getPath()).thenReturn("/user?userID1"); + String response = jaxrsUserService.lookupUser("userID1"); + assertNotNull(response); + + + } +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/RetiredConsumerTest.java b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/RetiredConsumerTest.java index 4a8a051..3810d44 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/RetiredConsumerTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/RetiredConsumerTest.java @@ -1,128 +1,129 @@ -/*-
- * ============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.retiredcustomer;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.aai.introspection.Version;
-import org.openecomp.aai.rest.retired.RetiredConsumer;
-
-import javax.ws.rs.core.*;
-import java.util.*;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.when;
-
-public abstract class RetiredConsumerTest {
-
- protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
-
- private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
-
- static {
- VALID_HTTP_STATUS_CODES.add(200);
- VALID_HTTP_STATUS_CODES.add(201);
- VALID_HTTP_STATUS_CODES.add(204);
- }
-
- protected RetiredConsumer retiredConsumer;
- protected HttpHeaders httpHeaders;
- protected UriInfo uriInfo;
-
- private MultivaluedMap<String, String> headersMultiMap;
- private MultivaluedMap<String, String> queryParameters;
-
- private List<String> aaiRequestContextList;
-
- private List<MediaType> outputMediaTypes;
-
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(RetiredConsumer.class.getName());
-
- @Before
- public void setup(){
- logger.info("Starting the setup for the integration tests of Rest Endpoints");
-
- retiredConsumer = getRetiredConsumer();
- httpHeaders = Mockito.mock(HttpHeaders.class);
- uriInfo = Mockito.mock(UriInfo.class);
-
- headersMultiMap = new MultivaluedHashMap<>();
- queryParameters = Mockito.spy(new MultivaluedHashMap<>());
-
- headersMultiMap.add("X-FromAppId", "JUNIT");
- headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
- headersMultiMap.add("Real-Time", "true");
- headersMultiMap.add("Accept", "application/json");
- headersMultiMap.add("aai-request-context", "");
-
- outputMediaTypes = new ArrayList<>();
- outputMediaTypes.add(APPLICATION_JSON);
-
- aaiRequestContextList = new ArrayList<>();
- aaiRequestContextList.add("");
-
- when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
- when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
-
- when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
-
-
- when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
- when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
-
- // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
- Mockito.doReturn(null).when(queryParameters).remove(anyObject());
-
- when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
- }
-
- @Test
- public void testRetiredForAllEndPoints(){
- when(uriInfo.getPath()).thenReturn("/aai/v3/cloud-infrastructure/pservers/pserver/test-pserver1");
-
- Response response = retiredConsumer.createMessageGet(Version.getLatest().toString(), httpHeaders, uriInfo, null);
- assertNotNull(response);
- assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
-
- response = retiredConsumer.createMessagePost(Version.getLatest().toString(), httpHeaders, uriInfo, null);
- assertNotNull(response);
- assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
-
- response = retiredConsumer.createMessagePatch(Version.getLatest().toString(), httpHeaders, uriInfo, null);
- assertNotNull(response);
- assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
-
- response = retiredConsumer.createMessagePut(Version.getLatest().toString(), httpHeaders, uriInfo, null);
- assertNotNull(response);
- assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
-
- response = retiredConsumer.createMessageDelete(Version.getLatest().toString(), httpHeaders, uriInfo, null);
- assertNotNull(response);
- assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
- }
-
- public abstract RetiredConsumer getRetiredConsumer();
-}
+/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.retiredcustomer; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.aai.introspection.Version; +import org.onap.aai.rest.retired.RetiredConsumer; + +import javax.ws.rs.core.*; +import java.util.*; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Mockito.when; + +public abstract class RetiredConsumerTest { + + protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json"); + + private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>(); + + static { + VALID_HTTP_STATUS_CODES.add(200); + VALID_HTTP_STATUS_CODES.add(201); + VALID_HTTP_STATUS_CODES.add(204); + } + + protected RetiredConsumer retiredConsumer; + protected HttpHeaders httpHeaders; + protected UriInfo uriInfo; + + private MultivaluedMap<String, String> headersMultiMap; + private MultivaluedMap<String, String> queryParameters; + + private List<String> aaiRequestContextList; + + private List<MediaType> outputMediaTypes; + + private static final EELFLogger logger = EELFManager.getInstance().getLogger(RetiredConsumer.class.getName()); + + @Before + public void setup(){ + logger.info("Starting the setup for the integration tests of Rest Endpoints"); + + retiredConsumer = getRetiredConsumer(); + httpHeaders = Mockito.mock(HttpHeaders.class); + uriInfo = Mockito.mock(UriInfo.class); + + headersMultiMap = new MultivaluedHashMap<>(); + queryParameters = Mockito.spy(new MultivaluedHashMap<>()); + + headersMultiMap.add("X-FromAppId", "JUNIT"); + headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString()); + headersMultiMap.add("Real-Time", "true"); + headersMultiMap.add("Accept", "application/json"); + headersMultiMap.add("aai-request-context", ""); + + outputMediaTypes = new ArrayList<>(); + outputMediaTypes.add(APPLICATION_JSON); + + aaiRequestContextList = new ArrayList<>(); + aaiRequestContextList.add(""); + + when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes); + when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap); + + when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList); + + + when(uriInfo.getQueryParameters()).thenReturn(queryParameters); + when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters); + + // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable + Mockito.doReturn(null).when(queryParameters).remove(anyObject()); + + when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON); + } + + @Test + public void testRetiredForAllEndPoints(){ + when(uriInfo.getPath()).thenReturn("/aai/v3/cloud-infrastructure/pservers/pserver/test-pserver1"); + + Response response = retiredConsumer.createMessageGet(Version.getLatest().toString(), httpHeaders, uriInfo, null); + assertNotNull(response); + assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus()); + + response = retiredConsumer.createMessagePost(Version.getLatest().toString(), httpHeaders, uriInfo, null); + assertNotNull(response); + assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus()); + + response = retiredConsumer.createMessagePatch(Version.getLatest().toString(), httpHeaders, uriInfo, null); + assertNotNull(response); + assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus()); + + response = retiredConsumer.createMessagePut(Version.getLatest().toString(), httpHeaders, uriInfo, null); + assertNotNull(response); + assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus()); + + response = retiredConsumer.createMessageDelete(Version.getLatest().toString(), httpHeaders, uriInfo, null); + assertNotNull(response); + assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus()); + } + + public abstract RetiredConsumer getRetiredConsumer(); +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/V3ThroughV7ConsumerTest.java b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V3ThroughV7ConsumerTest.java index ea8ea9c..e02cf38 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/V3ThroughV7ConsumerTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V3ThroughV7ConsumerTest.java @@ -1,33 +1,34 @@ -/*-
- * ============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.retiredcustomer;
-
-import org.openecomp.aai.rest.retired.RetiredConsumer;
-import org.openecomp.aai.rest.retired.V3ThroughV7Consumer;
-
-
-public class V3ThroughV7ConsumerTest extends RetiredConsumerTest {
-
- @Override
- public RetiredConsumer getRetiredConsumer() {
- return new V3ThroughV7Consumer();
- }
-}
+/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.retiredcustomer; + +import org.onap.aai.rest.retired.RetiredConsumer; +import org.onap.aai.rest.retired.V3ThroughV7Consumer; + + +public class V3ThroughV7ConsumerTest extends RetiredConsumerTest { + + @Override + public RetiredConsumer getRetiredConsumer() { + return new V3ThroughV7Consumer(); + } +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/V7V8NamedQueriesTest.java b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V7V8NamedQueriesTest.java index 9968ee8..7c75e60 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/retiredcustomer/V7V8NamedQueriesTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V7V8NamedQueriesTest.java @@ -1,33 +1,34 @@ -/*-
- * ============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.retiredcustomer;
-
-import org.openecomp.aai.rest.retired.RetiredConsumer;
-import org.openecomp.aai.rest.retired.V7V8NamedQueries;
-
-public class V7V8NamedQueriesTest extends RetiredConsumerTest {
-
- @Override
- public RetiredConsumer getRetiredConsumer() {
- return new V7V8NamedQueries();
- }
-}
+/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.aai.retiredcustomer; + +import org.onap.aai.rest.retired.RetiredConsumer; +import org.onap.aai.rest.retired.V7V8NamedQueries; + +public class V7V8NamedQueriesTest extends RetiredConsumerTest { + + @Override + public RetiredConsumer getRetiredConsumer() { + return new V7V8NamedQueries(); + } +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/transforms/JoltTestUtil.java b/aai-traversal/src/test/java/org/onap/aai/transforms/JoltTestUtil.java index 7df2790..6a1966c 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/transforms/JoltTestUtil.java +++ b/aai-traversal/src/test/java/org/onap/aai/transforms/JoltTestUtil.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.transforms; +package org.onap.aai.transforms; import java.io.IOException; diff --git a/aai-traversal/src/test/java/org/openecomp/aai/transforms/LowerHyphenToLowerCamelConverterTest.java b/aai-traversal/src/test/java/org/onap/aai/transforms/LowerHyphenToLowerCamelConverterTest.java index 3dc5299..8c8837c 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/transforms/LowerHyphenToLowerCamelConverterTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/transforms/LowerHyphenToLowerCamelConverterTest.java @@ -1,24 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - -package org.openecomp.aai.transforms; +package org.onap.aai.transforms; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/aai-traversal/src/test/java/org/openecomp/aai/transforms/MapTraverserTest.java b/aai-traversal/src/test/java/org/onap/aai/transforms/MapTraverserTest.java index e3b7760..f26f719 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/transforms/MapTraverserTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/transforms/MapTraverserTest.java @@ -1,27 +1,28 @@ -/*- +/** * ============LICENSE_START======================================================= - * org.openecomp.aai + * org.onap.aai * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 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 - * + * + * 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ +package org.onap.aai.transforms; -package org.openecomp.aai.transforms; - -import org.openecomp.aai.transforms.LowerCamelToLowerHyphenConverter; -import org.openecomp.aai.transforms.MapTraverser; +import org.onap.aai.transforms.LowerCamelToLowerHyphenConverter; +import org.onap.aai.transforms.MapTraverser; import com.bazaarvoice.jolt.JsonUtils; import org.junit.Test; diff --git a/aai-traversal/src/test/java/org/openecomp/aai/util/AAIAppServletContextListenerTest.java b/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java index d8e4928..003c4e0 100644 --- a/aai-traversal/src/test/java/org/openecomp/aai/util/AAIAppServletContextListenerTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java @@ -1,177 +1,178 @@ -/*-
- * ============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 ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.Logger;
-import ch.qos.logback.classic.PatternLayout;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.AppenderBase;
-import org.apache.commons.lang.ObjectUtils;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.openecomp.aai.dbmap.AAIGraph;
-import org.openecomp.aai.logging.ErrorLogHelper;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.agent.PowerMockAgent;
-import org.powermock.modules.junit4.rule.PowerMockRule;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletContextEvent;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-@PrepareForTest({AAIGraph.class, AAIConfig.class, ErrorLogHelper.class})
-public class AAIAppServletContextListenerTest {
-
- @Rule
- public PowerMockRule rule = new PowerMockRule();
-
- static {
- PowerMockAgent.initializeIfNeeded();
- }
-
- private ServletContextEvent arg;
- private AAIAppServletContextListener listener;
-
- /**
- * Initialize.
- */
- @Before
- @PrepareForTest({AAIGraph.class, AAIConfig.class, ErrorLogHelper.class})
- public void initialize(){
- arg = PowerMockito.mock(ServletContextEvent.class);
- PowerMockito.mockStatic(AAIGraph.class);
- PowerMockito.mockStatic(AAIConfig.class);
- PowerMockito.mockStatic(ErrorLogHelper.class);
-
- listener = new AAIAppServletContextListener();
- configureLog();
- }
-
- /**
- * Test contextDestroyed.
- */
- @Test(expected = NullPointerException.class)
- //@Ignore
- public void testContextDestroyed(){
- listener.contextDestroyed(arg);
- assertTrue(logContains(Level.DEBUG, "AAI Server shutdown"));
- assertTrue(logContains(Level.INFO, "AAI graph shutdown"));
- }
-
- /**
- * Test contextInitialized.
- */
- @Test
- //@Ignore
- public void testContextInitialized(){
- listener.contextInitialized(arg);
- assertFalse(logContains(Level.DEBUG, "Loading aaiconfig.properties"));
- assertFalse(logContains(Level.DEBUG, "Loading error.properties"));
- assertFalse(logContains(Level.DEBUG, "Loading graph database"));
- assertFalse(logContains(Level.INFO, "AAI Server initialization"));
- }
-
-
- /**
- * Helper method to check if a String appears in the desired log level.
- *
- * @param level Log level to use
- * @param expected String to search for
- * @return True if search String is found, false otherwise
- */
- private boolean logContains(Level level, String expected) {
- String actual[] = RecordingAppender.messages();
- for (String log : actual) {
- if (log.contains(level.toString()) && log.contains(expected))
- return true;
- }
- return false;
- }
-
- /**
- * Set logging level, and initialize log-appender.
- */
- private void configureLog() {
- org.slf4j.Logger rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
- rootLogger.debug("debug");
- // rootLogger.();
- // rootLogger.addAppender(RecordingAppender.appender(new PatternLayout()));
- }
-
-}
-
-
-/**
- * Appender class that appends log messages to a String List when some logging event occurs
- */
-class RecordingAppender extends AppenderBase<ILoggingEvent> {
- private static List<String> messages = new ArrayList<String>();
- private static RecordingAppender appender = new RecordingAppender();
- private PatternLayout patternLayout;
-
- private RecordingAppender() {
- super();
- }
-
- /**
- * @param patternLayout Pattern to format log message
- * @return Current appender
- */
- public static RecordingAppender appender(PatternLayout patternLayout) {
- appender.patternLayout = patternLayout;
- appender.clear();
- return appender;
- }
-
- @Override
- protected void append(ILoggingEvent event) {
- messages.add(patternLayout.doLayout(event));
- }
-
- public void close() {}
-
- public boolean requiresLayout() {
- return false;
- }
-
- /**
- * @return Return logs as a String array
- */
- public static String[] messages() {
- return (String[]) messages.toArray(new String[messages.size()]);
- }
-
- /**
- * Clear the message container
- */
- private void clear() {
- messages.clear();
- }
-
-}
+/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 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========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.util; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.PatternLayout; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.AppenderBase; +import org.apache.commons.lang.ObjectUtils; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.onap.aai.dbmap.AAIGraph; +import org.onap.aai.logging.ErrorLogHelper; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.agent.PowerMockAgent; +import org.powermock.modules.junit4.rule.PowerMockRule; +import org.slf4j.LoggerFactory; + +import javax.servlet.ServletContextEvent; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +@PrepareForTest({AAIGraph.class, AAIConfig.class, ErrorLogHelper.class}) +public class AAIAppServletContextListenerTest { + + @Rule + public PowerMockRule rule = new PowerMockRule(); + + static { + PowerMockAgent.initializeIfNeeded(); + } + + private ServletContextEvent arg; + private AAIAppServletContextListener listener; + + /** + * Initialize. + */ + @Before + @PrepareForTest({AAIGraph.class, AAIConfig.class, ErrorLogHelper.class}) + public void initialize(){ + arg = PowerMockito.mock(ServletContextEvent.class); + PowerMockito.mockStatic(AAIGraph.class); + PowerMockito.mockStatic(AAIConfig.class); + PowerMockito.mockStatic(ErrorLogHelper.class); + + listener = new AAIAppServletContextListener(); + configureLog(); + } + + /** + * Test contextDestroyed. + */ + @Test(expected = NullPointerException.class) + //@Ignore + public void testContextDestroyed(){ + listener.contextDestroyed(arg); + assertTrue(logContains(Level.DEBUG, "AAI Server shutdown")); + assertTrue(logContains(Level.INFO, "AAI graph shutdown")); + } + + /** + * Test contextInitialized. + */ + @Test + //@Ignore + public void testContextInitialized(){ + listener.contextInitialized(arg); + assertFalse(logContains(Level.DEBUG, "Loading aaiconfig.properties")); + assertFalse(logContains(Level.DEBUG, "Loading error.properties")); + assertFalse(logContains(Level.DEBUG, "Loading graph database")); + assertFalse(logContains(Level.INFO, "AAI Server initialization")); + } + + + /** + * Helper method to check if a String appears in the desired log level. + * + * @param level Log level to use + * @param expected String to search for + * @return True if search String is found, false otherwise + */ + private boolean logContains(Level level, String expected) { + String actual[] = RecordingAppender.messages(); + for (String log : actual) { + if (log.contains(level.toString()) && log.contains(expected)) + return true; + } + return false; + } + + /** + * Set logging level, and initialize log-appender. + */ + private void configureLog() { + org.slf4j.Logger rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); + rootLogger.debug("debug"); + // rootLogger.(); + // rootLogger.addAppender(RecordingAppender.appender(new PatternLayout())); + } + +} + + +/** + * Appender class that appends log messages to a String List when some logging event occurs + */ +class RecordingAppender extends AppenderBase<ILoggingEvent> { + private static List<String> messages = new ArrayList<String>(); + private static RecordingAppender appender = new RecordingAppender(); + private PatternLayout patternLayout; + + private RecordingAppender() { + super(); + } + + /** + * @param patternLayout Pattern to format log message + * @return Current appender + */ + public static RecordingAppender appender(PatternLayout patternLayout) { + appender.patternLayout = patternLayout; + appender.clear(); + return appender; + } + + @Override + protected void append(ILoggingEvent event) { + messages.add(patternLayout.doLayout(event)); + } + + public void close() {} + + public boolean requiresLayout() { + return false; + } + + /** + * @return Return logs as a String array + */ + public static String[] messages() { + return (String[]) messages.toArray(new String[messages.size()]); + } + + /** + * Clear the message container + */ + private void clear() { + messages.clear(); + } + +} diff --git a/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties b/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties index e138653..218d9ac 100644 --- a/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties +++ b/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties @@ -1,22 +1,24 @@ -### +# # ============LICENSE_START======================================================= -# org.openecomp.aai +# org.onap.aai # ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# Copyright © 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 -# +# +# 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========================================================= -### +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +# #################################################################### # REMEMBER TO THINK ABOUT ENVIRONMENTAL DIFFERENCES AND CHANGE THE diff --git a/aai-traversal/src/test/resources/config/etc/titan-cached.properties b/aai-traversal/src/test/resources/config/etc/titan-cached.properties index 6408909..2333d2a 100644 --- a/aai-traversal/src/test/resources/config/etc/titan-cached.properties +++ b/aai-traversal/src/test/resources/config/etc/titan-cached.properties @@ -1,22 +1,24 @@ -### +# # ============LICENSE_START======================================================= -# org.openecomp.aai +# org.onap.aai # ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# Copyright © 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 -# +# +# 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========================================================= -### +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +# query.fast-property=true # the following parameters are not reloaded automatically and require a manual bounce diff --git a/aai-traversal/src/test/resources/config/etc/titan-realtime.properties b/aai-traversal/src/test/resources/config/etc/titan-realtime.properties index c50b141..2d1d21d 100644 --- a/aai-traversal/src/test/resources/config/etc/titan-realtime.properties +++ b/aai-traversal/src/test/resources/config/etc/titan-realtime.properties @@ -1,22 +1,24 @@ -### +# # ============LICENSE_START======================================================= -# org.openecomp.aai +# org.onap.aai # ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# Copyright © 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 -# +# +# 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========================================================= -### +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +# query.fast-property=true # the following parameters are not reloaded automatically and require a manual bounce diff --git a/aai-traversal/src/test/resources/inmemory_titan.properties b/aai-traversal/src/test/resources/inmemory_titan.properties index 46695d6..cf4bbfd 100644 --- a/aai-traversal/src/test/resources/inmemory_titan.properties +++ b/aai-traversal/src/test/resources/inmemory_titan.properties @@ -1,21 +1,23 @@ -### +# # ============LICENSE_START======================================================= -# org.openecomp.aai +# org.onap.aai # ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# Copyright © 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 -# +# +# 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========================================================= -### +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +# storage.backend=inmemory diff --git a/aai-traversal/src/test/resources/logback.xml b/aai-traversal/src/test/resources/logback.xml index 042f052..cc64017 100644 --- a/aai-traversal/src/test/resources/logback.xml +++ b/aai-traversal/src/test/resources/logback.xml @@ -1,21 +1,26 @@ <!-- - ============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========================================================= - --> + ============LICENSE_START======================================================= + org.onap.aai + ================================================================================ + Copyright © 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========================================================= + + ECOMP is a trademark and service mark of AT&T Intellectual Property. + +--> <configuration scan="true" scanPeriod="60 seconds" debug="false"> <contextName>${module.ajsc.namespace.name}</contextName> <jmxConfigurator /> @@ -231,12 +236,12 @@ </logger> --> - <logger name="org.openecomp.aai" level="INFO" /> + <logger name="org.onap.aai" level="INFO" /> <!-- - <logger name="org.openecomp.aai.util" level="WARN" /> - <logger name="org.openecomp.aai.rest" level="WARN" /> - <logger name="org.openecomp.aai.rest.Business" level="WARN" /> + <logger name="org.onap.aai.util" level="WARN" /> + <logger name="org.onap.aai.rest" level="WARN" /> + <logger name="org.onap.aai.rest.Business" level="WARN" /> --> <logger name="org.apache" level="WARN" /> diff --git a/aai-traversal/src/test/resources/test_aaiconfig.properties b/aai-traversal/src/test/resources/test_aaiconfig.properties index 926d3f8..f984761 100644 --- a/aai-traversal/src/test/resources/test_aaiconfig.properties +++ b/aai-traversal/src/test/resources/test_aaiconfig.properties @@ -1,22 +1,24 @@ -### +# # ============LICENSE_START======================================================= -# org.openecomp.aai +# org.onap.aai # ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# Copyright © 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 -# +# +# 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========================================================= -### +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +# #################################################################### # REMEMBER TO THINK ABOUT ENVIRONMENTAL DIFFERENCES AND CHANGE THE |