Skip to content

Commit 29e6531

Browse files
authored
Merge pull request #1341 from SpineEventEngine/remove-empty-message-field
Remove empty `grand_origin`
2 parents 4dabb11 + 0e851aa commit 29e6531

File tree

10 files changed

+98
-69
lines changed

10 files changed

+98
-69
lines changed

core/src/main/java/io/spine/core/EventMixin.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,9 @@ default ActorContext actorContext() {
180180

181181
@Override
182182
default MessageId messageId() {
183-
return Signal.super.messageId()
184-
.toBuilder()
185-
.setVersion(context().getVersion())
186-
.build();
183+
return identityBuilder()
184+
.setVersion(context().getVersion())
185+
.vBuild();
187186
}
188187

189188
@Override

core/src/main/java/io/spine/core/Signal.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,15 @@ default MessageId.Builder identityBuilder() {
154154
/**
155155
* Obtains this signal as an origin of other signals.
156156
*
157-
* <p>This origin is assigned to any signal message produced as a reaction to this one..
157+
* <p>This origin is assigned to any signal message produced as a reaction to this one.
158158
*/
159159
default Origin asMessageOrigin() {
160-
MessageId commandQualifier = identityBuilder().buildPartial();
161-
Origin origin = Origin
160+
Origin.Builder originBuilder = Origin
162161
.newBuilder()
163162
.setActorContext(actorContext())
164-
.setMessage(commandQualifier)
165-
.setGrandOrigin(origin().orElse(Origin.getDefaultInstance()))
166-
.vBuild();
167-
return origin;
163+
.setMessage(messageId());
164+
origin().ifPresent(originBuilder::setGrandOrigin);
165+
return originBuilder.vBuild();
168166
}
169167

170168
/**

license-report.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
# Dependencies of `io.spine:spine-client:1.6.18`
3+
# Dependencies of `io.spine:spine-client:1.6.19`
44

55
## Runtime
66
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
@@ -399,12 +399,12 @@
399399
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
400400

401401

402-
This report was generated on **Thu Dec 03 17:11:38 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
402+
This report was generated on **Mon Dec 07 16:25:35 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
403403

404404

405405

406406

407-
# Dependencies of `io.spine:spine-core:1.6.18`
407+
# Dependencies of `io.spine:spine-core:1.6.19`
408408

409409
## Runtime
410410
1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2
@@ -763,12 +763,12 @@ This report was generated on **Thu Dec 03 17:11:38 EET 2020** using [Gradle-Lice
763763
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
764764

765765

766-
This report was generated on **Thu Dec 03 17:11:48 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
766+
This report was generated on **Mon Dec 07 16:25:35 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
767767

768768

769769

770770

771-
# Dependencies of `io.spine.tools:spine-model-assembler:1.6.18`
771+
# Dependencies of `io.spine.tools:spine-model-assembler:1.6.19`
772772

773773
## Runtime
774774
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
@@ -1162,12 +1162,12 @@ This report was generated on **Thu Dec 03 17:11:48 EET 2020** using [Gradle-Lice
11621162
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
11631163

11641164

1165-
This report was generated on **Thu Dec 03 17:11:51 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
1165+
This report was generated on **Mon Dec 07 16:25:36 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
11661166

11671167

11681168

11691169

1170-
# Dependencies of `io.spine.tools:spine-model-verifier:1.6.18`
1170+
# Dependencies of `io.spine.tools:spine-model-verifier:1.6.19`
11711171

11721172
## Runtime
11731173
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
@@ -1627,12 +1627,12 @@ This report was generated on **Thu Dec 03 17:11:51 EET 2020** using [Gradle-Lice
16271627
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
16281628

16291629

1630-
This report was generated on **Thu Dec 03 17:11:56 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
1630+
This report was generated on **Mon Dec 07 16:25:36 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
16311631

16321632

16331633

16341634

1635-
# Dependencies of `io.spine:spine-server:1.6.18`
1635+
# Dependencies of `io.spine:spine-server:1.6.19`
16361636

16371637
## Runtime
16381638
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
@@ -2039,12 +2039,12 @@ This report was generated on **Thu Dec 03 17:11:56 EET 2020** using [Gradle-Lice
20392039
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
20402040

20412041

2042-
This report was generated on **Thu Dec 03 17:12:29 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
2042+
This report was generated on **Mon Dec 07 16:25:37 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
20432043

20442044

20452045

20462046

2047-
# Dependencies of `io.spine:spine-testutil-client:1.6.18`
2047+
# Dependencies of `io.spine:spine-testutil-client:1.6.19`
20482048

20492049
## Runtime
20502050
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
@@ -2493,12 +2493,12 @@ This report was generated on **Thu Dec 03 17:12:29 EET 2020** using [Gradle-Lice
24932493
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
24942494

24952495

2496-
This report was generated on **Thu Dec 03 17:12:34 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
2496+
This report was generated on **Mon Dec 07 16:25:38 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
24972497

24982498

24992499

25002500

2501-
# Dependencies of `io.spine:spine-testutil-core:1.6.18`
2501+
# Dependencies of `io.spine:spine-testutil-core:1.6.19`
25022502

25032503
## Runtime
25042504
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
@@ -2947,12 +2947,12 @@ This report was generated on **Thu Dec 03 17:12:34 EET 2020** using [Gradle-Lice
29472947
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
29482948

29492949

2950-
This report was generated on **Thu Dec 03 17:12:37 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
2950+
This report was generated on **Mon Dec 07 16:25:39 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
29512951

29522952

29532953

29542954

2955-
# Dependencies of `io.spine:spine-testutil-server:1.6.18`
2955+
# Dependencies of `io.spine:spine-testutil-server:1.6.19`
29562956

29572957
## Runtime
29582958
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
@@ -3445,4 +3445,4 @@ This report was generated on **Thu Dec 03 17:12:37 EET 2020** using [Gradle-Lice
34453445
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
34463446

34473447

3448-
This report was generated on **Thu Dec 03 17:12:50 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
3448+
This report was generated on **Mon Dec 07 16:25:42 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject.
1212

1313
<groupId>io.spine</groupId>
1414
<artifactId>spine-core-java</artifactId>
15-
<version>1.6.18</version>
15+
<version>1.6.19</version>
1616

1717
<inceptionYear>2015</inceptionYear>
1818

server/src/main/java/io/spine/server/event/RejectionEnvelope.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@
2626
import io.spine.base.Identifier;
2727
import io.spine.base.RejectionMessage;
2828
import io.spine.base.ThrowableMessage;
29-
import io.spine.core.ActorContext;
3029
import io.spine.core.Command;
3130
import io.spine.core.Event;
3231
import io.spine.core.EventContext;
3332
import io.spine.core.EventId;
34-
import io.spine.core.Origin;
3533
import io.spine.core.RejectionEventContext;
3634
import io.spine.core.TenantId;
3735
import io.spine.server.type.AbstractMessageEnvelope;
@@ -152,11 +150,6 @@ public TenantId tenantId() {
152150
return event.tenantId();
153151
}
154152

155-
@Override
156-
public ActorContext actorContext() {
157-
return event.actorContext();
158-
}
159-
160153
@Override
161154
public EventId id() {
162155
return event.id();
@@ -182,11 +175,6 @@ public EventContext context() {
182175
return event.context();
183176
}
184177

185-
@Override
186-
public Origin asMessageOrigin() {
187-
return event.asMessageOrigin();
188-
}
189-
190178
@VisibleForTesting
191179
public EventEnvelope getEvent() {
192180
return event;

server/src/main/java/io/spine/server/type/CommandEnvelope.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@
2121
package io.spine.server.type;
2222

2323
import io.spine.base.CommandMessage;
24-
import io.spine.core.ActorContext;
2524
import io.spine.core.Command;
2625
import io.spine.core.CommandContext;
2726
import io.spine.core.CommandId;
28-
import io.spine.core.Origin;
2927
import io.spine.core.TenantId;
3028
import io.spine.type.TypeName;
3129

@@ -93,19 +91,6 @@ public CommandClass messageClass() {
9391
return commandClass;
9492
}
9593

96-
/**
97-
* Obtains the actor context of the enclosed command.
98-
*/
99-
@Override
100-
public ActorContext actorContext() {
101-
return context().getActorContext();
102-
}
103-
104-
@Override
105-
public Origin asMessageOrigin() {
106-
return command().asMessageOrigin();
107-
}
108-
10994
/**
11095
* Obtains the command context.
11196
*/

server/src/main/java/io/spine/server/type/EventEnvelope.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@
2222

2323
import io.spine.base.CommandMessage;
2424
import io.spine.base.EventMessage;
25-
import io.spine.core.ActorContext;
2625
import io.spine.core.Enrichment;
2726
import io.spine.core.Event;
2827
import io.spine.core.EventContext;
2928
import io.spine.core.EventId;
30-
import io.spine.core.Origin;
3129
import io.spine.core.RejectionEventContext;
3230
import io.spine.core.TenantId;
3331
import io.spine.server.enrich.EnrichmentService;
@@ -105,16 +103,6 @@ public EventClass messageClass() {
105103
return this.eventClass;
106104
}
107105

108-
@Override
109-
public ActorContext actorContext() {
110-
return outerObject().actorContext();
111-
}
112-
113-
@Override
114-
public Origin asMessageOrigin() {
115-
return outerObject().asMessageOrigin();
116-
}
117-
118106
/**
119107
* Obtains the context of the event.
120108
*/

server/src/main/java/io/spine/server/type/SignalEnvelope.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.spine.base.MessageContext;
2424
import io.spine.core.ActorContext;
2525
import io.spine.core.MessageId;
26+
import io.spine.core.Origin;
2627
import io.spine.core.Signal;
2728
import io.spine.core.SignalId;
2829
import io.spine.core.TenantId;
@@ -47,12 +48,19 @@ public interface SignalEnvelope<I extends SignalId,
4748
/**
4849
* Obtains an actor context for the wrapped message.
4950
*/
50-
ActorContext actorContext();
51+
default ActorContext actorContext() {
52+
return outerObject().actorContext();
53+
}
5154

5255
/**
5356
* Obtains the message ID of the signal.
5457
*/
5558
default MessageId messageId() {
5659
return outerObject().messageId();
5760
}
61+
62+
@Override
63+
default Origin asMessageOrigin() {
64+
return outerObject().asMessageOrigin();
65+
}
5866
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright 2020, TeamDev. All rights reserved.
3+
*
4+
* Redistribution and use in source and/or binary forms, with or without
5+
* modification, must retain the above copyright notice and the following
6+
* disclaimer.
7+
*
8+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
9+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
10+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
11+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
12+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
13+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
14+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
15+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
16+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
17+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
18+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19+
*/
20+
21+
package io.spine.core;
22+
23+
import io.spine.base.CommandMessage;
24+
import io.spine.server.event.EventFactory;
25+
import io.spine.server.type.EventEnvelope;
26+
import io.spine.server.type.given.GivenEvent;
27+
import io.spine.testing.core.given.GivenUserId;
28+
import io.spine.type.TypeUrl;
29+
import org.junit.jupiter.api.DisplayName;
30+
import org.junit.jupiter.api.Test;
31+
32+
import static com.google.common.truth.Truth.assertThat;
33+
import static io.spine.protobuf.AnyPacker.pack;
34+
import static io.spine.server.event.EventFactory.on;
35+
36+
/**
37+
* Extra tests for {@link Signal}s.
38+
*
39+
* <p>The main test suite for {@code Signal}s is located in the {@code core} module. This test suite
40+
* only hosts tests which rely on the components from the {@code server} module.
41+
*/
42+
@DisplayName("`Signal` also should")
43+
class SignalTest {
44+
45+
@Test
46+
@DisplayName("produce correct origin")
47+
void produceOrigin() {
48+
Event originalEvent = GivenEvent.arbitrary();
49+
UserId producerEntityId = GivenUserId.generated();
50+
EventFactory factory = on(EventEnvelope.of(originalEvent), pack(producerEntityId));
51+
Event derivativeEvent = factory.createEvent(GivenEvent.message(), null);
52+
Origin origin = derivativeEvent.getContext().getPastMessage();
53+
assertThat(origin.getMessage())
54+
.isEqualTo(originalEvent.messageId());
55+
Origin grandOrigin = origin.getGrandOrigin();
56+
TypeUrl grandOriginType = TypeUrl.parse(grandOrigin.getMessage()
57+
.getTypeUrl());
58+
assertThat(grandOriginType.toJavaClass())
59+
.isAssignableTo(CommandMessage.class);
60+
assertThat(grandOrigin.hasGrandOrigin())
61+
.isFalse();
62+
}
63+
}

version.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
/**
3535
* Version of this library.
3636
*/
37-
val coreJava = "1.6.18"
37+
val coreJava = "1.6.19"
3838

3939
/**
4040
* Versions of the Spine libraries that `core-java` depends on.

0 commit comments

Comments
 (0)