diff options
Diffstat (limited to 'catalog-dao/src/test')
5 files changed, 82 insertions, 110 deletions
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/ArtifactDaoTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/ArtifactDaoTest.java index aa9d30cb12..292ae08f0a 100644 --- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/ArtifactDaoTest.java +++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/ArtifactDaoTest.java @@ -98,7 +98,6 @@ public class ArtifactDaoTest { // clearIndex(ICatalogDAO.RESOURCES_INDEX, ArtifactData.class); // clearIndex(ICatalogDAO.RESOURCES_INDEX, ServiceArtifactData.class); // } catch (InterruptedException e) { - // TODO Auto-generated catch block // e.printStackTrace(); // } @@ -152,8 +151,7 @@ public class ArtifactDaoTest { * imageData.setResourceCreator("Marina"); * imageData.setResourceLastUpdater("Marina"); ResourceUploadStatus status = * daoUploader.saveImage(imageData, true); assertEquals(status, - * ResourceUploadStatus.OK); } catch (IOException e) { // TODO - * Auto-generated catch block e.printStackTrace(); } + * ResourceUploadStatus.OK); } catch (IOException e) { e.printStackTrace(); } * * * } @@ -456,7 +454,7 @@ public class ArtifactDaoTest { * status = daoUploader.saveServiceArtifact(serviceArData1, true); * * - * } catch (Exception e) { // TODO Auto-generated catch block + * } catch (Exception e) { * e.printStackTrace(); } * * } @@ -561,7 +559,7 @@ public class ArtifactDaoTest { * status = daoUploader.saveServiceArtifact(serviceArData1, true); * * - * } catch (Exception e) { // TODO Auto-generated catch block + * } catch (Exception e) { * e.printStackTrace(); } * * } diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/ESUsersDAOTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/ESUsersDAOTest.java deleted file mode 100644 index a99acbe2b7..0000000000 --- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/ESUsersDAOTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * 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.sdc.be.resources; - -//@RunWith(SpringJUnit4ClassRunner.class) -//@ContextConfiguration("classpath:application-context-test.xml") -//@TestExecutionListeners(listeners = {DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class}) -public class ESUsersDAOTest { - - // @Resource - // ElasticSearchClient esclient; - // - //// @Resource(name = "users-dao") - // private IUsersDAO usersDao; - - // @Test - public void testNewUserStub() { - - } - - // @Test - public void testNewUser() { - // if( usersDao == null ){ - // assertTrue(false); - // } - // - // String id = "yhufksd57834601"; - // UserData userData = new UserData("Myname", "Mylastname", id, "email", - // "Tester"); - // - // ActionStatus saveUserData = usersDao.saveUserData(userData); - // assertEquals(saveUserData, ActionStatus.OK); - // - // Either<UserData, ActionStatus> statusFromEs = - // usersDao.getUserData(id); - // assertTrue(statusFromEs.isLeft() ); - // UserData fromEs = statusFromEs.left().value(); - // assertNotNull(fromEs); - // assertEquals(userData, fromEs); - // - // - // usersDao.deleteUserData(id); - - } - -} diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JsonParserUtilsTests.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JsonParserUtilsTests.java new file mode 100644 index 0000000000..c0c49b7b13 --- /dev/null +++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JsonParserUtilsTests.java @@ -0,0 +1,56 @@ +package org.openecomp.sdc.be.resources; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.type.TypeReference; +import org.junit.Test; +import org.openecomp.sdc.be.dao.jsongraph.utils.JsonParserUtils; +import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; + +public class JsonParserUtilsTests { + @Test + public void testProperties() throws JsonGenerationException, JsonMappingException, IOException { + + PropertyDataDefinition dataDefinition = new PropertyDataDefinition(); + dataDefinition.setName("myName"); + dataDefinition.setDescription("description"); + dataDefinition.setDefaultValue("default11"); + SchemaDefinition entrySchema = new SchemaDefinition(); + PropertyDataDefinition property = new PropertyDataDefinition(); + property.setName("name12"); + property.setType("string"); + entrySchema.setProperty(property); + Map<String, PropertyDataDefinition> properties = new HashMap<>(); + properties.put("key1", property); + properties.put("key2", property); + + entrySchema.setProperties(properties ); + dataDefinition.setSchema(entrySchema); + + Map<String, PropertyDataDefinition> map = new HashMap<>(); + map.put("prop", dataDefinition); + +// String jsonstring = JsonParserUtils.jsonToString(map); + +// Map<String, PropertyDataDefinition> parseToJson = JsonParserUtils.parseToJson(jsonstring, PropertyDataDefinition.class); +// Map<String, PropertyDataDefinition> parseToJson; +// TypeReference<Map<String, PropertyDataDefinition>> typeRef = new TypeReference<Map<String, PropertyDataDefinition>>() { +// }; +// ObjectMapper mapper = new ObjectMapper(); +// try { +// parseToJson = mapper.readValue(jsonstring, typeRef); +// } catch (Exception e) { +//// logger.debug("Failed to parse json {}", json, e); +// } + +// System.out.println(parseToJson); + + } + +} diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/TitanGenericDaoTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/TitanGenericDaoTest.java index a4110f5be3..97ccb43959 100644 --- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/TitanGenericDaoTest.java +++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/TitanGenericDaoTest.java @@ -23,6 +23,7 @@ package org.openecomp.sdc.be.resources; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -72,6 +73,8 @@ import com.thinkaurelius.titan.core.TitanFactory; import com.thinkaurelius.titan.core.TitanGraph; import com.thinkaurelius.titan.core.TitanVertex; import com.thinkaurelius.titan.core.attribute.Text; +import com.thinkaurelius.titan.core.schema.ConsistencyModifier; +import com.thinkaurelius.titan.core.schema.TitanGraphIndex; import com.thinkaurelius.titan.core.schema.TitanManagement; import fj.data.Either; @@ -122,7 +125,7 @@ public class TitanGenericDaoTest { @Test public void testCrudNode() { - String id = "user12345abc"; + String id = "userId12345abc"; UserData userData = new UserData("Myname123", "Mylastname", id, "email123", "Tester", UserStatusEnum.ACTIVE.name(), null); @@ -163,7 +166,7 @@ public class TitanGenericDaoTest { public void testGetByCategoryAndAll() { // create 2 nodes - String id = "user12345abc"; + String id = "userId12345abc"; UserData userData1 = new UserData("Myname123", "Mylastname", id, "email123", "Tester", UserStatusEnum.ACTIVE.name(), null); @@ -171,7 +174,7 @@ public class TitanGenericDaoTest { assertTrue(node1.isLeft()); log.debug("{}", node1.left().value()); - id = "userdfkoer45abc"; + id = "userIddfkoer45abc"; UserData userData2 = new UserData("Mynadyhme123", "Mylasghtname", id, "emaighdl123", "Designer", UserStatusEnum.ACTIVE.name(), null); Either<UserData, TitanOperationStatus> node2 = titanDao.createNode(userData2, UserData.class); @@ -216,7 +219,7 @@ public class TitanGenericDaoTest { @Test public void testGetEdgesForNode() { - String id = "user12345abc"; + String id = "userId12345abc"; UserData userData = new UserData("Myname123", "Mylastname", id, "email123", UserRoleEnum.ADMIN.name(), UserStatusEnum.ACTIVE.name(), null); titanDao.createNode(userData, UserData.class); @@ -262,7 +265,7 @@ public class TitanGenericDaoTest { @Test public void testLockElement() { - + ResourceMetadataData resourceData = new ResourceMetadataData(); resourceData.getMetadataDataDefinition().setName("resourceForLock"); @@ -307,7 +310,7 @@ public class TitanGenericDaoTest { @Test public void testReLockElement() throws InterruptedException { - + ResourceMetadataData resourceData = new ResourceMetadataData(); resourceData.getMetadataDataDefinition().setName("resourceForReLock"); @@ -505,27 +508,6 @@ public class TitanGenericDaoTest { @Test public void testDuplicateResultDueToTitanBug() { - // TitanGraph titanGraph = titanDao.getGraph().left().value(); - // TitanManagement managementSystem = titanGraph.getManagementSystem(); - - // GraphPropertiesDictionary[] properties = { - // GraphPropertiesDictionary.IS_ABSTRACT, - // GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY, - // GraphPropertiesDictionary.POSITION_X, - // GraphPropertiesDictionary.ARTIFACT_TIMEOUT }; - // - // for (GraphPropertiesDictionary property : properties) { - // if (false == - // managementSystem.containsGraphIndex(property.getProperty())) { - // PropertyKey propKey1 = - // managementSystem.makePropertyKey(property.getProperty()).dataType(property.getClazz()).make(); - // managementSystem.buildIndex(property.getProperty(), - // Vertex.class).addKey(propKey1).unique().buildCompositeIndex(); - // } - // } - - // managementSystem.commit(); - ResourceMetadataData resourceData1 = new ResourceMetadataData(); resourceData1.getMetadataDataDefinition().setUniqueId("A"); ((ResourceMetadataDataDefinition) resourceData1.getMetadataDataDefinition()).setAbstract(true); @@ -667,7 +649,7 @@ public class TitanGenericDaoTest { @Test public void testDuplicateResultUSeHasNotQueryDueToTitanBug() { - + String name = "bbbb"; ResourceMetadataData resourceData1 = new ResourceMetadataData(); @@ -717,5 +699,5 @@ public class TitanGenericDaoTest { titanDao.rollback(); } - + } diff --git a/catalog-dao/src/test/resources/config/catalog-dao/configuration.yaml b/catalog-dao/src/test/resources/config/catalog-dao/configuration.yaml index 0b43e3b8c6..67c0ec7b20 100644 --- a/catalog-dao/src/test/resources/config/catalog-dao/configuration.yaml +++ b/catalog-dao/src/test/resources/config/catalog-dao/configuration.yaml @@ -7,8 +7,8 @@ identificationHeaderFields: # catalog backend hostname -beFqdn: 172.20.43.124:8080 - +beFqdn: 0.0.0.0 +# sdccatalog.att.com # catalog backend http port beHttpPort: 8080 @@ -48,7 +48,7 @@ neo4j: maxHttpPerRoute: 20 cassandraConfig: - cassandraHosts: ['mtanjv9sdcg44'] + cassandraHosts: ['000000000'] localDataCenter: reconnectTimeout : 30000 authenticate: false @@ -81,23 +81,23 @@ elasticSearch: creationPeriod: month switchoverDetector: - gBeFqdn: AIO-BE.ecomp.idns.cip - gFeFqdn: AIO-FE.ecomp.idns.cip - beVip: 1.2.3.4 - feVip: 1.2.3.4 + gBeFqdn: AIO-BE.ecomp.idns + gFeFqdn: AIO-FE.ecomp.idns + beVip: 0.0.0.0 + feVip: 0.0.0.0 beResolveAttempts: 3 feResolveAttempts: 3 enabled: false interval: 60 changePriorityUser: ecompasdc changePriorityPassword: ecompasdc123 - publishNetworkUrl: "http://cora.web/crt/CipDomain.ECOMP-ASDC-DEVST/config/update_network?user=root" + publishNetworkUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/update_network?user=root" publishNetworkBody: '{"note":"publish network"}' groups: - beSet: { changePriorityUrl: "http://cora.web/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-BE.ecomp.idns.cip?user=root", - changePriorityBody: '{"name":"AIO-BE.ecomp.idns.cip","uri":"/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-BE.ecomp.idns.cip","no_ad_redirection":false,"v4groups":{"failover_groups":["/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_mg_be","/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_bs_be"],"failover_policy":["FAILALL"]},"comment":"AIO BE G-fqdn","intended_app_proto":"DNS"}'} - feSet: { changePriorityUrl: "http://cora.web/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-FE.ecomp.idns.cip?user=root", - changePriorityBody: '{"comment":"AIO G-fqdn","name":"AIO-FE.ecomp.idns.cip","v4groups":{"failover_groups":["/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_mg_fe","/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_bs_fe"],"failover_policy":["FAILALL"]},"no_ad_redirection":false,"intended_app_proto":"DNS","uri":"/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-FE.ecomp.idns.cip"}'} + beSet: { changePriorityUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-BE.ecomp.idns.com?user=root", + changePriorityBody: '{"name":"AIO-BE.ecomp.idns.com","uri":"/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-BE.ecomp.idns.com","no_ad_redirection":false,"v4groups":{"failover_groups":["/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_mg_be","/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_bs_be"],"failover_policy":["FAILALL"]},"comment":"AIO BE G-fqdn","intended_app_proto":"DNS"}'} + feSet: { changePriorityUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-FE.ecomp.idns.com?user=root", + changePriorityBody: '{"comment":"AIO G-fqdn","name":"AIO-FE.ecomp.idns.com","v4groups":{"failover_groups":["/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_mg_fe","/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_bs_fe"],"failover_policy":["FAILALL"]},"no_ad_redirection":false,"intended_app_proto":"DNS","uri":"/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-FE.ecomp.idns.com"}'} applicationL1Cache: datatypes: |