public async Task changeGroupTest() { await NewTraceTest(); Assert.NotNull(someTraceState); Assert.Equal(someTraceState.UpdatedByGroupId, config.MY_GROUP); Sdk <Object> sdk = GetSdk(); // Appendlink Dictionary <string, object> dataMap = new Dictionary <string, object> { ["comment"] = "commment" }; AppendLinkInput <Dictionary <string, object> > appLinkInput = new AppendLinkInput <Dictionary <string, object> >( config.COMMENT_ACTION_KEY, dataMap, someTraceState.TraceId); // change group for action appLinkInput.GroupLabel = config.OTHER_GROUP_LABEL; TraceState <Object, Dictionary <string, object> > state = await sdk.AppendLinkAsync(appLinkInput); // should equal group2 id Assert.Equal(state.UpdatedByGroupId, config.OTHER_GROUP); AppendLinkInput <Dictionary <string, object> > appLinkInputWithGroupLabel = new AppendLinkInput <Dictionary <string, object> >( config.COMMENT_ACTION_KEY, dataMap, someTraceState.TraceId); appLinkInputWithGroupLabel.GroupLabel = config.MY_GROUP_LABEL; state = await sdk.AppendLinkAsync(appLinkInputWithGroupLabel); // should equal group2 id Assert.Equal(state.UpdatedByGroupId, config.MY_GROUP); }
public async Task AppendLinkTestWithPojo() { var sdk = GetSdk <StateExample>(); await NewTraceTestWithPojo(); Assert.IsNotNull(someTraceState); Dictionary <string, object> data; string json = "{ operation: \"XYZ shipment departed port for ABC\"," + " destination: \"ABC\", " + " customsCheck: true, " + " eta: \"2019-07-02T12:00:00.000Z\"" + " }"; data = JsonHelper.ObjectToMap(json); DataClass d = new DataClass() { f11 = 1, f22 = data }; AppendLinkInput <DataClass> appLinkInput = new AppendLinkInput <DataClass>(FORM_ID, d, someTraceState.TraceId); TraceState <StateExample, DataClass> state = await sdk.AppendLinkAsync <DataClass>(appLinkInput); Assert.IsNotNull(state.TraceId); }
public async Task changeGroupTest() { await NewTraceTestWithPojo(); Assert.NotNull(initTraceState); Assert.Equal(initTraceState.UpdatedByGroupId, config.MY_GROUP); Sdk <StateExample> sdk = GetSdk <StateExample>(); // Appendlink CommentClass dataMap = new CommentClass() { comment = "commment" }; AppendLinkInput <CommentClass> appLinkInput = new AppendLinkInput <CommentClass>( config.COMMENT_ACTION_KEY, dataMap, initTraceState.TraceId); // change group for action appLinkInput.GroupLabel = config.OTHER_GROUP_LABEL; TraceState <StateExample, CommentClass> state = await sdk.AppendLinkAsync(appLinkInput); // should equal group2 id Assert.Equal(state.UpdatedByGroupId, config.OTHER_GROUP); AppendLinkInput <CommentClass> appLinkInputWithGroupLabel = new AppendLinkInput <CommentClass>( config.COMMENT_ACTION_KEY, dataMap, initTraceState.TraceId); appLinkInputWithGroupLabel.GroupLabel = config.MY_GROUP_LABEL; state = await sdk.AppendLinkAsync(appLinkInputWithGroupLabel); // should equal group2 id Assert.Equal(state.UpdatedByGroupId, config.MY_GROUP); }
public async Task NewTraceUploadTest() { await NewTraceTest(); IDictionary <string, object> data = new Dictionary <string, object>(); data.Add("documents", new Identifiable[] { FileWrapper.FromFilePath(GetTestFilePath()) }); AppendLinkInput <object> appLinkInput = new AppendLinkInput <object>(config.UPLOAD_DOCUMENTS_ACTION_KEY, data, someTraceState.TraceId); TraceState <object, object> state = await GetOtherGroupSdk().AppendLinkAsync <object>(appLinkInput); Assert.NotNull(state.TraceId); traceStateWithFile = state; }
public async Task AppendLinkTest() { await NewTraceTest(); Assert.NotNull(someTraceState); Dictionary <string, object> data = new Dictionary <string, object> { ["comment"] = "comment" }; AppendLinkInput <object> appLinkInput = new AppendLinkInput <object>(config.COMMENT_ACTION_KEY, data, someTraceState.TraceId); TraceState <object, object> state = await GetSdk().AppendLinkAsync(appLinkInput); Assert.NotNull(state.TraceId); }
public async Task NewTraceUploadInClassTest() { await NewTraceTestWithPojo(); UploadDocumentsClass data = new UploadDocumentsClass(); data.documents = new Identifiable[] { FileWrapper.FromFilePath(GetTestFilePath()) }; data.comment = "upload comment"; AppendLinkInput <UploadDocumentsClass> appLinkInput = new AppendLinkInput <UploadDocumentsClass>(config.UPLOAD_DOCUMENTS_ACTION_KEY, data, initTraceState.TraceId); TraceState <StateExample, UploadDocumentsClass> state = await GetOtherGroupSdk <StateExample>().AppendLinkAsync(appLinkInput); Assert.NotNull(state.TraceId); }
public async Task AppendLinkTest() { await NewTraceTest(); Assert.IsNotNull(someTraceState); Dictionary <string, object> data; string json = "{ operation: \"XYZ shipment departed port for ABC\"," + " destination: \"ABC\", " + " customsCheck: true, " + " eta: \"2019-07-02T12:00:00.000Z\"" + " }"; data = JsonHelper.ObjectToMap(json); AppendLinkInput <object> appLinkInput = new AppendLinkInput <object>(FORM_ID, data, someTraceState.TraceId); TraceState <object, object> state = await GetSdk().AppendLinkAsync(appLinkInput); Assert.IsNotNull(state.TraceId); }
public async Task AppendLinkTestWithPojo() { var sdk = GetSdk <StateExample>(); await NewTraceTestWithPojo(); Assert.NotNull(initTraceState); CommentClass data = new CommentClass(); data.comment = "comment"; AppendLinkInput <CommentClass> appLinkInput = new AppendLinkInput <CommentClass>(config.COMMENT_ACTION_KEY, data, initTraceState.TraceId); TraceState <StateExample, CommentClass> state = await sdk.AppendLinkAsync <CommentClass>(appLinkInput); Assert.NotNull(state.TraceId); }
public async Task ImportDataCsvTest() { await NewTraceTestWithPojo(); ImportTaClass data = new ImportTaClass(); // dirty simulate loading from csv string json = "[{ reference: \"reference\", entityName: \"entity\", currency: \"EUR\", amount: 500, endDate: \"2020-06-25\"}," + "{reference: \"reference 2\", entityName: \"entity 2\", currency: \"EUR\", amount: 1300, endDate: \"2020-06-28\"" + "}]"; data.taSummary = JsonHelper.FromJson <Object>(json); data.file = FileWrapper.FromFilePath(GetTaFilePath()); AppendLinkInput <ImportTaClass> appLinkInput = new AppendLinkInput <ImportTaClass>(config.IMPORT_TA_ACTION_KEY, data, initTraceState.TraceId); TraceState <StateExample, ImportTaClass> state = await GetSdk <StateExample>().AppendLinkAsync <ImportTaClass>(appLinkInput); Assert.NotNull(state.TraceId); }
public async Task ImportDataCsvTest() { await NewTraceTest(); IDictionary <string, object> data = new Dictionary <string, object>(); // dirty simulate loading from csv IDictionary <string, object> taSummary = new Dictionary <string, object>(); string json = "[{ reference: \"reference\", entityName: \"entity\", currency: \"EUR\", amount: 500, endDate: \"2020-06-25\"}," + "{reference: \"reference 2\", entityName: \"entity 2\", currency: \"EUR\", amount: 1300, endDate: \"2020-06-28\"" + "}]"; data.Add("taSummary", JsonHelper.FromJson <Object>(json)); data.Add("file", FileWrapper.FromFilePath(GetTaFilePath())); AppendLinkInput <object> appLinkInput = new AppendLinkInput <object>(config.IMPORT_TA_ACTION_KEY, data, someTraceState.TraceId); TraceState <object, object> state = await GetSdk().AppendLinkAsync <object>(appLinkInput); Assert.NotNull(state.TraceId); }
/// <summary> /// The AppendLink /// </summary> /// <typeparam name="TLinkData"></typeparam> /// <param name="input">The input<see cref="AppendLinkInput{TLinkData}"/></param> /// <returns>The <see cref="Task{TraceState{TState, TLinkData}}"/></returns> public async Task <TraceState <TState, TLinkData> > AppendLinkAsync <TLinkData>(AppendLinkInput <TLinkData> input) { // retrieve parent link TransferResponseInput <TLinkData> headLinkInput = new TransferResponseInput <TLinkData>(input.TraceId, null); TraceLink <TLinkData> parentLink = await this.GetHeadLinkAsync <TLinkData>(headLinkInput); //extract info from input string actionKey = input.ActionKey; TLinkData data = input.Data; string groupLabel = input.GroupLabel; SdkConfig sdkConfig = await this.GetConfigAsync(); string workflowId = sdkConfig.WorkflowId; string configId = sdkConfig.ConfigId; string accountId = sdkConfig.AccountId; string groupId = sdkConfig.GetGroupId(groupLabel); // upload files and transform data await this.UploadFilesInLinkData(data); TraceLinkBuilderConfig <TLinkData> cfg = new TraceLinkBuilderConfig <TLinkData>() { // provide workflow id WorkflowId = workflowId, // and workflow config id ConfigId = configId, // and parent link to append to the existing trace ParentLink = parentLink }; // use a TraceLinkBuilder to create the first link // only provide workflowId to initiate a new trace TraceLinkBuilder <TLinkData> linkBuilder = new TraceLinkBuilder <TLinkData>(cfg); // this is an attestation linkBuilder.ForAttestation(actionKey, data) .WithGroup(groupId) .WithCreatedBy(accountId); // call createLink helper return(await this.CreateLinkAsync(linkBuilder)); }
/// <summary> /// The AppendLink /// </summary> /// <typeparam name="TLinkData"></typeparam> /// <param name="input">The input<see cref="AppendLinkInput{TLinkData}"/></param> /// <returns>The <see cref="Task{TraceState{TState, TLinkData}}"/></returns> public async Task <TraceState <TState, TLinkData> > AppendLinkAsync <TLinkData>(AppendLinkInput <TLinkData> input) { // retrieve parent link TransferResponseInput <TLinkData> headLinkInput = new TransferResponseInput <TLinkData>(input.TraceId, null); TraceLink <TLinkData> parentLink = await this.GetHeadLinkAsync <TLinkData>(headLinkInput); //extract info from input string formId = input.FormId; TLinkData data = input.Data; SdkConfig sdkConfig = await this.GetConfigAsync(); string workflowId = sdkConfig.WorkflowId; string userId = sdkConfig.UserId; string ownerId = sdkConfig.OwnerId; string groupId = sdkConfig.GroupId; IDictionary <string, string> actionNames = sdkConfig.ActionNames; // upload files and transform data await this.UploadFilesInLinkData(data); TraceLinkBuilderConfig <TLinkData> cfg = new TraceLinkBuilderConfig <TLinkData>() { // provide workflow id WorkflowId = workflowId, // and parent link to append to the existing trace ParentLink = parentLink }; // use a TraceLinkBuilder to create the first link // only provide workflowId to initiate a new trace TraceLinkBuilder <TLinkData> linkBuilder = new TraceLinkBuilder <TLinkData>(cfg); // this is an attestation linkBuilder.ForAttestation(formId, actionNames.ContainsKey(formId)?actionNames[formId]:null, data) .WithOwner(ownerId) .WithGroup(groupId) .WithCreatedBy(userId); // call createLink helper return(await this.CreateLinkAsync(linkBuilder)); }