diff --git a/common/types/mapper/thrift/history_test.go b/common/types/mapper/thrift/history_test.go new file mode 100644 index 00000000000..1ab81c603cc --- /dev/null +++ b/common/types/mapper/thrift/history_test.go @@ -0,0 +1,677 @@ +// Copyright (c) 2021 Uber Technologies Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +package thrift + +import ( + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/stretchr/testify/assert" + + "github.com/uber/cadence/common" + "github.com/uber/cadence/common/types" + "github.com/uber/cadence/common/types/testdata" +) + +func TestHistoryTerminateWorkflowExecutionRequestConversion(t *testing.T) { + for _, item := range []*types.HistoryTerminateWorkflowExecutionRequest{nil, {}, &testdata.HistoryTerminateWorkflowExecutionRequest} { + assert.Equal(t, item, ToHistoryTerminateWorkflowExecutionRequest(FromHistoryTerminateWorkflowExecutionRequest(item))) + } +} + +func TestDescribeMutableStateRequestConversion(t *testing.T) { + testCases := []*types.DescribeMutableStateRequest{ + nil, + {}, + &testdata.HistoryDescribeMutableStateRequest, + } + + for _, original := range testCases { + thriftObj := FromDescribeMutableStateRequest(original) + roundTripObj := ToDescribeMutableStateRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDescribeMutableStateResponseConversion(t *testing.T) { + testCases := []*types.DescribeMutableStateResponse{ + nil, + {}, + &testdata.HistoryDescribeMutableStateResponse, + } + + for _, original := range testCases { + thriftObj := FromDescribeMutableStateResponse(original) + roundTripObj := ToDescribeMutableStateResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryDescribeWorkflowExecutionRequestConversion(t *testing.T) { + testCases := []*types.HistoryDescribeWorkflowExecutionRequest{ + nil, + {}, + &testdata.HistoryDescribeWorkflowExecutionRequest, + } + + for _, original := range testCases { + thriftObj := FromHistoryDescribeWorkflowExecutionRequest(original) + roundTripObj := ToHistoryDescribeWorkflowExecutionRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDomainFilterConversion(t *testing.T) { + testCases := []*types.DomainFilter{ + nil, + {}, + {DomainIDs: []string{"test"}, ReverseMatch: true}, + } + + for _, original := range testCases { + thriftObj := FromDomainFilter(original) + roundTripObj := ToDomainFilter(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestEventAlreadyStartedErrorConversion(t *testing.T) { + testCases := []*types.EventAlreadyStartedError{ + nil, + {}, + &testdata.EventAlreadyStartedError, + } + + for _, original := range testCases { + thriftObj := FromEventAlreadyStartedError(original) + roundTripObj := ToEventAlreadyStartedError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestFailoverMarkerTokenConversion(t *testing.T) { + testCases := []*types.FailoverMarkerToken{ + nil, + {}, + &testdata.FailoverMarkerToken, + } + + for _, original := range testCases { + thriftObj := FromFailoverMarkerToken(original) + roundTripObj := ToFailoverMarkerToken(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestGetMutableStateRequestConversion(t *testing.T) { + testCases := []*types.GetMutableStateRequest{ + nil, + {}, + &testdata.HistoryGetMutableStateRequest, + } + + for _, original := range testCases { + thriftObj := FromGetMutableStateRequest(original) + roundTripObj := ToGetMutableStateRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestGetMutableStateResponseConversion(t *testing.T) { + testCases := []*types.GetMutableStateResponse{ + nil, + {}, + &testdata.HistoryGetMutableStateResponse, + } + + for _, original := range testCases { + thriftObj := FromGetMutableStateResponse(original) + roundTripObj := ToGetMutableStateResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestNotifyFailoverMarkersRequestConversion(t *testing.T) { + testCases := []*types.NotifyFailoverMarkersRequest{ + nil, + {}, + {FailoverMarkerTokens: []*types.FailoverMarkerToken{&testdata.FailoverMarkerToken}}, + } + + for _, original := range testCases { + thriftObj := FromNotifyFailoverMarkersRequest(original) + roundTripObj := ToNotifyFailoverMarkersRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestParentExecutionInfoConversion(t *testing.T) { + testCases := []*types.ParentExecutionInfo{ + nil, + {}, + &testdata.ParentExecutionInfo, + } + + for _, original := range testCases { + thriftObj := FromParentExecutionInfo(original) + roundTripObj := ToParentExecutionInfo(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestPollMutableStateRequestConversion(t *testing.T) { + testCases := []*types.PollMutableStateRequest{ + nil, + {}, + &testdata.HistoryPollMutableStateRequest, + } + + for _, original := range testCases { + thriftObj := FromPollMutableStateRequest(original) + roundTripObj := ToPollMutableStateRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestPollMutableStateResponseConversion(t *testing.T) { + testCases := []*types.PollMutableStateResponse{ + nil, + {}, + &testdata.HistoryPollMutableStateResponse, + } + + for _, original := range testCases { + thriftObj := FromPollMutableStateResponse(original) + roundTripObj := ToPollMutableStateResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestProcessingQueueStateConversion(t *testing.T) { + testCases := []*types.ProcessingQueueState{ + nil, + {}, + {Level: common.Int32Ptr(1), AckLevel: common.Int64Ptr(1), MaxLevel: common.Int64Ptr(1), DomainFilter: &types.DomainFilter{DomainIDs: []string{"test"}, ReverseMatch: true}}, + } + + for _, original := range testCases { + thriftObj := FromProcessingQueueState(original) + roundTripObj := ToProcessingQueueState(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestProcessingQueueStatesConversion(t *testing.T) { + testCases := []*types.ProcessingQueueStates{ + nil, + {}, + { + StatesByCluster: map[string][]*types.ProcessingQueueState{ + "test": { + {Level: common.Int32Ptr(1), AckLevel: common.Int64Ptr(1), MaxLevel: common.Int64Ptr(1), DomainFilter: &types.DomainFilter{DomainIDs: []string{"test"}, ReverseMatch: true}}, + }, + }, + }, + } + + for _, original := range testCases { + thriftObj := FromProcessingQueueStates(original) + roundTripObj := ToProcessingQueueStates(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryQueryWorkflowRequestConversion(t *testing.T) { + testCases := []*types.HistoryQueryWorkflowRequest{ + nil, + {}, + &testdata.HistoryQueryWorkflowRequest, + } + + for _, original := range testCases { + thriftObj := FromHistoryQueryWorkflowRequest(original) + roundTripObj := ToHistoryQueryWorkflowRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryQueryWorkflowResponseConversion(t *testing.T) { + testCases := []*types.HistoryQueryWorkflowResponse{ + nil, + {}, + &testdata.HistoryQueryWorkflowResponse, + } + + for _, original := range testCases { + thriftObj := FromHistoryQueryWorkflowResponse(original) + roundTripObj := ToHistoryQueryWorkflowResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryReapplyEventsRequestConversion(t *testing.T) { + testCases := []*types.HistoryReapplyEventsRequest{ + nil, + {}, + &testdata.HistoryReapplyEventsRequest, + } + + for _, original := range testCases { + thriftObj := FromHistoryReapplyEventsRequest(original) + roundTripObj := ToHistoryReapplyEventsRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} +func TestHistoryRecordActivityTaskHeartbeatRequestConversion(t *testing.T) { + testCases := []*types.HistoryRecordActivityTaskHeartbeatRequest{ + nil, + {}, + &testdata.HistoryRecordActivityTaskHeartbeatRequest, + } + + for _, original := range testCases { + thriftObj := FromHistoryRecordActivityTaskHeartbeatRequest(original) + roundTripObj := ToHistoryRecordActivityTaskHeartbeatRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRecordActivityTaskStartedRequestConversion(t *testing.T) { + testCases := []*types.RecordActivityTaskStartedRequest{ + nil, + {}, + &testdata.HistoryRecordActivityTaskStartedRequest, + } + + for _, original := range testCases { + thriftObj := FromRecordActivityTaskStartedRequest(original) + roundTripObj := ToRecordActivityTaskStartedRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRecordActivityTaskStartedResponseConversion(t *testing.T) { + testCases := []*types.RecordActivityTaskStartedResponse{ + nil, + {}, + &testdata.HistoryRecordActivityTaskStartedResponse, + } + + for _, original := range testCases { + thriftObj := FromRecordActivityTaskStartedResponse(original) + roundTripObj := ToRecordActivityTaskStartedResponse(thriftObj) + opt := cmpopts.IgnoreFields(types.WorkflowExecutionStartedEventAttributes{}, "ParentWorkflowDomainID") + if diff := cmp.Diff(original, roundTripObj, opt); diff != "" { + t.Fatalf("Mismatch (-want +got):\n%s", diff) + } + } +} + +func TestRecordChildExecutionCompletedRequestConversion(t *testing.T) { + testCases := []*types.RecordChildExecutionCompletedRequest{ + nil, + {}, + &testdata.HistoryRecordChildExecutionCompletedRequest, + } + + for _, original := range testCases { + thriftObj := FromRecordChildExecutionCompletedRequest(original) + roundTripObj := ToRecordChildExecutionCompletedRequest(thriftObj) + opt := cmpopts.IgnoreFields(types.WorkflowExecutionStartedEventAttributes{}, "ParentWorkflowDomainID") + if diff := cmp.Diff(original, roundTripObj, opt); diff != "" { + t.Fatalf("Mismatch (-want +got):\n%s", diff) + } + } +} + +func TestRecordDecisionTaskStartedRequestConversion(t *testing.T) { + testCases := []*types.RecordDecisionTaskStartedRequest{ + nil, + {}, + &testdata.HistoryRecordDecisionTaskStartedRequest, + } + + for _, original := range testCases { + thriftObj := FromRecordDecisionTaskStartedRequest(original) + roundTripObj := ToRecordDecisionTaskStartedRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRecordDecisionTaskStartedResponseConversion(t *testing.T) { + testCases := []*types.RecordDecisionTaskStartedResponse{ + nil, + {}, + &testdata.HistoryRecordDecisionTaskStartedResponse, + } + + for _, original := range testCases { + thriftObj := FromRecordDecisionTaskStartedResponse(original) + roundTripObj := ToRecordDecisionTaskStartedResponse(thriftObj) + opt := cmpopts.IgnoreFields(types.WorkflowExecutionStartedEventAttributes{}, "ParentWorkflowDomainID") + if diff := cmp.Diff(original, roundTripObj, opt); diff != "" { + t.Fatalf("Mismatch (-want +got):\n%s", diff) + } + } +} + +func TestHistoryRefreshWorkflowTasksRequestConversion(t *testing.T) { + testCases := []*types.HistoryRefreshWorkflowTasksRequest{ + nil, + {}, + &testdata.HistoryRefreshWorkflowTasksRequest, + } + + for _, original := range testCases { + thriftObj := FromHistoryRefreshWorkflowTasksRequest(original) + roundTripObj := ToHistoryRefreshWorkflowTasksRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRemoveSignalMutableStateRequestConversion(t *testing.T) { + testCases := []*types.RemoveSignalMutableStateRequest{ + nil, + {}, + {DomainUUID: "test-uuid", WorkflowExecution: &types.WorkflowExecution{WorkflowID: "test", RunID: "test"}, RequestID: "test-req"}, + } + + for _, original := range testCases { + thriftObj := FromRemoveSignalMutableStateRequest(original) + roundTripObj := ToRemoveSignalMutableStateRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestReplicateEventsV2RequestConversion(t *testing.T) { + testCases := []*types.ReplicateEventsV2Request{ + nil, + {}, + &testdata.HistoryReplicateEventsV2Request, + } + + for _, original := range testCases { + thriftObj := FromReplicateEventsV2Request(original) + roundTripObj := ToReplicateEventsV2Request(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryRequestCancelWorkflowExecutionRequestConversion(t *testing.T) { + testCases := []*types.HistoryRequestCancelWorkflowExecutionRequest{ + nil, + {}, + &testdata.HistoryRequestCancelWorkflowExecutionRequest, + } + + for _, original := range testCases { + thriftObj := FromHistoryRequestCancelWorkflowExecutionRequest(original) + roundTripObj := ToHistoryRequestCancelWorkflowExecutionRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryResetStickyTaskListRequestConversion(t *testing.T) { + testCases := []*types.HistoryResetStickyTaskListRequest{ + nil, + {}, + &testdata.HistoryResetStickyTaskListRequest, + } + + for _, original := range testCases { + thriftObj := FromHistoryResetStickyTaskListRequest(original) + roundTripObj := ToHistoryResetStickyTaskListRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryResetStickyTaskListResponseConversion(t *testing.T) { + testCases := []*types.HistoryResetStickyTaskListResponse{ + nil, + {}, + } + + for _, original := range testCases { + thriftObj := FromHistoryResetStickyTaskListResponse(original) + roundTripObj := ToHistoryResetStickyTaskListResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryResetWorkflowExecutionRequestConversion(t *testing.T) { + testCases := []*types.HistoryResetWorkflowExecutionRequest{ + nil, + {}, + &testdata.HistoryResetWorkflowExecutionRequest, + } + + for _, original := range testCases { + thriftObj := FromHistoryResetWorkflowExecutionRequest(original) + roundTripObj := ToHistoryResetWorkflowExecutionRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryRespondActivityTaskCanceledRequestConversion(t *testing.T) { + testCases := []*types.HistoryRespondActivityTaskCanceledRequest{ + nil, + {}, + &testdata.HistoryRespondActivityTaskCanceledRequest, + } + + for _, original := range testCases { + thriftObj := FromHistoryRespondActivityTaskCanceledRequest(original) + roundTripObj := ToHistoryRespondActivityTaskCanceledRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryRespondActivityTaskCompletedRequestConversion(t *testing.T) { + testCases := []*types.HistoryRespondActivityTaskCompletedRequest{ + nil, + {}, + &testdata.HistoryRespondActivityTaskCompletedRequest, + } + + for _, original := range testCases { + thriftObj := FromHistoryRespondActivityTaskCompletedRequest(original) + roundTripObj := ToHistoryRespondActivityTaskCompletedRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryRespondActivityTaskFailedRequestConversion(t *testing.T) { + testCases := []*types.HistoryRespondActivityTaskFailedRequest{ + nil, + {}, + &testdata.HistoryRespondActivityTaskFailedRequest, + } + + for _, original := range testCases { + thriftObj := FromHistoryRespondActivityTaskFailedRequest(original) + roundTripObj := ToHistoryRespondActivityTaskFailedRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryRespondDecisionTaskCompletedRequestConversion(t *testing.T) { + testCases := []*types.HistoryRespondDecisionTaskCompletedRequest{ + nil, + {}, + &testdata.HistoryRespondDecisionTaskCompletedRequest, + } + + for _, original := range testCases { + thriftObj := FromHistoryRespondDecisionTaskCompletedRequest(original) + roundTripObj := ToHistoryRespondDecisionTaskCompletedRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryRespondDecisionTaskCompletedResponseConversion(t *testing.T) { + testCases := []*types.HistoryRespondDecisionTaskCompletedResponse{ + nil, + {}, + &testdata.HistoryRespondDecisionTaskCompletedResponse, + } + + for _, original := range testCases { + thriftObj := FromHistoryRespondDecisionTaskCompletedResponse(original) + roundTripObj := ToHistoryRespondDecisionTaskCompletedResponse(thriftObj) + opt := cmpopts.IgnoreFields(types.WorkflowExecutionStartedEventAttributes{}, "ParentWorkflowDomainID") + if diff := cmp.Diff(original, roundTripObj, opt); diff != "" { + t.Fatalf("Mismatch (-want +got):\n%s", diff) + } + } +} + +func TestHistoryRespondDecisionTaskFailedRequestConversion(t *testing.T) { + testCases := []*types.HistoryRespondDecisionTaskFailedRequest{ + nil, + {}, + &testdata.HistoryRespondDecisionTaskFailedRequest, + } + + for _, original := range testCases { + thriftObj := FromHistoryRespondDecisionTaskFailedRequest(original) + roundTripObj := ToHistoryRespondDecisionTaskFailedRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestScheduleDecisionTaskRequestConversion(t *testing.T) { + testCases := []*types.ScheduleDecisionTaskRequest{ + nil, + {}, + &testdata.HistoryScheduleDecisionTaskRequest, + } + + for _, original := range testCases { + thriftObj := FromScheduleDecisionTaskRequest(original) + roundTripObj := ToScheduleDecisionTaskRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestShardOwnershipLostErrorConversion(t *testing.T) { + testCases := []*types.ShardOwnershipLostError{ + nil, + {}, + &testdata.ShardOwnershipLostError, + } + + for _, original := range testCases { + thriftObj := FromShardOwnershipLostError(original) + roundTripObj := ToShardOwnershipLostError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistorySignalWithStartWorkflowExecutionRequestConversion(t *testing.T) { + testCases := []*types.HistorySignalWithStartWorkflowExecutionRequest{ + nil, + {}, + &testdata.HistorySignalWithStartWorkflowExecutionRequest, + } + + for _, original := range testCases { + thriftObj := FromHistorySignalWithStartWorkflowExecutionRequest(original) + roundTripObj := ToHistorySignalWithStartWorkflowExecutionRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistorySignalWorkflowExecutionRequestConversion(t *testing.T) { + testCases := []*types.HistorySignalWorkflowExecutionRequest{ + nil, + {}, + &testdata.HistorySignalWorkflowExecutionRequest, + } + + for _, original := range testCases { + thriftObj := FromHistorySignalWorkflowExecutionRequest(original) + roundTripObj := ToHistorySignalWorkflowExecutionRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryStartWorkflowExecutionRequestConversion(t *testing.T) { + testCases := []*types.HistoryStartWorkflowExecutionRequest{ + nil, + {}, + &testdata.HistoryStartWorkflowExecutionRequest, + } + + for _, original := range testCases { + thriftObj := FromHistoryStartWorkflowExecutionRequest(original) + roundTripObj := ToHistoryStartWorkflowExecutionRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestSyncActivityRequestConversion(t *testing.T) { + testCases := []*types.SyncActivityRequest{ + nil, + {}, + { + DomainID: "test-domain-id", + WorkflowID: "test-workflow-id", + RunID: "test-run-id", + Version: 1, + ScheduledID: 1, + ScheduledTime: common.Int64Ptr(98765), + StartedID: 1, + StartedTime: common.Int64Ptr(98765), + LastHeartbeatTime: common.Int64Ptr(98765), + Details: []byte("test-details"), + Attempt: 3, + LastFailureReason: common.StringPtr("test-last-failure-reason"), + LastWorkerIdentity: "test-last-worker-identity", + LastFailureDetails: []byte("test-last-failure-details"), + VersionHistory: &testdata.VersionHistory, + }, + } + + for _, original := range testCases { + thriftObj := FromSyncActivityRequest(original) + roundTripObj := ToSyncActivityRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestSyncShardStatusRequestConversion(t *testing.T) { + testCases := []*types.SyncShardStatusRequest{ + nil, + {}, + { + SourceCluster: "test-source-cluster", + ShardID: 1, + Timestamp: common.Int64Ptr(98765), + }, + } + + for _, original := range testCases { + thriftObj := FromSyncShardStatusRequest(original) + roundTripObj := ToSyncShardStatusRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} diff --git a/common/types/mapper/thrift/shared.go b/common/types/mapper/thrift/shared.go index abcf533a70f..27840df48cf 100644 --- a/common/types/mapper/thrift/shared.go +++ b/common/types/mapper/thrift/shared.go @@ -894,6 +894,7 @@ func FromContinueAsNewWorkflowExecutionDecisionAttributes(t *types.ContinueAsNew Header: FromHeader(t.Header), Memo: FromMemo(t.Memo), SearchAttributes: FromSearchAttributes(t.SearchAttributes), + JitterStartSeconds: t.JitterStartSeconds, } } @@ -918,6 +919,7 @@ func ToContinueAsNewWorkflowExecutionDecisionAttributes(t *shared.ContinueAsNewW Header: ToHeader(t.Header), Memo: ToMemo(t.Memo), SearchAttributes: ToSearchAttributes(t.SearchAttributes), + JitterStartSeconds: t.JitterStartSeconds, } } @@ -1575,17 +1577,6 @@ func FromDescribeHistoryHostRequest(t *types.DescribeHistoryHostRequest) *shared } } -// FromDescribeShardDistributionRequest converts internal DescribeHistoryHostRequest type to thrift -func FromDescribeShardDistributionRequest(t *types.DescribeShardDistributionRequest) *shared.DescribeShardDistributionRequest { - if t == nil { - return nil - } - return &shared.DescribeShardDistributionRequest{ - PageSize: &t.PageSize, - PageID: &t.PageID, - } -} - // ToDescribeHistoryHostRequest converts thrift DescribeHistoryHostRequest type to internal func ToDescribeHistoryHostRequest(t *shared.DescribeHistoryHostRequest) *types.DescribeHistoryHostRequest { if t == nil { @@ -1598,6 +1589,17 @@ func ToDescribeHistoryHostRequest(t *shared.DescribeHistoryHostRequest) *types.D } } +// FromDescribeShardDistributionRequest converts internal DescribeHistoryHostRequest type to thrift +func FromDescribeShardDistributionRequest(t *types.DescribeShardDistributionRequest) *shared.DescribeShardDistributionRequest { + if t == nil { + return nil + } + return &shared.DescribeShardDistributionRequest{ + PageSize: &t.PageSize, + PageID: &t.PageID, + } +} + // ToDescribeShardDistributionRequest converts thrift DescribeHistoryHostRequest type to internal func ToDescribeShardDistributionRequest(t *shared.DescribeShardDistributionRequest) *types.DescribeShardDistributionRequest { if t == nil { @@ -1623,17 +1625,6 @@ func FromDescribeHistoryHostResponse(t *types.DescribeHistoryHostResponse) *shar } } -// FromDescribeShardDistributionResponse converts internal DescribeHistoryHostResponse type to thrift -func FromDescribeShardDistributionResponse(t *types.DescribeShardDistributionResponse) *shared.DescribeShardDistributionResponse { - if t == nil { - return nil - } - return &shared.DescribeShardDistributionResponse{ - NumberOfShards: &t.NumberOfShards, - Shards: t.Shards, - } -} - // ToDescribeHistoryHostResponse converts thrift DescribeHistoryHostResponse type to internal func ToDescribeHistoryHostResponse(t *shared.DescribeHistoryHostResponse) *types.DescribeHistoryHostResponse { if t == nil { @@ -1648,6 +1639,17 @@ func ToDescribeHistoryHostResponse(t *shared.DescribeHistoryHostResponse) *types } } +// FromDescribeShardDistributionResponse converts internal DescribeHistoryHostResponse type to thrift +func FromDescribeShardDistributionResponse(t *types.DescribeShardDistributionResponse) *shared.DescribeShardDistributionResponse { + if t == nil { + return nil + } + return &shared.DescribeShardDistributionResponse{ + NumberOfShards: &t.NumberOfShards, + Shards: t.Shards, + } +} + // ToDescribeShardDistributionResponse converts thrift DescribeHistoryHostResponse type to internal func ToDescribeShardDistributionResponse(t *shared.DescribeShardDistributionResponse) *types.DescribeShardDistributionResponse { if t == nil { @@ -4765,6 +4767,18 @@ func ToRetryTaskV2Error(t *shared.RetryTaskV2Error) *types.RetryTaskV2Error { } } +// FromRestartWorkflowExecutionRequest converts internal RestartWorkflowExecutionRequest type to thrift +func FromRestartWorkflowExecutionRequest(t *types.RestartWorkflowExecutionRequest) *shared.RestartWorkflowExecutionRequest { + if t == nil { + return nil + } + return &shared.RestartWorkflowExecutionRequest{ + Domain: &t.Domain, + WorkflowExecution: FromWorkflowExecution(t.WorkflowExecution), + Identity: &t.Identity, + } +} + // ToRestartWorkflowExecutionRequest converts thrift RestartWorkflowExecutionRequest type to internal func ToRestartWorkflowExecutionRequest(t *shared.RestartWorkflowExecutionRequest) *types.RestartWorkflowExecutionRequest { if t == nil { @@ -5551,18 +5565,6 @@ func ToRestartWorkflowExecutionResponse(t *shared.RestartWorkflowExecutionRespon } } -// FromRestartWorkflowExecutionRequest converts internal RestartWorkflowExecutionRequest type to thrift -func FromRestartWorkflowExecutionRequest(t *types.RestartWorkflowExecutionRequest) *shared.RestartWorkflowExecutionRequest { - if t == nil { - return nil - } - return &shared.RestartWorkflowExecutionRequest{ - Domain: &t.Domain, - WorkflowExecution: FromWorkflowExecution(t.WorkflowExecution), - Identity: &t.Identity, - } -} - // FromTerminateWorkflowExecutionRequest converts internal TerminateWorkflowExecutionRequest type to thrift func FromTerminateWorkflowExecutionRequest(t *types.TerminateWorkflowExecutionRequest) *shared.TerminateWorkflowExecutionRequest { if t == nil { diff --git a/common/types/mapper/thrift/shared_test.go b/common/types/mapper/thrift/shared_test.go index 22372aa0973..91165c3a9f1 100644 --- a/common/types/mapper/thrift/shared_test.go +++ b/common/types/mapper/thrift/shared_test.go @@ -1,7 +1,5 @@ -// The MIT License (MIT) - -// Copyright (c) 2017-2020 Uber Technologies Inc. - +// Copyright (c) 2021 Uber Technologies Inc. +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights @@ -20,20 +18,3239 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -package thrift_test +package thrift import ( "testing" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" "github.com/stretchr/testify/assert" + "github.com/uber/cadence/.gen/go/shared" + "github.com/uber/cadence/common" "github.com/uber/cadence/common/types" - "github.com/uber/cadence/common/types/mapper/thrift" "github.com/uber/cadence/common/types/testdata" ) -func TestWorkflowExecutionInfo(t *testing.T) { +func TestCrossClusterTaskInfoConversion(t *testing.T) { + for _, item := range []*types.CrossClusterTaskInfo{nil, {}, &testdata.CrossClusterTaskInfo} { + assert.Equal(t, item, ToCrossClusterTaskInfo(FromCrossClusterTaskInfo(item))) + } +} + +func TestCrossClusterTaskRequestConversion(t *testing.T) { + for _, item := range []*types.CrossClusterTaskRequest{ + nil, + {}, + &testdata.CrossClusterTaskRequestStartChildExecution, + &testdata.CrossClusterTaskRequestCancelExecution, + &testdata.CrossClusterTaskRequestSignalExecution, + } { + assert.Equal(t, item, ToCrossClusterTaskRequest(FromCrossClusterTaskRequest(item))) + } +} + +func TestCrossClusterTaskResponseConversion(t *testing.T) { + for _, item := range []*types.CrossClusterTaskResponse{ + nil, + {}, + &testdata.CrossClusterTaskResponseStartChildExecution, + &testdata.CrossClusterTaskResponseCancelExecution, + &testdata.CrossClusterTaskResponseSignalExecution, + } { + assert.Equal(t, item, ToCrossClusterTaskResponse(FromCrossClusterTaskResponse(item))) + } +} + +func TestCrossClusterTaskRequestArrayConversion(t *testing.T) { + for _, item := range [][]*types.CrossClusterTaskRequest{nil, {}, testdata.CrossClusterTaskRequestArray} { + assert.Equal(t, item, ToCrossClusterTaskRequestArray(FromCrossClusterTaskRequestArray(item))) + } +} + +func TestCrossClusterTaskResponseArrayConversion(t *testing.T) { + for _, item := range [][]*types.CrossClusterTaskResponse{nil, {}, testdata.CrossClusterTaskResponseArray} { + assert.Equal(t, item, ToCrossClusterTaskResponseArray(FromCrossClusterTaskResponseArray(item))) + } +} + +func TestCrossClusterTaskRequestMapConversion(t *testing.T) { + for _, item := range []map[int32][]*types.CrossClusterTaskRequest{nil, {}, testdata.CrossClusterTaskRequestMap} { + assert.Equal(t, item, ToCrossClusterTaskRequestMap(FromCrossClusterTaskRequestMap(item))) + } +} + +func TestGetTaskFailedCauseMapConversion(t *testing.T) { + for _, item := range []map[int32]types.GetTaskFailedCause{nil, {}, testdata.GetCrossClusterTaskFailedCauseMap} { + assert.Equal(t, item, ToGetTaskFailedCauseMap(FromGetTaskFailedCauseMap(item))) + } +} + +func TestGetCrossClusterTasksRequestConversion(t *testing.T) { + for _, item := range []*types.GetCrossClusterTasksRequest{nil, {}, &testdata.GetCrossClusterTasksRequest} { + assert.Equal(t, item, ToGetCrossClusterTasksRequest(FromGetCrossClusterTasksRequest(item))) + } +} + +func TestGetCrossClusterTasksResponseConversion(t *testing.T) { + for _, item := range []*types.GetCrossClusterTasksResponse{nil, {}, &testdata.GetCrossClusterTasksResponse} { + assert.Equal(t, item, ToGetCrossClusterTasksResponse(FromGetCrossClusterTasksResponse(item))) + } +} + +func TestRespondCrossClusterTasksCompletedRequestConversion(t *testing.T) { + for _, item := range []*types.RespondCrossClusterTasksCompletedRequest{nil, {}, &testdata.RespondCrossClusterTasksCompletedRequest} { + assert.Equal(t, item, ToRespondCrossClusterTasksCompletedRequest(FromRespondCrossClusterTasksCompletedRequest(item))) + } +} + +func TestRespondCrossClusterTasksCompletedResponseConversion(t *testing.T) { + for _, item := range []*types.RespondCrossClusterTasksCompletedResponse{nil, {}, &testdata.RespondCrossClusterTasksCompletedResponse} { + assert.Equal(t, item, ToRespondCrossClusterTasksCompletedResponse(FromRespondCrossClusterTasksCompletedResponse(item))) + } +} + +func TestGetFailoverInfoRequestConversion(t *testing.T) { + for _, item := range []*types.GetFailoverInfoRequest{nil, {}, &testdata.GetFailoverInfoRequest} { + assert.Equal(t, item, ToGetFailoverInfoRequest(FromGetFailoverInfoRequest(item))) + } +} + +func TestGetFailoverInfoResponseConversion(t *testing.T) { + for _, item := range []*types.GetFailoverInfoResponse{nil, {}, &testdata.GetFailoverInfoResponse} { + assert.Equal(t, item, ToGetFailoverInfoResponse(FromGetFailoverInfoResponse(item))) + } +} + +func TestCrossClusterApplyParentClosePolicyRequestAttributesConversion(t *testing.T) { + item := testdata.CrossClusterApplyParentClosePolicyRequestAttributes + assert.Equal( + t, + &item, + ToCrossClusterApplyParentClosePolicyRequestAttributes( + FromCrossClusterApplyParentClosePolicyRequestAttributes(&item), + ), + ) +} + +func TestApplyParentClosePolicyAttributesConversion(t *testing.T) { + item := testdata.ApplyParentClosePolicyAttributes + assert.Equal( + t, + &item, + ToApplyParentClosePolicyAttributes( + FromApplyParentClosePolicyAttributes(&item), + ), + ) +} + +func TestApplyParentClosePolicyResultConversion(t *testing.T) { + item := testdata.ApplyParentClosePolicyResult + assert.Equal( + t, + &item, + ToApplyParentClosePolicyResult( + FromApplyParentClosePolicyResult(&item), + ), + ) +} + +func TestCrossClusterApplyParentClosePolicyResponseConversion(t *testing.T) { + item := testdata.CrossClusterApplyParentClosePolicyResponseWithChildren + assert.Equal( + t, + &item, + ToCrossClusterApplyParentClosePolicyResponseAttributes( + FromCrossClusterApplyParentClosePolicyResponseAttributes(&item), + ), + ) +} + +func TestIsolationGroupToDomainBlobConversion(t *testing.T) { + zone1 := "zone-1" + zone2 := "zone-2" + drained := shared.IsolationGroupStateDrained + healthy := shared.IsolationGroupStateHealthy + + tests := map[string]struct { + in *types.IsolationGroupConfiguration + expectedOut *shared.IsolationGroupConfiguration + }{ + "valid input": { + in: &types.IsolationGroupConfiguration{ + "zone-1": { + Name: zone1, + State: types.IsolationGroupStateDrained, + }, + "zone-2": { + Name: zone2, + State: types.IsolationGroupStateHealthy, + }, + }, + expectedOut: &shared.IsolationGroupConfiguration{ + IsolationGroups: []*shared.IsolationGroupPartition{ + { + Name: &zone1, + State: &drained, + }, + { + Name: &zone2, + State: &healthy, + }, + }, + }, + }, + "empty input": { + in: &types.IsolationGroupConfiguration{}, + expectedOut: &shared.IsolationGroupConfiguration{}, + }, + "nil input": { + in: nil, + expectedOut: nil, + }, + } + + for name, td := range tests { + t.Run(name, func(t *testing.T) { + out := FromIsolationGroupConfig(td.in) + assert.Equal(t, td.expectedOut, out) + roundTrip := ToIsolationGroupConfig(out) + assert.Equal(t, td.in, roundTrip) + }) + } +} + +func TestIsolationGroupFromDomainBlobConversion(t *testing.T) { + zone1 := "zone-1" + zone2 := "zone-2" + drained := shared.IsolationGroupStateDrained + healthy := shared.IsolationGroupStateHealthy + + tests := map[string]struct { + in *shared.IsolationGroupConfiguration + expectedOut *types.IsolationGroupConfiguration + }{ + "valid input": { + in: &shared.IsolationGroupConfiguration{ + IsolationGroups: []*shared.IsolationGroupPartition{ + { + Name: &zone1, + State: &drained, + }, + { + Name: &zone2, + State: &healthy, + }, + }, + }, + expectedOut: &types.IsolationGroupConfiguration{ + "zone-1": { + Name: zone1, + State: types.IsolationGroupStateDrained, + }, + "zone-2": { + Name: zone2, + State: types.IsolationGroupStateHealthy, + }, + }, + }, + "empty input": { + in: &shared.IsolationGroupConfiguration{}, + expectedOut: &types.IsolationGroupConfiguration{}, + }, + "nil input": { + in: nil, + expectedOut: nil, + }, + } + + for name, td := range tests { + t.Run(name, func(t *testing.T) { + out := ToIsolationGroupConfig(td.in) + assert.Equal(t, td.expectedOut, out) + roundTrip := FromIsolationGroupConfig(out) + assert.Equal(t, td.in, roundTrip) + }) + } +} + +func TestWorkflowExecutionInfoConversion(t *testing.T) { for _, item := range []*types.WorkflowExecutionInfo{nil, {}, &testdata.WorkflowExecutionInfo, &testdata.CronWorkflowExecutionInfo} { - assert.Equal(t, item, thrift.ToWorkflowExecutionInfo(thrift.FromWorkflowExecutionInfo(item))) + assert.Equal(t, item, ToWorkflowExecutionInfo(FromWorkflowExecutionInfo(item))) + } +} + +func TestActivityLocalDispatchInfoConversion(t *testing.T) { + testCases := []*types.ActivityLocalDispatchInfo{ + nil, + {}, + &testdata.ActivityLocalDispatchInfo, + } + + for _, original := range testCases { + thriftObj := FromActivityLocalDispatchInfo(original) + roundTripObj := ToActivityLocalDispatchInfo(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestActivityTaskCancelRequestedEventAttributesConversion(t *testing.T) { + testCases := []*types.ActivityTaskCancelRequestedEventAttributes{ + nil, + {}, + &testdata.ActivityTaskCancelRequestedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromActivityTaskCancelRequestedEventAttributes(original) + roundTripObj := ToActivityTaskCancelRequestedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestActivityTaskCanceledEventAttributesConversion(t *testing.T) { + testCases := []*types.ActivityTaskCanceledEventAttributes{ + nil, + {}, + &testdata.ActivityTaskCanceledEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromActivityTaskCanceledEventAttributes(original) + roundTripObj := ToActivityTaskCanceledEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestAccessDeniedErrorConversion(t *testing.T) { + testCases := []*types.AccessDeniedError{ + nil, + {}, + &testdata.AccessDeniedError, + } + + for _, original := range testCases { + thriftObj := FromAccessDeniedError(original) + roundTripObj := ToAccessDeniedError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestActivityTaskCompletedEventAttributesConversion(t *testing.T) { + testCases := []*types.ActivityTaskCompletedEventAttributes{ + nil, + {}, + &testdata.ActivityTaskCompletedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromActivityTaskCompletedEventAttributes(original) + roundTripObj := ToActivityTaskCompletedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestActivityTaskFailedEventAttributesConversion(t *testing.T) { + testCases := []*types.ActivityTaskFailedEventAttributes{ + nil, + {}, + &testdata.ActivityTaskFailedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromActivityTaskFailedEventAttributes(original) + roundTripObj := ToActivityTaskFailedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestActivityTaskScheduledEventAttributesConversion(t *testing.T) { + testCases := []*types.ActivityTaskScheduledEventAttributes{ + nil, + {}, + &testdata.ActivityTaskScheduledEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromActivityTaskScheduledEventAttributes(original) + roundTripObj := ToActivityTaskScheduledEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestActivityTaskStartedEventAttributesConversion(t *testing.T) { + testCases := []*types.ActivityTaskStartedEventAttributes{ + nil, + {}, + &testdata.ActivityTaskStartedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromActivityTaskStartedEventAttributes(original) + roundTripObj := ToActivityTaskStartedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestActivityTaskTimedEventAttributesConversion(t *testing.T) { + testCases := []*types.ActivityTaskTimedOutEventAttributes{ + nil, + {}, + &testdata.ActivityTaskTimedOutEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromActivityTaskTimedOutEventAttributes(original) + roundTripObj := ToActivityTaskTimedOutEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestArchivalStatusConversion(t *testing.T) { + enabledStatus := types.ArchivalStatus(1) + disabledStatus := types.ArchivalStatus(0) + testCases := []*types.ArchivalStatus{ + nil, + &enabledStatus, + &disabledStatus, + } + + for _, original := range testCases { + thriftObj := FromArchivalStatus(original) + roundTripObj := ToArchivalStatus(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestBadBinariesConversion(t *testing.T) { + testCases := []*types.BadBinaries{ + nil, + {}, + &testdata.BadBinaries, + } + + for _, original := range testCases { + thriftObj := FromBadBinaries(original) + roundTripObj := ToBadBinaries(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestBadBinaryInfoConversion(t *testing.T) { + testCases := []*types.BadBinaryInfo{ + nil, + {}, + &testdata.BadBinaryInfo, + } + + for _, original := range testCases { + thriftObj := FromBadBinaryInfo(original) + roundTripObj := ToBadBinaryInfo(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestBadRequestErrorConversion(t *testing.T) { + testCases := []*types.BadRequestError{ + nil, + {}, + {Message: "Error message for bad request"}, + } + + for _, original := range testCases { + thriftObj := FromBadRequestError(original) + roundTripObj := ToBadRequestError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestCancelExternalWorkflowExecutionFailedCauseConversion(t *testing.T) { + testCases := []*types.CancelExternalWorkflowExecutionFailedCause{ + nil, + types.CancelExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromCancelExternalWorkflowExecutionFailedCause(original) + roundTripObj := ToCancelExternalWorkflowExecutionFailedCause(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestCancelTimerDecisionAttributesConversion(t *testing.T) { + testCases := []*types.CancelTimerDecisionAttributes{ + nil, + {}, + &testdata.CancelTimerDecisionAttributes, + } + + for _, original := range testCases { + thriftObj := FromCancelTimerDecisionAttributes(original) + roundTripObj := ToCancelTimerDecisionAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestCancelTimerFailedEventAttributesConversion(t *testing.T) { + testCases := []*types.CancelTimerFailedEventAttributes{ + nil, + {}, + &testdata.CancelTimerFailedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromCancelTimerFailedEventAttributes(original) + roundTripObj := ToCancelTimerFailedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestCancelWorkflowExecutionDecisionAttributesConversion(t *testing.T) { + testCases := []*types.CancelWorkflowExecutionDecisionAttributes{ + nil, + {}, + &testdata.CancelWorkflowExecutionDecisionAttributes, + } + + for _, original := range testCases { + thriftObj := FromCancelWorkflowExecutionDecisionAttributes(original) + roundTripObj := ToCancelWorkflowExecutionDecisionAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestCancellationAlreadyRequestedErrorConversion(t *testing.T) { + testCases := []*types.CancellationAlreadyRequestedError{ + nil, + {}, + &testdata.CancellationAlreadyRequestedError, + } + + for _, original := range testCases { + thriftObj := FromCancellationAlreadyRequestedError(original) + roundTripObj := ToCancellationAlreadyRequestedError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestChildWorkflowExecutionCanceledEventAttributesConversion(t *testing.T) { + testCases := []*types.ChildWorkflowExecutionCanceledEventAttributes{ + nil, + {}, + &testdata.ChildWorkflowExecutionCanceledEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromChildWorkflowExecutionCanceledEventAttributes(original) + roundTripObj := ToChildWorkflowExecutionCanceledEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestChildWorkflowExecutionCompletedEventAttributesConversion(t *testing.T) { + testCases := []*types.ChildWorkflowExecutionCompletedEventAttributes{ + nil, + {}, + &testdata.ChildWorkflowExecutionCompletedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromChildWorkflowExecutionCompletedEventAttributes(original) + roundTripObj := ToChildWorkflowExecutionCompletedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestChildWorkflowExecutionFailedEventAttributesConversion(t *testing.T) { + testCases := []*types.ChildWorkflowExecutionFailedEventAttributes{ + nil, + {}, + &testdata.ChildWorkflowExecutionFailedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromChildWorkflowExecutionFailedEventAttributes(original) + roundTripObj := ToChildWorkflowExecutionFailedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestChildWorkflowExecutionStartedEventAttributesConversion(t *testing.T) { + testCases := []*types.ChildWorkflowExecutionStartedEventAttributes{ + nil, + {}, + &testdata.ChildWorkflowExecutionStartedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromChildWorkflowExecutionStartedEventAttributes(original) + roundTripObj := ToChildWorkflowExecutionStartedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestChildWorkflowExecutionTerminatedEventAttributesConversion(t *testing.T) { + testCases := []*types.ChildWorkflowExecutionTerminatedEventAttributes{ + nil, + {}, + &testdata.ChildWorkflowExecutionTerminatedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromChildWorkflowExecutionTerminatedEventAttributes(original) + roundTripObj := ToChildWorkflowExecutionTerminatedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestChildWorkflowExecutionTimedOutEventAttributesConversion(t *testing.T) { + testCases := []*types.ChildWorkflowExecutionTimedOutEventAttributes{ + nil, + {}, + &testdata.ChildWorkflowExecutionTimedOutEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromChildWorkflowExecutionTimedOutEventAttributes(original) + roundTripObj := ToChildWorkflowExecutionTimedOutEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestClientVersionNotSupportedErrorConversion(t *testing.T) { + testCases := []*types.ClientVersionNotSupportedError{ + nil, + {}, + &testdata.ClientVersionNotSupportedError, + } + + for _, original := range testCases { + thriftObj := FromClientVersionNotSupportedError(original) + roundTripObj := ToClientVersionNotSupportedError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestFeatureNotEnabledErrorConversion(t *testing.T) { + testCases := []*types.FeatureNotEnabledError{ + nil, + {}, + {FeatureFlag: "test-feature-flag"}, + } + + for _, original := range testCases { + thriftObj := FromFeatureNotEnabledError(original) + roundTripObj := ToFeatureNotEnabledError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestCloseShardRequestConversion(t *testing.T) { + testCases := []*types.CloseShardRequest{ + nil, + {}, + {ShardID: 5}, + } + + for _, original := range testCases { + thriftObj := FromCloseShardRequest(original) + roundTripObj := ToCloseShardRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestClusterInfoConversion(t *testing.T) { + testCases := []*types.ClusterInfo{ + nil, + {}, + &testdata.ClusterInfo, + } + + for _, original := range testCases { + thriftObj := FromClusterInfo(original) + roundTripObj := ToClusterInfo(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestClusterReplicationConfigurationConversion(t *testing.T) { + testCases := []*types.ClusterReplicationConfiguration{ + nil, + {}, + &testdata.ClusterReplicationConfiguration, + } + + for _, original := range testCases { + thriftObj := FromClusterReplicationConfiguration(original) + roundTripObj := ToClusterReplicationConfiguration(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestCompleteWorkflowExecutionDecisionAttributesConversion(t *testing.T) { + testCases := []*types.CompleteWorkflowExecutionDecisionAttributes{ + nil, + {}, + &testdata.CompleteWorkflowExecutionDecisionAttributes, + } + + for _, original := range testCases { + thriftObj := FromCompleteWorkflowExecutionDecisionAttributes(original) + roundTripObj := ToCompleteWorkflowExecutionDecisionAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestContinueAsNewInitiatorConversion(t *testing.T) { + testCases := []*types.ContinueAsNewInitiator{ + nil, + types.ContinueAsNewInitiatorDecider.Ptr(), + types.ContinueAsNewInitiatorRetryPolicy.Ptr(), + types.ContinueAsNewInitiatorCronSchedule.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromContinueAsNewInitiator(original) + roundTripObj := ToContinueAsNewInitiator(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestContinueAsNewWorkflowExecutionDecisionAttributesConversion(t *testing.T) { + testCases := []*types.ContinueAsNewWorkflowExecutionDecisionAttributes{ + nil, + {}, + &testdata.ContinueAsNewWorkflowExecutionDecisionAttributes, + } + + for _, original := range testCases { + thriftObj := FromContinueAsNewWorkflowExecutionDecisionAttributes(original) + roundTripObj := ToContinueAsNewWorkflowExecutionDecisionAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestCountWorkflowExecutionsRequestConversion(t *testing.T) { + testCases := []*types.CountWorkflowExecutionsRequest{ + nil, + {}, + &testdata.CountWorkflowExecutionsRequest, + } + + for _, original := range testCases { + thriftObj := FromCountWorkflowExecutionsRequest(original) + roundTripObj := ToCountWorkflowExecutionsRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestCountWorkflowExecutionsResponseConversion(t *testing.T) { + testCases := []*types.CountWorkflowExecutionsResponse{ + nil, + {}, + &testdata.CountWorkflowExecutionsResponse, + } + + for _, original := range testCases { + thriftObj := FromCountWorkflowExecutionsResponse(original) + roundTripObj := ToCountWorkflowExecutionsResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestCurrentBranchChangedErrorConversion(t *testing.T) { + testCases := []*types.CurrentBranchChangedError{ + nil, + {}, + &testdata.CurrentBranchChangedError, + } + + for _, original := range testCases { + thriftObj := FromCurrentBranchChangedError(original) + roundTripObj := ToCurrentBranchChangedError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDataBlobConversion(t *testing.T) { + testCases := []*types.DataBlob{ + nil, + {}, + &testdata.DataBlob, + } + + for _, original := range testCases { + thriftObj := FromDataBlob(original) + roundTripObj := ToDataBlob(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDecisionConverson(t *testing.T) { + testCases := []*types.Decision{ + nil, + {}, + { + DecisionType: types.DecisionTypeScheduleActivityTask.Ptr(), + ScheduleActivityTaskDecisionAttributes: &testdata.ScheduleActivityTaskDecisionAttributes, + }, + } + + for _, original := range testCases { + thriftObj := FromDecision(original) + roundTripObj := ToDecision(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDecisionTaskCompletedEventAttributesConversion(t *testing.T) { + testCases := []*types.DecisionTaskCompletedEventAttributes{ + nil, + {}, + &testdata.DecisionTaskCompletedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromDecisionTaskCompletedEventAttributes(original) + roundTripObj := ToDecisionTaskCompletedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDecisionTaskFailedCauseConversion(t *testing.T) { + testCases := []*types.DecisionTaskFailedCause{ + nil, + types.DecisionTaskFailedCauseUnhandledDecision.Ptr(), + types.DecisionTaskFailedCauseBadScheduleActivityAttributes.Ptr(), + types.DecisionTaskFailedCauseBadRequestCancelActivityAttributes.Ptr(), + types.DecisionTaskFailedCauseBadStartTimerAttributes.Ptr(), + types.DecisionTaskFailedCauseBadCancelTimerAttributes.Ptr(), + types.DecisionTaskFailedCauseBadRecordMarkerAttributes.Ptr(), + types.DecisionTaskFailedCauseBadCompleteWorkflowExecutionAttributes.Ptr(), + types.DecisionTaskFailedCauseBadFailWorkflowExecutionAttributes.Ptr(), + types.DecisionTaskFailedCauseBadCancelWorkflowExecutionAttributes.Ptr(), + types.DecisionTaskFailedCauseBadRequestCancelExternalWorkflowExecutionAttributes.Ptr(), + types.DecisionTaskFailedCauseBadContinueAsNewAttributes.Ptr(), + types.DecisionTaskFailedCauseStartTimerDuplicateID.Ptr(), + types.DecisionTaskFailedCauseResetStickyTasklist.Ptr(), + types.DecisionTaskFailedCauseWorkflowWorkerUnhandledFailure.Ptr(), + types.DecisionTaskFailedCauseBadSignalWorkflowExecutionAttributes.Ptr(), + types.DecisionTaskFailedCauseBadStartChildExecutionAttributes.Ptr(), + types.DecisionTaskFailedCauseForceCloseDecision.Ptr(), + types.DecisionTaskFailedCauseFailoverCloseDecision.Ptr(), + types.DecisionTaskFailedCauseBadSignalInputSize.Ptr(), + types.DecisionTaskFailedCauseResetWorkflow.Ptr(), + types.DecisionTaskFailedCauseBadBinary.Ptr(), + types.DecisionTaskFailedCauseScheduleActivityDuplicateID.Ptr(), + types.DecisionTaskFailedCauseBadSearchAttributes.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromDecisionTaskFailedCause(original) + roundTripObj := ToDecisionTaskFailedCause(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDecisionTaskFailedEventAttributesConversion(t *testing.T) { + testCases := []*types.DecisionTaskFailedEventAttributes{ + nil, + {}, + &testdata.DecisionTaskFailedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromDecisionTaskFailedEventAttributes(original) + roundTripObj := ToDecisionTaskFailedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDecisionTaskScheduledEventAttributesConversion(t *testing.T) { + testCases := []*types.DecisionTaskScheduledEventAttributes{ + nil, + {}, + &testdata.DecisionTaskScheduledEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromDecisionTaskScheduledEventAttributes(original) + roundTripObj := ToDecisionTaskScheduledEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDecisionTaskStartedEventAttributesConversion(t *testing.T) { + testCases := []*types.DecisionTaskStartedEventAttributes{ + nil, + {}, + &testdata.DecisionTaskStartedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromDecisionTaskStartedEventAttributes(original) + roundTripObj := ToDecisionTaskStartedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDecisionTaskTimedOutCauseConversion(t *testing.T) { + testCases := []*types.DecisionTaskTimedOutCause{ + nil, + types.DecisionTaskTimedOutCauseTimeout.Ptr(), + types.DecisionTaskTimedOutCauseReset.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromDecisionTaskTimedOutCause(original) + roundTripObj := ToDecisionTaskTimedOutCause(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDecisionTaskTimedOutEventAttributesConversion(t *testing.T) { + testCases := []*types.DecisionTaskTimedOutEventAttributes{ + nil, + {}, + &testdata.DecisionTaskTimedOutEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromDecisionTaskTimedOutEventAttributes(original) + roundTripObj := ToDecisionTaskTimedOutEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDecisionTypeConversion(t *testing.T) { + testCases := []*types.DecisionType{ + nil, + types.DecisionTypeScheduleActivityTask.Ptr(), + types.DecisionTypeRequestCancelActivityTask.Ptr(), + types.DecisionTypeStartTimer.Ptr(), + types.DecisionTypeCompleteWorkflowExecution.Ptr(), + types.DecisionTypeFailWorkflowExecution.Ptr(), + types.DecisionTypeCancelTimer.Ptr(), + types.DecisionTypeCancelWorkflowExecution.Ptr(), + types.DecisionTypeRequestCancelExternalWorkflowExecution.Ptr(), + types.DecisionTypeRecordMarker.Ptr(), + types.DecisionTypeContinueAsNewWorkflowExecution.Ptr(), + types.DecisionTypeStartChildWorkflowExecution.Ptr(), + types.DecisionTypeSignalExternalWorkflowExecution.Ptr(), + types.DecisionTypeUpsertWorkflowSearchAttributes.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromDecisionType(original) + roundTripObj := ToDecisionType(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDeprecateDomainRequestConversion(t *testing.T) { + testCases := []*types.DeprecateDomainRequest{ + nil, + {}, + &testdata.DeprecateDomainRequest, + } + + for _, original := range testCases { + thriftObj := FromDeprecateDomainRequest(original) + roundTripObj := ToDeprecateDomainRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDescribeDomainRequestConversion(t *testing.T) { + testCases := []*types.DescribeDomainRequest{ + nil, + {}, + {Name: common.StringPtr("test-name"), UUID: common.StringPtr("test-uuid")}, + } + + for _, original := range testCases { + thriftObj := FromDescribeDomainRequest(original) + roundTripObj := ToDescribeDomainRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDescribeDomainResponseConversion(t *testing.T) { + testCases := []*types.DescribeDomainResponse{ + nil, + {}, + &testdata.DescribeDomainResponse, + } + + for _, original := range testCases { + thriftObj := FromDescribeDomainResponse(original) + roundTripObj := ToDescribeDomainResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDecribeHistoryHostRequstConversion(t *testing.T) { + testCases := []*types.DescribeHistoryHostRequest{ + nil, + {}, + {HostAddress: common.StringPtr("test-host-address")}, + } + + for _, original := range testCases { + thriftObj := FromDescribeHistoryHostRequest(original) + roundTripObj := ToDescribeHistoryHostRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDescribeShardDistributionRequestConversion(t *testing.T) { + testCases := []*types.DescribeShardDistributionRequest{ + nil, + {}, + {PageSize: 100}, + } + + for _, original := range testCases { + thriftObj := FromDescribeShardDistributionRequest(original) + roundTripObj := ToDescribeShardDistributionRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDescribeHistoryHostResponseConversion(t *testing.T) { + testCases := []*types.DescribeHistoryHostResponse{ + nil, + {}, + {NumberOfShards: 10, ShardIDs: []int32{1, 2, 3}, Address: "test-address"}, + } + + for _, original := range testCases { + thriftObj := FromDescribeHistoryHostResponse(original) + roundTripObj := ToDescribeHistoryHostResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDescribeShardDistributionResponseConversion(t *testing.T) { + testCases := []*types.DescribeShardDistributionResponse{ + nil, + {}, + {NumberOfShards: 10, Shards: map[int32]string{1: "test-host-1", 2: "test-host-2"}}, + } + + for _, original := range testCases { + thriftObj := FromDescribeShardDistributionResponse(original) + roundTripObj := ToDescribeShardDistributionResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDescribeQueueRequestConversion(t *testing.T) { + testCases := []*types.DescribeQueueRequest{ + nil, + {}, + {ShardID: 10}, + } + + for _, original := range testCases { + thriftObj := FromDescribeQueueRequest(original) + roundTripObj := ToDescribeQueueRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDescribeQueueResponseConversion(t *testing.T) { + testCases := []*types.DescribeQueueResponse{ + nil, + {}, + &testdata.HistoryDescribeQueueResponse, + } + + for _, original := range testCases { + thriftObj := FromDescribeQueueResponse(original) + roundTripObj := ToDescribeQueueResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDescribeTaskListRequestConversion(t *testing.T) { + testCases := []*types.DescribeTaskListRequest{ + nil, + {}, + &testdata.DescribeTaskListRequest, + } + + for _, original := range testCases { + thriftObj := FromDescribeTaskListRequest(original) + roundTripObj := ToDescribeTaskListRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDescribeTaskListResponseConversion(t *testing.T) { + testCases := []*types.DescribeTaskListResponse{ + nil, + {}, + &testdata.DescribeTaskListResponse, + } + + for _, original := range testCases { + thriftObj := FromDescribeTaskListResponse(original) + roundTripObj := ToDescribeTaskListResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDescribeWorkflowExecutionRequestConversion(t *testing.T) { + testCases := []*types.DescribeWorkflowExecutionRequest{ + nil, + {}, + &testdata.DescribeWorkflowExecutionRequest, + } + + for _, original := range testCases { + thriftObj := FromDescribeWorkflowExecutionRequest(original) + roundTripObj := ToDescribeWorkflowExecutionRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDescribeWorkflowExecutionResponseConversion(t *testing.T) { + testCases := []*types.DescribeWorkflowExecutionResponse{ + nil, + {}, + &testdata.DescribeWorkflowExecutionResponse, + } + + for _, original := range testCases { + thriftObj := FromDescribeWorkflowExecutionResponse(original) + roundTripObj := ToDescribeWorkflowExecutionResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDomainAlreadyExistsErrorConversion(t *testing.T) { + testCases := []*types.DomainAlreadyExistsError{ + nil, + {}, + {Message: "test-message"}, + } + + for _, original := range testCases { + thriftObj := FromDomainAlreadyExistsError(original) + roundTripObj := ToDomainAlreadyExistsError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDomainCacheInfoConversion(t *testing.T) { + testCases := []*types.DomainCacheInfo{ + nil, + {}, + &testdata.DomainCacheInfo, + } + + for _, original := range testCases { + thriftObj := FromDomainCacheInfo(original) + roundTripObj := ToDomainCacheInfo(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDomainConfigurationConversion(t *testing.T) { + testCases := []*types.DomainConfiguration{ + nil, + {}, + &testdata.DomainConfiguration, + } + + for _, original := range testCases { + thriftObj := FromDomainConfiguration(original) + roundTripObj := ToDomainConfiguration(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDomainInfoConversion(t *testing.T) { + testCases := []*types.DomainInfo{ + nil, + {}, + &testdata.DomainInfo, + } + + for _, original := range testCases { + thriftObj := FromDomainInfo(original) + roundTripObj := ToDomainInfo(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestFailoverInfoConversion(t *testing.T) { + testCases := []*types.FailoverInfo{ + nil, + {}, + &testdata.FailoverInfo, + } + + for _, original := range testCases { + thriftObj := FromFailoverInfo(original) + roundTripObj := ToFailoverInfo(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDomainNotActiveErrorConversion(t *testing.T) { + testCases := []*types.DomainNotActiveError{ + nil, + {}, + {Message: "test-message"}, + } + + for _, original := range testCases { + thriftObj := FromDomainNotActiveError(original) + roundTripObj := ToDomainNotActiveError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDomainReplicationConfigurationConversion(t *testing.T) { + testCases := []*types.DomainReplicationConfiguration{ + nil, + {}, + &testdata.DomainReplicationConfiguration, + } + + for _, original := range testCases { + thriftObj := FromDomainReplicationConfiguration(original) + roundTripObj := ToDomainReplicationConfiguration(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDomainStatusConversion(t *testing.T) { + testCases := []*types.DomainStatus{ + nil, + types.DomainStatusRegistered.Ptr(), + types.DomainStatusDeprecated.Ptr(), + types.DomainStatusDeleted.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromDomainStatus(original) + roundTripObj := ToDomainStatus(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestEncodingTypeConversion(t *testing.T) { + testCases := []*types.EncodingType{ + nil, + types.EncodingTypeThriftRW.Ptr(), + types.EncodingTypeJSON.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromEncodingType(original) + roundTripObj := ToEncodingType(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestEntityNotExistsErrorConversion(t *testing.T) { + testCases := []*types.EntityNotExistsError{ + nil, + {}, + &testdata.EntityNotExistsError, + } + + for _, original := range testCases { + thriftObj := FromEntityNotExistsError(original) + roundTripObj := ToEntityNotExistsError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestWorkflowExecutionAlreadyCompletedErrorConversion(t *testing.T) { + testCases := []*types.WorkflowExecutionAlreadyCompletedError{ + nil, + {}, + &testdata.WorkflowExecutionAlreadyCompletedError, + } + + for _, original := range testCases { + thriftObj := FromWorkflowExecutionAlreadyCompletedError(original) + roundTripObj := ToWorkflowExecutionAlreadyCompletedError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestEventTypeConversion(t *testing.T) { + testCases := []*types.EventType{ + nil, + types.EventTypeWorkflowExecutionStarted.Ptr(), + types.EventTypeWorkflowExecutionCompleted.Ptr(), + types.EventTypeWorkflowExecutionFailed.Ptr(), + types.EventTypeWorkflowExecutionTimedOut.Ptr(), + types.EventTypeDecisionTaskScheduled.Ptr(), + types.EventTypeDecisionTaskStarted.Ptr(), + types.EventTypeDecisionTaskCompleted.Ptr(), + types.EventTypeDecisionTaskTimedOut.Ptr(), + types.EventTypeDecisionTaskFailed.Ptr(), + types.EventTypeActivityTaskScheduled.Ptr(), + types.EventTypeActivityTaskStarted.Ptr(), + types.EventTypeActivityTaskCompleted.Ptr(), + types.EventTypeActivityTaskFailed.Ptr(), + types.EventTypeActivityTaskTimedOut.Ptr(), + types.EventTypeActivityTaskCancelRequested.Ptr(), + types.EventTypeActivityTaskCanceled.Ptr(), + types.EventTypeTimerStarted.Ptr(), + types.EventTypeTimerFired.Ptr(), + types.EventTypeCancelTimerFailed.Ptr(), + types.EventTypeTimerCanceled.Ptr(), + types.EventTypeWorkflowExecutionCancelRequested.Ptr(), + types.EventTypeWorkflowExecutionCanceled.Ptr(), + types.EventTypeRequestCancelExternalWorkflowExecutionInitiated.Ptr(), + types.EventTypeRequestCancelExternalWorkflowExecutionFailed.Ptr(), + types.EventTypeExternalWorkflowExecutionCancelRequested.Ptr(), + types.EventTypeMarkerRecorded.Ptr(), + types.EventTypeWorkflowExecutionSignaled.Ptr(), + types.EventTypeWorkflowExecutionTerminated.Ptr(), + types.EventTypeWorkflowExecutionContinuedAsNew.Ptr(), + types.EventTypeStartChildWorkflowExecutionInitiated.Ptr(), + types.EventTypeStartChildWorkflowExecutionFailed.Ptr(), + types.EventTypeChildWorkflowExecutionStarted.Ptr(), + types.EventTypeChildWorkflowExecutionCompleted.Ptr(), + types.EventTypeChildWorkflowExecutionFailed.Ptr(), + types.EventTypeChildWorkflowExecutionCanceled.Ptr(), + types.EventTypeChildWorkflowExecutionTimedOut.Ptr(), + types.EventTypeChildWorkflowExecutionTerminated.Ptr(), + types.EventTypeSignalExternalWorkflowExecutionInitiated.Ptr(), + types.EventTypeSignalExternalWorkflowExecutionFailed.Ptr(), + types.EventTypeExternalWorkflowExecutionSignaled.Ptr(), + types.EventTypeUpsertWorkflowSearchAttributes.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromEventType(original) + roundTripObj := ToEventType(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestExternalWorkflowExecutionSignaledEventAttributesConversion(t *testing.T) { + testCases := []*types.ExternalWorkflowExecutionSignaledEventAttributes{ + nil, + {}, + &testdata.ExternalWorkflowExecutionSignaledEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromExternalWorkflowExecutionSignaledEventAttributes(original) + roundTripObj := ToExternalWorkflowExecutionSignaledEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestFailWorkflowExecutionDecisionAttributesConversion(t *testing.T) { + testCases := []*types.FailWorkflowExecutionDecisionAttributes{ + nil, + {}, + &testdata.FailWorkflowExecutionDecisionAttributes, + } + + for _, original := range testCases { + thriftObj := FromFailWorkflowExecutionDecisionAttributes(original) + roundTripObj := ToFailWorkflowExecutionDecisionAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestGetSearchAttributesResponseConversion(t *testing.T) { + testCases := []*types.GetSearchAttributesResponse{ + nil, + {}, + &testdata.GetSearchAttributesResponse, + } + + for _, original := range testCases { + thriftObj := FromGetSearchAttributesResponse(original) + roundTripObj := ToGetSearchAttributesResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestGetWorkflowExecutionHistoryRequestConversion(t *testing.T) { + testCases := []*types.GetWorkflowExecutionHistoryRequest{ + nil, + {}, + &testdata.GetWorkflowExecutionHistoryRequest, + } + + for _, original := range testCases { + thriftObj := FromGetWorkflowExecutionHistoryRequest(original) + roundTripObj := ToGetWorkflowExecutionHistoryRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestGetWorkflowExecutionHistoryResponseConvesion(t *testing.T) { + testCases := []*types.GetWorkflowExecutionHistoryResponse{ + nil, + {}, + &testdata.GetWorkflowExecutionHistoryResponse, + } + + for _, original := range testCases { + thriftObj := FromGetWorkflowExecutionHistoryResponse(original) + roundTripObj := ToGetWorkflowExecutionHistoryResponse(thriftObj) + opt := cmpopts.IgnoreFields(types.WorkflowExecutionStartedEventAttributes{}, "ParentWorkflowDomainID") + if diff := cmp.Diff(original, roundTripObj, opt); diff != "" { + t.Fatalf("Mismatch (-want +got):\n%s", diff) + } + } +} + +func TestHeaderConversion(t *testing.T) { + testCases := []*types.Header{ + nil, + {}, + &testdata.Header, + } + + for _, original := range testCases { + thriftObj := FromHeader(original) + roundTripObj := ToHeader(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryConversion(t *testing.T) { + testCases := []*types.History{ + nil, + {}, + &testdata.History, + } + + for _, original := range testCases { + thriftObj := FromHistory(original) + roundTripObj := ToHistory(thriftObj) + opt := cmpopts.IgnoreFields(types.WorkflowExecutionStartedEventAttributes{}, "ParentWorkflowDomainID") + if diff := cmp.Diff(original, roundTripObj, opt); diff != "" { + t.Fatalf("Mismatch (-want +got):\n%s", diff) + } + } +} + +func TestHistoryBranchConversion(t *testing.T) { + testCases := []*types.HistoryBranch{ + nil, + {}, + {TreeID: "test-tree-id", BranchID: "test-branch-id"}, + } + + for _, original := range testCases { + thriftObj := FromHistoryBranch(original) + roundTripObj := ToHistoryBranch(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryBranchRangeConversion(t *testing.T) { + testCases := []*types.HistoryBranchRange{ + nil, + {}, + {BranchID: "test-branch-id", BeginNodeID: 5, EndNodeID: 10}, + } + + for _, original := range testCases { + thriftObj := FromHistoryBranchRange(original) + roundTripObj := ToHistoryBranchRange(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryEventConversion(t *testing.T) { + testCases := []*types.HistoryEvent{ + nil, + {}, + { + ID: 5, + Timestamp: common.Int64Ptr(10), + EventType: types.EventTypeWorkflowExecutionStarted.Ptr(), + WorkflowExecutionStartedEventAttributes: &testdata.WorkflowExecutionStartedEventAttributes, + }, + } + + for _, original := range testCases { + thriftObj := FromHistoryEvent(original) + roundTripObj := ToHistoryEvent(thriftObj) + opt := cmpopts.IgnoreFields(types.WorkflowExecutionStartedEventAttributes{}, "ParentWorkflowDomainID") + if diff := cmp.Diff(original, roundTripObj, opt); diff != "" { + t.Fatalf("Mismatch (-want +got):\n%s", diff) + } + } +} + +func TestHistoryEventFilterTypeConversion(t *testing.T) { + testCases := []*types.HistoryEventFilterType{ + nil, + types.HistoryEventFilterTypeAllEvent.Ptr(), + types.HistoryEventFilterTypeCloseEvent.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromHistoryEventFilterType(original) + roundTripObj := ToHistoryEventFilterType(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestIndexedValueTypeConversion(t *testing.T) { + testCases := []types.IndexedValueType{ + types.IndexedValueTypeString, + types.IndexedValueTypeKeyword, + types.IndexedValueTypeInt, + types.IndexedValueTypeDouble, + types.IndexedValueTypeBool, + types.IndexedValueTypeDatetime, + } + + for _, original := range testCases { + thriftObj := FromIndexedValueType(original) + roundTripObj := ToIndexedValueType(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestInternalDataInconsistencyErrorConversion(t *testing.T) { + testCases := []*types.InternalDataInconsistencyError{ + nil, + {}, + &testdata.InternalDataInconsistencyError, + } + + for _, original := range testCases { + thriftObj := FromInternalDataInconsistencyError(original) + roundTripObj := ToInternalDataInconsistencyError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestInternalServiceErrorConversion(t *testing.T) { + testCases := []*types.InternalServiceError{ + nil, + {}, + &testdata.InternalServiceError, + } + + for _, original := range testCases { + thriftObj := FromInternalServiceError(original) + roundTripObj := ToInternalServiceError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestLimitExceededErrorConversion(t *testing.T) { + testCases := []*types.LimitExceededError{ + nil, + {}, + &testdata.LimitExceededError, + } + + for _, original := range testCases { + thriftObj := FromLimitExceededError(original) + roundTripObj := ToLimitExceededError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestListArchivedWorkflowExecutionsRequestConversion(t *testing.T) { + testCases := []*types.ListArchivedWorkflowExecutionsRequest{ + nil, + {}, + &testdata.ListArchivedWorkflowExecutionsRequest, + } + + for _, original := range testCases { + thriftObj := FromListArchivedWorkflowExecutionsRequest(original) + roundTripObj := ToListArchivedWorkflowExecutionsRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestListArchivedWorkflowExecutionsResponseConversion(t *testing.T) { + testCases := []*types.ListArchivedWorkflowExecutionsResponse{ + nil, + {}, + &testdata.ListArchivedWorkflowExecutionsResponse, + } + + for _, original := range testCases { + thriftObj := FromListArchivedWorkflowExecutionsResponse(original) + roundTripObj := ToListArchivedWorkflowExecutionsResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestListClosedWorkflowExecutionsRequestConversion(t *testing.T) { + testCases := []*types.ListClosedWorkflowExecutionsRequest{ + nil, + {}, + {Domain: "test-domain", MaximumPageSize: 100, NextPageToken: []byte("test-next-page-token")}, + } + + for _, original := range testCases { + thriftObj := FromListClosedWorkflowExecutionsRequest(original) + roundTripObj := ToListClosedWorkflowExecutionsRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestListClosedWorkflowExecutionsResponseConversion(t *testing.T) { + testCases := []*types.ListClosedWorkflowExecutionsResponse{ + nil, + {}, + &testdata.ListClosedWorkflowExecutionsResponse, + } + + for _, original := range testCases { + thriftObj := FromListClosedWorkflowExecutionsResponse(original) + roundTripObj := ToListClosedWorkflowExecutionsResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestListDomainsRequestConversion(t *testing.T) { + testCases := []*types.ListDomainsRequest{ + nil, + {}, + &testdata.ListDomainsRequest, + } + + for _, original := range testCases { + thriftObj := FromListDomainsRequest(original) + roundTripObj := ToListDomainsRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestListDomainsResponseConversion(t *testing.T) { + testCases := []*types.ListDomainsResponse{ + nil, + {}, + &testdata.ListDomainsResponse, + } + + for _, original := range testCases { + thriftObj := FromListDomainsResponse(original) + roundTripObj := ToListDomainsResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestListOpenWorkflowExecutionsRequestConversion(t *testing.T) { + testCases := []*types.ListOpenWorkflowExecutionsRequest{ + nil, + {}, + {Domain: "test-domain", MaximumPageSize: 100, NextPageToken: []byte("test-next-page-token")}, + } + + for _, original := range testCases { + thriftObj := FromListOpenWorkflowExecutionsRequest(original) + roundTripObj := ToListOpenWorkflowExecutionsRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestListOpenWorkflowExecutionsResponseConversion(t *testing.T) { + testCases := []*types.ListOpenWorkflowExecutionsResponse{ + nil, + {}, + &testdata.ListOpenWorkflowExecutionsResponse, + } + + for _, original := range testCases { + thriftObj := FromListOpenWorkflowExecutionsResponse(original) + roundTripObj := ToListOpenWorkflowExecutionsResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestListTaskListPartitionsRequestConversion(t *testing.T) { + testCases := []*types.ListTaskListPartitionsRequest{ + nil, + {}, + &testdata.ListTaskListPartitionsRequest, + } + + for _, original := range testCases { + thriftObj := FromListTaskListPartitionsRequest(original) + roundTripObj := ToListTaskListPartitionsRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestListTaskListPartitionsResponseConversion(t *testing.T) { + testCases := []*types.ListTaskListPartitionsResponse{ + nil, + {}, + &testdata.ListTaskListPartitionsResponse, + } + + for _, original := range testCases { + thriftObj := FromListTaskListPartitionsResponse(original) + roundTripObj := ToListTaskListPartitionsResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestGetTaskListsByDomainRequestConversion(t *testing.T) { + testCases := []*types.GetTaskListsByDomainRequest{ + nil, + {}, + &testdata.MatchingGetTaskListsByDomainRequest, + } + + for _, original := range testCases { + thriftObj := FromGetTaskListsByDomainRequest(original) + roundTripObj := ToGetTaskListsByDomainRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestGetTaskListsByDomainResponseConversion(t *testing.T) { + testCases := []*types.GetTaskListsByDomainResponse{ + nil, + {}, + &testdata.GetTaskListsByDomainResponse, + } + + for _, original := range testCases { + thriftObj := FromGetTaskListsByDomainResponse(original) + roundTripObj := ToGetTaskListsByDomainResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestDescribeTaskListResponseMapConversion(t *testing.T) { + testCases := []map[string]*types.DescribeTaskListResponse{ + nil, + {}, + {"test-key": &testdata.DescribeTaskListResponse}, + } + + for _, original := range testCases { + thriftObj := FromDescribeTaskListResponseMap(original) + roundTripObj := ToDescribeTaskListResponseMap(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestListWorkflowExecutionsRequestConversion(t *testing.T) { + testCases := []*types.ListWorkflowExecutionsRequest{ + nil, + {}, + &testdata.ListWorkflowExecutionsRequest, + } + + for _, original := range testCases { + thriftObj := FromListWorkflowExecutionsRequest(original) + roundTripObj := ToListWorkflowExecutionsRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestListWorkflowExecutionsResponseConversion(t *testing.T) { + testCases := []*types.ListWorkflowExecutionsResponse{ + nil, + {}, + &testdata.ListWorkflowExecutionsResponse, + } + + for _, original := range testCases { + thriftObj := FromListWorkflowExecutionsResponse(original) + roundTripObj := ToListWorkflowExecutionsResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestMarkerRecordedEventAttributesConversion(t *testing.T) { + testCases := []*types.MarkerRecordedEventAttributes{ + nil, + {}, + &testdata.MarkerRecordedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromMarkerRecordedEventAttributes(original) + roundTripObj := ToMarkerRecordedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestMemoConversion(t *testing.T) { + testCases := []*types.Memo{ + nil, + {}, + &testdata.Memo, + } + + for _, original := range testCases { + thriftObj := FromMemo(original) + roundTripObj := ToMemo(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestParentClosePolicyConversion(t *testing.T) { + testCases := []*types.ParentClosePolicy{ + nil, + types.ParentClosePolicyAbandon.Ptr(), + types.ParentClosePolicyRequestCancel.Ptr(), + types.ParentClosePolicyTerminate.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromParentClosePolicy(original) + roundTripObj := ToParentClosePolicy(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestPendingActivityInfoConversion(t *testing.T) { + testCases := []*types.PendingActivityInfo{ + nil, + {}, + &testdata.PendingActivityInfo, + } + + for _, original := range testCases { + thriftObj := FromPendingActivityInfo(original) + roundTripObj := ToPendingActivityInfo(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestPendingActivityStateConversion(t *testing.T) { + testCases := []*types.PendingActivityState{ + nil, + types.PendingActivityStateScheduled.Ptr(), + types.PendingActivityStateStarted.Ptr(), + types.PendingActivityStateCancelRequested.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromPendingActivityState(original) + roundTripObj := ToPendingActivityState(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestPendingChildExecutionInfoConversion(t *testing.T) { + testCases := []*types.PendingChildExecutionInfo{ + nil, + {}, + &testdata.PendingChildExecutionInfo, + } + + for _, original := range testCases { + thriftObj := FromPendingChildExecutionInfo(original) + roundTripObj := ToPendingChildExecutionInfo(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestPendingDecisionInfoConversion(t *testing.T) { + testCases := []*types.PendingDecisionInfo{ + nil, + {}, + &testdata.PendingDecisionInfo, + } + + for _, original := range testCases { + thriftObj := FromPendingDecisionInfo(original) + roundTripObj := ToPendingDecisionInfo(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestPendingDecisionStateConversion(t *testing.T) { + testCases := []*types.PendingDecisionState{ + nil, + types.PendingDecisionStateScheduled.Ptr(), + types.PendingDecisionStateStarted.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromPendingDecisionState(original) + roundTripObj := ToPendingDecisionState(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestPollForActivityTaskRequestConversion(t *testing.T) { + testCases := []*types.PollForActivityTaskRequest{ + nil, + {}, + &testdata.PollForActivityTaskRequest, + } + + for _, original := range testCases { + thriftObj := FromPollForActivityTaskRequest(original) + roundTripObj := ToPollForActivityTaskRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestPollForActivityTaskResponseConversion(t *testing.T) { + testCases := []*types.PollForActivityTaskResponse{ + nil, + {}, + &testdata.PollForActivityTaskResponse, + } + + for _, original := range testCases { + thriftObj := FromPollForActivityTaskResponse(original) + roundTripObj := ToPollForActivityTaskResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestPollForDecisionTaskRequestConversion(t *testing.T) { + testCases := []*types.PollForDecisionTaskRequest{ + nil, + {}, + &testdata.PollForDecisionTaskRequest, + } + + for _, original := range testCases { + thriftObj := FromPollForDecisionTaskRequest(original) + roundTripObj := ToPollForDecisionTaskRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestPollForDecisionTaskResponseConversion(t *testing.T) { + testCases := []*types.PollForDecisionTaskResponse{ + nil, + {}, + &testdata.PollForDecisionTaskResponse, + } + + for _, original := range testCases { + thriftObj := FromPollForDecisionTaskResponse(original) + roundTripObj := ToPollForDecisionTaskResponse(thriftObj) + opt := cmpopts.IgnoreFields(types.WorkflowExecutionStartedEventAttributes{}, "ParentWorkflowDomainID") + if diff := cmp.Diff(original, roundTripObj, opt); diff != "" { + t.Fatalf("Mismatch (-want +got):\n%s", diff) + } + } +} + +func TestPollerInfoConversion(t *testing.T) { + testCases := []*types.PollerInfo{ + nil, + {}, + &testdata.PollerInfo, + } + + for _, original := range testCases { + thriftObj := FromPollerInfo(original) + roundTripObj := ToPollerInfo(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestQueryConsistencyLevelConversion(t *testing.T) { + testCases := []*types.QueryConsistencyLevel{ + nil, + types.QueryConsistencyLevelEventual.Ptr(), + types.QueryConsistencyLevelStrong.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromQueryConsistencyLevel(original) + roundTripObj := ToQueryConsistencyLevel(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestQueryFailedErrorConversion(t *testing.T) { + testCases := []*types.QueryFailedError{ + nil, + {}, + &testdata.QueryFailedError, + } + + for _, original := range testCases { + thriftObj := FromQueryFailedError(original) + roundTripObj := ToQueryFailedError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestQueryRejectConditionConversion(t *testing.T) { + testCases := []*types.QueryRejectCondition{ + nil, + types.QueryRejectConditionNotOpen.Ptr(), + types.QueryRejectConditionNotCompletedCleanly.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromQueryRejectCondition(original) + roundTripObj := ToQueryRejectCondition(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestQueryRejectedConversion(t *testing.T) { + testCases := []*types.QueryRejected{ + nil, + {}, + &testdata.QueryRejected, + } + + for _, original := range testCases { + thriftObj := FromQueryRejected(original) + roundTripObj := ToQueryRejected(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestQueryResultTypeConversion(t *testing.T) { + testCases := []*types.QueryResultType{ + nil, + types.QueryResultTypeAnswered.Ptr(), + types.QueryResultTypeFailed.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromQueryResultType(original) + roundTripObj := ToQueryResultType(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestQueryTaskCompletedTypeConversion(t *testing.T) { + testCases := []*types.QueryTaskCompletedType{ + nil, + types.QueryTaskCompletedTypeCompleted.Ptr(), + types.QueryTaskCompletedTypeFailed.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromQueryTaskCompletedType(original) + roundTripObj := ToQueryTaskCompletedType(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestQueryWorkflowRequestConversion(t *testing.T) { + testCases := []*types.QueryWorkflowRequest{ + nil, + {}, + &testdata.QueryWorkflowRequest, + } + + for _, original := range testCases { + thriftObj := FromQueryWorkflowRequest(original) + roundTripObj := ToQueryWorkflowRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestQueryWorkflowResponseConversion(t *testing.T) { + testCases := []*types.QueryWorkflowResponse{ + nil, + {}, + &testdata.QueryWorkflowResponse, + } + + for _, original := range testCases { + thriftObj := FromQueryWorkflowResponse(original) + roundTripObj := ToQueryWorkflowResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestReapplyEventsRequestConversion(t *testing.T) { + testCases := []*types.ReapplyEventsRequest{ + nil, + {}, + {DomainName: "test-domain-name", WorkflowExecution: &testdata.WorkflowExecution}, + } + + for _, original := range testCases { + thriftObj := FromReapplyEventsRequest(original) + roundTripObj := ToReapplyEventsRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRecordActivityTaskHeartbeatByIDRequestConversion(t *testing.T) { + testCases := []*types.RecordActivityTaskHeartbeatByIDRequest{ + nil, + {}, + &testdata.RecordActivityTaskHeartbeatByIDRequest, + } + + for _, original := range testCases { + thriftObj := FromRecordActivityTaskHeartbeatByIDRequest(original) + roundTripObj := ToRecordActivityTaskHeartbeatByIDRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRecordActivityTaskHeartbeatRequestConversion(t *testing.T) { + testCases := []*types.RecordActivityTaskHeartbeatRequest{ + nil, + {}, + &testdata.RecordActivityTaskHeartbeatRequest, + } + + for _, original := range testCases { + thriftObj := FromRecordActivityTaskHeartbeatRequest(original) + roundTripObj := ToRecordActivityTaskHeartbeatRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRecordActivityTaskHeartbeatResponseConversion(t *testing.T) { + testCases := []*types.RecordActivityTaskHeartbeatResponse{ + nil, + {}, + &testdata.RecordActivityTaskHeartbeatResponse, + } + + for _, original := range testCases { + thriftObj := FromRecordActivityTaskHeartbeatResponse(original) + roundTripObj := ToRecordActivityTaskHeartbeatResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRecordMarkerDecisionAttributesConversion(t *testing.T) { + testCases := []*types.RecordMarkerDecisionAttributes{ + nil, + {}, + &testdata.RecordMarkerDecisionAttributes, + } + + for _, original := range testCases { + thriftObj := FromRecordMarkerDecisionAttributes(original) + roundTripObj := ToRecordMarkerDecisionAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRefreshWorkflowTasksRequestConversion(t *testing.T) { + testCases := []*types.RefreshWorkflowTasksRequest{ + nil, + {}, + {Domain: "test-domain", Execution: &testdata.WorkflowExecution}, + } + + for _, original := range testCases { + thriftObj := FromRefreshWorkflowTasksRequest(original) + roundTripObj := ToRefreshWorkflowTasksRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRegisterDomainRequestConversion(t *testing.T) { + testCases := []*types.RegisterDomainRequest{ + nil, + {}, + &testdata.RegisterDomainRequest, + } + + for _, original := range testCases { + thriftObj := FromRegisterDomainRequest(original) + roundTripObj := ToRegisterDomainRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRemoteSyncMatchedErrorConversion(t *testing.T) { + testCases := []*types.RemoteSyncMatchedError{ + nil, + {}, + &testdata.RemoteSyncMatchedError, + } + + for _, original := range testCases { + thriftObj := FromRemoteSyncMatchedError(original) + roundTripObj := ToRemoteSyncMatchedError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRemoveTaskRequestConversion(t *testing.T) { + testCases := []*types.RemoveTaskRequest{ + nil, + {}, + {ShardID: 10, Type: common.Int32Ptr(1), TaskID: 5, ClusterName: "test-cluster-name"}, + } + + for _, original := range testCases { + thriftObj := FromRemoveTaskRequest(original) + roundTripObj := ToRemoveTaskRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRequestCancelActivityTaskDecisionAttributesConversion(t *testing.T) { + testCases := []*types.RequestCancelActivityTaskDecisionAttributes{ + nil, + {}, + &testdata.RequestCancelActivityTaskDecisionAttributes, + } + + for _, original := range testCases { + thriftObj := FromRequestCancelActivityTaskDecisionAttributes(original) + roundTripObj := ToRequestCancelActivityTaskDecisionAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRequestCancelActivityTaskFailedEventAttributesConversion(t *testing.T) { + testCases := []*types.RequestCancelActivityTaskFailedEventAttributes{ + nil, + {}, + &testdata.RequestCancelActivityTaskFailedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromRequestCancelActivityTaskFailedEventAttributes(original) + roundTripObj := ToRequestCancelActivityTaskFailedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRequestCancelExternalWorkflowExecutionDecisionAttributesConversion(t *testing.T) { + testCases := []*types.RequestCancelExternalWorkflowExecutionDecisionAttributes{ + nil, + {}, + &testdata.RequestCancelExternalWorkflowExecutionDecisionAttributes, + } + + for _, original := range testCases { + thriftObj := FromRequestCancelExternalWorkflowExecutionDecisionAttributes(original) + roundTripObj := ToRequestCancelExternalWorkflowExecutionDecisionAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRequestCancelExternalWorkflowExecutionFailedEventAttributesConversion(t *testing.T) { + testCases := []*types.RequestCancelExternalWorkflowExecutionFailedEventAttributes{ + nil, + {}, + &testdata.RequestCancelExternalWorkflowExecutionFailedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromRequestCancelExternalWorkflowExecutionFailedEventAttributes(original) + roundTripObj := ToRequestCancelExternalWorkflowExecutionFailedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRequestCancelWorkflowExecutionRequestConversion(t *testing.T) { + testCases := []*types.RequestCancelWorkflowExecutionRequest{ + nil, + {}, + &testdata.RequestCancelWorkflowExecutionRequest, + } + + for _, original := range testCases { + thriftObj := FromRequestCancelWorkflowExecutionRequest(original) + roundTripObj := ToRequestCancelWorkflowExecutionRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestResetPointInfoConversion(t *testing.T) { + testCases := []*types.ResetPointInfo{ + nil, + {}, + &testdata.ResetPointInfo, + } + + for _, original := range testCases { + thriftObj := FromResetPointInfo(original) + roundTripObj := ToResetPointInfo(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestResetPointsConversion(t *testing.T) { + testCases := []*types.ResetPoints{ + nil, + {}, + &testdata.ResetPoints, + } + + for _, original := range testCases { + thriftObj := FromResetPoints(original) + roundTripObj := ToResetPoints(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestResetQueueRequestConversion(t *testing.T) { + testCases := []*types.ResetQueueRequest{ + nil, + {}, + {ShardID: 10, ClusterName: "test-cluster-name"}, + } + + for _, original := range testCases { + thriftObj := FromResetQueueRequest(original) + roundTripObj := ToResetQueueRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestResetStickyTaskListRequestConversion(t *testing.T) { + testCases := []*types.ResetStickyTaskListRequest{ + nil, + {}, + &testdata.ResetStickyTaskListRequest, + } + + for _, original := range testCases { + thriftObj := FromResetStickyTaskListRequest(original) + roundTripObj := ToResetStickyTaskListRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestResetStickyTaskListResponseConversion(t *testing.T) { + testCases := []*types.ResetStickyTaskListResponse{ + nil, + {}, + &testdata.ResetStickyTaskListResponse, + } + + for _, original := range testCases { + thriftObj := FromResetStickyTaskListResponse(original) + roundTripObj := ToResetStickyTaskListResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestResetWorkflowExecutionRequestConversion(t *testing.T) { + testCases := []*types.ResetWorkflowExecutionRequest{ + nil, + {}, + &testdata.ResetWorkflowExecutionRequest, + } + + for _, original := range testCases { + thriftObj := FromResetWorkflowExecutionRequest(original) + roundTripObj := ToResetWorkflowExecutionRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestResetWorkflowExecutionResponseConversion(t *testing.T) { + testCases := []*types.ResetWorkflowExecutionResponse{ + nil, + {}, + &testdata.ResetWorkflowExecutionResponse, + } + + for _, original := range testCases { + thriftObj := FromResetWorkflowExecutionResponse(original) + roundTripObj := ToResetWorkflowExecutionResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRespondActivityTaskCanceledByIDRequestConversion(t *testing.T) { + testCases := []*types.RespondActivityTaskCanceledByIDRequest{ + nil, + {}, + &testdata.RespondActivityTaskCanceledByIDRequest, + } + + for _, original := range testCases { + thriftObj := FromRespondActivityTaskCanceledByIDRequest(original) + roundTripObj := ToRespondActivityTaskCanceledByIDRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRespondActivityTaskCanceledRequestConversion(t *testing.T) { + testCases := []*types.RespondActivityTaskCanceledRequest{ + nil, + {}, + &testdata.RespondActivityTaskCanceledRequest, + } + + for _, original := range testCases { + thriftObj := FromRespondActivityTaskCanceledRequest(original) + roundTripObj := ToRespondActivityTaskCanceledRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRespondActivityTaskCompletedByIDRequestConversion(t *testing.T) { + testCases := []*types.RespondActivityTaskCompletedByIDRequest{ + nil, + {}, + &testdata.RespondActivityTaskCompletedByIDRequest, + } + + for _, original := range testCases { + thriftObj := FromRespondActivityTaskCompletedByIDRequest(original) + roundTripObj := ToRespondActivityTaskCompletedByIDRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRespondActivityTaskCompletedRequestConversion(t *testing.T) { + testCases := []*types.RespondActivityTaskCompletedRequest{ + nil, + {}, + &testdata.RespondActivityTaskCompletedRequest, + } + + for _, original := range testCases { + thriftObj := FromRespondActivityTaskCompletedRequest(original) + roundTripObj := ToRespondActivityTaskCompletedRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRespondActivityTaskFailedByIDRequestConversion(t *testing.T) { + testCases := []*types.RespondActivityTaskFailedByIDRequest{ + nil, + {}, + &testdata.RespondActivityTaskFailedByIDRequest, + } + + for _, original := range testCases { + thriftObj := FromRespondActivityTaskFailedByIDRequest(original) + roundTripObj := ToRespondActivityTaskFailedByIDRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRespondActivityTaskFailedRequestConversion(t *testing.T) { + testCases := []*types.RespondActivityTaskFailedRequest{ + nil, + {}, + &testdata.RespondActivityTaskFailedRequest, + } + + for _, original := range testCases { + thriftObj := FromRespondActivityTaskFailedRequest(original) + roundTripObj := ToRespondActivityTaskFailedRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRespondDecisionTaskCompletedRequestConversion(t *testing.T) { + testCases := []*types.RespondDecisionTaskCompletedRequest{ + nil, + {}, + &testdata.RespondDecisionTaskCompletedRequest, + } + + for _, original := range testCases { + thriftObj := FromRespondDecisionTaskCompletedRequest(original) + roundTripObj := ToRespondDecisionTaskCompletedRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRespondDecisionTaskFailedRequestConversion(t *testing.T) { + testCases := []*types.RespondDecisionTaskFailedRequest{ + nil, + {}, + &testdata.RespondDecisionTaskFailedRequest, + } + + for _, original := range testCases { + thriftObj := FromRespondDecisionTaskFailedRequest(original) + roundTripObj := ToRespondDecisionTaskFailedRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRespondQueryTaskCompletedRequestConversion(t *testing.T) { + testCases := []*types.RespondQueryTaskCompletedRequest{ + nil, + {}, + &testdata.RespondQueryTaskCompletedRequest, + } + + for _, original := range testCases { + thriftObj := FromRespondQueryTaskCompletedRequest(original) + roundTripObj := ToRespondQueryTaskCompletedRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRetryPolicyConversion(t *testing.T) { + testCases := []*types.RetryPolicy{ + nil, + {}, + &testdata.RetryPolicy, + } + + for _, original := range testCases { + thriftObj := FromRetryPolicy(original) + roundTripObj := ToRetryPolicy(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRetryTaskV2ErrorConversion(t *testing.T) { + testCases := []*types.RetryTaskV2Error{ + nil, + {}, + &testdata.RetryTaskV2Error, + } + + for _, original := range testCases { + thriftObj := FromRetryTaskV2Error(original) + roundTripObj := ToRetryTaskV2Error(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRestartWorkflowExecutionRequestConversion(t *testing.T) { + testCases := []*types.RestartWorkflowExecutionRequest{ + nil, + {}, + {Domain: "test-domain", WorkflowExecution: &testdata.WorkflowExecution}, + } + + for _, original := range testCases { + thriftObj := FromRestartWorkflowExecutionRequest(original) + roundTripObj := ToRestartWorkflowExecutionRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestScheduleActivityTaskDecisionAttributesConversion(t *testing.T) { + testCases := []*types.ScheduleActivityTaskDecisionAttributes{ + nil, + {}, + &testdata.ScheduleActivityTaskDecisionAttributes, + } + + for _, original := range testCases { + thriftObj := FromScheduleActivityTaskDecisionAttributes(original) + roundTripObj := ToScheduleActivityTaskDecisionAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestSearchAttributesConversion(t *testing.T) { + testCases := []*types.SearchAttributes{ + nil, + {}, + &testdata.SearchAttributes, + } + + for _, original := range testCases { + thriftObj := FromSearchAttributes(original) + roundTripObj := ToSearchAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestServiceBusyErrorConversion(t *testing.T) { + testCases := []*types.ServiceBusyError{ + nil, + {}, + &testdata.ServiceBusyError, + } + + for _, original := range testCases { + thriftObj := FromServiceBusyError(original) + roundTripObj := ToServiceBusyError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestSignalExternalWorkflowExecutionDecisionAttributesConversion(t *testing.T) { + testCases := []*types.SignalExternalWorkflowExecutionDecisionAttributes{ + nil, + {}, + &testdata.SignalExternalWorkflowExecutionDecisionAttributes, + } + + for _, original := range testCases { + thriftObj := FromSignalExternalWorkflowExecutionDecisionAttributes(original) + roundTripObj := ToSignalExternalWorkflowExecutionDecisionAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestSignalExternalWorkflowExecutionFailedCauseConversion(t *testing.T) { + testCases := []*types.SignalExternalWorkflowExecutionFailedCause{ + nil, + types.SignalExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromSignalExternalWorkflowExecutionFailedCause(original) + roundTripObj := ToSignalExternalWorkflowExecutionFailedCause(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestSignalExternalWorkflowExecutionFailedEventAttributesConversion(t *testing.T) { + testCases := []*types.SignalExternalWorkflowExecutionFailedEventAttributes{ + nil, + {}, + &testdata.SignalExternalWorkflowExecutionFailedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromSignalExternalWorkflowExecutionFailedEventAttributes(original) + roundTripObj := ToSignalExternalWorkflowExecutionFailedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestSignalExternalWorkflowExecutionInitiatedEventAttributesConversion(t *testing.T) { + testCases := []*types.SignalExternalWorkflowExecutionInitiatedEventAttributes{ + nil, + {}, + &testdata.SignalExternalWorkflowExecutionInitiatedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromSignalExternalWorkflowExecutionInitiatedEventAttributes(original) + roundTripObj := ToSignalExternalWorkflowExecutionInitiatedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestSignalWithStartWorkflowExecutionRequestConversion(t *testing.T) { + testCases := []*types.SignalWithStartWorkflowExecutionRequest{ + nil, + {}, + &testdata.SignalWithStartWorkflowExecutionRequest, + } + + for _, original := range testCases { + thriftObj := FromSignalWithStartWorkflowExecutionRequest(original) + roundTripObj := ToSignalWithStartWorkflowExecutionRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestSignalWorkflowExecutionRequestConversion(t *testing.T) { + testCases := []*types.SignalWorkflowExecutionRequest{ + nil, + {}, + &testdata.SignalWorkflowExecutionRequest, + } + + for _, original := range testCases { + thriftObj := FromSignalWorkflowExecutionRequest(original) + roundTripObj := ToSignalWorkflowExecutionRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestStartChildWorkflowExecutionDecisionAttributesConversion(t *testing.T) { + testCases := []*types.StartChildWorkflowExecutionDecisionAttributes{ + nil, + {}, + &testdata.StartChildWorkflowExecutionDecisionAttributes, + } + + for _, original := range testCases { + thriftObj := FromStartChildWorkflowExecutionDecisionAttributes(original) + roundTripObj := ToStartChildWorkflowExecutionDecisionAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestStartChildWorkflowExecutionFailedEventAttributesConversion(t *testing.T) { + testCases := []*types.StartChildWorkflowExecutionFailedEventAttributes{ + nil, + {}, + &testdata.StartChildWorkflowExecutionFailedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromStartChildWorkflowExecutionFailedEventAttributes(original) + roundTripObj := ToStartChildWorkflowExecutionFailedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestStartChildWorkflowExecutionInitiatedEventAttributesConversion(t *testing.T) { + testCases := []*types.StartChildWorkflowExecutionInitiatedEventAttributes{ + nil, + {}, + &testdata.StartChildWorkflowExecutionInitiatedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromStartChildWorkflowExecutionInitiatedEventAttributes(original) + roundTripObj := ToStartChildWorkflowExecutionInitiatedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestStartTimeFilterConversion(t *testing.T) { + testCases := []*types.StartTimeFilter{ + nil, + {}, + &testdata.StartTimeFilter, + } + + for _, original := range testCases { + thriftObj := FromStartTimeFilter(original) + roundTripObj := ToStartTimeFilter(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestStartTimerDecisionAttributesConversion(t *testing.T) { + testCases := []*types.StartTimerDecisionAttributes{ + nil, + {}, + &testdata.StartTimerDecisionAttributes, + } + + for _, original := range testCases { + thriftObj := FromStartTimerDecisionAttributes(original) + roundTripObj := ToStartTimerDecisionAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestStartWorkflowExecutionRequestConversion(t *testing.T) { + testCases := []*types.StartWorkflowExecutionRequest{ + nil, + {}, + &testdata.StartWorkflowExecutionRequest, + } + + for _, original := range testCases { + thriftObj := FromStartWorkflowExecutionRequest(original) + roundTripObj := ToStartWorkflowExecutionRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestRestartWorkflowExecutionResponseConversion(t *testing.T) { + testCases := []*types.RestartWorkflowExecutionResponse{ + nil, + {}, + {RunID: "test-run-id"}, + } + + for _, original := range testCases { + thriftObj := FromRestartWorkflowExecutionResponse(original) + roundTripObj := ToRestartWorkflowExecutionResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestStartWorkflowExecutionResponseConversion(t *testing.T) { + testCases := []*types.StartWorkflowExecutionResponse{ + nil, + {}, + {RunID: "test-run-id"}, + } + + for _, original := range testCases { + thriftObj := FromStartWorkflowExecutionResponse(original) + roundTripObj := ToStartWorkflowExecutionResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestStickyExecutionAttributesConversion(t *testing.T) { + testCases := []*types.StickyExecutionAttributes{ + nil, + {}, + &testdata.StickyExecutionAttributes, + } + + for _, original := range testCases { + thriftObj := FromStickyExecutionAttributes(original) + roundTripObj := ToStickyExecutionAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestSupportedClientVersionsConversion(t *testing.T) { + testCases := []*types.SupportedClientVersions{ + nil, + {}, + &testdata.SupportedClientVersions, + } + + for _, original := range testCases { + thriftObj := FromSupportedClientVersions(original) + roundTripObj := ToSupportedClientVersions(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestTaskIDBlockConversion(t *testing.T) { + testCases := []*types.TaskIDBlock{ + nil, + {}, + &testdata.TaskIDBlock, + } + + for _, original := range testCases { + thriftObj := FromTaskIDBlock(original) + roundTripObj := ToTaskIDBlock(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestTaskListConversion(t *testing.T) { + testCases := []*types.TaskList{ + nil, + {}, + &testdata.TaskList, + } + + for _, original := range testCases { + thriftObj := FromTaskList(original) + roundTripObj := ToTaskList(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestTaskListMetadataConversion(t *testing.T) { + testCases := []*types.TaskListMetadata{ + nil, + {}, + &testdata.TaskListMetadata, + } + + for _, original := range testCases { + thriftObj := FromTaskListMetadata(original) + roundTripObj := ToTaskListMetadata(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestTaskListPartitionMetadataConversion(t *testing.T) { + testCases := []*types.TaskListPartitionMetadata{ + nil, + {}, + &testdata.TaskListPartitionMetadata, + } + + for _, original := range testCases { + thriftObj := FromTaskListPartitionMetadata(original) + roundTripObj := ToTaskListPartitionMetadata(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestTaskListStatusConversion(t *testing.T) { + testCases := []*types.TaskListStatus{ + nil, + {}, + &testdata.TaskListStatus, + } + + for _, original := range testCases { + thriftObj := FromTaskListStatus(original) + roundTripObj := ToTaskListStatus(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestTaskListTypeConversion(t *testing.T) { + testCases := []*types.TaskListType{ + nil, + types.TaskListTypeDecision.Ptr(), + types.TaskListTypeActivity.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromTaskListType(original) + roundTripObj := ToTaskListType(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestTimeoutTypeConversion(t *testing.T) { + testCases := []*types.TimeoutType{ + nil, + types.TimeoutTypeStartToClose.Ptr(), + types.TimeoutTypeScheduleToStart.Ptr(), + types.TimeoutTypeScheduleToClose.Ptr(), + types.TimeoutTypeHeartbeat.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromTimeoutType(original) + roundTripObj := ToTimeoutType(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestTimerCanceledEventAttributesConversion(t *testing.T) { + testCases := []*types.TimerCanceledEventAttributes{ + nil, + {}, + &testdata.TimerCanceledEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromTimerCanceledEventAttributes(original) + roundTripObj := ToTimerCanceledEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestTimerFiredEventAttributesConversion(t *testing.T) { + testCases := []*types.TimerFiredEventAttributes{ + nil, + {}, + &testdata.TimerFiredEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromTimerFiredEventAttributes(original) + roundTripObj := ToTimerFiredEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestTimerStartedEventAttributesConversion(t *testing.T) { + testCases := []*types.TimerStartedEventAttributes{ + nil, + {}, + &testdata.TimerStartedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromTimerStartedEventAttributes(original) + roundTripObj := ToTimerStartedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestTransientDecisionInfoConversion(t *testing.T) { + testCases := []*types.TransientDecisionInfo{ + nil, + {}, + &testdata.TransientDecisionInfo, + } + + for _, original := range testCases { + thriftObj := FromTransientDecisionInfo(original) + roundTripObj := ToTransientDecisionInfo(thriftObj) + opt := cmpopts.IgnoreFields(types.WorkflowExecutionStartedEventAttributes{}, "ParentWorkflowDomainID") + if diff := cmp.Diff(original, roundTripObj, opt); diff != "" { + t.Fatalf("Mismatch (-want +got):\n%s", diff) + } + } +} + +func TestUpdateDomainRequestConversion(t *testing.T) { + testCases := []*types.UpdateDomainRequest{ + nil, + {}, + &testdata.UpdateDomainRequest, + } + + for _, original := range testCases { + thriftObj := FromUpdateDomainRequest(original) + roundTripObj := ToUpdateDomainRequest(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestUpdateDomainResponseConversion(t *testing.T) { + testCases := []*types.UpdateDomainResponse{ + nil, + {}, + &testdata.UpdateDomainResponse, + } + + for _, original := range testCases { + thriftObj := FromUpdateDomainResponse(original) + roundTripObj := ToUpdateDomainResponse(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestUpsertWorkflowSearchAttributesDecisionAttributesConversion(t *testing.T) { + testCases := []*types.UpsertWorkflowSearchAttributesDecisionAttributes{ + nil, + {}, + &testdata.UpsertWorkflowSearchAttributesDecisionAttributes, + } + + for _, original := range testCases { + thriftObj := FromUpsertWorkflowSearchAttributesDecisionAttributes(original) + roundTripObj := ToUpsertWorkflowSearchAttributesDecisionAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestUpsertWorkflowSearchAttributesEventAttributesConversion(t *testing.T) { + testCases := []*types.UpsertWorkflowSearchAttributesEventAttributes{ + nil, + {}, + &testdata.UpsertWorkflowSearchAttributesEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromUpsertWorkflowSearchAttributesEventAttributes(original) + roundTripObj := ToUpsertWorkflowSearchAttributesEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestVersionHistoriesConversion(t *testing.T) { + testCases := []*types.VersionHistories{ + nil, + {}, + &testdata.VersionHistories, + } + + for _, original := range testCases { + thriftObj := FromVersionHistories(original) + roundTripObj := ToVersionHistories(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestVersionHistoryConversion(t *testing.T) { + testCases := []*types.VersionHistory{ + nil, + {}, + &testdata.VersionHistory, + } + + for _, original := range testCases { + thriftObj := FromVersionHistory(original) + roundTripObj := ToVersionHistory(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestVersionHistoryItemConversion(t *testing.T) { + testCases := []*types.VersionHistoryItem{ + nil, + {}, + &testdata.VersionHistoryItem, + } + + for _, original := range testCases { + thriftObj := FromVersionHistoryItem(original) + roundTripObj := ToVersionHistoryItem(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestWorkerVersionInfoConversion(t *testing.T) { + testCases := []*types.WorkerVersionInfo{ + nil, + {}, + &testdata.WorkerVersionInfo, + } + + for _, original := range testCases { + thriftObj := FromWorkerVersionInfo(original) + roundTripObj := ToWorkerVersionInfo(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestWorkflowExecutionConversion(t *testing.T) { + testCases := []*types.WorkflowExecution{ + nil, + {}, + &testdata.WorkflowExecution, + } + + for _, original := range testCases { + thriftObj := FromWorkflowExecution(original) + roundTripObj := ToWorkflowExecution(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestWorkflowExecutionAlreadyStartedErrorConversion(t *testing.T) { + testCases := []*types.WorkflowExecutionAlreadyStartedError{ + nil, + {}, + &testdata.WorkflowExecutionAlreadyStartedError, + } + + for _, original := range testCases { + thriftObj := FromWorkflowExecutionAlreadyStartedError(original) + roundTripObj := ToWorkflowExecutionAlreadyStartedError(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestWorkflowExecutionCancelRequestedEventAttributesConversion(t *testing.T) { + testCases := []*types.WorkflowExecutionCancelRequestedEventAttributes{ + nil, + {}, + &testdata.WorkflowExecutionCancelRequestedEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromWorkflowExecutionCancelRequestedEventAttributes(original) + roundTripObj := ToWorkflowExecutionCancelRequestedEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestWorkflowExecutionCanceledEventAttributesConversion(t *testing.T) { + testCases := []*types.WorkflowExecutionCanceledEventAttributes{ + nil, + {}, + &testdata.WorkflowExecutionCanceledEventAttributes, + } + + for _, original := range testCases { + thriftObj := FromWorkflowExecutionCanceledEventAttributes(original) + roundTripObj := ToWorkflowExecutionCanceledEventAttributes(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestWorkflowExecutionCloseStatusConversion(t *testing.T) { + testCases := []*types.WorkflowExecutionCloseStatus{ + nil, + types.WorkflowExecutionCloseStatusCompleted.Ptr(), + types.WorkflowExecutionCloseStatusFailed.Ptr(), + types.WorkflowExecutionCloseStatusCanceled.Ptr(), + types.WorkflowExecutionCloseStatusTerminated.Ptr(), + types.WorkflowExecutionCloseStatusContinuedAsNew.Ptr(), + types.WorkflowExecutionCloseStatusTimedOut.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromWorkflowExecutionCloseStatus(original) + roundTripObj := ToWorkflowExecutionCloseStatus(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestWorkflowExecutionFilterConversion(t *testing.T) { + testCases := []*types.WorkflowExecutionFilter{ + nil, + {}, + &testdata.WorkflowExecutionFilter, + } + + for _, original := range testCases { + thriftObj := FromWorkflowExecutionFilter(original) + roundTripObj := ToWorkflowExecutionFilter(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestWorkflowIDReusePolicyConversion(t *testing.T) { + testCases := []*types.WorkflowIDReusePolicy{ + nil, + types.WorkflowIDReusePolicyAllowDuplicate.Ptr(), + types.WorkflowIDReusePolicyAllowDuplicateFailedOnly.Ptr(), + types.WorkflowIDReusePolicyRejectDuplicate.Ptr(), + types.WorkflowIDReusePolicyTerminateIfRunning.Ptr(), + } + + for _, original := range testCases { + thriftObj := FromWorkflowIDReusePolicy(original) + roundTripObj := ToWorkflowIDReusePolicy(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestWorkflowTypeFilterConversion(t *testing.T) { + testCases := []*types.WorkflowTypeFilter{ + nil, + {}, + &testdata.WorkflowTypeFilter, + } + + for _, original := range testCases { + thriftObj := FromWorkflowTypeFilter(original) + roundTripObj := ToWorkflowTypeFilter(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryBranchRangeArrayConversion(t *testing.T) { + testCases := [][]*types.HistoryBranchRange{ + nil, + {}, + { + {BranchID: "test-branch-id-1", BeginNodeID: 1, EndNodeID: 2}, + {BranchID: "test-branch-id-2", BeginNodeID: 5, EndNodeID: 6}, + }, + } + + for _, original := range testCases { + thriftObj := FromHistoryBranchRangeArray(original) + roundTripObj := ToHistoryBranchRangeArray(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestActivityLocalDispatchInfoMapConversion(t *testing.T) { + testCases := []map[string]*types.ActivityLocalDispatchInfo{ + nil, + {}, + { + "test-key-1": &testdata.ActivityLocalDispatchInfo, + "test-key-2": &testdata.ActivityLocalDispatchInfo, + }, + } + + for _, original := range testCases { + thriftObj := FromActivityLocalDispatchInfoMap(original) + roundTripObj := ToActivityLocalDispatchInfoMap(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestHistoryArrayConversion(t *testing.T) { + testCases := [][]*types.History{ + nil, + {}, + { + {Events: []*types.HistoryEvent{{ID: 1}, {ID: 2}}}, + {Events: []*types.HistoryEvent{{ID: 3}, {ID: 4}}}, + }, + } + + for _, original := range testCases { + thriftObj := FromHistoryArray(original) + roundTripObj := ToHistoryArray(thriftObj) + assert.Equal(t, original, roundTripObj) + } +} + +func TestStickyWorkerUnavailableErrorConversion(t *testing.T) { + testCases := []*types.StickyWorkerUnavailableError{ + nil, + {}, + &testdata.StickyWorkerUnavailableError, + } + + for _, original := range testCases { + thriftObj := FromStickyWorkerUnavailableError(original) + roundTripObj := ToStickyWorkerUnavailableError(thriftObj) + assert.Equal(t, original, roundTripObj) } } diff --git a/common/types/mapper/thrift/thrift-tests/history_test.go b/common/types/mapper/thrift/thrift-tests/history_test.go deleted file mode 100644 index 28512d1b74b..00000000000 --- a/common/types/mapper/thrift/thrift-tests/history_test.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2021 Uber Technologies Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -package thrifttests - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/uber/cadence/common/types" - "github.com/uber/cadence/common/types/mapper/thrift" - "github.com/uber/cadence/common/types/testdata" -) - -func TestHistoryTerminateWorkflowExecutionRequest(t *testing.T) { - for _, item := range []*types.HistoryTerminateWorkflowExecutionRequest{nil, {}, &testdata.HistoryTerminateWorkflowExecutionRequest} { - assert.Equal(t, item, thrift.ToHistoryTerminateWorkflowExecutionRequest(thrift.FromHistoryTerminateWorkflowExecutionRequest(item))) - } -} diff --git a/common/types/mapper/thrift/thrift-tests/shared_test.go b/common/types/mapper/thrift/thrift-tests/shared_test.go deleted file mode 100644 index f55dcd5609b..00000000000 --- a/common/types/mapper/thrift/thrift-tests/shared_test.go +++ /dev/null @@ -1,320 +0,0 @@ -// Copyright (c) 2021 Uber Technologies Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -package thrifttests - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/uber/cadence/.gen/go/shared" - "github.com/uber/cadence/common/types" - "github.com/uber/cadence/common/types/mapper/thrift" - "github.com/uber/cadence/common/types/testdata" -) - -// TODO: this package is create to avoid the cycle dependency where -// "github.com/uber/cadence/common/types/mapper/thrift" imports -// "github.com/uber/cadence/common/types/mapper/testdata" imports -// "github.com/uber/cadence/common/persistence" imports -// "github.com/uber/cadence/common/types/mapper/thrift" - -func TestDecisionTaskTimedOutEventAttributes(t *testing.T) { - for _, item := range []*types.DecisionTaskTimedOutEventAttributes{nil, {}, &testdata.DecisionTaskTimedOutEventAttributes} { - assert.Equal(t, item, thrift.ToDecisionTaskTimedOutEventAttributes(thrift.FromDecisionTaskTimedOutEventAttributes(item))) - } -} - -func TestRemoveTaskRequest(t *testing.T) { - for _, item := range []*types.RemoveTaskRequest{nil, {}, &testdata.AdminRemoveTaskRequest} { - assert.Equal(t, item, thrift.ToRemoveTaskRequest(thrift.FromRemoveTaskRequest(item))) - } -} - -func TestCrossClusterTaskInfo(t *testing.T) { - for _, item := range []*types.CrossClusterTaskInfo{nil, {}, &testdata.CrossClusterTaskInfo} { - assert.Equal(t, item, thrift.ToCrossClusterTaskInfo(thrift.FromCrossClusterTaskInfo(item))) - } -} - -func TestCrossClusterTaskRequest(t *testing.T) { - for _, item := range []*types.CrossClusterTaskRequest{ - nil, - {}, - &testdata.CrossClusterTaskRequestStartChildExecution, - &testdata.CrossClusterTaskRequestCancelExecution, - &testdata.CrossClusterTaskRequestSignalExecution, - } { - assert.Equal(t, item, thrift.ToCrossClusterTaskRequest(thrift.FromCrossClusterTaskRequest(item))) - } -} - -func TestCrossClusterTaskResponse(t *testing.T) { - for _, item := range []*types.CrossClusterTaskResponse{ - nil, - {}, - &testdata.CrossClusterTaskResponseStartChildExecution, - &testdata.CrossClusterTaskResponseCancelExecution, - &testdata.CrossClusterTaskResponseSignalExecution, - } { - assert.Equal(t, item, thrift.ToCrossClusterTaskResponse(thrift.FromCrossClusterTaskResponse(item))) - } -} - -func TestCrossClusterTaskRequestArray(t *testing.T) { - for _, item := range [][]*types.CrossClusterTaskRequest{nil, {}, testdata.CrossClusterTaskRequestArray} { - assert.Equal(t, item, thrift.ToCrossClusterTaskRequestArray(thrift.FromCrossClusterTaskRequestArray(item))) - } -} - -func TestCrossClusterTaskResponseArray(t *testing.T) { - for _, item := range [][]*types.CrossClusterTaskResponse{nil, {}, testdata.CrossClusterTaskResponseArray} { - assert.Equal(t, item, thrift.ToCrossClusterTaskResponseArray(thrift.FromCrossClusterTaskResponseArray(item))) - } -} - -func TestCrossClusterTaskRequestMap(t *testing.T) { - for _, item := range []map[int32][]*types.CrossClusterTaskRequest{nil, {}, testdata.CrossClusterTaskRequestMap} { - assert.Equal(t, item, thrift.ToCrossClusterTaskRequestMap(thrift.FromCrossClusterTaskRequestMap(item))) - } -} - -func TestGetTaskFailedCauseMap(t *testing.T) { - for _, item := range []map[int32]types.GetTaskFailedCause{nil, {}, testdata.GetCrossClusterTaskFailedCauseMap} { - assert.Equal(t, item, thrift.ToGetTaskFailedCauseMap(thrift.FromGetTaskFailedCauseMap(item))) - } -} - -func TestGetCrossClusterTasksRequest(t *testing.T) { - for _, item := range []*types.GetCrossClusterTasksRequest{nil, {}, &testdata.GetCrossClusterTasksRequest} { - assert.Equal(t, item, thrift.ToGetCrossClusterTasksRequest(thrift.FromGetCrossClusterTasksRequest(item))) - } -} - -func TestGetCrossClusterTasksResponse(t *testing.T) { - for _, item := range []*types.GetCrossClusterTasksResponse{nil, {}, &testdata.GetCrossClusterTasksResponse} { - assert.Equal(t, item, thrift.ToGetCrossClusterTasksResponse(thrift.FromGetCrossClusterTasksResponse(item))) - } -} - -func TestRespondCrossClusterTasksCompletedRequest(t *testing.T) { - for _, item := range []*types.RespondCrossClusterTasksCompletedRequest{nil, {}, &testdata.RespondCrossClusterTasksCompletedRequest} { - assert.Equal(t, item, thrift.ToRespondCrossClusterTasksCompletedRequest(thrift.FromRespondCrossClusterTasksCompletedRequest(item))) - } -} - -func TestRespondCrossClusterTasksCompletedResponse(t *testing.T) { - for _, item := range []*types.RespondCrossClusterTasksCompletedResponse{nil, {}, &testdata.RespondCrossClusterTasksCompletedResponse} { - assert.Equal(t, item, thrift.ToRespondCrossClusterTasksCompletedResponse(thrift.FromRespondCrossClusterTasksCompletedResponse(item))) - } -} - -func TestGetTaskListsByDomainRequest(t *testing.T) { - for _, item := range []*types.GetTaskListsByDomainRequest{nil, {}, &testdata.MatchingGetTaskListsByDomainRequest} { - assert.Equal(t, item, thrift.ToGetTaskListsByDomainRequest(thrift.FromGetTaskListsByDomainRequest(item))) - } -} - -func TestGetTaskListsByDomainResponse(t *testing.T) { - for _, item := range []*types.GetTaskListsByDomainResponse{nil, {}, &testdata.GetTaskListsByDomainResponse} { - i := thrift.FromGetTaskListsByDomainResponse(item) - assert.Equal(t, item, thrift.ToGetTaskListsByDomainResponse(i)) - } -} - -func TestDescribeTaskListResponseMap(t *testing.T) { - for _, item := range []map[string]*types.DescribeTaskListResponse{nil, {}, testdata.DescribeTaskListResponseMap} { - i := thrift.FromDescribeTaskListResponseMap(item) - assert.Equal(t, item, thrift.ToDescribeTaskListResponseMap(i)) - } -} - -func TestGetFailoverInfoRequest(t *testing.T) { - for _, item := range []*types.GetFailoverInfoRequest{nil, {}, &testdata.GetFailoverInfoRequest} { - assert.Equal(t, item, thrift.ToGetFailoverInfoRequest(thrift.FromGetFailoverInfoRequest(item))) - } -} - -func TestGetFailoverInfoResponse(t *testing.T) { - for _, item := range []*types.GetFailoverInfoResponse{nil, {}, &testdata.GetFailoverInfoResponse} { - assert.Equal(t, item, thrift.ToGetFailoverInfoResponse(thrift.FromGetFailoverInfoResponse(item))) - } -} - -func TestFailoverInfo(t *testing.T) { - for _, item := range []*types.FailoverInfo{nil, {}, &testdata.FailoverInfo} { - assert.Equal(t, item, thrift.ToFailoverInfo(thrift.FromFailoverInfo(item))) - } -} - -func TestCrossClusterApplyParentClosePolicyRequestAttributes(t *testing.T) { - item := testdata.CrossClusterApplyParentClosePolicyRequestAttributes - assert.Equal( - t, - &item, - thrift.ToCrossClusterApplyParentClosePolicyRequestAttributes( - thrift.FromCrossClusterApplyParentClosePolicyRequestAttributes(&item), - ), - ) -} - -func TestApplyParentClosePolicyAttributes(t *testing.T) { - item := testdata.ApplyParentClosePolicyAttributes - assert.Equal( - t, - &item, - thrift.ToApplyParentClosePolicyAttributes( - thrift.FromApplyParentClosePolicyAttributes(&item), - ), - ) -} - -func TestApplyParentClosePolicyResult(t *testing.T) { - item := testdata.ApplyParentClosePolicyResult - assert.Equal( - t, - &item, - thrift.ToApplyParentClosePolicyResult( - thrift.FromApplyParentClosePolicyResult(&item), - ), - ) -} - -func TestCrossClusterApplyParentClosePolicyResponse(t *testing.T) { - item := testdata.CrossClusterApplyParentClosePolicyResponseWithChildren - assert.Equal( - t, - &item, - thrift.ToCrossClusterApplyParentClosePolicyResponseAttributes( - thrift.FromCrossClusterApplyParentClosePolicyResponseAttributes(&item), - ), - ) -} - -func TestIsolationGroupToDomainBlob(t *testing.T) { - - zone1 := "zone-1" - zone2 := "zone-2" - drained := shared.IsolationGroupStateDrained - healthy := shared.IsolationGroupStateHealthy - - tests := map[string]struct { - in *types.IsolationGroupConfiguration - expectedOut *shared.IsolationGroupConfiguration - }{ - "valid input": { - in: &types.IsolationGroupConfiguration{ - "zone-1": { - Name: zone1, - State: types.IsolationGroupStateDrained, - }, - "zone-2": { - Name: zone2, - State: types.IsolationGroupStateHealthy, - }, - }, - expectedOut: &shared.IsolationGroupConfiguration{ - IsolationGroups: []*shared.IsolationGroupPartition{ - { - Name: &zone1, - State: &drained, - }, - { - Name: &zone2, - State: &healthy, - }, - }, - }, - }, - "empty input": { - in: &types.IsolationGroupConfiguration{}, - expectedOut: &shared.IsolationGroupConfiguration{}, - }, - "nil input": { - in: nil, - expectedOut: nil, - }, - } - - for name, td := range tests { - t.Run(name, func(t *testing.T) { - out := thrift.FromIsolationGroupConfig(td.in) - assert.Equal(t, td.expectedOut, out) - roundTrip := thrift.ToIsolationGroupConfig(out) - assert.Equal(t, td.in, roundTrip) - }) - } -} - -func TestIsolationGroupFromDomainBlob(t *testing.T) { - - zone1 := "zone-1" - zone2 := "zone-2" - drained := shared.IsolationGroupStateDrained - healthy := shared.IsolationGroupStateHealthy - - tests := map[string]struct { - in *shared.IsolationGroupConfiguration - expectedOut *types.IsolationGroupConfiguration - }{ - "valid input": { - in: &shared.IsolationGroupConfiguration{ - IsolationGroups: []*shared.IsolationGroupPartition{ - { - Name: &zone1, - State: &drained, - }, - { - Name: &zone2, - State: &healthy, - }, - }, - }, - expectedOut: &types.IsolationGroupConfiguration{ - "zone-1": { - Name: zone1, - State: types.IsolationGroupStateDrained, - }, - "zone-2": { - Name: zone2, - State: types.IsolationGroupStateHealthy, - }, - }, - }, - "empty input": { - in: &shared.IsolationGroupConfiguration{}, - expectedOut: &types.IsolationGroupConfiguration{}, - }, - "nil input": { - in: nil, - expectedOut: nil, - }, - } - - for name, td := range tests { - t.Run(name, func(t *testing.T) { - out := thrift.ToIsolationGroupConfig(td.in) - assert.Equal(t, td.expectedOut, out) - roundTrip := thrift.FromIsolationGroupConfig(out) - assert.Equal(t, td.in, roundTrip) - }) - } -} diff --git a/common/types/testdata/service_history.go b/common/types/testdata/service_history.go index f8b446f6ce0..f9b8800df01 100644 --- a/common/types/testdata/service_history.go +++ b/common/types/testdata/service_history.go @@ -22,7 +22,6 @@ package testdata import ( "github.com/uber/cadence/common" - "github.com/uber/cadence/common/persistence" "github.com/uber/cadence/common/types" ) @@ -68,8 +67,8 @@ var ( StickyTaskListScheduleToStartTimeout: &Duration1, EventStoreVersion: EventStoreVersion, CurrentBranchToken: BranchToken, - WorkflowState: common.Int32Ptr(persistence.WorkflowStateRunning), - WorkflowCloseState: common.Int32Ptr(persistence.WorkflowCloseStatusTimedOut), + WorkflowState: common.Int32Ptr(1), // persistence.WorkflowStateRunning + WorkflowCloseState: common.Int32Ptr(6), // persistence.WorkflowCloseStatusTimedOut VersionHistories: &VersionHistories, IsStickyTaskListEnabled: true, HistorySize: HistorySizeInBytes, @@ -103,8 +102,8 @@ var ( StickyTaskListScheduleToStartTimeout: &Duration1, CurrentBranchToken: BranchToken, VersionHistories: &VersionHistories, - WorkflowState: common.Int32Ptr(persistence.WorkflowStateCorrupted), - WorkflowCloseState: common.Int32Ptr(persistence.WorkflowCloseStatusTimedOut), + WorkflowState: common.Int32Ptr(5), // persistence.WorkflowStateCorrupted + WorkflowCloseState: common.Int32Ptr(6), // persistence.WorkflowCloseStatusTimedOut } HistoryPurgeDLQMessagesRequest = AdminPurgeDLQMessagesRequest HistoryQueryWorkflowRequest = types.HistoryQueryWorkflowRequest{