Пример #1
0
        GivenExistingEndpointsWhenFeedDeleteWithoutParametersWhenPerformingQueryThenTheMessageShouldNotBeOkBecauseTheMessageIdsAreMissing()
        {
            var feedDeleteService    = new FeedDeleteService(new HttpMessagingService(HttpClient));
            var feedDeleteParameters = new FeedDeleteParameters
            {
                OnboardResponse = OnboardResponse
            };

            feedDeleteService.Send(feedDeleteParameters);

            Thread.Sleep(TimeSpan.FromSeconds(5));

            var fetchMessageService = new FetchMessageService(HttpClient);
            var fetch = fetchMessageService.Fetch(OnboardResponse);

            Assert.Single(fetch);

            var decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message);

            Assert.Equal(400, decodedMessage.ResponseEnvelope.ResponseCode);

            var messages = DecodeMessageService.Decode(decodedMessage.ResponsePayloadWrapper.Details);

            Assert.NotNull(messages);
            Assert.NotEmpty(messages.Messages_);
            Assert.Single(messages.Messages_);
            Assert.Equal("VAL_000017", messages.Messages_[0].MessageCode);
            Assert.Equal(
                "messageIds information required to process message is missing or malformed.",
                messages.Messages_[0].Message_);
        }
Пример #2
0
        /// <summary>
        ///     The actions for the recipient are the following:
        ///     1. Query the message headers.
        ///     2. Let the AR process the message for some seconds to be sure (this depends on the use case and is just an example
        ///     time limit)
        ///     3. Fetch the response from the AR and check.
        ///     4. Delete the messages using the message IDs to clean the feed.
        ///     5. Let the AR process the message for some seconds to be sure (this depends on the use case and is just an example
        ///     time limit)
        ///     6. Fetch the response from the AR and check.
        /// </summary>
        private static void ActionsForRecipient()
        {
            var queryMessageHeadersService =
                new QueryMessageHeadersService(new HttpMessagingService(HttpClientForRecipient));
            var queryMessageHeadersParameters = new QueryMessagesParameters
            {
                OnboardResponse = Recipient,
                Senders         = new List <string> {
                    Sender.SensorAlternateId
                }
            };

            queryMessageHeadersService.Send(queryMessageHeadersParameters);

            Thread.Sleep(TimeSpan.FromSeconds(2));

            var fetchMessageService = new FetchMessageService(HttpClientForRecipient);
            var fetch = fetchMessageService.Fetch(Recipient);

            Assert.Single(fetch);

            var decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message);

            Assert.Equal(200, decodedMessage.ResponseEnvelope.ResponseCode);
            Assert.Equal(ResponseEnvelope.Types.ResponseBodyType.AckForFeedHeaderList,
                         decodedMessage.ResponseEnvelope.Type);

            var feedMessageHeaderQuery =
                queryMessageHeadersService.Decode(decodedMessage.ResponsePayloadWrapper.Details);

            Assert.True(feedMessageHeaderQuery.QueryMetrics.TotalMessagesInQuery > 0,
                        "There has to be at least one message in the query.");

            var messageIds =
                (from feed in feedMessageHeaderQuery.Feed from feedHeader in feed.Headers select feedHeader.MessageId)
                .ToList();

            var feedDeleteService =
                new FeedDeleteService(new HttpMessagingService(HttpClientForRecipient));
            var feedDeleteParameters = new FeedDeleteParameters
            {
                OnboardResponse = Recipient,
                MessageIds      = messageIds
            };

            feedDeleteService.Send(feedDeleteParameters);

            Thread.Sleep(TimeSpan.FromSeconds(2));

            fetch = fetchMessageService.Fetch(Recipient);
            Assert.Single(fetch);

            decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message);
            Assert.Equal(200, decodedMessage.ResponseEnvelope.ResponseCode);
        }
