Merge remote-tracking branch 'remotes/upstream/wip-eventuate-client-java' into wip-customer

This commit is contained in:
Main
2016-07-25 23:06:05 +03:00
105 changed files with 392 additions and 704 deletions

View File

@@ -1,15 +1,13 @@
apply plugin: 'java'
dependencies {
compile "net.chrisrichardson.eventstore.client:eventstore-java-client_2.10:$eventStoreClientVersion"
compile "io.eventuate.client.java:eventuate-client-java-spring:$eventuateClientVersion"
compile 'com.fasterxml.jackson.core:jackson-core:2.4.3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.3'
compile 'com.fasterxml.jackson.module:jackson-module-scala_2.10:2.4.3'
compile "junit:junit:4.11"
compile "io.reactivex:rxjava:1.1.5"
testCompile "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
testCompile "net.chrisrichardson.eventstore.client:eventstore-jdbc_2.10:$eventStoreClientVersion"
testCompile "io.eventuate.client.java:eventuate-client-java-jdbc:$eventuateClientVersion"
}

View File

@@ -1,10 +1,10 @@
package net.chrisrichardson.eventstorestore.javaexamples.testutil;
import net.chrisrichardson.eventstore.Aggregate;
import net.chrisrichardson.eventstore.ReflectiveMutableCommandProcessingAggregate;
import net.chrisrichardson.eventstore.subscriptions.EventEntityUtil;
import org.springframework.util.ReflectionUtils;
import io.eventuate.Aggregate;
import io.eventuate.ReflectiveMutableCommandProcessingAggregate;
import io.eventuate.javaclient.spring.EventEntityUtil;
import org.junit.Test;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Method;
@@ -17,19 +17,15 @@ public abstract class AbstractEntityEventTest {
@Override
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
Class eventClass = method.getParameterTypes()[0];
String entityClassName = EventEntityUtil.entityClassFor(eventClass);
try {
Class.forName(entityClassName);
} catch (ClassNotFoundException e) {
throw new RuntimeException("for " + entityClassName, e);
}
EventEntityUtil.toEntityType(eventClass);
}
},
new ReflectionUtils.MethodFilter() {
@Override
public boolean matches(Method method) {
return method.getName().startsWith("apply") && method.getDeclaringClass() != Aggregate.class && method.getDeclaringClass() != ReflectiveMutableCommandProcessingAggregate.class;
return method.getName().startsWith("apply") &&
method.getDeclaringClass() != Aggregate.class &&
method.getDeclaringClass() != ReflectiveMutableCommandProcessingAggregate.class;
}
});

View File

@@ -1,7 +1,7 @@
package net.chrisrichardson.eventstorestore.javaexamples.testutil;
import rx.Observable;
import java.util.concurrent.CompletableFuture;
public interface Producer<T> {
public Observable<T> produce();
public CompletableFuture<T> produce();
}

View File

@@ -1,16 +1,25 @@
package net.chrisrichardson.eventstorestore.javaexamples.testutil;
import rx.Observable;
import rx.Subscriber;
import rx.functions.Action1;
import rx.functions.Func1;
import rx.functions.Func2;
import rx.internal.operators.OnSubscribeRefCount;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class TestUtil {
public static <T> T await(Observable<T> o) {
return o.single().timeout(1, TimeUnit.SECONDS).toBlocking().getIterator().next();
public static <T> T await(CompletableFuture<T> o) {
try {
return o.get(1, TimeUnit.SECONDS);
} catch (InterruptedException | TimeoutException | ExecutionException e) {
throw new RuntimeException(e);
}
}
@@ -52,7 +61,7 @@ public class TestUtil {
@Override
public Observable<Outcome<T>> call(Long aLong) {
try {
return producer.produce().map(new Func1<T, Outcome<T>>() {
return fromCompletableFuture(producer.produce()).map(new Func1<T, Outcome<T>>() {
@Override
public Outcome<T> call(T t) {
return new Success<T>(t);
@@ -92,4 +101,21 @@ public class TestUtil {
throw new RuntimeException((Throwable)possibleException);
}
private static <T> Observable<T> fromCompletableFuture(CompletableFuture<T> future) {
return Observable.create(new Observable.OnSubscribe<T>() {
@Override
public void call(Subscriber<? super T> subscriber) {
future.handle((result, throwable) -> {
if (throwable != null)
subscriber.onError(throwable);
else {
subscriber.onNext(result);
subscriber.onCompleted();
}
return null;
});
}
});
}
}