public void GivenSingleSubscriptionEntryWhenSendingSubscriptionMessageThenTheMessageShouldBeAccepted() { var subscriptionService = new SubscriptionService(new HttpMessagingService(HttpClient)); var subscriptionParameters = new SubscriptionParameters { OnboardResponse = OnboardResponse, TechnicalMessageTypes = new List <Subscription.Types.MessageTypeSubscriptionItem>() }; var technicalMessageType = new Subscription.Types.MessageTypeSubscriptionItem { TechnicalMessageType = TechnicalMessageTypes.ImgPng }; subscriptionParameters.TechnicalMessageTypes.Add(technicalMessageType); subscriptionService.Send(subscriptionParameters); 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(201, decodedMessage.ResponseEnvelope.ResponseCode); Assert.Equal(ResponseEnvelope.Types.ResponseBodyType.Ack, decodedMessage.ResponseEnvelope.Type); }
GivenMultipleSubscriptionEntriesWithOneInvalidTechnicalMessageTypeWhenSendingSubscriptionMessageThenTheMessageShouldBeNotBeAccepted() { var subscriptionService = new SubscriptionService(new HttpMessagingService(HttpClient)); var subscriptionParameters = new SubscriptionParameters { OnboardResponse = OnboardResponse, TechnicalMessageTypes = new List <Subscription.Types.MessageTypeSubscriptionItem>() }; var technicalMessageTypeForTaskdata = new Subscription.Types.MessageTypeSubscriptionItem { TechnicalMessageType = TechnicalMessageTypes.ImgPng }; subscriptionParameters.TechnicalMessageTypes.Add(technicalMessageTypeForTaskdata); var technicalMessageTypeForProtobuf = new Subscription.Types.MessageTypeSubscriptionItem { TechnicalMessageType = TechnicalMessageTypes.Iso11783DeviceDescriptionProtobuf }; subscriptionParameters.TechnicalMessageTypes.Add(technicalMessageTypeForProtobuf); subscriptionService.Send(subscriptionParameters); 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_000006", messages.Messages_[0].MessageCode); Assert.Equal( "Subscription to \"iso:11783:-10:device_description:protobuf\" is not valid per reported capabilities.", messages.Messages_[0].Message_); }
public void GivenValidMessageContentWhenPublishingMessageThenTheMessageShouldBeDelivered() { // Description of the messaging process. // 1. Set all capabilities for each endpoint - this is done once, not each time. // Done once before the test. // 2. Recipient has to create his subscriptions in order to get the messages. If they are not set correctly the AR will return a HTTP 400. var subscriptionService = new SubscriptionService(new HttpMessagingService(HttpClientForRecipient)); var subscriptionParameters = new SubscriptionParameters { OnboardResponse = Recipient, TechnicalMessageTypes = new List <Subscription.Types.MessageTypeSubscriptionItem>() }; var technicalMessageType = new Subscription.Types.MessageTypeSubscriptionItem { TechnicalMessageType = TechnicalMessageTypes.ImgPng }; subscriptionParameters.TechnicalMessageTypes.Add(technicalMessageType); subscriptionService.Send(subscriptionParameters); Thread.Sleep(TimeSpan.FromSeconds(5)); var fetchMessageService = new FetchMessageService(HttpClientForRecipient); var fetch = fetchMessageService.Fetch(Recipient); Assert.Single(fetch); var decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message); Assert.Equal(201, decodedMessage.ResponseEnvelope.ResponseCode); // 3. Set routes within the UI - this is done once, not each time. // Done manually, not API interaction necessary. // 4. Publish message from sender to recipient. var publishMessageService = new PublishMessageService(new HttpMessagingService(HttpClientForSender)); var sendMessageParameters = new SendMessageParameters { OnboardResponse = Sender, ApplicationMessageId = MessageIdService.ApplicationMessageId(), TechnicalMessageType = TechnicalMessageTypes.ImgPng, Base64MessageContent = DataProvider.ReadBase64EncodedImage() }; publishMessageService.Send(sendMessageParameters); // 5. Let the AR handle the message - this can take up to multiple seconds before receiving the ACK. Thread.Sleep(TimeSpan.FromSeconds(5)); // 6. Fetch and analyze the ACK from the AR. fetchMessageService = new FetchMessageService(HttpClientForSender); fetch = fetchMessageService.Fetch(Sender); Assert.Single(fetch); decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message); Assert.Equal(201, decodedMessage.ResponseEnvelope.ResponseCode); }
public void GivenMultipleValidMessageContentWhenPublishingMessagesThenTheMessageShouldBeDelivered() { var subscriptionService = new SubscriptionService(new HttpMessagingService(HttpClientForRecipient)); var subscriptionParameters = new SubscriptionParameters { OnboardResponse = Recipient, TechnicalMessageTypes = new List <Subscription.Types.MessageTypeSubscriptionItem>() }; var technicalMessageType = new Subscription.Types.MessageTypeSubscriptionItem { TechnicalMessageType = TechnicalMessageTypes.ImgPng }; subscriptionParameters.TechnicalMessageTypes.Add(technicalMessageType); subscriptionService.Send(subscriptionParameters); Thread.Sleep(TimeSpan.FromSeconds(5)); var fetchMessageService = new FetchMessageService(HttpClientForRecipient); var fetch = fetchMessageService.Fetch(Recipient); Assert.Single(fetch); var decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message); Assert.Equal(201, decodedMessage.ResponseEnvelope.ResponseCode); var publishMultipleMessagesService = new PublishMultipleMessagesService(new HttpMessagingService(HttpClientForSender)); var sendMessageParameters = new SendMultipleMessagesParameters { OnboardResponse = Sender, ApplicationMessageId = MessageIdService.ApplicationMessageId(), MultipleMessageEntries = new List <MultipleMessageEntry> { new MultipleMessageEntry { ApplicationMessageId = MessageIdService.ApplicationMessageId(), TechnicalMessageType = TechnicalMessageTypes.ImgPng, Base64MessageContent = DataProvider.ReadBase64EncodedImage() }, new MultipleMessageEntry { ApplicationMessageId = MessageIdService.ApplicationMessageId(), TechnicalMessageType = TechnicalMessageTypes.ImgPng, Base64MessageContent = DataProvider.ReadBase64EncodedImage() } } }; publishMultipleMessagesService.Send(sendMessageParameters); Thread.Sleep(TimeSpan.FromSeconds(5)); fetchMessageService = new FetchMessageService(HttpClientForSender); fetch = fetchMessageService.Fetch(Sender); Assert.Equal(2, fetch.Count); Assert.Equal(201, DecodeMessageService.Decode(fetch[0].Command.Message).ResponseEnvelope.ResponseCode); Assert.Equal(201, DecodeMessageService.Decode(fetch[1].Command.Message).ResponseEnvelope.ResponseCode); }