protected static void Because_of()
        {
            entity = CurveData.CreateBasicEntityWithOneMapping();
            mapping = entity.Mappings[0];
            client = new HttpClient(ServiceUrl["Curve"] + string.Format("{0}/mapping/{1}", entity.Id, mapping.Id));

            response = client.Get();
            mappingResponse = response.Content.ReadAsDataContract<Contracts.MappingResponse>();
        }
Ejemplo n.º 2
0
        protected static void Because_of()
        {
            entity  = CounterpartyData.CreateBasicEntityWithOneMapping();
            mapping = entity.Mappings[0];
            client  = new HttpClient(ServiceUrl["Counterparty"] + string.Format("{0}/mapping/{1}", entity.Id, mapping.Id));

            response        = client.Get();
            mappingResponse = response.Content.ReadAsDataContract <EnergyTrading.Mdm.Contracts.MappingResponse>();
        }
Ejemplo n.º 3
0
        protected static void Because_of()
        {
            entity = PartyRoleData.CreateEntityWithTwoDetailsAndTwoMappings();

            client = new HttpClient(ServiceUrl["PartyRole"] +
                                    "crossmap?source-system=trayport&destination-system=endur&mapping-string=" + entity.Mappings[0].MappingValue
                                    + "&as-of=" + entity.Mappings[0].Validity.Start.ToString(DateFormatString));

            response        = client.Get();
            mappingResponse = response.Content.ReadAsDataContract <EnergyTrading.Mdm.Contracts.MappingResponse>();
        }
Ejemplo n.º 4
0
        protected static void Because_of()
        {
            entity = CurveData.CreateEntityWithTwoDetailsAndTwoMappings();

            client = new HttpClient(ServiceUrl["Curve"] +
                                    "crossmap?source-system=trayport&destination-system=endur&mapping-string=" + entity.Mappings[0].MappingValue);

            response = client.Get();

            mappingResponse = response.Content.ReadAsDataContract <Contracts.MappingResponse>();
        }
        protected static void Because_of()
        {
            entity = CurveData.CreateEntityWithTwoDetailsAndTwoMappings();

            client = new HttpClient(ServiceUrl["Curve"] +
                "crossmap?source-system=trayport&destination-system=endur&mapping-string=" + entity.Mappings[0].MappingValue
                + "&as-of=" + entity.Mappings[0].Validity.Start.ToString(DateFormatString));

            response = client.Get();
            mappingResponse = response.Content.ReadAsDataContract<Contracts.MappingResponse>();
        }
Ejemplo n.º 6
0
        public void HasMultipleMappingsWithNoDefault_should_return_true()
        {
            var mappingResponse = new MappingResponse()
            {
                Mappings = new MdmIdList()
            };

            mappingResponse.Mappings.Add(new MdmId()
            {
                DefaultReverseInd = false
            });
            mappingResponse.Mappings.Add(new MdmId()
            {
                DefaultReverseInd = false
            });
            Assert.IsTrue(mappingResponse.HasMultipleMappingsWithNoDefault());
        }
Ejemplo n.º 7
0
        public void HasMultipleDefaultMapping_should_return_false()
        {
            var mappingResponse = new MappingResponse()
            {
                Mappings = new MdmIdList()
            };

            mappingResponse.Mappings.Add(new MdmId()
            {
                DefaultReverseInd = true
            });
            mappingResponse.Mappings.Add(new MdmId()
            {
                DefaultReverseInd = false
            });
            Assert.IsFalse(mappingResponse.HasMultipleDefaultMapping());
        }
Ejemplo n.º 8
0
        private ContractResponse <MappingResponse> ConstructResponse(TEntity entity, CrossMappingRequest request)
        {
            if (entity != null)
            {
                var response = new MappingResponse();
                this.AssignIdentifiers(
                    entity,
                    x => response.Mappings.Add(x),
                    x =>
                    string.Equals(x.System.Name, request.TargetSystemName, StringComparison.InvariantCultureIgnoreCase) &&
                    x.Validity.ValidAt(request.ValidAt));

                if (response.HasMultipleDefaultMapping() || response.HasMultipleMappingsWithNoDefault())
                {
                    return(new ContractResponse <MappingResponse>
                    {
                        Error = new ContractError {
                            Type = ErrorType.Ambiguous
                        }, IsValid = false
                    });
                }

                if (response.HasMutlipleMappingsWithOneDefault())
                {
                    response.Mappings = new MdmIdList()
                    {
                        response.Mappings.Where(x => x.DefaultReverseInd.HasValue && x.DefaultReverseInd.Value).
                        First()
                    };
                }

                return(new ContractResponse <MappingResponse>
                {
                    Contract = request.Version == entity.Version ? null : response, Version = entity.Version,
                });
            }

            return(new ContractResponse <MappingResponse>
            {
                Error = new ContractError {
                    Type = ErrorType.NotFound
                }, IsValid = false
            });
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Get a particular mapping
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ContractResponse <MappingResponse> RequestMapping(GetMappingRequest request)
        {
            // Get the entity
            var mapping = this.repository.FindOne <TMapping>(request.MappingId);

            if (mapping == null || request.EntityId != mapping.Entity.Id)
            {
                return(new ContractResponse <MappingResponse>
                {
                    Error = new ContractError
                    {
                        Type = ErrorType.NotFound
                    },
                    IsValid = false
                });
            }
            if (mapping.Entity.Id != request.EntityId)
            {
                return(new ContractResponse <MappingResponse>
                {
                    Error = new ContractError
                    {
                        Type = ErrorType.NotFound
                    },
                    IsValid = false
                });
            }

            var mr = new MappingResponse();

            mr.Mappings.Add(this.MappingEngine.Map <TMapping, MdmId>(mapping));
            var response = new ContractResponse <MappingResponse>
            {
                Contract = mr,
                Version  = mapping.Entity.Version,
                IsValid  = true
            };

            return(response);
        }
 public static bool HasMultipleDefaultMapping(this MappingResponse response)
 {
     return(response.Mappings.Where(x => x.DefaultReverseInd.HasValue && x.DefaultReverseInd.Value).Count() > 1);
 }
 public static bool HasMutlipleMappingsWithOneDefault(this MappingResponse response)
 {
     return(response.Mappings.Where(x => x.DefaultReverseInd.HasValue && x.DefaultReverseInd.Value).Count() == 1 && response.Mappings.Count > 1);
 }