Exemplo n.º 1
0
        public async Task RejectTransferTestWithPojo()
        {
            PaginationInfo paginationInfo = new PaginationInfo(10, null, null, null);

            var sdk = GetSdk <StateExample>();

            TracesState <StateExample, DataClass> tracesIn = await sdk.GetIncomingTracesAsync <DataClass>(paginationInfo);

            string traceId = null;

            if (tracesIn.TotalCount == 0)
            {
                await PushTraceTestWithPojo();

                traceId = someTraceState.TraceId;
            }
            else
            {
                someTraceState = tracesIn.Traces[0];
                traceId        = someTraceState.TraceId;
            }
            TransferResponseInput <DataClass>    trInput     = new TransferResponseInput <DataClass>(traceId, null, null);
            TraceState <StateExample, DataClass> stateReject = await GetOtherGroupSdk <StateExample>().RejectTransferAsync <DataClass>(trInput);

            Assert.NotNull(stateReject.TraceId);
        }
Exemplo n.º 2
0
        public async Task GetOutoingTrafesTestWithPojo()
        {
            Sdk <StateExample> sdk            = GetSdk <StateExample>();
            PaginationInfo     paginationInfo = new PaginationInfo(10, null, null, null);
            TracesState <StateExample, HeadLinkData> state = await sdk.GetOutgoingTracesAsync <HeadLinkData>(paginationInfo);

            Console.WriteLine(JsonHelper.ToJson(state));
        }
Exemplo n.º 3
0
        public async Task GetOutgoingTracesTest()
        {
            Sdk <object>   sdk                 = GetSdk();
            PaginationInfo paginationInfo      = new PaginationInfo(10, null, null, null);
            TracesState <object, object> state = await sdk.GetOutgoingTracesAsync <object>(paginationInfo);

            Assert.NotNull(state);
        }
Exemplo n.º 4
0
        public async Task GetAttestationTracesTestWithPojo()
        {
            Sdk <StateExample> sdk            = GetSdk <StateExample>();
            PaginationInfo     paginationInfo = new PaginationInfo(10, null, null, null);
            TracesState <StateExample, HeadLinkData> state = await sdk.GetAttestationTracesAsync <HeadLinkData>(ACTION_KEY, paginationInfo);

            Debug.WriteLine(JsonHelper.ToJson(state));
            Assert.NotNull(state);
        }
