Skip to content

chore: remove deprecated methods #316

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

Merged
merged 3 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 0 additions & 24 deletions src/main/java/io/kurrent/dbclient/EventData.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,6 @@ public byte[] getUserMetadata() {
return userMetadata;
}

/**
* Configures an event data builder to host a JSON payload.
* @param eventType event's type.
* @param eventData event's payload.
* @return an event data builder.
* @param <A> a type that can be serialized in JSON.
*/
@Deprecated
public static <A> EventDataBuilder builderAsJson(String eventType, A eventData) {
return builderAsJson(null, eventType, eventData);
}

/**
* Configures an event data builder to host a JSON payload.
* @param eventId event's id.
* @param eventType event's type.
* @param eventData event's payload.
* @return an event data builder.
* @param <A> a type that can be serialized in JSON.
*/
public static <A> EventDataBuilder builderAsJson(UUID eventId, String eventType, A eventData) {
return EventDataBuilder.json(eventId, eventType, eventData);
}

/**
* Configures an event data builder to host a JSON payload.
* @param eventType event's type.
Expand Down
45 changes: 0 additions & 45 deletions src/main/java/io/kurrent/dbclient/EventDataBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,6 @@ public class EventDataBuilder {

EventDataBuilder(){}

/**
* Configures builder to serialize event data as JSON.
* @param eventType event's type.
* @param eventData event's payload.
* @return an event data builder.
* @param <A> a type that can be serialized in JSON.
*/
public static <A> EventDataBuilder json(String eventType, A eventData) {
return json(null, eventType, eventData);
}

