Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
5f68be4
Add creation test covering various Builder params.
dmdashenkov Sep 13, 2016
cad1d94
Bump gradle version,
dmdashenkov Sep 13, 2016
d700a41
Add some more tests (need to be processed).
dmdashenkov Sep 13, 2016
09b2231
Fix deliver mock updates test.
dmdashenkov Sep 13, 2016
16612e2
Explicit "Given" for stand tests.
dmdashenkov Sep 14, 2016
7666072
Add threading test.
dmdashenkov Sep 14, 2016
231f7cb
Reduce executor await time.
dmdashenkov Sep 14, 2016
e38b6c1
Add deliver updates form projection repo test skeleton,
dmdashenkov Sep 14, 2016
cc95a13
Suppress not yet ready test.
dmdashenkov Sep 14, 2016
4841102
Finish delivery from projection repo test.
dmdashenkov Sep 14, 2016
ad275ef
Finish delivery form an aggregate repo test.
dmdashenkov Sep 14, 2016
c280b88
Delete redundant "TestFailure" declaration.
dmdashenkov Sep 14, 2016
04a211a
Extract common test operations.
dmdashenkov Sep 14, 2016
0ef157d
Refactor and add delivery tests for several repositories successively…
dmdashenkov Sep 14, 2016
cfa0535
Add creation test covering various Builder params.
dmdashenkov Sep 13, 2016
000f360
Bump gradle version,
dmdashenkov Sep 13, 2016
b33eca7
Add some more tests (need to be processed).
dmdashenkov Sep 13, 2016
88d48a7
Fix deliver mock updates test.
dmdashenkov Sep 13, 2016
1efce72
Explicit "Given" for stand tests.
dmdashenkov Sep 14, 2016
cddf64c
Add threading test.
dmdashenkov Sep 14, 2016
935f7a9
Reduce executor await time.
dmdashenkov Sep 14, 2016
3f90a6f
Add deliver updates form projection repo test skeleton,
dmdashenkov Sep 14, 2016
68c908b
Suppress not yet ready test.
dmdashenkov Sep 14, 2016
3b6601c
Finish delivery from projection repo test.
dmdashenkov Sep 14, 2016
cba94e5
Finish delivery form an aggregate repo test.
dmdashenkov Sep 14, 2016
7c49973
Delete redundant "TestFailure" declaration.
dmdashenkov Sep 14, 2016
8526977
Extract common test operations.
dmdashenkov Sep 14, 2016
f553109
Refactor and add delivery tests for several repositories successively…
dmdashenkov Sep 14, 2016
47944ea
Merge remote-tracking branch 'origin/stand-funnel-tests' into stand-f…
dmdashenkov Sep 14, 2016
7a7f6a9
Fix failing build by adding "await" for a concurrent test.
dmdashenkov Sep 14, 2016
459a42b
Return a query result as an instance of List; test bulk reading of ag…
Sep 14, 2016
47ab39e
Test aggregate state query processing in case of:
Sep 14, 2016
f2c99a1
Stand tests: use Mockito#times() instead of Mockito#calls(), since th…
Sep 14, 2016
ecf1161
Fix issues form PR.
dmdashenkov Sep 14, 2016
6fa6f14
Increase await time for concurrent check execution.
dmdashenkov Sep 14, 2016
5226db6
Add tests for projection repositories used in stand: reading by IDs.
Sep 14, 2016
1eb8445
Increase await time for concurrent check execution again.
dmdashenkov Sep 14, 2016
d34a80b
Reduce randomness of generated test data.
dmdashenkov Sep 14, 2016
ecfede8
Remove redundant imports.
dmdashenkov Sep 14, 2016
dfd823d
Test handling an unknown type in a Query.
Sep 15, 2016
ff73389
Add creation test covering various Builder params.
dmdashenkov Sep 13, 2016
bfeec82
Bump gradle version,
dmdashenkov Sep 13, 2016
d141f24
Add some more tests (need to be processed).
dmdashenkov Sep 13, 2016
927a50c
Fix deliver mock updates test.
dmdashenkov Sep 13, 2016
4e1f868
Explicit "Given" for stand tests.
dmdashenkov Sep 14, 2016
7e814e9
Add threading test.
dmdashenkov Sep 14, 2016
13393bf
Reduce executor await time.
dmdashenkov Sep 14, 2016
8d43860
Add deliver updates form projection repo test skeleton,
dmdashenkov Sep 14, 2016
c95265c
Suppress not yet ready test.
dmdashenkov Sep 14, 2016
1fa2b52
Finish delivery from projection repo test.
dmdashenkov Sep 14, 2016
2660489
Finish delivery form an aggregate repo test.
dmdashenkov Sep 14, 2016
84fed4b
Delete redundant "TestFailure" declaration.
dmdashenkov Sep 14, 2016
8c93ffc
Extract common test operations.
dmdashenkov Sep 14, 2016
15c815f
Refactor and add delivery tests for several repositories successively…
dmdashenkov Sep 14, 2016
e1256f4
Add creation test covering various Builder params.
dmdashenkov Sep 13, 2016
f2697c2
Add some more tests (need to be processed).
dmdashenkov Sep 13, 2016
21fd7ae
Fix deliver mock updates test.
dmdashenkov Sep 13, 2016
83da39f
Explicit "Given" for stand tests.
dmdashenkov Sep 14, 2016
10f2add
Add threading test.
dmdashenkov Sep 14, 2016
c222815
Add deliver updates form projection repo test skeleton,
dmdashenkov Sep 14, 2016
7f8665b
Refactor and add delivery tests for several repositories successively…
dmdashenkov Sep 14, 2016
b3b7a1f
Fix failing build by adding "await" for a concurrent test.
dmdashenkov Sep 14, 2016
a5528d5
Fix issues form PR.
dmdashenkov Sep 14, 2016
7a794f7
Increase await time for concurrent check execution.
dmdashenkov Sep 14, 2016
8669683
Increase await time for concurrent check execution again.
dmdashenkov Sep 14, 2016
a383f88
Reduce randomness of generated test data.
dmdashenkov Sep 14, 2016
57f08a9
Remove redundant imports.
dmdashenkov Sep 14, 2016
cf7b94f
Add a straightforward Stand#watch() test.
Sep 15, 2016
1659a0a
* Define SubscriptionService and extract related objects as separate …
Sep 15, 2016
a23c6b8
Merge.
dmdashenkov Sep 15, 2016
c0e3e49
Merge remote-tracking branch 'origin/stand-funnel-tests' into stand-f…
dmdashenkov Sep 15, 2016
7cc18e2
Address issues in PR.
dmdashenkov Sep 15, 2016
36b6d95
Fix broken test.
dmdashenkov Sep 15, 2016
9b9dde6
Resolve compilation errors after moving Topic message.
Sep 15, 2016
ed8784b
Add creation test covering various Builder params.
dmdashenkov Sep 13, 2016
c5ab931
Bump gradle version,
dmdashenkov Sep 13, 2016
756df64
Add some more tests (need to be processed).
dmdashenkov Sep 13, 2016
26fb807
Fix deliver mock updates test.
dmdashenkov Sep 13, 2016
abec37b
Explicit "Given" for stand tests.
dmdashenkov Sep 14, 2016
e3313a8
Add threading test.
dmdashenkov Sep 14, 2016
1e4338a
Reduce executor await time.
dmdashenkov Sep 14, 2016
ca292e9
Add deliver updates form projection repo test skeleton,
dmdashenkov Sep 14, 2016
1fae7e3
Suppress not yet ready test.
dmdashenkov Sep 14, 2016
f9e01c5
Finish delivery from projection repo test.
dmdashenkov Sep 14, 2016
5c6e578
Finish delivery form an aggregate repo test.
dmdashenkov Sep 14, 2016
196848b
Delete redundant "TestFailure" declaration.
dmdashenkov Sep 14, 2016
0ae977c
Extract common test operations.
dmdashenkov Sep 14, 2016
5d3c719
Refactor and add delivery tests for several repositories successively…
dmdashenkov Sep 14, 2016
94aa4e5
Explicit "Given" for stand tests.
dmdashenkov Sep 14, 2016
fa2017a
Fix failing build by adding "await" for a concurrent test.
dmdashenkov Sep 14, 2016
1edb4cc
Fix issues form PR.
dmdashenkov Sep 14, 2016
d31c2ae
Increase await time for concurrent check execution.
dmdashenkov Sep 14, 2016
c534ae8
Increase await time for concurrent check execution again.
dmdashenkov Sep 14, 2016
f88c0b1
Reduce randomness of generated test data.
dmdashenkov Sep 14, 2016
3daae3b
Remove redundant imports.
dmdashenkov Sep 14, 2016
91f673c
Explicit "Given" for stand tests.
dmdashenkov Sep 14, 2016
7eb6454
Explicit "Given" for stand tests.
dmdashenkov Sep 14, 2016
3aeb517
Add deliver updates form projection repo test skeleton,
dmdashenkov Sep 14, 2016
646964a
Merge.
dmdashenkov Sep 15, 2016
d29cc4d
Merge remote-tracking branch 'origin/stand-funnel-tests' into stand-f…
dmdashenkov Sep 15, 2016
6405863
Correct docs.
dmdashenkov Sep 15, 2016
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
1 change: 0 additions & 1 deletion client/src/main/proto/spine/client/client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ option java_outer_classname = "ClientProto";
option java_package = "org.spine3.client";

