Skip to content
This repository was archived by the owner on Dec 27, 2021. It is now read-only.

Commit 24df82a

Browse files
authored
Fix proto breaking changes ✨ (#197)
1 parent 1549536 commit 24df82a

File tree

9 files changed

+22
-14
lines changed

9 files changed

+22
-14
lines changed

core/lagompb-core/src/main/scala/io/superflat/lagompb/AggregateRoot.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ abstract class AggregateRoot(
166166
*/
167167
private[lagompb] def nextMeta(
168168
stateWrapper: StateWrapper,
169-
data: Map[String, String]
169+
data: Map[String, Any]
170170
): MetaData = {
171171
MetaData()
172172
.withRevisionNumber(stateWrapper.getMeta.revisionNumber + 1)

core/lagompb-core/src/main/scala/io/superflat/lagompb/BaseServiceImpl.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.superflat.lagompb
22

33
import akka.cluster.sharding.typed.scaladsl.ClusterSharding
44
import akka.grpc.GrpcServiceException
5+
import com.google.protobuf.any.Any
56
import com.lightbend.lagom.scaladsl.api.transport.{BadRequest, NotFound}
67
import com.lightbend.lagom.scaladsl.persistence.PersistentEntityRegistry
78
import io.grpc.Status
@@ -32,7 +33,7 @@ trait SharedBaseServiceImpl extends SendCommand {
3233
def sendCommand(
3334
entityId: String,
3435
cmd: GeneratedMessage,
35-
data: Map[String, String]
36+
data: Map[String, Any]
3637
)(implicit
3738
ec: ExecutionContext
3839
): Future[StateWrapper] = {

core/lagompb-core/src/main/scala/io/superflat/lagompb/Command.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ import io.superflat.lagompb.protobuf.v1.core.CommandReply
1717
final case class Command(
1818
command: Any,
1919
replyTo: ActorRef[CommandReply],
20-
data: Map[String, String]
20+
data: Map[String, Any]
2121
)

core/lagompb-core/src/main/scala/io/superflat/lagompb/SendCommand.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ trait SendCommand {
3434
aggregateRoot: AggregateRoot,
3535
entityId: String,
3636
cmd: scalapb.GeneratedMessage,
37-
data: Map[String, String]
37+
data: Map[String, Any]
3838
)(implicit ec: ExecutionContext): Future[StateWrapper] =
3939
clusterSharding
4040
.entityRefFor(aggregateRoot.typeKey, entityId)
@@ -59,7 +59,7 @@ trait SendCommand {
5959
aggregateRoot: AggregateRoot,
6060
entityId: String,
6161
cmd: scalapb.GeneratedMessage,
62-
data: Map[String, String]
62+
data: Map[String, Any]
6363
)(implicit
6464
ec: ExecutionContext
6565
): Future[(scalapb.GeneratedMessage, MetaData)] =

core/lagompb-core/src/test/protobuf/lagompb/v1/tests.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ message TestCommand {
1313
string name = 2;
1414
}
1515

16+
// used for auditing plugin
17+
message AuditingData{
18+
map<string, string> data = 1;
19+
}
20+
1621
// used to test NoEvent to be persisted
1722
message NoEventTestCommand {}
1823

core/lagompb-core/src/test/scala/io/superflat/lagompb/AggregateRootSpec.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class AggregateRootSpec extends BaseActorTestKit(s"""
6565
val testCmd = TestCommand(companyUUID, "first test")
6666

6767
// let us send the command to the aggregate
68-
val data = Map("audit|employeeUuid" -> "1223", "audit|createdAt" -> "2020-04-17")
68+
val auditing = AuditingData.defaultInstance.withData(Map("employeeUuid" -> "123"))
69+
val data = Map("audit" -> Any.pack(auditing))
6970

7071
aggregateRef ! Command(Any.pack(testCmd), commandSender.ref, data)
7172

@@ -104,7 +105,7 @@ class AggregateRootSpec extends BaseActorTestKit(s"""
104105
val testCmd = TestCommand("", "first test")
105106

106107
// let us send the command to the aggregate
107-
aggregateRef ! Command(Any.pack(testCmd), commandSender.ref, Map.empty[String, String])
108+
aggregateRef ! Command(Any.pack(testCmd), commandSender.ref, Map.empty[String, Any])
108109

109110
commandSender.receiveMessage(replyTimeout) match {
110111
case CommandReply(reply, _) =>
@@ -141,8 +142,8 @@ class AggregateRootSpec extends BaseActorTestKit(s"""
141142
val testCmd = NoEventTestCommand.defaultInstance
142143

143144
// let us send the command to the aggregate
144-
val data =
145-
Map("audit|employeeUuid" -> "1223", "audit|createdAt" -> "2020-04-17")
145+
val auditing = AuditingData.defaultInstance.withData(Map("employeeUuid" -> "123"))
146+
val data = Map("audit" -> Any.pack(auditing))
146147

147148
aggregateRef ! Command(Any.pack(testCmd), commandSender.ref, data)
148149

core/lagompb-core/src/test/scala/io/superflat/lagompb/CommandSerializerSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package io.superflat.lagompb
33
import akka.actor.testkit.typed.scaladsl.TestProbe
44
import com.google.protobuf.any.Any
55
import io.superflat.lagompb.protobuf.v1.core.CommandReply
6-
import io.superflat.lagompb.protobuf.v1.tests.TestCommand
6+
import io.superflat.lagompb.protobuf.v1.tests.{AuditingData, TestCommand}
77
import io.superflat.lagompb.testkit.BaseActorTestKit
88

99
class CommandSerializerSpec extends BaseActorTestKit(s"""
@@ -26,8 +26,8 @@ class CommandSerializerSpec extends BaseActorTestKit(s"""
2626
"Verification of command serializer" in {
2727
val probe: TestProbe[CommandReply] = createTestProbe[CommandReply]()
2828
val command = TestCommand(companyUUID, "John Ross")
29-
val data =
30-
Map("audit|employeeUuid" -> "1223", "audit|createdAt" -> "2020-04-17")
29+
val auditing = AuditingData.defaultInstance.withData(Map("employeeUuid" -> "123"))
30+
val data = Map("audit" -> Any.pack(auditing))
3131
serializationTestKit.verifySerialization(Command(Any.pack(command), probe.ref, data))
3232
}
3333
}

core/lagompb-core/src/test/scala/io/superflat/lagompb/data/TestService.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import java.util.UUID
44

55
import akka.actor.ActorSystem
66
import akka.cluster.sharding.typed.scaladsl.ClusterSharding
7+
import com.google.protobuf.any.Any
78
import com.lightbend.lagom.scaladsl.api.Service.restCall
89
import com.lightbend.lagom.scaladsl.api.transport.Method
910
import com.lightbend.lagom.scaladsl.api.{Descriptor, ServiceCall}
@@ -37,7 +38,7 @@ class TestServiceImpl(
3738
override def testHello: ServiceCall[TestCommand, TestState] = { req =>
3839
val companyId: String = UUID.randomUUID().toString
3940
val cmd = req.update(_.companyUuid := companyId)
40-
sendCommand(companyId, cmd, Map.empty[String, String])
41+
sendCommand(companyId, cmd, Map.empty[String, Any])
4142
.map((rst: StateWrapper) => rst.state.get.unpack(TestState))
4243
}
4344
}

submodules/protobuf

0 commit comments

Comments
 (0)