adelapena commented on code in PR #2467:
URL: https://github.com/apache/cassandra/pull/2467#discussion_r1259477767


##########
test/unit/org/apache/cassandra/cql3/SystemKeyspaceTablesNamesTest.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.cql3;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.cassandra.auth.AuthKeyspace;
+import org.apache.cassandra.db.SystemKeyspace;
+import org.apache.cassandra.schema.Schema;
+import org.apache.cassandra.schema.SchemaConstants;
+import org.apache.cassandra.schema.SchemaKeyspaceTables;
+import org.apache.cassandra.schema.SystemDistributedKeyspace;
+import org.apache.cassandra.tracing.TraceKeyspace;
+
+import static org.junit.Assert.assertTrue;
+
+public class SystemKeyspaceTablesNamesTest extends CQLTester
+{
+    @BeforeClass
+    public static void setUp()
+    {
+        // Needed for distributed keyspaces
+        requireNetwork();
+    }
+
+    @Test
+    public void testSystemKeyspaceTableNames()
+    {
+        Set<String> tables = 
Schema.instance.getKeyspaceMetadata(SchemaConstants.SYSTEM_KEYSPACE_NAME).tables
+                             .stream().map(t -> 
t.name).collect(Collectors.toSet());

Review Comment:
   This block is more or less repeated in all the tests, producing a warning 
about the chance of the `KeyspaceMetadata` being null. We could put it in a 
utility method:
   ```java
   private static Set<String> tableNames(String keyspaceName)
   {
       KeyspaceMetadata keyspace = 
Schema.instance.getKeyspaceMetadata(keyspaceName);
       assertNotNull(keyspace);
       return keyspace.tables.stream().map(t -> 
t.name).collect(Collectors.toSet());
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to