-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: moving @migration to java-sdk-protobuf (#1780)
* fix: moving @migration to java-sdk-protobuf * fixing tests * fixing samples
- Loading branch information
Showing
12 changed files
with
33 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,40 +3,26 @@ | |
import com.google.protobuf.Any; | ||
import com.google.protobuf.ByteString; | ||
import com.google.protobuf.InvalidProtocolBufferException; | ||
import customer.domain.schemaevolution.AddressChangedMigration; | ||
import customer.domain.schemaevolution.NameChangedMigration; | ||
import kalix.javasdk.JsonSupport; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Base64; | ||
import java.util.Optional; | ||
|
||
import static customer.domain.schemaevolution.CustomerEvent.*; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
import static customer.domain.schemaevolution.CustomerEvent.AddressChanged; | ||
import static customer.domain.schemaevolution.CustomerEvent.CustomerCreated; | ||
import static customer.domain.schemaevolution.CustomerEvent.NameChanged; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class CustomerEventSerializationTest { | ||
|
||
@Test | ||
public void shouldDeserializeWithOptionalField() { | ||
//given | ||
Any serialized = JsonSupport.encodeJson(new CustomerEvent.NameChanged("andre")); | ||
|
||
//when | ||
NameChanged deserialized = JsonSupport.decodeJson(NameChanged.class, serialized); | ||
|
||
//then | ||
assertEquals("andre", deserialized.newName()); | ||
assertEquals(Optional.empty(), deserialized.oldName()); | ||
assertEquals(null, deserialized.reason()); | ||
} | ||
|
||
@Test | ||
public void shouldDeserializeWithMandatoryField() { | ||
//given | ||
Any serialized = JsonSupport.encodeJson(new CustomerEvent.NameChanged("andre")); | ||
|
||
//when | ||
NameChanged deserialized = JsonSupport.decodeJson(NameChanged.class, serialized, Optional.of(new NameChangedMigration())); | ||
NameChanged deserialized = JsonSupport.decodeJson(NameChanged.class, serialized); | ||
|
||
//then | ||
assertEquals("andre", deserialized.newName()); | ||
|
@@ -51,7 +37,7 @@ public void shouldDeserializeWithChangedFieldName() { | |
Any serialized = JsonSupport.encodeJson(new CustomerEvent.AddressChanged(address)); | ||
|
||
//when | ||
AddressChanged deserialized = JsonSupport.decodeJson(AddressChanged.class, serialized, Optional.of(new AddressChangedMigration())); | ||
AddressChanged deserialized = JsonSupport.decodeJson(AddressChanged.class, serialized); | ||
|
||
//then | ||
assertEquals(address, deserialized.newAddress()); | ||
|
@@ -63,7 +49,7 @@ public void shouldDeserializeWithStructureMigration() { | |
Any serialized = JsonSupport.encodeJson(new CustomerCreated("[email protected]", "bob", "Wall Street", "New York")); | ||
|
||
//when | ||
CustomerEvent.CustomerCreated deserialized = JsonSupport.decodeJson(CustomerEvent.CustomerCreated.class, serialized, Optional.of(new CustomerCreatedMigration())); | ||
CustomerEvent.CustomerCreated deserialized = JsonSupport.decodeJson(CustomerEvent.CustomerCreated.class, serialized); | ||
|
||
//then | ||
assertEquals("Wall Street", deserialized.address().street()); | ||
|
@@ -84,8 +70,7 @@ public void shouldDeserializeCustomerCreated_V0() throws InvalidProtocolBufferEx | |
Any serializedAny = Any.parseFrom(ByteString.copyFrom(bytes)); // <2> | ||
|
||
CustomerEvent.CustomerCreated deserialized = JsonSupport.decodeJson(CustomerEvent.CustomerCreated.class, | ||
serializedAny, | ||
Optional.of(new CustomerCreatedMigration())); // <3> | ||
serializedAny); // <3> | ||
|
||
assertEquals("Wall Street", deserialized.address().street()); | ||
assertEquals("New York", deserialized.address().city()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
sdk/java-sdk-spring/src/main/scala/kalix/javasdk/impl/reflection/MigrationExtractor.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters