3b4f6349a782f4b7f8e219b5990c4aed2f7d5172
[sdc.git] /
1 package org.openecomp.sdc.ci.tests.migration.v1707.preupgrade;
2
3 import com.thinkaurelius.titan.core.TitanVertex;
4 import org.junit.Rule;
5 import org.junit.rules.TestName;
6 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
7 import org.openecomp.sdc.ci.tests.migration.v1707.CommonMigrationUtils;
8 import org.openecomp.sdc.ci.tests.utils.graph.GraphFileUtils;
9 import org.testng.annotations.Test;
10
11 import java.io.IOException;
12
13 import static org.testng.Assert.assertTrue;
14
15 public class AttKeyPropertiesBeforeRenameTest extends ComponentBaseTest {
16
17
18     @Rule
19     public static TestName name = new TestName();
20
21     public AttKeyPropertiesBeforeRenameTest() {
22         super(name, AttKeyPropertiesBeforeRenameTest.class.getName());
23     }
24
25     @Test
26     public void verifyAttPropertyKeys() throws Exception {
27         initGraph();
28         CommonMigrationUtils.assertKeyExists(titanGraph, "attContact");
29         CommonMigrationUtils.assertKeyExists(titanGraph, "attCreator");
30         CommonMigrationUtils.assertKeyExists(titanGraph, "attuid");
31         CommonMigrationUtils.assertKeyExists(titanGraph, "pmatt");
32
33         CommonMigrationUtils.assertKeyNotExist(titanGraph, "userId");
34         CommonMigrationUtils.assertKeyNotExist(titanGraph, "projectCode");
35         CommonMigrationUtils.assertKeyNotExist(titanGraph, "contactId");
36         CommonMigrationUtils.assertKeyNotExist(titanGraph, "creatorId");
37
38         saveVerticesWithPropertyKeyToFile("attContact");
39         saveVerticesWithPropertyKeyToFile("attCreator");
40         saveVerticesWithPropertyKeyToFile("attuid");
41         saveVerticesWithPropertyKeyToFile("pmatt");
42     }
43
44     private void saveVerticesWithPropertyKeyToFile(String propertyKey) throws IOException {
45         Iterable<TitanVertex> vertices = titanGraph.query().has(propertyKey).vertices();
46         assertTrue(vertices.iterator().hasNext());
47         GraphFileUtils.writeVerticesUIDToFile(propertyKey, vertices);
48     }
49 }