81fe8b4acf186ebe62af25db4dab70ccdb9bf2c8
[sdc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.ci.tests.migration.v1707.preupgrade;
22
23 import com.thinkaurelius.titan.core.TitanVertex;
24 import org.junit.Rule;
25 import org.junit.rules.TestName;
26 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
27 import org.openecomp.sdc.ci.tests.migration.v1707.CommonMigrationUtils;
28 import org.openecomp.sdc.ci.tests.utils.graph.GraphFileUtils;
29 import org.testng.annotations.Test;
30
31 import java.io.IOException;
32
33 import static org.testng.Assert.assertTrue;
34
35 public class AttKeyPropertiesBeforeRenameTest extends ComponentBaseTest {
36
37
38     @Rule
39     public static TestName name = new TestName();
40
41     public AttKeyPropertiesBeforeRenameTest() {
42         super(name, AttKeyPropertiesBeforeRenameTest.class.getName());
43     }
44
45     @Test
46     public void verifyAttPropertyKeys() throws Exception {
47         initGraph();
48         CommonMigrationUtils.assertKeyExists(titanGraph, "attContact");
49         CommonMigrationUtils.assertKeyExists(titanGraph, "attCreator");
50         CommonMigrationUtils.assertKeyExists(titanGraph, "attuid");
51         CommonMigrationUtils.assertKeyExists(titanGraph, "pmatt");
52
53         CommonMigrationUtils.assertKeyNotExist(titanGraph, "userId");
54         CommonMigrationUtils.assertKeyNotExist(titanGraph, "projectCode");
55         CommonMigrationUtils.assertKeyNotExist(titanGraph, "contactId");
56         CommonMigrationUtils.assertKeyNotExist(titanGraph, "creatorId");
57
58         saveVerticesWithPropertyKeyToFile("attContact");
59         saveVerticesWithPropertyKeyToFile("attCreator");
60         saveVerticesWithPropertyKeyToFile("attuid");
61         saveVerticesWithPropertyKeyToFile("pmatt");
62     }
63
64     private void saveVerticesWithPropertyKeyToFile(String propertyKey) throws IOException {
65         Iterable<TitanVertex> vertices = titanGraph.query().has(propertyKey).vertices();
66         assertTrue(vertices.iterator().hasNext());
67         GraphFileUtils.writeVerticesUIDToFile(propertyKey, vertices);
68     }
69 }