Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ void updateItem(String inventoryId,
Long tokenId,
String metadataUrl,
String traceId,
ItemState itemState) throws Exception;
ItemState itemState,
Long version) throws Exception;

void updateItems(List<SagaItemUpdate> updates, String traceId) throws Exception;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class SagaItem {
@DtoExclude
private Instant updatedAt;
private String state;
private long version;

public static SagaItem fromProto(ItemProto proto) {
var user = ProtoUtil.toDto(proto, SagaItem.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class SagaItemUpdate {
private String oauthId;
private long tokenId;
private String metadataUrl;
private long version;
@DtoExclude
private ItemState itemState;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ private void handleItemUpdate(ItemUpdate update, String traceId) throws Exceptio
message.getTokenId(),
message.getMetadataUrl(),
traceId,
message.getItemState()
message.getItemState(),
message.getVersion()
);
} else {
final var updates = update.getStatusUpdates().getStatusUpdatesList().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public void getItem() throws Exception {
.setMetadataUrl("metadata-url")
.setCreatedAt(Timestamps.fromMillis(Instant.now().toEpochMilli() - 86400))
.setUpdatedAt(Timestamps.fromMillis(Instant.now().toEpochMilli()))
.setVersion(1L)
.build();
when(mockServiceBlockingStub.getItem(any())).thenReturn(expectedResponse);
var itemResponse = itemClient.getItem(INVENTORY_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class MockItemExecutor extends MockBaseExecutor implements SagaItemExecut
private String metadataUri;
private String traceId;
private ItemState itemState;
private Long version;

@Override
public void updateItem(String inventoryId,
Expand All @@ -25,14 +26,16 @@ public void updateItem(String inventoryId,
Long tokenId,
String metadataUrl,
String traceId,
ItemState itemState) throws Exception {
ItemState itemState,
Long version) throws Exception {
this.inventoryId = inventoryId;
this.itemTypeId = itemTypeId;
this.oauthId = oauthId;
this.tokenId = tokenId;
this.metadataUri = metadataUrl;
this.traceId = traceId;
this.itemState = itemState;
this.version = version;
}

@Override
Expand All @@ -45,7 +48,8 @@ public void updateItems(List<SagaItemUpdate> updates, String traceId) throws Exc
update.getTokenId(),
update.getMetadataUrl(),
traceId,
update.getItemState()
update.getItemState(),
update.getVersion()
);
}

Expand Down
2 changes: 1 addition & 1 deletion saga-sdk-proto/src/main/proto
Loading