13
13
import java .time .format .DateTimeFormatter ;
14
14
import java .util .ArrayList ;
15
15
import java .util .List ;
16
- import java .util .Objects ;
17
16
18
17
19
18
/**
@@ -69,22 +68,14 @@ protected File getRandomFile(){
69
68
}
70
69
71
70
public void Create () {
72
- // // Drop key space
73
- // session.execute(f"DROP KEYSPACE IF EXISTS {self._run_setup['keyspace']};");
74
-
75
-
76
- // alter keyspace "prftest"
77
- // with replication = {'class' : 'NetworkTopologyStrategy', 'replication_factor' : 3}
78
- // and durable_writes = true;
79
-
80
- if (!sameKeyspace (setup .getOnlyKeyspace ())) {
71
+ if (!requestedKeyspace (setup .getOnlyKeyspace ())) {
81
72
// Create key space, if not exist
82
73
session .execute (String .format ("CREATE KEYSPACE IF NOT EXISTS %s WITH replication = %s;" ,
83
74
setup .getOnlyKeyspace (),
84
75
((TestSetup ) setup ).replication ));
85
76
}
86
77
87
- if (!sameTable (setup .getOnlyKeyspace (), setup .getOnlyTable ())) {
78
+ if (!requestedTable (setup .getOnlyKeyspace (), setup .getOnlyTable ())) {
88
79
// DROP TABLE
89
80
//session.execute(String.format("DROP TABLE IF EXISTS %s;", setup.table));
90
81
@@ -97,28 +88,30 @@ public void Create() {
97
88
}
98
89
}
99
90
100
- private boolean sameKeyspace (String keyspaceName ){
101
-
102
- boolean result =false ;
103
-
91
+ /**
92
+ * Check, if keyspace has the requested structure
93
+ *
94
+ * @param keyspaceName tested key space
95
+ * @return true - the requested content, false - different content
96
+ */
97
+ private boolean requestedKeyspace (String keyspaceName ){
104
98
try {
105
- Row row = session .execute (String .format ("SELECT keyspace_name FROM system_schema.keyspaces " +
106
- "WHERE keyspace_name='%s';" , keyspaceName )).one ();
107
- result = row != null ;
99
+ return session .execute (String .format ("SELECT keyspace_name FROM system_schema.keyspaces " +
100
+ "WHERE keyspace_name='%s';" , keyspaceName )).one () != null ;
108
101
}
109
102
catch (Exception ex ){
110
103
}
111
- return result ;
112
-
104
+ return false ;
113
105
}
106
+
114
107
/**
115
108
* Check, if table has the requested structure
116
109
*
117
110
* @param keyspaceName tested key space
118
111
* @param tableName tested table
119
- * @return true - the same table , false - different tables
112
+ * @return true - the requested content , false - different content
120
113
*/
121
- private boolean sameTable (String keyspaceName , String tableName ){
114
+ private boolean requestedTable (String keyspaceName , String tableName ){
122
115
boolean result =false ;
123
116
124
117
try {
0 commit comments