import "spine/annotations.proto";
import "spine/base/event.proto";

// Version of the code executed on the client.
message CodeVersion {
Expand Down
15 changes: 0 additions & 15 deletions client/src/main/proto/spine/client/client_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,11 @@ option java_generate_equals_and_hash = true;

import "spine/annotations.proto";
import "spine/base/command.proto";
import "spine/base/event.proto";
import "spine/base/response.proto";

// A topic of interest the client can subscribe and unsubscribe.
message Topic {
//TODO:2016-01-14:alexander.yevsyukov: Define this type. E.g. there can be some structure, which describes many
// points of interest at once. See Pub-sub for possible API inspiration. Chances are it's going to be one of underlying
// implementations.
string value = 1;
}

// A service for sending commands from clients.
service ClientService {
// Request to handle a command.
rpc Post(base.Command) returns (base.Response);

// Request to receive events on the topic of interest.
rpc Subscribe(Topic) returns (stream base.Event);

// The request to unsubscribe from the topic.
// This should close the stream opened by `Subscribe` call with the same `Topic` value.
rpc Unsubscribe(Topic) returns (base.Response);
}
3 changes: 0 additions & 3 deletions client/src/main/proto/spine/client/entities.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ option java_outer_classname = "EntitiesProto";
option java_package = "org.spine3.client";

import "google/protobuf/any.proto";
import "google/protobuf/field_mask.proto";

import "spine/annotations.proto";
import "spine/ui/language.proto";
import "spine/base/response.proto";

// Represents an ID of an entity.
//
Expand Down
1 change: 0 additions & 1 deletion client/src/main/proto/spine/client/query_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ option java_multiple_files = true;
option java_outer_classname = "QueryServiceProto";
option java_generate_equals_and_hash = true;

import "google/protobuf/any.proto";

import "spine/annotations.proto";
import "spine/client/query.proto";
Expand Down
83 changes: 83 additions & 0 deletions client/src/main/proto/spine/client/subscription.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//
// Copyright 2016, TeamDev Ltd. All rights reserved.
//
// Redistribution and use in source and/or binary forms, with or without
// modification, must retain the above copyright notice and the following
// disclaimer.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
syntax = "proto3";

package spine.client;

option (type_url_prefix) = "type.spine3.org";
option java_generate_equals_and_hash = true;
option java_multiple_files = true;
option java_outer_classname = "SubscriptionProto";
option java_package = "org.spine3.client";


import "google/protobuf/any.proto";
import "google/protobuf/field_mask.proto";

import "spine/annotations.proto";
import "spine/base/response.proto";
import "spine/client/entities.proto";

// An object defining a unit of subscription.
//
// Defines the target (entities and criteria) of subscription.
message Topic {

// Defines the entity of interest, e.g. entity type URL and a set of subscription criteria.
Target target = 1;

// Field mask to be applied to the entity updates applicable to this topic.
//
// Applied to each of the entity state messages before returning in scope of SubscriptionUpdate.
google.protobuf.FieldMask field_mask = 2;

// Reserved for utility fields.
reserved 3 to 6;
}

// Wrapped set of read-side entity updates on a topic with the specific subscription ID.
message SubscriptionUpdate {

// The ID of the current subscription.
SubscriptionId id = 1;

// Represents the base part of the response. I.e. whether the Topic subscription requires has been acked or not.
base.Response response = 2;

// Reserved for more subscription update attributes.
reserved 3 to 9;

// Entity updates packed as Any.
//
// Each of the update messages is affected by the field mask set for the current subscription.
repeated google.protobuf.Any updates = 10;
}

// The ID of the subscription.
//
// Created when the client subscribes to a topic.
// See SubscriptionService#Subscribe(Topic).
message SubscriptionId {

// Unique identifier of the subscription.
//
// Typically built using Java's UUID.toString() functionality.
string uuid = 1;
}
46 changes: 46 additions & 0 deletions client/src/main/proto/spine/client/subscription_service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// Copyright 2016, TeamDev Ltd. All rights reserved.
//
// Redistribution and use in source and/or binary forms, with or without
// modification, must retain the above copyright notice and the following
// disclaimer.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
syntax = "proto3";

package spine.client;

option (type_url_prefix) = "type.spine3.org";
option java_package = "org.spine3.client.grpc";
option java_multiple_files = true;
option java_outer_classname = "SubscriptionServiceProto";
option java_generate_equals_and_hash = true;


import "spine/annotations.proto";
import "spine/client/subscription.proto";
import "spine/base/response.proto";

// A service for subscribing to the read-side changes by clients.
service SubscriptionService {

// Subscribe to a particular read-side updates.
//
// Topic defines the target of subscription and other attributes (like field masks).
// The result is a SubscriptionUpdate stream,
rpc Subscribe (Topic) returns (stream SubscriptionUpdate);

// Cancel the subscription by its ID.
rpc CancelSubscription (SubscriptionId) returns (base.Response);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.spine3.base.Response;
import org.spine3.client.CommandFactory;
import org.spine3.client.grpc.ClientServiceGrpc;
import org.spine3.client.grpc.Topic;
import org.spine3.examples.aggregate.command.AddOrderLine;
import org.spine3.examples.aggregate.command.CreateOrder;
import org.spine3.examples.aggregate.command.PayForOrder;
Expand Down Expand Up @@ -66,9 +65,9 @@ public class ClientApp {
private static final int SHUTDOWN_TIMEOUT_SEC = 5;

private final CommandFactory commandFactory;
private final Topic topic = Topic.getDefaultInstance();
private final ManagedChannel channel;
private final ClientServiceGrpc.ClientServiceBlockingStub blockingClient;
// TODO[alex.tymchenko]: switch to SubscriptionService instead.
private final ClientServiceGrpc.ClientServiceStub nonBlockingClient;

private final StreamObserver<Event> observer = new StreamObserver<Event>() {
Expand Down Expand Up @@ -140,14 +139,10 @@ private Command payForOrder(OrderId orderId) {
return commandFactory.create(msg);
}

private void subscribe() {
nonBlockingClient.subscribe(topic, observer);
}

/** Sends requests to the server. */
public static void main(String[] args) throws InterruptedException {
final ClientApp client = new ClientApp(SERVICE_HOST, DEFAULT_CLIENT_SERVICE_PORT);
client.subscribe();

final List<Command> requests = client.generateRequests();

Expand Down Expand Up @@ -178,7 +173,6 @@ private List<Command> generateRequests() {
* @throws InterruptedException if waiting is interrupted.
*/
private void shutdown() throws InterruptedException {
blockingClient.unsubscribe(topic);
channel.shutdown().awaitTermination(SHUTDOWN_TIMEOUT_SEC, SECONDS);
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip
19 changes: 0 additions & 19 deletions server/src/main/java/org/spine3/server/ClientService.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spine3.base.Command;
import org.spine3.base.Event;
import org.spine3.base.Response;
import org.spine3.base.Responses;
import org.spine3.client.grpc.Topic;
import org.spine3.server.command.error.CommandException;
import org.spine3.server.command.error.UnsupportedCommandException;
import org.spine3.server.type.CommandClass;
Expand Down Expand Up @@ -75,22 +72,6 @@ private static void handleUnsupported(Command request, StreamObserver<Response>
responseObserver.onError(Statuses.invalidArgumentWithCause(unsupported));
}

@SuppressWarnings("RefusedBequest") // as we override default implementation with `unimplemented` status.
@Override
public void subscribe(Topic request, StreamObserver<Event> responseObserver) {
//TODO:2016-05-25:alexander.yevsyukov: Subscribe the client to the topic in the corresponding BoundedContext.
// This API is likely to change to support Firebase-like registration where listening is
// done by the client SDK implementation.
}

@SuppressWarnings("RefusedBequest") // as we override default implementation with `unimplemented` status.
@Override
public void unsubscribe(Topic request, StreamObserver<Response> responseObserver) {
//TODO:2016-05-25:alexander.yevsyukov: Unsubscribe the client from the topic in the corresponding BoundedContext.
responseObserver.onNext(Responses.ok());
responseObserver.onCompleted();
}

public static class Builder {

private final Set<BoundedContext> boundedContexts = Sets.newHashSet();
Expand Down
12 changes: 7 additions & 5 deletions server/src/main/java/org/spine3/server/stand/Stand.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public void execute(Query query, StreamObserver<QueryResponse> responseObserver)

private ImmutableCollection<Any> internalExecute(Query query) {

final ImmutableSet.Builder<Any> resultBuilder = ImmutableSet.builder();
final ImmutableList.Builder<Any> resultBuilder = ImmutableList.builder();

final Target target = query.getTarget();

Expand All @@ -280,7 +280,7 @@ private ImmutableCollection<Any> internalExecute(Query query) {
feedStateRecordsToBuilder(resultBuilder, stateRecords);
}

final ImmutableSet<Any> result = resultBuilder.build();
final ImmutableList<Any> result = resultBuilder.build();

return result;
}
Expand All @@ -293,7 +293,9 @@ private ImmutableCollection<EntityStorageRecord> fetchFromStandStorage(Target ta

} else {
final EntityFilters filters = target.getFilters();
if (filters != null && filters.getIdFilter() != null) {

// TODO[alex.tymchenko]: do we need to check for null at all? How about, say, Python gRPC client?
if (filters != null && filters.getIdFilter() != null && !filters.getIdFilter().getIdsList().isEmpty()) {
final EntityIdFilter idFilter = filters.getIdFilter();
final Collection<AggregateStateId> stateIds = Collections2.transform(idFilter.getIdsList(), aggregateStateIdTransformer(typeUrl));

Expand Down Expand Up @@ -355,15 +357,15 @@ private static ImmutableCollection<? extends Entity> fetchFromEntityRepository(T
return result;
}

private static void feedEntitiesToBuilder(ImmutableSet.Builder<Any> resultBuilder, ImmutableCollection<? extends Entity> all) {
private static void feedEntitiesToBuilder(ImmutableList.Builder<Any> resultBuilder, ImmutableCollection<? extends Entity> all) {
for (Entity record : all) {
final Message state = record.getState();
final Any packedState = AnyPacker.pack(state);
resultBuilder.add(packedState);
}
}

private static void feedStateRecordsToBuilder(ImmutableSet.Builder<Any> resultBuilder, ImmutableCollection<EntityStorageRecord> all) {
private static void feedStateRecordsToBuilder(ImmutableList.Builder<Any> resultBuilder, ImmutableCollection<EntityStorageRecord> all) {
for (EntityStorageRecord record : all) {
final Any state = record.getState();
resultBuilder.add(state);
Expand Down
4 changes: 2 additions & 2 deletions server/src/main/java/org/spine3/server/stand/StandFunnel.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ public Stand getStand() {
*
* <p> The value must not be null.
*
* <p> If this method is not used, a default value will be used.
*
* @param stand the instance of {@link Stand}.
* @return {@code this} instance of {@code Builder}
*/
Expand All @@ -127,6 +125,8 @@ public Executor getExecutor() {
*
* <p>The value must not be {@code null}.
*
* <p> If this method is not used, a default value will be used.
*
* @param executor the instance of {@code Executor}.
* @return {@code this} instance of {@code Builder}
*/
Expand Down
Loading