Search in sources :

Example 11 with SchemaRefresh

use of com.datastax.oss.driver.internal.core.metadata.schema.refresh.SchemaRefresh in project java-driver by datastax.

the class SchemaParserTest method should_parse_multiple_keyspaces.

@Test
public void should_parse_multiple_keyspaces() {
    SchemaRefresh refresh = (SchemaRefresh) parse(rows -> rows.withKeyspaces(ImmutableList.of(mockModernKeyspaceRow("ks1"), mockModernKeyspaceRow("ks2"))).withTypes(ImmutableList.of(mockTypeRow("ks1", "t1", ImmutableList.of("i"), ImmutableList.of("int")), mockTypeRow("ks2", "t2", ImmutableList.of("i"), ImmutableList.of("int")))));
    Map<CqlIdentifier, KeyspaceMetadata> keyspaces = refresh.newKeyspaces;
    assertThat(keyspaces).hasSize(2);
    KeyspaceMetadata ks1 = keyspaces.get(CqlIdentifier.fromInternal("ks1"));
    KeyspaceMetadata ks2 = keyspaces.get(CqlIdentifier.fromInternal("ks2"));
    assertThat(ks1.getName().asInternal()).isEqualTo("ks1");
    assertThat(ks1.getUserDefinedTypes()).hasSize(1).containsKey(CqlIdentifier.fromInternal("t1"));
    assertThat(ks2.getName().asInternal()).isEqualTo("ks2");
    assertThat(ks2.getUserDefinedTypes()).hasSize(1).containsKey(CqlIdentifier.fromInternal("t2"));
}
Also used : CodecRegistry(com.datastax.oss.driver.api.core.type.codec.registry.CodecRegistry) CqlIdentifier(com.datastax.oss.driver.api.core.CqlIdentifier) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) SchemaRefresh(com.datastax.oss.driver.internal.core.metadata.schema.refresh.SchemaRefresh) MetadataRefresh(com.datastax.oss.driver.internal.core.metadata.MetadataRefresh) ImmutableList(com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList) CassandraSchemaRows(com.datastax.oss.driver.internal.core.metadata.schema.queries.CassandraSchemaRows) Consumer(java.util.function.Consumer) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) DataTypes(com.datastax.oss.driver.api.core.type.DataTypes) SchemaRows(com.datastax.oss.driver.internal.core.metadata.schema.queries.SchemaRows) FunctionSignature(com.datastax.oss.driver.api.core.metadata.schema.FunctionSignature) Map(java.util.Map) Assertions.assertThat(com.datastax.oss.driver.Assertions.assertThat) SchemaRefresh(com.datastax.oss.driver.internal.core.metadata.schema.refresh.SchemaRefresh) CqlIdentifier(com.datastax.oss.driver.api.core.CqlIdentifier) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata) Test(org.junit.Test)

Aggregations

SchemaRefresh (com.datastax.oss.driver.internal.core.metadata.schema.refresh.SchemaRefresh)11 MetadataRefresh (com.datastax.oss.driver.internal.core.metadata.MetadataRefresh)9 Test (org.junit.Test)9 DefaultDseKeyspaceMetadata (com.datastax.dse.driver.internal.core.metadata.schema.DefaultDseKeyspaceMetadata)6 CqlIdentifier (com.datastax.oss.driver.api.core.CqlIdentifier)6 KeyspaceMetadata (com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata)6 Assertions.assertThat (com.datastax.oss.driver.Assertions.assertThat)4 FunctionSignature (com.datastax.oss.driver.api.core.metadata.schema.FunctionSignature)4 DataTypes (com.datastax.oss.driver.api.core.type.DataTypes)4 CodecRegistry (com.datastax.oss.driver.api.core.type.codec.registry.CodecRegistry)4 CassandraSchemaRows (com.datastax.oss.driver.internal.core.metadata.schema.queries.CassandraSchemaRows)4 SchemaRows (com.datastax.oss.driver.internal.core.metadata.schema.queries.SchemaRows)4 ImmutableList (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList)4 Map (java.util.Map)4 Consumer (java.util.function.Consumer)4 Mockito.when (org.mockito.Mockito.when)4 DseGraphTableMetadata (com.datastax.dse.driver.api.core.metadata.schema.DseGraphTableMetadata)2 DefaultDseTableMetadata (com.datastax.dse.driver.internal.core.metadata.schema.DefaultDseTableMetadata)2 AdminRow (com.datastax.oss.driver.internal.core.adminrequest.AdminRow)2 DefaultMetadata (com.datastax.oss.driver.internal.core.metadata.DefaultMetadata)2