diff options
author | 2017-06-09 03:19:04 +0300 | |
---|---|---|
committer | 2017-06-09 03:19:04 +0300 | |
commit | ed64b5edff15e702493df21aa3230b81593e6133 (patch) | |
tree | a4cb01fdaccc34930a8db403a3097c0d1e40914b /catalog-dao/src/test/java/org/openecomp | |
parent | 280f8015d06af1f41a3ef12e8300801c7a5e0d54 (diff) |
[SDC-29] catalog 1707 rebase commit.
Change-Id: I43c3dc5cf44abf5da817649bc738938a3e8388c1
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-dao/src/test/java/org/openecomp')
4 files changed, 70 insertions, 98 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(); } - + } |