Пример #3
0
        public void GivenExistingEndpointsWhenFeedDeleteWithUnknownMessageIdsMessageIdsThenTheResultShouldBeOk()
        {
            var feedDeleteService    = new FeedDeleteService(new HttpMessagingService(HttpClient));
            var feedDeleteParameters = new FeedDeleteParameters
            {
                OnboardResponse = OnboardResponse,
                MessageIds      = new List <string> {
                    Guid.NewGuid().ToString()
                }
            };

            feedDeleteService.Send(feedDeleteParameters);

            Thread.Sleep(TimeSpan.FromSeconds(5));

            var fetchMessageService = new FetchMessageService(HttpClient);
            var fetch = fetchMessageService.Fetch(OnboardResponse);

            Assert.Single(fetch);

            var decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message);

            Assert.Equal(200, decodedMessage.ResponseEnvelope.ResponseCode);
            Assert.Equal(ResponseEnvelope.Types.ResponseBodyType.AckWithMessages,
                         decodedMessage.ResponseEnvelope.Type);

            var messages = DecodeMessageService.Decode(decodedMessage.ResponsePayloadWrapper.Details);

            Assert.NotNull(messages);
            Assert.NotEmpty(messages.Messages_);
            Assert.Single(messages.Messages_);
            Assert.Equal("VAL_000205", messages.Messages_[0].MessageCode);
            Assert.Equal(
                "Feed message cannot be found.",
                messages.Messages_[0].Message_);
        }
Пример #4
0
        GivenExistingEndpointsWhenFeedDeleteWithValidityPeriodThenTheResultShouldNotBeOkBecauseTheMessageIdsAreMissing()
        {
            var feedDeleteService    = new FeedDeleteService(new HttpMessagingService(HttpClient));
            var feedDeleteParameters = new FeedDeleteParameters
            {
                OnboardResponse = OnboardResponse,
                ValidityPeriod  = new ValidityPeriod()
            };

            feedDeleteParameters.ValidityPeriod.SentTo = UtcDataService.Timestamp(TimestampOffset.None);
            feedDeleteParameters.ValidityPeriod.SentTo = UtcDataService.Timestamp(TimestampOffset.FourWeeks);
            feedDeleteService.Send(feedDeleteParameters);

            Thread.Sleep(TimeSpan.FromSeconds(5));

            var fetchMessageService = new FetchMessageService(HttpClient);
            var fetch = fetchMessageService.Fetch(OnboardResponse);

            Assert.Single(fetch);

            var decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message);

            Assert.Equal(400, decodedMessage.ResponseEnvelope.ResponseCode);
            Assert.Equal(ResponseEnvelope.Types.ResponseBodyType.AckWithFailure,
                         decodedMessage.ResponseEnvelope.Type);

            var messages = DecodeMessageService.Decode(decodedMessage.ResponsePayloadWrapper.Details);

            Assert.NotNull(messages);
            Assert.NotEmpty(messages.Messages_);
            Assert.Single(messages.Messages_);
            Assert.Equal("VAL_000017", messages.Messages_[0].MessageCode);
            Assert.Equal(
                "messageIds information required to process message is missing or malformed.",
                messages.Messages_[0].Message_);
        }
Пример #5
0
        GivenExistingEndpointsWhenFeedDeleteWithUnknownMessageIdsSenderIdsThenTheResultShouldNotBeOkBecauseTheMessageIdsAreMissing()
        {
            var feedDeleteService    = new FeedDeleteService(new HttpMessagingService(HttpClient));
            var feedDeleteParameters = new FeedDeleteParameters
            {
                OnboardResponse = OnboardResponse,
                Senders         = new List <string> {
                    Guid.NewGuid().ToString()
                }
            };

            feedDeleteService.Send(feedDeleteParameters);

            Thread.Sleep(TimeSpan.FromSeconds(5));

            var fetchMessageService = new FetchMessageService(HttpClient);
            var fetch = fetchMessageService.Fetch(OnboardResponse);

            Assert.Single(fetch);

            var decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message);

            Assert.Equal(400, decodedMessage.ResponseEnvelope.ResponseCode);
            Assert.Equal(ResponseEnvelope.Types.ResponseBodyType.AckWithFailure,
                         decodedMessage.ResponseEnvelope.Type);

            var messages = DecodeMessageService.Decode(decodedMessage.ResponsePayloadWrapper.Details);

            Assert.NotNull(messages);
            Assert.NotEmpty(messages.Messages_);
            Assert.Single(messages.Messages_);
            Assert.Equal("VAL_000017", messages.Messages_[0].MessageCode);
            Assert.Equal(
                "messageIds information required to process message is missing or malformed.",
                messages.Messages_[0].Message_);
        }