Ejemplo n.º 1
0
        private static UserMessage CreateMultihopUserMessage(string receivePModeId, SendingProcessingMode pmode)
        {
            var collaboration =
                new Model.Core.CollaborationInfo(
                    new Model.Core.AgreementReference(
                        value: "http://agreements.europa.org/agreement",
                        pmodeId: receivePModeId),
                    service: new Model.Core.Service(
                        value: "Forward_Push_Service",
                        type: "eu:europa:services"),
                    action: "Forward_Push_Action",
                    conversationId: "eu:europe:conversation");

            IEnumerable <MessageProperty> properties =
                pmode.MessagePackaging?.MessageProperties?.Select(
                    p => new MessageProperty(p.Name, p.Value, p.Type)) ?? new MessageProperty[0];

            Party p1 = pmode.MessagePackaging?.PartyInfo.FromParty;
            Party p2 = pmode.MessagePackaging?.PartyInfo.ToParty;

            return(new UserMessage(
                       $"multihop-message-id-{Guid.NewGuid()}",
                       collaboration,
                       SendingPModeMap.ResolveSender(p1),
                       SendingPModeMap.ResolveSender(p2),
                       new Model.Core.PartInfo[0],
                       properties));
        }
        public Property Then_Sender_Gets_Populated_When_Present(
            NonEmptyString role,
            NonEmptyString partyId)
        {
            return(Prop.ForAll(
                       ArbParty(role, partyId),
                       p =>
            {
                var actual = SendingPModeMap.ResolveSender(p);

                bool isDefault = actual.Equals(CoreParty.DefaultFrom);
                bool isResolved = actual.Role == role.Get && actual.PrimaryPartyId == partyId.Get;

                return (isDefault == (p == null)).And(isResolved == (p != null));
            }));
        }
Ejemplo n.º 3
0
        private static Party ResolveSenderParty(SubmitMessage submit, SendingProcessingMode sendingPMode)
        {
            var pmodeParty  = sendingPMode?.MessagePackaging?.PartyInfo?.FromParty;
            var submitParty = submit?.PartyInfo?.FromParty;

            if (sendingPMode?.AllowOverride == false &&
                submitParty != null &&
                pmodeParty != null &&
                !submitParty.Equals(pmodeParty))
            {
                throw new NotSupportedException(
                          $"SubmitMessage is not allowed by SendingPMode {sendingPMode.Id} to override Sender Party");
            }

            if (submitParty != null)
            {
                var ids = submitParty.PartyIds ?? Enumerable.Empty <Model.Common.PartyId>();
                return(new Party(submitParty.Role, ids.Select(x => new PartyId(x.Id, x.Type)).ToArray()));
            }

            return(SendingPModeMap.ResolveSender(pmodeParty));
        }