Exemplo n.º 5
0
        public async Task searchByMultipletagsTest()
        {
            Sdk <Object> sdk = GetSdk();

            // search the trace by tags
            List <String> tags = new List <string>();

            tags.Add("tag1");
            tags.Add("tag2");
            SearchTracesFilter f = new SearchTracesFilter();

            f.Tags       = tags;
            f.SearchType = SearchTracesFilter.SEARCH_TYPE.TAGS_CONTAINS;
            TracesState <Object, Object> res = await sdk.SearchTracesAsync <Object>(f, new PaginationInfo());

            Assert.Equal(1, res.TotalCount);
            Assert.Equal(config.TRACE_ID, res.Traces[0].TraceId);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Search all the traces of the workflow
        /// </summary>
        /// <typeparam name="SearchTracesFilter"></typeparam>
        /// <param name="filter">the filter to use in the search</param>
        /// <typeparam name="PaginationInfo"></typeparam>
        /// <param name="paginationInfo">the wanted pagination</param>
        /// <returns>The <see cref="Task{TraceState{TState, TLinkData}}"/></returns>
        public async Task <TracesState <TState, TLinkData> > SearchTracesAsync <TLinkData>(SearchTracesFilter filter,
                                                                                           PaginationInfo paginationInfo)
        {
            // create variables
            Dictionary <String, object> variables = new Dictionary <String, object> {
                { "filter", filter.GetFilters() },
                { "workflowId", this.opts.WorkflowId }
            };
            Dictionary <String, object> variablesPaginationInfo = JsonHelper.ObjectToMap(paginationInfo);

            variablesPaginationInfo.ToList().ForEach(x => variables.Add(x.Key, x.Value));

            // execute graphql query
            string query = GraphQL.QUERY_SEARCHTRACES;
            GraphQLResponse <dynamic> jsonResponse = await this.client.GraphqlAsync(query, variables, null, null);

            // get all the traces
            var traceResponse = jsonResponse.Data.workflow.traces;

            List <TraceState <TState, TLinkData> > traces = new List <TraceState <TState, TLinkData> >();
            var nodes = traceResponse.nodes;

            foreach (var node in nodes)
            {
                traces.Add(this.MakeTraceState <TLinkData>((JObject)node));
            }

            var info       = traceResponse.info;
            int totalCount = (int)traceResponse.totalCount;

            // construct the traces list object
            TracesState <TState, TLinkData> tracesList = new TracesState <TState, TLinkData>()
            {
                Traces     = traces,
                TotalCount = totalCount,
                Info       = info.ToObject <Info>()
            };

            return(tracesList);
        }
Exemplo n.º 7
0
        public async Task RejectTransferTest()
        {
            PaginationInfo paginationInfo         = new PaginationInfo(10, null, null, null);
            TracesState <Object, Object> tracesIn = await GetSdk().GetIncomingTracesAsync <Object>(paginationInfo);

            string traceId = null;

            if (tracesIn.TotalCount == 0)
            {
                await PushTraceTest();

                traceId = someTraceState.TraceId;
            }
            else
            {
                someTraceState = tracesIn.Traces[0];
                traceId        = someTraceState.TraceId;
            }
            TransferResponseInput <Object> trInput     = new TransferResponseInput <Object>(traceId, null, null);
            TraceState <Object, Object>    stateReject = await GetOtherGroupSdk().RejectTransferAsync(trInput);

            Assert.NotNull(stateReject.TraceId);
        }
Exemplo n.º 8
0
        public async Task traceTagsRWTest()
        {
            Sdk <object> sdk = GetSdk();

            // Add a tag to a trace
            string traceId            = config.TRACE_ID;
            Guid   uuid               = System.Guid.NewGuid();
            string randomUUIDString   = uuid.ToString();
            AddTagsToTraceInput input = new AddTagsToTraceInput(traceId, new string[] { randomUUIDString, "tag1", "tag2" });

            TraceState <Object, Object> state = await sdk.AddTagsToTraceAsync <Object>(input);

            Assert.Equal(traceId, state.TraceId);

            // search the trace by tags
            List <String> tags = new List <string>();

            tags.Add(randomUUIDString);
            SearchTracesFilter           f   = new SearchTracesFilter(tags);
            TracesState <Object, Object> res = await sdk.SearchTracesAsync <Object>(f, new PaginationInfo());

            Assert.Equal(1, res.TotalCount);
            Assert.Equal(traceId, res.Traces[0].TraceId);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Get the traces in a given stage (INCOMING, OUTGOING, BACKLOG, ATTESTATION)T
        /// When stageType=ATTESTATION, you must also provide the form id to identify the
        /// stage. If no stage correspond to the stageType x actionKey, it will throw. If
        /// more than one stage is found it will also throw.
        ///
        /// @param stageType      the stage type
        /// @param paginationInfo the pagination info
        /// @param actionKey (optional) the action key in case of ATTESTATION
        /// @return the traces in a given stage
        /// @throws Error
        /// @throws Exception
        ////
        /// </summary>
        /// <typeparam name="TLinkData"></typeparam>
        /// <param name="stageType">The stageType<see cref="TraceStageType"/></param>
        /// <param name="paginationInfo">The paginationInfo<see cref="PaginationInfo"/></param>
        /// <param name="actionKey">The action key<see cref="String"/></param>
        /// <returns>The <see cref="Task{TracesState{TState, TLinkData}}"/></returns>
        public async Task <TracesState <TState, TLinkData> > GetTracesInStageAsync <TLinkData>(TraceStageType stageType, PaginationInfo paginationInfo,
                                                                                               String actionKey)
        {
            // actionKey can only be set in ATTESTATION case
            if (stageType == TraceStageType.ATTESTATION && actionKey == null)
            {
                throw new Exception("You must and can only provide actionKey when stageType is ATTESTATION");
            }
            // extract info from config
            SdkConfig sdkConfig = await this.GetConfigAsync();

            String groupId = sdkConfig.GetGroupId();

            // create variables
            Dictionary <String, object> variables = new Dictionary <String, object>
            {
                { "groupId", groupId },
                { "stageType", stageType.ToString() },
            };

            if (actionKey != null)
            {
                variables.Add("actionKey", actionKey);
            }

            Dictionary <String, object> variablesPaginationInfo = JsonHelper.ObjectToMap(paginationInfo);

            variablesPaginationInfo.ToList().ForEach(x => variables.Add(x.Key, x.Value));


            // execute the graphql query
            string query = GraphQL.QUERY_GETTRACESINSTAGE;
            GraphQLResponse <dynamic> jsonResponse = await this.client.GraphqlAsync(query, variables, null, null);

            var jsonData = jsonResponse.Data;


            // extract relevant info from the response
            var stages = jsonData.group.stages.nodes;

            // there must be exactly one stage
            if (stages.Count == 1)
            {
                var stage = stages[0];

                var trace = stage.traces;
                // extract traces response and pagination
                var info       = trace.info;
                int totalCount = trace.totalCount;

                List <TraceState <TState, TLinkData> > traces = new List <TraceState <TState, TLinkData> >();

                // get all the groups that are owned by one of my accounts
                var nodes = trace.nodes;
                foreach (var node in nodes)
                {
                    traces.Add(this.MakeTraceState <TLinkData>((JObject)node));
                }

                TracesState <TState, TLinkData> tracesList = new TracesState <TState, TLinkData>()
                {
                    Traces     = traces,
                    TotalCount = totalCount,
                    Info       = nodes.Count >= 1 ? info.ToObject <Info>() : null
                };
                return(tracesList);
            }

            // comAdde detail for error
            String stageDetail = stageType.ToString() + actionKey ?? "";

            // throw if no stages were found if
            if (stages.size() == 0)
            {
                throw new Exception("No " + stageDetail + " stage");
            }
            // throw if multiple stages were found throw new
            throw new Exception("Multiple " + stageDetail + " stages");
        }
Exemplo n.º 10
0
 public async Task GetAttestationTracesTest()
 {
     Sdk <object>   sdk                 = GetSdk();
     PaginationInfo paginationInfo      = new PaginationInfo(10, null, null, null);
     TracesState <object, object> state = await sdk.GetAttestationTracesAsync <object>(FORM_ID, paginationInfo);
 }