Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests and documentation for datastax driver SSL integration #403

Merged
merged 21 commits into from
Jan 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup test code and improve package definitions
wetted committed Jan 24, 2024
commit f39027a8728430fba1dedcc0ab480c4e8d91e735
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package example
package io.micronaut.cassandra.micrometertest

import groovy.transform.Canonical
import io.micronaut.core.annotation.Introspected

@Canonical
@Introspected
class CassandraInfo {

String clusterName
String releaseVersion
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package example
package io.micronaut.cassandra.micrometertest

import com.datastax.oss.driver.api.core.CqlSession
import io.micrometer.core.instrument.Counter
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package example
package io.micronaut.cassandra.micrometertest

import com.datastax.oss.driver.api.core.CqlSession
import com.datastax.oss.driver.api.core.cql.ResultSet
import com.datastax.oss.driver.api.core.cql.Row
import io.micronaut.context.annotation.Requires
import jakarta.inject.Singleton

@@ -18,10 +17,6 @@ class CassandraRepository {

Optional<CassandraInfo> getInfo() {
ResultSet resultSet = cqlSession.execute('select cluster_name, release_version from system.local')
Row row = resultSet.one()

row == null
? Optional.empty()
: Optional.of(new CassandraInfo(row.getString('cluster_name'), row.getString('release_version')))
Optional.ofNullable(resultSet.one()).map(r -> new CassandraInfo(r.getString('cluster_name'), r.getString('release_version')))
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package example;
package io.micronaut.cassandra.graaltest;

import io.micronaut.core.annotation.Introspected;

@@ -19,4 +19,4 @@ public String getClusterName() {
public String getReleaseVersion() {
return releaseVersion;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package example;
package io.micronaut.cassandra.graaltest;

import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.Row;
import io.micronaut.context.annotation.Requires;
import jakarta.inject.Singleton;

@@ -19,16 +18,7 @@ public CassandraRepository(CqlSession cqlSession) {

public Optional<CassandraInfo> getInfo() {
ResultSet resultSet = cqlSession.execute("select cluster_name, release_version from system.local");
Row row = resultSet.one();

if (row != null) {
return Optional.of(
new CassandraInfo(
row.getString("cluster_name"),
row.getString("release_version")
)
);
}
return Optional.empty();
return Optional.ofNullable(resultSet.one())
.map(r -> new CassandraInfo(r.getString("cluster_name"), r.getString("release_version")));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package example;
package io.micronaut.cassandra.graaltest;

import static org.junit.jupiter.api.Assertions.assertTrue;

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package example
package io.micronaut.cassandra.jacksontest

import com.fasterxml.jackson.annotation.JsonInclude
import io.micronaut.cassandra.health.CassandraHealthIndicator