aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilderTest.java
blob: 14eda51a03cf89f86665b088cdffdb8dd0168eac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package org.openecomp.sdc.be.dao.cassandra.schema;

import com.datastax.driver.core.Session;
import mockit.Deencapsulation;
import org.junit.Test;
import org.mockito.Mockito;
import org.openecomp.sdc.be.config.Configuration.CassandrConfig.KeyspaceConfig;
import org.openecomp.sdc.be.dao.cassandra.schema.SdcSchemaBuilder.ReplicationStrategy;
import org.openecomp.sdc.be.utils.DAOConfDependentTest;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public class SdcSchemaBuilderTest extends DAOConfDependentTest{

	private SdcSchemaBuilder createTestSubject() {
		return new SdcSchemaBuilder();
	}

	@Test
	public void testHandle1707OSMigration() throws Exception {
		Map<String, Map<String, List<String>>> cassndraMetadata = new HashMap<>();
		Map<String, List<ITableDescription>> schemeData = new HashMap<>();

		// default test
		Deencapsulation.invoke(SdcSchemaBuilder.class, "handle1707OSMigration", cassndraMetadata, schemeData);
	}

	@Test
	public void testCreateSchema() throws Exception {
		boolean result;

		// default test
		result = SdcSchemaBuilder.createSchema();
	}

	@Test
	public void testDeleteSchema() throws Exception {
		boolean result;

		// default test
		result = SdcSchemaBuilder.deleteSchema();
	}

	/*@Test
	public void testParseKeyspaceMetadata() throws Exception {
		List<KeyspaceMetadata> keyspacesMetadata = new LinkedList<>();
		Map<String, Map<String, List<String>>> result;

		// default test
		result = Deencapsulation.invoke(SdcSchemaBuilder.class, "parseKeyspaceMetadata", keyspacesMetadata);
	}*/

	/*@Test
	public void testGetMetadataTablesStructure() throws Exception {
		List<KeyspaceMetadata> keyspacesMetadata = new LinkedList<>();
		Map<String, Map<String, List<String>>> result;

		// default test
		result = Deencapsulation.invoke(SdcSchemaBuilder.class, "getMetadataTablesStructure", keyspacesMetadata);
	}*/

	@Test
	public void testCreateIndexName() throws Exception {
		String table = "";
		String column = "";
		String result;

		// default test
		result = Deencapsulation.invoke(SdcSchemaBuilder.class, "createIndexName", table, column);
	}

	/*@Test
	public void testAlterTable() throws Exception {
		Session session = null;
		Map<String, List<String>> existingTablesMetadata = null;
		ITableDescription tableDescription = null;
		String tableName = "";
		Map<String, ImmutablePair<DataType, Boolean>> columnDescription = null;

		// default test
		Deencapsulation.invoke(SdcSchemaBuilder.class, "alterTable",
				new Object[] { Session.class, Map.class, ITableDescription.class, tableName, Map.class });
	}*/

	@Test
	public void testCreateKeyspace() throws Exception {
		String keyspace = "mock";
		Map<String, Map<String, List<String>>> cassndraMetadata = new HashMap<>();
		Session session = Mockito.mock(Session.class);
		boolean result;

		// default test
		result = Deencapsulation.invoke(SdcSchemaBuilder.class, "createKeyspace",
				keyspace, cassndraMetadata, session);
		
		cassndraMetadata.put(keyspace, new HashMap<>());
		result = Deencapsulation.invoke(SdcSchemaBuilder.class, "createKeyspace",
				keyspace, cassndraMetadata, session);
	}

	@Test
	public void testGetSchemeData() throws Exception {
		Map<String, List<ITableDescription>> result;

		// default test
		result = Deencapsulation.invoke(SdcSchemaBuilder.class, "getSchemeData");
	}

	@Test
	public void testCreateKeyspaceQuereyString() throws Exception {
		String keyspace = "mock";
		KeyspaceConfig keyspaceInfo = new KeyspaceConfig();
		String result;

		// default test
		result = Deencapsulation.invoke(SdcSchemaBuilder.class, "createKeyspaceQuereyString", keyspace, keyspaceInfo);
		
		keyspaceInfo.setReplicationStrategy(ReplicationStrategy.NETWORK_TOPOLOGY_STRATEGY.getName());
		LinkedList<String> replicationInfo = new LinkedList<>();
		keyspaceInfo.setReplicationInfo(replicationInfo);
		//Test1
		result = Deencapsulation.invoke(SdcSchemaBuilder.class, "createKeyspaceQuereyString", keyspace, keyspaceInfo);
		replicationInfo.add("mock1");
		replicationInfo.add("mock2");
		
		result = Deencapsulation.invoke(SdcSchemaBuilder.class, "createKeyspaceQuereyString", keyspace, keyspaceInfo);
		
		//Test2
		keyspaceInfo.setReplicationStrategy(ReplicationStrategy.SIMPLE_STRATEGY.getName());
		result = Deencapsulation.invoke(SdcSchemaBuilder.class, "createKeyspaceQuereyString", keyspace, keyspaceInfo);
	}
}