Skip to content

Commit

Permalink
fixes cassandra tests
Browse files Browse the repository at this point in the history
  • Loading branch information
otaviojava committed Apr 21, 2019
1 parent 0f2f9b9 commit 4f29db1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 31 deletions.
Expand Up @@ -96,7 +96,7 @@ public static CassandraProperties of(Map<String, String> configurations) {
settings.prefix(Arrays.asList(OldCassandraConfigurations.HOST.get(),
CassandraConfigurations.HOST.get(),
Configurations.HOST.get())).stream()
.map(configurations::get).forEach(cp::addNodes);
.map(Object::toString).forEach(cp::addNodes);

settings.prefix(Arrays.asList(OldCassandraConfigurations.QUERY.get(), CassandraConfigurations.QUERY.get()))
.stream().map(Object::toString).sorted().forEach(cp::addQuery);
Expand Down
Expand Up @@ -20,25 +20,11 @@
import org.jnosql.diana.api.column.ColumnFamilyManagerFactory;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class CassandraConfigurationTest {


@Test
public void shoudlCreateDocumentEntityManagerFactory() {
Settings settings = ManagerFactorySupplier.INSTANCE.getSettings();

Map<String, String> map = new HashMap<>();
settings.forEach((k,v) -> map.put(k, v.toString()));
CassandraConfiguration cassandraConfiguration = new CassandraConfiguration();
ColumnFamilyManagerFactory entityManagerFactory = cassandraConfiguration.getManagerFactory(map);
assertNotNull(entityManagerFactory);
}

@Test
public void shoudlCreateDocumentEntityManagerFactoryFromSettings() {
Expand All @@ -57,10 +43,5 @@ public void shoudlCreateDocumentEntityManagerFactoryFromFile() {
assertNotNull(entityManagerFactory);
}

@Test
public void shouldReturnNPEWhenMapIsNull() {
CassandraConfiguration cassandraConfiguration = new CassandraConfiguration();
assertThrows(NullPointerException.class, () -> cassandraConfiguration.getManagerFactory(null));
}

}
Expand Up @@ -48,8 +48,8 @@ public CassandraColumnFamilyManagerFactory get() {

Settings getSettings() {
Map<String, Object> configuration = new HashMap<>(ConfigurationReader.from(CASSANDRA_FILE_CONFIGURATION));
configuration.put("cassandra-host-1", cassandra.getContainerIpAddress());
configuration.put("cassandra-port", cassandra.getFirstMappedPort());
configuration.put("cassandra.host-1", cassandra.getContainerIpAddress());
configuration.put("cassandra.port", cassandra.getFirstMappedPort());
return Settings.of(configuration);
}
}
17 changes: 8 additions & 9 deletions cassandra-driver/src/test/resources/diana-cassandra.properties
Expand Up @@ -12,12 +12,11 @@
#
# Otavio Santana
#
cassandra-host-1=localhost
cassandra-port=9142
cassandra-threads-number=4
cassandra-query-1=CREATE KEYSPACE IF NOT EXISTS newKeySpace WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3};
cassandra-query-2=CREATE TYPE IF NOT EXISTS newKeySpace.fullname ( firstname text, lastname text);
cassandra-query-3=CREATE COLUMNFAMILY IF NOT EXISTS newKeySpace.newColumnFamily (id bigint PRIMARY KEY, version double, options list<int>, name text);
cassandra-query-4=CREATE COLUMNFAMILY IF NOT EXISTS newKeySpace.users ( nickname text PRIMARY KEY, name frozen <fullname>);
cassandra-query-5=CREATE COLUMNFAMILY IF NOT EXISTS newKeySpace.history ( name text PRIMARY KEY, dataStart date, dateEnd timestamp);
cassandra-query-6=CREATE COLUMNFAMILY IF NOT EXISTS newKeySpace.contacts ( user text PRIMARY KEY, names list<frozen <fullname>>);
cassandra.host-1=localhost
cassandra.port=9142
cassandra.query-1=CREATE KEYSPACE IF NOT EXISTS newKeySpace WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3};
cassandra.query-2=CREATE TYPE IF NOT EXISTS newKeySpace.fullname ( firstname text, lastname text);
cassandra.query-3=CREATE COLUMNFAMILY IF NOT EXISTS newKeySpace.newColumnFamily (id bigint PRIMARY KEY, version double, options list<int>, name text);
cassandra.query-4=CREATE COLUMNFAMILY IF NOT EXISTS newKeySpace.users ( nickname text PRIMARY KEY, name frozen <fullname>);
cassandra.query-5=CREATE COLUMNFAMILY IF NOT EXISTS newKeySpace.history ( name text PRIMARY KEY, dataStart date, dateEnd timestamp);
cassandra.query-6=CREATE COLUMNFAMILY IF NOT EXISTS newKeySpace.contacts ( user text PRIMARY KEY, names list<frozen <fullname>>);

0 comments on commit 4f29db1

Please sign in to comment.