/**
* Configures an event data builder to host a JSON payload.
* @param id event's id.
* @param eventType event's type.
* @param eventData event's payload.
* @return an event data builder.
* @param <A> a type that can be serialized in JSON.
*/
@Deprecated
public static <A> EventDataBuilder json(UUID id, String eventType, A eventData) {
try {
JsonMapper mapper = new JsonMapper();
return json(id, eventType, mapper.writeValueAsBytes(eventData));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}

/**
* Configures an event data builder to host a JSON payload.
* @param eventType event's type.
Expand Down Expand Up @@ -115,22 +86,6 @@ public EventDataBuilder eventId(UUID id) {
return this;
}

/**
* Sets event's custom user metadata.
* @param <A> an object that can be serialized in JSON.
*/
@Deprecated
public <A> EventDataBuilder metadataAsJson(A value) {
try {
JsonMapper mapper = new JsonMapper();
this.metadata = mapper.writeValueAsBytes(value);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}

return this;
}

/**
* Sets event's custom user metadata.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
package io.kurrent.dbclient.samples.appending_events;

import com.fasterxml.jackson.core.JsonProcessingException;
import io.kurrent.dbclient.*;
import io.kurrent.dbclient.samples.TestEvent;

import java.util.UUID;
import java.util.concurrent.ExecutionException;

import com.fasterxml.jackson.databind.ObjectMapper;


public class AppendingEvents {
private static void appendToStream(KurrentDBClient client) throws ExecutionException, InterruptedException {
private static void appendToStream(KurrentDBClient client) throws ExecutionException, InterruptedException, JsonProcessingException {
// region append-to-stream
ObjectMapper objectMapper = new ObjectMapper();

EventData eventData = EventData
.builderAsJson(
UUID.randomUUID(),
"some-event",
new TestEvent(
"1",
"some value"
))
objectMapper.writeValueAsBytes(new TestEvent("1", "some value"))
)
.build();

AppendToStreamOptions options = AppendToStreamOptions.get()
Expand All @@ -27,16 +31,15 @@ private static void appendToStream(KurrentDBClient client) throws ExecutionExcep
// endregion append-to-stream
}

private static void appendWithSameId(KurrentDBClient client) throws ExecutionException, InterruptedException {
private static void appendWithSameId(KurrentDBClient client) throws ExecutionException, InterruptedException, JsonProcessingException {
// region append-duplicate-event
ObjectMapper objectMapper = new ObjectMapper();

EventData eventData = EventData
.builderAsJson(
UUID.randomUUID(),
"some-event",
new TestEvent(
"1",
"some value"
))
objectMapper.writeValueAsBytes(new TestEvent("1", "some value")))
.build();

AppendToStreamOptions options = AppendToStreamOptions.get()
Expand All @@ -51,26 +54,22 @@ private static void appendWithSameId(KurrentDBClient client) throws ExecutionExc
// endregion append-duplicate-event
}

private static void appendWithNoStream(KurrentDBClient client) throws ExecutionException, InterruptedException {
private static void appendWithNoStream(KurrentDBClient client) throws ExecutionException, InterruptedException, JsonProcessingException {
// region append-with-no-stream
ObjectMapper objectMapper = new ObjectMapper();

EventData eventDataOne = EventData
.builderAsJson(
UUID.randomUUID(),
"some-event",
new TestEvent(
"1",
"some value"
))
objectMapper.writeValueAsBytes(new TestEvent("1", "some value")))
.build();

EventData eventDataTwo = EventData
.builderAsJson(
UUID.randomUUID(),
"some-event",
new TestEvent(
"2",
"some other value"
))
objectMapper.writeValueAsBytes(new TestEvent("2", "some other value")))
.build();

AppendToStreamOptions options = AppendToStreamOptions.get()
Expand All @@ -85,8 +84,9 @@ private static void appendWithNoStream(KurrentDBClient client) throws ExecutionE
// endregion append-with-no-stream
}

private static void appendWithConcurrencyCheck(KurrentDBClient client) throws ExecutionException, InterruptedException {
private static void appendWithConcurrencyCheck(KurrentDBClient client) throws ExecutionException, InterruptedException, JsonProcessingException {
// region append-with-concurrency-check
ObjectMapper objectMapper = new ObjectMapper();

ReadStreamOptions readStreamOptions = ReadStreamOptions.get()
.forwards()
Expand All @@ -99,20 +99,14 @@ private static void appendWithConcurrencyCheck(KurrentDBClient client) throws Ex
.builderAsJson(
UUID.randomUUID(),
"some-event",
new TestEvent(
"1",
"clientOne"
))
objectMapper.writeValueAsBytes(new TestEvent("1", "clientOne")))
.build();

EventData clientTwoData = EventData
.builderAsJson(
UUID.randomUUID(),
"some-event",
new TestEvent(
"2",
"clientTwo"
))
objectMapper.writeValueAsBytes(new TestEvent("2", "clientTwo")))
.build();


Expand All @@ -127,15 +121,14 @@ private static void appendWithConcurrencyCheck(KurrentDBClient client) throws Ex
// endregion append-with-concurrency-check
}

public void appendOverridingUserCredentials(KurrentDBClient client) throws ExecutionException, InterruptedException {
public void appendOverridingUserCredentials(KurrentDBClient client) throws ExecutionException, InterruptedException, JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();

EventData eventData = EventData
.builderAsJson(
UUID.randomUUID(),
"some-event",
new TestEvent(
"1",
"some value"
))
objectMapper.writeValueAsBytes(new TestEvent("1", "some value")))
.build();
//region overriding-user-credentials
UserCredentials credentials = new UserCredentials("admin", "changeit");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package io.kurrent.dbclient.samples.opentelemetry;
import org.testcontainers.shaded.com.fasterxml.jackson.core.JsonProcessingException;

import io.kurrent.dbclient.*;
import io.kurrent.dbclient.samples.TestEvent;
Expand All @@ -9,6 +10,7 @@
import io.opentelemetry.sdk.resources.Resource;
import io.opentelemetry.sdk.trace.SdkTracerProvider;
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;
// endregion import-required-packages

import java.util.UUID;
Expand All @@ -17,7 +19,9 @@
import static io.opentelemetry.semconv.ServiceAttributes.SERVICE_NAME;

public class Instrumentation {
private static void tracing(KurrentDBClient client) throws ExecutionException, InterruptedException {
private static void tracing(KurrentDBClient client) throws ExecutionException, InterruptedException, JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();

Resource resource = Resource.getDefault().toBuilder()
.put(SERVICE_NAME, "sample")
.build();
Expand Down Expand Up @@ -47,10 +51,7 @@ private static void tracing(KurrentDBClient client) throws ExecutionException, I
.builderAsJson(
UUID.randomUUID(),
"some-event",
new TestEvent(
"1",
"some value"
))
objectMapper.writeValueAsBytes(new TestEvent("1", "some value")))
.build();
// endregion setup-client-for-tracing

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/io/kurrent/dbclient/streams/MetadataTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ default void testSetStreamMetadata() throws Throwable {

metadata.setAcl(acl);

HashMap<String, Object> payload = new HashMap<>();
byte[] payload = "data".getBytes();

String streamName = generateName();

Expand All @@ -43,7 +43,7 @@ default void testSetStreamMetadata() throws Throwable {
default void testReadNoExistingMetadata() throws Throwable {
KurrentDBClient client = getDatabase().defaultClient();
String streamName = generateName();
client.appendToStream(streamName, EventDataBuilder.json("bar", new HashMap<String, Object>()).build()).get();
client.appendToStream(streamName, EventDataBuilder.json("bar", "data".getBytes()).build()).get();

StreamMetadata got = client.getStreamMetadata(streamName).get();

Expand All @@ -54,7 +54,7 @@ default void testReadNoExistingMetadata() throws Throwable {
default void testReadMetadataAfterStreamDeletion() throws Throwable {
KurrentDBClient client = getDatabase().defaultClient();
String streamName = generateName();
client.appendToStream(streamName, EventDataBuilder.json("bar", new HashMap<String, Object>()).build()).get();
client.appendToStream(streamName, EventDataBuilder.json("bar", "data".getBytes()).build()).get();

client.deleteStream(streamName).get();
client.getStreamMetadata(streamName).get();
Expand Down
Loading