Skip to content

Commit 613ddcc

Browse files
committed
Cleaning & Simplification
1 parent 98cf0dd commit 613ddcc

File tree

1 file changed

+15
-22
lines changed
  • nifi/cql-processor/nifi-cql-processors/src/test/java/org/george0st/processors/cql/helper

1 file changed

+15
-22
lines changed

nifi/cql-processor/nifi-cql-processors/src/test/java/org/george0st/processors/cql/helper/CqlCreateSchema.java

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import java.time.format.DateTimeFormatter;
1414
import java.util.ArrayList;
1515
import java.util.List;
16-
import java.util.Objects;
1716

1817

1918
/**
@@ -69,22 +68,14 @@ protected File getRandomFile(){
6968
}
7069

7170
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())) {
8172
// Create key space, if not exist
8273
session.execute(String.format("CREATE KEYSPACE IF NOT EXISTS %s WITH replication = %s;",
8374
setup.getOnlyKeyspace(),
8475
((TestSetup) setup).replication));
8576
}
8677

87-
if (!sameTable(setup.getOnlyKeyspace(), setup.getOnlyTable())) {
78+
if (!requestedTable(setup.getOnlyKeyspace(), setup.getOnlyTable())) {
8879
// DROP TABLE
8980
//session.execute(String.format("DROP TABLE IF EXISTS %s;", setup.table));
9081

@@ -97,28 +88,30 @@ public void Create() {
9788
}
9889
}
9990

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){
10498
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;
108101
}
109102
catch(Exception ex){
110103
}
111-
return result;
112-
104+
return false;
113105
}
106+
114107
/**
115108
* Check, if table has the requested structure
116109
*
117110
* @param keyspaceName tested key space
118111
* @param tableName tested table
119-
* @return true - the same table, false - different tables
112+
* @return true - the requested content, false - different content
120113
*/
121-
private boolean sameTable(String keyspaceName, String tableName){
114+
private boolean requestedTable(String keyspaceName, String tableName){
122115
boolean result=false;
123116

124117
try {

0 commit comments

Comments
 (0)