public async Task ResetPolicy() { using (MockContext.Start(this.GetType())) { HttpMockServer.Initialize(this.GetType(), "ResetPolicy"); IPersonalizerClient client = GetClient(HttpMockServer.CreateInstance()); PolicyContract policy = await client.Policy.ResetAsync(); Assert.Equal("--cb_explore_adf --quadratic GT --quadratic MR --quadratic GR --quadratic ME --quadratic OT --quadratic OE --quadratic OR --quadratic MS --quadratic GX --ignore A --cb_type ips --epsilon 0.2", policy.Arguments); } }
public async Task UpdatePolicy() { using (MockContext.Start(this.GetType())) { HttpMockServer.Initialize(this.GetType(), "UpdatePolicy"); IPersonalizerClient client = GetClient(HttpMockServer.CreateInstance()); var policy = new PolicyContract { Name = "app1", Arguments = "--cb_explore_adf --quadratic GT --quadratic MR --quadratic GR --quadratic ME --quadratic OT --quadratic OE --quadratic OR --quadratic MS --quadratic GX --ignore A --cb_type ips --epsilon 0.2" }; var updatedPolicy = await client.Policy.UpdateAsync(policy); Assert.NotNull(updatedPolicy); Assert.Equal(policy.Arguments, updatedPolicy.Arguments); } }
public async Task <IActionResult> AddWildcart([FromBody] PolicyContract contract) { try { if (!Regex.IsMatch(contract.Wildcart, @"^\w+|\*:\w+|\*$")) { return(Ok(_response.SetStatus(true, "OK. Invalid wildcard format"))); } bool registerResult = await _manager.Postgres.RegisterPolicy(contract.Info, contract.Wildcart); return(Ok(_response.SetStatus(true, $"OK. {(registerResult ? "Successfully registered" : "Already exists")}"))); } catch (Exception e) { return(BadRequest(_response.SetStatus(false, $"NOK. {e.Message}"))); } }
public void QuoteValuesMatchSubscribePolicy_False() { // Assign var quote = new Quote(); var submission = new globalVM::Validus.Models.Submission(); var policyContract = new PolicyContract { InsdNm = "Insured Name...", BkrSeqId = 1, NonLonBkr = "AON", Uwr = "UC", Brokerage = 3, AccYr = "1976", ExpyDt = "19761229", IncpDt = "19761229", SettDueDt = "19761229" }; // Act var actualResult = SubmissionModuleHelpers.QuoteValuesMatchSubscribePolicy(policyContract, quote, submission); // Assert Assert.IsFalse(actualResult); }
public static bool SynchroniseSubmission(Submission submission, PolicyContract polAsSubscribe) { return(true); }
/// <summary> /// Creates or updates the global policy configuration of the Api Management /// service. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='serviceName'> /// The name of the API Management service. /// </param> /// <param name='parameters'> /// The policy contents to apply. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <PolicyContract> CreateOrUpdateAsync(this IPolicyOperations operations, string resourceGroupName, string serviceName, PolicyContract parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serviceName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public void SynchroniseQuote_Success() { // Assign var quote = new Quote(); var policyContract = new PolicyContract { AccYr = "1976", ExpyDt = "19761229", IncpDt = "19761229", SettDueDt = "19761229" }; // Act SubmissionModuleHelpers.SynchroniseQuote(quote, policyContract); // Assert Assert.AreEqual(quote.AccountYear.ToString(), policyContract.AccYr); }
public static bool SynchroniseSubmission(Submission submission, PolicyContract polAsSubscribe) { submission.InsuredName = polAsSubscribe.InsdNm; submission.BrokerSequenceId = polAsSubscribe.BkrSeqId; submission.NonLondonBrokerCode = polAsSubscribe.NonLonBkr; submission.UnderwriterCode = polAsSubscribe.Uwr; submission.Brokerage = polAsSubscribe.Brokerage; submission.LeaderNo = polAsSubscribe.LdrNo; submission.Leader = polAsSubscribe.Ldr; if (polAsSubscribe.AddlInsuredCollection != null) { submission.AdditionalInsuredList = new List<AdditionalInsured> ( polAsSubscribe.AddlInsuredCollection .Where(i => i.AddlInsdTy != "Insured") .Select(i => new AdditionalInsured { InsuredId = i.AddlInsdId, InsuredName = i.AddlInsdNm, InsuredType = i.AddlInsdTy }) ); } // TODO: values missing from service response... //s.Domicile = polAsSubscribe. //s.BrokerContact = polAsSubscribe. //s.Description = polAsSubscribe. return true; }
public static UpdatePolicyResponse UpdateSubscribeRecord(Quote q, Submission s, ILogHandler logHandler, IPolicyService subsribeService) { var insuredList = new InsuredCollection(); if (s.AdditionalInsuredList != null) { insuredList.AddRange(s.AdditionalInsuredList .Select(insured => new Insured { AddlInsdId = insured.InsuredId, AddlInsdNm = insured.InsuredId == 0 ? insured.InsuredName : null, AddlInsdTy = insured.InsuredType })); } var policyContract = new PolicyContract { AccYr = q.AccountYear.ToString(), BenchPrm = q.BenchmarkPremium, BindSt = q.TechnicalPricingBindStatus, BkrNo = "???", // TODO - not referenced in CreateQuote sp BkrPsu = s.BrokerPseudonym, // No validation carried out in service validation sp BkrSeqId = s.BrokerSequenceId, Brokerage = s.Brokerage, COB = q.COBId, DeclineReason = q.DeclinatureReason, DOM = s.Domicile, EntSt = q.EntryStatus, ExpyDt = (q.ExpiryDate.HasValue) ? q.ExpiryDate.Value.ToString("yyyyMMdd") : null, ExsAmt = q.ExcessAmount, FacyPolId = q.FacilityRef, LdrNo = s.LeaderNo, Ldr = s.Leader, IncpDt = (q.InceptionDate.HasValue) ? q.InceptionDate.Value.ToString("yyyyMMdd") : null, InsdId = s.InsuredId, InsdNm = s.InsuredName, AddlInsuredCollection = insuredList, LmtAmt = q.LimitAmount, LmtCcy = q.LimitCCY, MOA = q.MOA, OrigOff = q.OriginatingOfficeId, PolTy = q.PolicyType, PricingCcy = q.Currency, RenPolId = q.RenPolId, Status = q.SubmissionStatus, TechPrm = q.TechnicalPremium, UnitPsu = "AGY", Uwr = s.UnderwriterCode, ExsCcy = q.ExcessCCY, Method = q.TechnicalPricingMethod, NonLonBkr = s.NonLondonBrokerCode, PctgAmt = q.TechnicalPricingPremiumPctgAmt, SettDueDt = q.QuoteExpiryDate.ToString("yyyyMMdd"), TechPmTy = "TechPm", // TODO - not referenced in CreateQuote sp PolDsc = q.Description, // These are the fields required for edit only TimeStamp = q.SubscribeTimestamp, PolId = q.SubscribeReference, CtcNm = (string.IsNullOrEmpty(s.BrokerContact)) ? s.NewBrokerContactName : s.BrokerContact, CtcTelNo = s.NewBrokerContactPhoneNumber, CtcEmail = s.NewBrokerContactEmail }; if (q.RenewalRate.HasValue) policyContract.RenewalRate = q.RenewalRate; if (q.RenewalConditions.HasValue) policyContract.RenewalConditions = q.RenewalConditions; if (q.RenewalDeductibles.HasValue) policyContract.RenewalDeductibles = q.RenewalDeductibles; if (q.RenewalExposure.HasValue) policyContract.RenewalExposurePctg = q.RenewalExposure; if (q.RenewalBase.HasValue) policyContract.RenewalBase = q.RenewalBase; if (q.RenewalFull.HasValue) policyContract.RenewalFull = q.RenewalFull; var updateResp = subsribeService.UpdatePolicy(new UpdatePolicyRequest { objPolicyContract = policyContract }); if (updateResp.UpdatePolicyResult.ErrorInfo == null) { var doc = new XmlDocument(); doc.LoadXml(updateResp.UpdatePolicyResult.OutputXml); q.SubscribeTimestamp = long.Parse(doc.GetElementsByTagName("TimeStamp")[0].InnerText); q.FacilityRef = string.IsNullOrEmpty(doc.GetElementsByTagName("NewFacyPolId")[0].InnerText) ? q.FacilityRef : doc.GetElementsByTagName("NewFacyPolId")[0].InnerText; } else { logHandler.WriteLog(updateResp.UpdatePolicyResult.ErrorInfo.ErrorXML, LogSeverity.Error, LogCategory.BusinessComponent); throw new ApplicationException( string.IsNullOrEmpty(updateResp.UpdatePolicyResult.ErrorInfo.Description) ? ParseDetailedError(updateResp.UpdatePolicyResult.ErrorInfo.DetailedDescription) : updateResp.UpdatePolicyResult.ErrorInfo.Description); } return updateResp; }
public void CreateQuote_Fail() { // Assign IPolicyService subscribeService = new PolicyServiceClient(); var policyContract = new PolicyContract { UnitPsu = "", PolTy = "", EntSt = "", InsdNm = "", InsdId = 0, PolDsc = "", Uwr = "", DOM = "", BkrSeqId = 0, CtcNm = "", IncpDt = "", ExpyDt = "", AccYr = "", SettDueDt = "", Brokerage = 0, DeclineReason = "", COB = "", MOA = "", NonLonBkr = "", OrigOff = "", FacyPolId = "", RenPolId = "", PolId = "", LmtCcy = "", LmtAmt = null, ExsCcy = "", ExsAmt = null, BindSt = "", PctgAmt = "", PricingCcy = "", Method = "", TechPrm = null, BenchPrm = null, Status = "", TimeStamp = null, BkrPsu = "", BkrNo = "", TechPmTy = "" }; var request = new CreateQuoteRequest { objPolicyContract = policyContract }; // Act var actualResponse = subscribeService.CreateQuote(request); // Assert Assert.IsNotNull(actualResponse.CreateQuoteResult.ErrorInfo); }
/// <summary> /// Creates or updates policy configuration for the API Operation level. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='serviceName'> /// The name of the API Management service. /// </param> /// <param name='apiId'> /// API revision identifier. Must be unique in the current API Management /// service instance. Non-current revision has ;rev=n as a suffix where n is /// the revision number. /// </param> /// <param name='operationId'> /// Operation identifier within an API. Must be unique in the current API /// Management service instance. /// </param> /// <param name='parameters'> /// The policy contents to apply. /// </param> /// <param name='ifMatch'> /// ETag of the Entity. Not required when creating an entity, but required when /// updating an entity. /// </param> public static PolicyContract CreateOrUpdate(this IApiOperationPolicyOperations operations, string resourceGroupName, string serviceName, string apiId, string operationId, PolicyContract parameters, string ifMatch = default(string)) { return(operations.CreateOrUpdateAsync(resourceGroupName, serviceName, apiId, operationId, parameters, ifMatch).GetAwaiter().GetResult()); }
public static void SynchroniseQuote(Quote q, PolicyContract polAsSubscribe) { // Fields used to determine if submission quote is the same as subscribe policy q.AccountYear = int.Parse(polAsSubscribe.AccYr); q.TechnicalPricingBindStatus = polAsSubscribe.BindSt; q.BrokerPseudonym = polAsSubscribe.BkrPsu; q.BrokerSequenceId = polAsSubscribe.BkrSeqId; q.COBId = polAsSubscribe.COB; q.BrokerContact = polAsSubscribe.CtcNm; q.DeclinatureReason = polAsSubscribe.DeclineReason; q.Domicile = polAsSubscribe.DOM; q.EntryStatus = polAsSubscribe.EntSt; q.ExcessCCY = polAsSubscribe.ExsCcy; q.FacilityRef = polAsSubscribe.FacyPolId; q.InsuredId = polAsSubscribe.InsdId; q.InsuredName = polAsSubscribe.InsdNm; q.LimitCCY = polAsSubscribe.LmtCcy; q.TechnicalPricingMethod = polAsSubscribe.Method; q.MOA = polAsSubscribe.MOA; q.FSAClass = polAsSubscribe.FSA_Class; q.AggsRequired = polAsSubscribe.AggsReqd; q.WordingRequired = polAsSubscribe.WordReqd; q.NonLondonBrokerCode = polAsSubscribe.NonLonBkr; q.OriginatingOfficeId = polAsSubscribe.OrigOff; q.TechnicalPricingPremiumPctgAmt = polAsSubscribe.PctgAmt; q.SubscribeReference = polAsSubscribe.PolId; q.PolicyType = polAsSubscribe.PolTy; q.Currency = polAsSubscribe.PricingCcy; // BUG: "???" problem in quotesheet q.RenPolId = polAsSubscribe.RenPolId; q.SubmissionStatus = polAsSubscribe.Status; q.UnderwriterCode = polAsSubscribe.Uwr; q.LeaderNo = polAsSubscribe.LdrNo; q.Leader = polAsSubscribe.Ldr; q.BenchmarkPremium = polAsSubscribe.BenchPrm.HasValue ? polAsSubscribe.BenchPrm.Value : 0; q.TechnicalPremium = polAsSubscribe.TechPrm.HasValue ? polAsSubscribe.TechPrm.Value : 0; q.Brokerage = polAsSubscribe.Brokerage; q.ExpiryDate = polAsSubscribe.ExpyDt != null ? (DateTime?)DateTime.ParseExact(polAsSubscribe.ExpyDt, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None) : null; q.InceptionDate = polAsSubscribe.IncpDt != null ? (DateTime?)DateTime.ParseExact(polAsSubscribe.IncpDt, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None) : null; q.ExcessAmount = polAsSubscribe.ExsAmt.HasValue ? polAsSubscribe.ExsAmt.Value : 0; q.LimitAmount = polAsSubscribe.LmtAmt.HasValue ? polAsSubscribe.LmtAmt.Value : 0; // end of fields used to compare submission quote vs subscribe policy if (q.AdditionalInsuredList != null) { //Remove the one deleted in subscribe var removeListAdditionalInsureds = q.AdditionalInsuredList.Where( additionalInsured => polAsSubscribe.AddlInsuredCollection.Where(i => i.AddlInsdTy != "Insured") .All(psai => psai.AddlInsdId != additionalInsured.InsuredId)).ToList(); foreach (var additionalInsured in removeListAdditionalInsureds) { q.AdditionalInsuredList.Remove(additionalInsured); } //sync old ones foreach (var additionalInsured in q.AdditionalInsuredList) { if (polAsSubscribe.AddlInsuredCollection.Where(i => i.AddlInsdTy != "Insured") .All(psai => psai.AddlInsdId == additionalInsured.InsuredId)) { var polsubsAdditionalInsured = polAsSubscribe.AddlInsuredCollection.Single( i => i.AddlInsdTy != "Insured" && i.AddlInsdId == additionalInsured.InsuredId); additionalInsured.InsuredName = polsubsAdditionalInsured.AddlInsdNm; additionalInsured.InsuredType = polsubsAdditionalInsured.AddlInsdTy; } } //Add new ones foreach ( var polAssubsAdditionalInsured in polAsSubscribe.AddlInsuredCollection.Where(i => i.AddlInsdTy != "Insured") .Where( polsubsAdditionalInsured => q.AdditionalInsuredList.All( ai => ai.InsuredId != polsubsAdditionalInsured.AddlInsdId))) { q.AdditionalInsuredList.Add(new AdditionalInsured { InsuredId = polAssubsAdditionalInsured.AddlInsdId, InsuredName = polAssubsAdditionalInsured.AddlInsdNm, InsuredType = polAssubsAdditionalInsured.AddlInsdTy }); } } // Note: Bug 1631 - do not sync back the SDD... //q.QuoteExpiryDate = DateTime.ParseExact(polAsSubscribe.SettDueDt, "yyyyMMdd", // CultureInfo.InvariantCulture, // DateTimeStyles.None); q.SubscribeTimestamp = polAsSubscribe.TimeStamp.HasValue ? polAsSubscribe.TimeStamp.Value : 0; q.TechnicalPricingMethod = polAsSubscribe.Method; q.Description = polAsSubscribe.PolDsc; q.RenewalRate = polAsSubscribe.RenewalRate; q.RenewalConditions = polAsSubscribe.RenewalConditions; q.RenewalDeductibles = polAsSubscribe.RenewalDeductibles; q.RenewalExposure = polAsSubscribe.RenewalExposurePctg; q.RenewalBase = polAsSubscribe.RenewalBase; q.RenewalFull = polAsSubscribe.RenewalFull; }
public void CreateQuote_ExpectedException() { // Assign long actualTimeStamp = 0; IPolicyService subscribeService = new PolicyServiceClient(); var policyContract = new PolicyContract(); var request = new CreateQuoteRequest { objPolicyContract = policyContract }; // Act var actualResponse = subscribeService.CreateQuote(request); // Assert Assert.IsNotNull(actualResponse.CreateQuoteResult.ErrorInfo); }
public static bool SynchroniseSubmission(Submission submission, PolicyContract polAsSubscribe) { return true; }
public static bool QuoteValuesMatchSubscribePolicy(PolicyContract polAsSubscribe, Quote q, Submission s) { // Is this most efficient, or are separate if statements better? // For debugging this has been split out, it is hard to debug if all one line of && evaluations var retVal = true; if (polAsSubscribe.AccYr != q.AccountYear.ToString()) retVal = false; else if (polAsSubscribe.BindSt != q.TechnicalPricingBindStatus) retVal = false; else if (polAsSubscribe.BkrPsu != q.BrokerPseudonym) retVal = false; else if (polAsSubscribe.BkrSeqId != q.BrokerSequenceId) retVal = false; else if (polAsSubscribe.COB != q.COBId) retVal = false; else if (polAsSubscribe.CtcNm != q.BrokerContact) retVal = false; else if (polAsSubscribe.DeclineReason != q.DeclinatureReason) retVal = false; else if (polAsSubscribe.DOM != q.Domicile) retVal = false; else if (polAsSubscribe.EntSt != q.EntryStatus) retVal = false; else if (polAsSubscribe.ExsCcy != q.ExcessCCY) retVal = false; else if (polAsSubscribe.FacyPolId != q.FacilityRef) retVal = false; else if (polAsSubscribe.InsdId != q.InsuredId) retVal = false; else if (polAsSubscribe.InsdNm != q.InsuredName) retVal = false; else if (polAsSubscribe.LmtCcy != q.LimitCCY) retVal = false; else if (polAsSubscribe.Method != q.TechnicalPricingMethod) retVal = false; else if (polAsSubscribe.MOA != q.MOA) retVal = false; else if (polAsSubscribe.FSA_Class != q.FSAClass) retVal = false; else if (polAsSubscribe.AggsReqd != q.AggsRequired) retVal = false; else if (polAsSubscribe.WordReqd != q.WordingRequired) retVal = false; else if (polAsSubscribe.NonLonBkr != q.NonLondonBrokerCode) retVal = false; else if (polAsSubscribe.OrigOff != q.OriginatingOfficeId) retVal = false; else if (polAsSubscribe.PctgAmt != q.TechnicalPricingPremiumPctgAmt) retVal = false; else if (polAsSubscribe.PolId != q.SubscribeReference) retVal = false; else if (polAsSubscribe.PolTy != q.PolicyType) retVal = false; else if (polAsSubscribe.PricingCcy != q.Currency) retVal = false; else if (polAsSubscribe.RenPolId != q.RenPolId) retVal = false; else if (polAsSubscribe.Status != q.SubmissionStatus) retVal = false; else if (polAsSubscribe.Uwr != q.UnderwriterCode) retVal = false; else if ((polAsSubscribe.BenchPrm.HasValue) && (polAsSubscribe.BenchPrm.Value != q.BenchmarkPremium)) retVal = false; else if ((!polAsSubscribe.BenchPrm.HasValue) && (q.BenchmarkPremium != 0)) retVal = false; else if ((polAsSubscribe.TechPrm.HasValue) && (polAsSubscribe.TechPrm.Value != q.TechnicalPremium)) retVal = false; else if ((!polAsSubscribe.TechPrm.HasValue) && (q.TechnicalPremium != 0)) retVal = false; else if ((polAsSubscribe.Brokerage.HasValue) && (polAsSubscribe.Brokerage.Value != q.Brokerage)) retVal = false; else if ((!polAsSubscribe.Brokerage.HasValue) && (q.Brokerage.HasValue) && (q.Brokerage != 0)) retVal = false; else if ((q.ExpiryDate.HasValue) && (polAsSubscribe.ExpyDt != q.ExpiryDate.Value.ToString("yyyyMMdd"))) retVal = false; else if ((!q.ExpiryDate.HasValue) && (!string.IsNullOrEmpty(polAsSubscribe.ExpyDt))) retVal = false; else if ((q.InceptionDate.HasValue) && (polAsSubscribe.IncpDt != q.InceptionDate.Value.ToString("yyyyMMdd"))) retVal = false; else if ((!q.InceptionDate.HasValue) && (!string.IsNullOrEmpty(polAsSubscribe.IncpDt))) retVal = false; else if (q.QuoteExpiryDate.HasValue && polAsSubscribe.SettDueDt != SetSettlementDueDate(q.QuoteExpiryDate.Value, s.ExpiryDateOffset, q.InceptionDate)) retVal = false; else if ((polAsSubscribe.ExsAmt.HasValue) && (polAsSubscribe.ExsAmt.Value != q.ExcessAmount)) retVal = false; else if ((!polAsSubscribe.ExsAmt.HasValue) && (q.ExcessAmount != 0)) retVal = false; else if ((polAsSubscribe.LmtAmt.HasValue) && (polAsSubscribe.LmtAmt.Value != q.LimitAmount)) retVal = false; else if ((!polAsSubscribe.LmtAmt.HasValue) && (q.LimitAmount != 0)) retVal = false; return retVal; }
public static CreateQuoteResponse CreateSubscribeRecord(Quote q, Submission s, ILogHandler logHandler, IPolicyService subsribeService) { var insuredList = new InsuredCollection(); if (q.AdditionalInsuredList != null) { insuredList.AddRange(q.AdditionalInsuredList .Select(insured => new Insured { AddlInsdId = insured.InsuredId, AddlInsdNm = insured.InsuredId == 0 ? insured.InsuredName : null, AddlInsdTy = insured.InsuredType })); } var policyContract = new PolicyContract { AccYr = q.AccountYear.ToString(), BenchPrm = q.BenchmarkPremium, BindSt = q.TechnicalPricingBindStatus, BkrNo = "???", // TODO - not referenced in CreateQuote sp BkrPsu = q.BrokerPseudonym, // No validation carried out in service validation sp BkrSeqId = q.BrokerSequenceId, Brokerage = q.Brokerage, COB = q.COBId, DeclineReason = q.DeclinatureReason, DOM = q.Domicile, EntSt = q.EntryStatus, ExpyDt = (q.ExpiryDate.HasValue) ? q.ExpiryDate.Value.ToString("yyyyMMdd") : null, ExsAmt = q.ExcessAmount, FacyPolId = (String.IsNullOrEmpty(q.RenPolId) ? q.FacilityRef : String.Empty), LdrNo = q.LeaderNo, Ldr = q.Leader, IncpDt = (q.InceptionDate.HasValue) ? q.InceptionDate.Value.ToString("yyyyMMdd") : null, InsdId = q.InsuredId, InsdNm = q.InsuredName, AddlInsuredCollection = insuredList, LmtAmt = q.LimitAmount, LmtCcy = q.LimitCCY, MOA = q.MOA, OrigOff = q.OriginatingOfficeId, PolTy = q.PolicyType, PricingCcy = q.Currency, RenPolId = q.RenPolId, Status = q.SubmissionStatus, TechPrm = q.TechnicalPremium, UnitPsu = "AGY", Uwr = q.UnderwriterCode, ExsCcy = q.ExcessCCY, Method = q.TechnicalPricingMethod, NonLonBkr = q.NonLondonBrokerCode, PctgAmt = q.TechnicalPricingPremiumPctgAmt, TechPmTy = "TechPm", // TODO - not referenced in CreateQuote sp PolDsc = q.Description, // These are the fields required for edit only TimeStamp = q.SubscribeTimestamp, PolId = q.SubscribeReference, // PolAnlyCd // TODO: Update this win value from form. WordReqd = (string.IsNullOrEmpty(q.WordingRequired)) ? "" : q.WordingRequired, AggsReqd = (string.IsNullOrEmpty(q.AggsRequired)) ? "" : q.AggsRequired, FSA_Class = (string.IsNullOrEmpty(q.FSAClass)) ? "" : q.FSAClass, CtcNm = q.BrokerContact, //CtcTelNo = q.BrokerContactPhone, //CtcEmail = q.BrokerContactEmail }; if (q.QuoteExpiryDate != null) policyContract.SettDueDt = SetSettlementDueDate(q.QuoteExpiryDate.Value, s.ExpiryDateOffset, q.InceptionDate); if (!string.IsNullOrEmpty(q.BrokerContactPhone)) policyContract.CtcTelNo = q.BrokerContactPhone; if (!string.IsNullOrEmpty(q.BrokerContactEmail)) policyContract.CtcEmail = q.BrokerContactEmail; if (q.RenewalRate.HasValue) policyContract.RenewalRate = q.RenewalRate; if (q.RenewalConditions.HasValue) policyContract.RenewalConditions = q.RenewalConditions; if (q.RenewalDeductibles.HasValue) policyContract.RenewalDeductibles = q.RenewalDeductibles; if (q.RenewalExposure.HasValue) policyContract.RenewalExposurePctg = q.RenewalExposure; if (q.RenewalBase.HasValue) policyContract.RenewalBase = q.RenewalBase; if (q.RenewalFull.HasValue) policyContract.RenewalFull = q.RenewalFull; var createQuoteResponse = subsribeService.CreateQuote(new CreateQuoteRequest { objPolicyContract = policyContract }); if (createQuoteResponse.CreateQuoteResult.ErrorInfo == null) { q.SubscribeReference = createQuoteResponse.objInfoCollection.PolId; var doc = new XmlDocument(); doc.LoadXml(createQuoteResponse.CreateQuoteResult.OutputXml); var subscribeTimestamp = default(long); q.SubscribeTimestamp = long.TryParse(doc.GetElementsByTagName("TimeStamp")[0].InnerText, out subscribeTimestamp) ? subscribeTimestamp : 0; SyncQuoteCreateAndUpdate(s, q, subsribeService); } else { logHandler.WriteLog(createQuoteResponse.CreateQuoteResult.ErrorInfo.ErrorXML, LogSeverity.Error, LogCategory.BusinessComponent); throw new ApplicationException( string.IsNullOrEmpty(createQuoteResponse.CreateQuoteResult.ErrorInfo.Description) ? ParseDetailedError(createQuoteResponse.CreateQuoteResult.ErrorInfo.DetailedDescription) : createQuoteResponse.CreateQuoteResult.ErrorInfo.Description); } return createQuoteResponse; }
public static void SynchroniseQuote(Quote q, PolicyContract polAsSubscribe) { // Fields used to determine if submission quote is the same as subscribe policy q.AccountYear = int.Parse(polAsSubscribe.AccYr); q.TechnicalPricingBindStatus = polAsSubscribe.BindSt; q.BrokerPseudonym = polAsSubscribe.BkrPsu; q.BrokerSequenceId = polAsSubscribe.BkrSeqId; q.COBId = polAsSubscribe.COB; q.BrokerContact = polAsSubscribe.CtcNm; q.DeclinatureReason = polAsSubscribe.DeclineReason; q.Domicile = polAsSubscribe.DOM; q.EntryStatus = polAsSubscribe.EntSt; q.ExcessCCY = polAsSubscribe.ExsCcy; q.FacilityRef = polAsSubscribe.FacyPolId; q.InsuredId = polAsSubscribe.InsdId; q.InsuredName = polAsSubscribe.InsdNm; q.LimitCCY = polAsSubscribe.LmtCcy; q.TechnicalPricingMethod = polAsSubscribe.Method; q.MOA = polAsSubscribe.MOA; q.FSAClass = polAsSubscribe.FSA_Class; q.AggsRequired = polAsSubscribe.AggsReqd; q.WordingRequired = polAsSubscribe.WordReqd; q.NonLondonBrokerCode = polAsSubscribe.NonLonBkr; q.OriginatingOfficeId = polAsSubscribe.OrigOff; q.TechnicalPricingPremiumPctgAmt = polAsSubscribe.PctgAmt; q.SubscribeReference = polAsSubscribe.PolId; q.PolicyType = polAsSubscribe.PolTy; q.Currency = polAsSubscribe.PricingCcy; // BUG: "???" problem in quotesheet q.RenPolId = polAsSubscribe.RenPolId; q.SubmissionStatus = polAsSubscribe.Status; q.UnderwriterCode = polAsSubscribe.Uwr; q.LeaderNo = polAsSubscribe.LdrNo; q.Leader = polAsSubscribe.Ldr; q.BenchmarkPremium = polAsSubscribe.BenchPrm.HasValue ? polAsSubscribe.BenchPrm.Value : 0; q.TechnicalPremium = polAsSubscribe.TechPrm.HasValue ? polAsSubscribe.TechPrm.Value : 0; q.Brokerage = polAsSubscribe.Brokerage; q.ExpiryDate = polAsSubscribe.ExpyDt != null ? (DateTime?)DateTime.ParseExact(polAsSubscribe.ExpyDt, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None) : null; q.InceptionDate = polAsSubscribe.IncpDt != null ? (DateTime?)DateTime.ParseExact(polAsSubscribe.IncpDt, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None) : null; q.ExcessAmount = polAsSubscribe.ExsAmt.HasValue ? polAsSubscribe.ExsAmt.Value : 0; q.LimitAmount = polAsSubscribe.LmtAmt.HasValue ? polAsSubscribe.LmtAmt.Value : 0; // end of fields used to compare submission quote vs subscribe policy if (q.AdditionalInsuredList != null) { //Remove the one deleted in subscribe var removeListAdditionalInsureds = q.AdditionalInsuredList.Where( additionalInsured => polAsSubscribe.AddlInsuredCollection.Where(i => i.AddlInsdTy != "Insured") .All(psai => psai.AddlInsdId != additionalInsured.InsuredId)).ToList(); foreach (var additionalInsured in removeListAdditionalInsureds) { q.AdditionalInsuredList.Remove(additionalInsured); } //sync old ones foreach (var additionalInsured in q.AdditionalInsuredList) { if (polAsSubscribe.AddlInsuredCollection.Where(i => i.AddlInsdTy != "Insured") .All(psai => psai.AddlInsdId == additionalInsured.InsuredId)) { var polsubsAdditionalInsured = polAsSubscribe.AddlInsuredCollection.Single( i => i.AddlInsdTy != "Insured" && i.AddlInsdId == additionalInsured.InsuredId); additionalInsured.InsuredName = polsubsAdditionalInsured.AddlInsdNm; additionalInsured.InsuredType = polsubsAdditionalInsured.AddlInsdTy; } } //Add new ones foreach ( var polAssubsAdditionalInsured in polAsSubscribe.AddlInsuredCollection.Where(i => i.AddlInsdTy != "Insured") .Where( polsubsAdditionalInsured => q.AdditionalInsuredList.All( ai => ai.InsuredId != polsubsAdditionalInsured.AddlInsdId))) { q.AdditionalInsuredList.Add(new AdditionalInsured { InsuredId = polAssubsAdditionalInsured.AddlInsdId, InsuredName = polAssubsAdditionalInsured.AddlInsdNm, InsuredType = polAssubsAdditionalInsured.AddlInsdTy }); } } // Note: Bug 1631 - do not sync back the SDD... //q.QuoteExpiryDate = DateTime.ParseExact(polAsSubscribe.SettDueDt, "yyyyMMdd", // CultureInfo.InvariantCulture, // DateTimeStyles.None); q.SubscribeTimestamp = polAsSubscribe.TimeStamp.HasValue ? polAsSubscribe.TimeStamp.Value : 0; q.TechnicalPricingMethod = polAsSubscribe.Method; q.Description = polAsSubscribe.PolDsc; q.RenewalRate = polAsSubscribe.RenewalRate; q.RenewalConditions = polAsSubscribe.RenewalConditions; q.RenewalDeductibles = polAsSubscribe.RenewalDeductibles; q.RenewalExposure = polAsSubscribe.RenewalExposurePctg; q.RenewalBase = polAsSubscribe.RenewalBase; q.RenewalFull = polAsSubscribe.RenewalFull; }
public void UpdatePolicy_Fail() { // Assign IPolicyService subscribeService = new PolicyServiceClient(); var policyContract = new PolicyContract { UnitPsu = "AGY", PolTy = "NONMARINE", EntSt = "PARTIAL", InsdNm = "- N/A", InsdId = 182396, PolDsc = "Unit Test Submission", Uwr = "AED", DOM = "AD", BkrSeqId = 822, CtcNm = "ALLAN MURRAY", IncpDt = "20130628", ExpyDt = "20140628", AccYr = "2013", SettDueDt = "20130628", Brokerage = 1, DeclineReason = null, COB = "AD", MOA = "FA", NonLonBkr = null, OrigOff = "LON", FacyPolId = null, RenPolId = null, PolId = null, LmtCcy = "USD", LmtAmt = null, ExsCcy = "USD", ExsAmt = null, BindSt = "PRE", PctgAmt = "AMT", PricingCcy = "USD", Method = "UW", TechPrm = null, BenchPrm = null, Status = "SUBMITTED", TimeStamp = null, BkrPsu = "AAA", BkrNo = "???", TechPmTy = "TechPm" }; var updatePolicyRequest = new UpdatePolicyRequest { objPolicyContract = policyContract }; // Act var actualResponse = subscribeService.UpdatePolicy(updatePolicyRequest); // Assert Assert.IsNotNull(actualResponse.UpdatePolicyResult.ErrorInfo); }
public async Task CreateListUpdateDelete() { Environment.SetEnvironmentVariable("AZURE_TEST_MODE", "Playback"); using (MockContext context = MockContext.Start(this.GetType())) { var testBase = new ApiManagementTestBase(context); testBase.TryCreateApiManagementService(); // test tenant policy var globalPolicy = testBase.client.Policy.Get(testBase.rgName, testBase.serviceName); Assert.NotNull(globalPolicy); // test api policy string newApiId = TestUtilities.GenerateName("policyapi"); try { var createdApiContract = testBase.client.Api.CreateOrUpdate( testBase.rgName, testBase.serviceName, newApiId, new ApiCreateOrUpdateParameter { DisplayName = TestUtilities.GenerateName("display"), Description = TestUtilities.GenerateName("description"), Path = TestUtilities.GenerateName("path"), ServiceUrl = "https://echoapi.cloudapp.net/echo", Protocols = new List <string> { Protocol.Https, Protocol.Http } }); Assert.NotNull(createdApiContract); var policyContract = new PolicyContract(); policyContract.Value = ApiValid; policyContract.Format = PolicyContentFormat.XmlLink; var apiPolicyContract = await testBase.client.ApiPolicy.CreateOrUpdateAsync( testBase.rgName, testBase.serviceName, newApiId, policyContract); Assert.NotNull(apiPolicyContract); Assert.NotNull(apiPolicyContract.Value); // get policy tag var apiPolicyTag = await testBase.client.ApiPolicy.GetEntityTagAsync( testBase.rgName, testBase.serviceName, newApiId); Assert.NotNull(apiPolicyTag); Assert.NotNull(apiPolicyTag.ETag); // delete policy await testBase.client.ApiPolicy.DeleteAsync( testBase.rgName, testBase.serviceName, newApiId, apiPolicyTag.ETag); Assert.Throws <ErrorResponseException>(() => testBase.client.ApiPolicy.Get(testBase.rgName, testBase.serviceName, newApiId)); } finally { await testBase.client.Api.DeleteAsync( testBase.rgName, testBase.serviceName, newApiId, "*", deleteRevisions : true); } // test product policy // get 'Unlimited' product var getProductResponse = testBase.client.Product.ListByService( testBase.rgName, testBase.serviceName, new Microsoft.Rest.Azure.OData.ODataQuery <ProductContract> { Filter = "name eq 'Unlimited'" }); var product = getProductResponse.Single(); // get product policy try { testBase.client.ProductPolicy.Get( testBase.rgName, testBase.serviceName, product.Name); } catch (ErrorResponseException ex) { Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode); } // create product policy contract var productPolicyContract = new PolicyContract(); productPolicyContract.Value = ProductValid; productPolicyContract.Format = PolicyContentFormat.XmlLink; var productPolicyResponse = testBase.client.ProductPolicy.CreateOrUpdate( testBase.rgName, testBase.serviceName, product.Name, productPolicyContract); Assert.NotNull(productPolicyResponse); Assert.NotNull(productPolicyResponse.Value); Assert.Equal("policy", productPolicyResponse.Name); // there can be only one policy per product // get policy to check it was added var getProductPolicy = await testBase.client.ProductPolicy.GetAsync( testBase.rgName, testBase.serviceName, product.Name); Assert.NotNull(getProductPolicy); Assert.NotNull(getProductPolicy.Format); // get product policy etag var productPolicyTag = await testBase.client.ProductPolicy.GetEntityTagAsync( testBase.rgName, testBase.serviceName, product.Name); Assert.NotNull(productPolicyTag); Assert.NotNull(productPolicyTag.ETag); // remove policy testBase.client.ProductPolicy.Delete( testBase.rgName, testBase.serviceName, product.Name, productPolicyTag.ETag); // get policy to check it was removed try { testBase.client.ProductPolicy.Get( testBase.rgName, testBase.serviceName, product.Name); } catch (ErrorResponseException ex) { Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode); } } }
public void CreateQuote_Success() { // Assign long actualTimeStamp = 0; IPolicyService subscribeService = new PolicyServiceClient(); var policyContract = new PolicyContract { UnitPsu = "AGY", PolTy = "NONMARINE", EntSt = "PARTIAL", InsdNm= "- N/A", InsdId= 182396, PolDsc= "Unit Test Submission", Uwr= "AED", DOM= "AD", BkrSeqId= 822, CtcNm= "ALLAN MURRAY", IncpDt= "20130628", ExpyDt= "20140628", AccYr= "2013", SettDueDt= "20130628", Brokerage= 1, DeclineReason= null, COB= "AD", MOA= "FA", NonLonBkr= null, OrigOff= "LON", FacyPolId= null, RenPolId= null, PolId= null, LmtCcy= "USD", LmtAmt= null, ExsCcy= "USD", ExsAmt= null, BindSt= "PRE", PctgAmt= "AMT", PricingCcy= "USD", Method= "UW", TechPrm= null, BenchPrm= null, Status= "SUBMITTED", TimeStamp= null, BkrPsu= "AAA", BkrNo= "???", TechPmTy= "TechPm" }; var request = new CreateQuoteRequest { objPolicyContract = policyContract }; // Act var actualResponse = subscribeService.CreateQuote(request); if (actualResponse.CreateQuoteResult.ErrorInfo != null) { _logHandler.WriteLog(actualResponse.CreateQuoteResult.ErrorInfo.Description, LogSeverity.Error, LogCategory.BusinessComponent); _logHandler.WriteLog(actualResponse.CreateQuoteResult.ErrorInfo.ErrorXML, LogSeverity.Error, LogCategory.BusinessComponent); _logHandler.WriteLog(actualResponse.CreateQuoteResult.ErrorInfo.DetailedDescription, LogSeverity.Error, LogCategory.BusinessComponent); _logHandler.WriteLog(actualResponse.CreateQuoteResult.ErrorInfo.Severity.ToString(), LogSeverity.Error, LogCategory.BusinessComponent); } var doc = new XmlDocument(); doc.LoadXml(actualResponse.CreateQuoteResult.OutputXml); _subscribeReference = doc.GetElementsByTagName("PolId")[0].InnerText; long subscribeTimestamp; actualTimeStamp = long.TryParse(doc.GetElementsByTagName("TimeStamp")[0].InnerText, out subscribeTimestamp) ? subscribeTimestamp : 0; // Assert Assert.IsNull(actualResponse.CreateQuoteResult.ErrorInfo); Assert.AreNotEqual(actualTimeStamp, 0); Assert.IsNotNull(_subscribeReference); }
public static bool QuoteValuesMatchSubscribePolicy(PolicyContract polAsSubscribe, Quote q, Submission s) { // Is this most efficient, or are separate if statements better? return polAsSubscribe.AccYr == q.AccountYear.ToString() && (polAsSubscribe.BenchPrm.HasValue ? polAsSubscribe.BenchPrm.Value == q.BenchmarkPremium : q.BenchmarkPremium == 0) && polAsSubscribe.BindSt == q.TechnicalPricingBindStatus //&& polAsSubscribe.BkrNo == s.? // Should we bother checking? not used by service && polAsSubscribe.BkrPsu == s.BrokerPseudonym && polAsSubscribe.BkrSeqId == s.BrokerSequenceId && (polAsSubscribe.Brokerage.HasValue ? polAsSubscribe.Brokerage.Value == s.Brokerage : s.Brokerage == 0) && polAsSubscribe.COB == q.COBId && polAsSubscribe.CtcNm == s.BrokerContact && polAsSubscribe.DeclineReason == q.DeclinatureReason && polAsSubscribe.DOM == s.Domicile && polAsSubscribe.EntSt == q.EntryStatus && (q.ExpiryDate.HasValue ? polAsSubscribe.ExpyDt == q.ExpiryDate.Value.ToString("yyyyMMdd") : string.IsNullOrEmpty(polAsSubscribe.ExpyDt)) && (q.InceptionDate.HasValue ? polAsSubscribe.IncpDt == q.InceptionDate.Value.ToString("yyyyMMdd") : string.IsNullOrEmpty(polAsSubscribe.IncpDt)) && (polAsSubscribe.SettDueDt == q.QuoteExpiryDate.ToString("yyyyMMdd")) && (polAsSubscribe.ExsAmt.HasValue ? polAsSubscribe.ExsAmt == q.ExcessAmount : q.ExcessAmount == 0) && polAsSubscribe.ExsCcy == q.ExcessCCY && polAsSubscribe.FacyPolId == q.FacilityRef && polAsSubscribe.InsdId == s.InsuredId && polAsSubscribe.InsdNm == s.InsuredName && (polAsSubscribe.LmtAmt.HasValue ? polAsSubscribe.LmtAmt.Value == q.LimitAmount : q.LimitAmount == 0) && polAsSubscribe.LmtCcy == q.LimitCCY && polAsSubscribe.Method == q.TechnicalPricingMethod && polAsSubscribe.MOA == q.MOA && polAsSubscribe.NonLonBkr == s.NonLondonBrokerCode && polAsSubscribe.OrigOff == q.OriginatingOfficeId && polAsSubscribe.PctgAmt == q.TechnicalPricingPremiumPctgAmt && polAsSubscribe.PolId == q.SubscribeReference && polAsSubscribe.PolTy == q.PolicyType && polAsSubscribe.PricingCcy == q.Currency && polAsSubscribe.RenPolId == q.RenPolId && polAsSubscribe.Status == q.SubmissionStatus //&& polAsSubscribe.TechPmTy == "TechPm" && (polAsSubscribe.TechPrm.HasValue ? polAsSubscribe.TechPrm.Value == q.TechnicalPremium : q.TechnicalPremium == 0) && polAsSubscribe.Uwr == s.UnderwriterCode; }
public void SynchroniseSubmission_Success() { // Assign var submission = new globalVM::Validus.Models.Submission(); var policyContract = new PolicyContract { InsdNm = "Insured Name...", BkrSeqId = 1, NonLonBkr = "AON", Uwr = "UC", Brokerage = 3, AccYr = "1976", ExpyDt = "19761229", IncpDt = "19761229", SettDueDt = "19761229" }; // Act SubmissionModuleHelpers.SynchroniseSubmission(submission, policyContract); // Assert Assert.AreEqual(submission.InsuredName, policyContract.InsdNm); }
public static void SynchroniseQuote(Quote q, PolicyContract polAsSubscribe) { q.TechnicalPricingMethod = polAsSubscribe.Method; q.AccountYear = int.Parse(polAsSubscribe.AccYr); q.BenchmarkPremium = polAsSubscribe.BenchPrm.HasValue ? polAsSubscribe.BenchPrm.Value : 0; q.TechnicalPricingBindStatus = polAsSubscribe.BindSt; q.COBId = polAsSubscribe.COB; q.Currency = polAsSubscribe.PricingCcy; q.DeclinatureReason = polAsSubscribe.DeclineReason; q.EntryStatus = polAsSubscribe.EntSt; q.ExpiryDate = polAsSubscribe.ExpyDt != null ? (DateTime?)DateTime.ParseExact(polAsSubscribe.ExpyDt, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None) : null; q.InceptionDate = polAsSubscribe.IncpDt != null ? (DateTime?)DateTime.ParseExact(polAsSubscribe.IncpDt, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None) : null; // TODO: Why is QuoteExpiryDate nullable ? q.QuoteExpiryDate = DateTime.ParseExact(polAsSubscribe.SettDueDt, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None); q.ExcessAmount = polAsSubscribe.ExsAmt.HasValue ? polAsSubscribe.ExsAmt.Value : 0; q.ExcessCCY = polAsSubscribe.ExsCcy; q.FacilityRef = polAsSubscribe.FacyPolId; q.LimitAmount = polAsSubscribe.LmtAmt.HasValue ? polAsSubscribe.LmtAmt.Value : 0; q.LimitCCY = polAsSubscribe.LmtCcy; q.MOA = polAsSubscribe.MOA; q.OriginatingOfficeId = polAsSubscribe.OrigOff; q.PolicyType = polAsSubscribe.PolTy; q.RenPolId = polAsSubscribe.RenPolId; q.SubmissionStatus = polAsSubscribe.Status; q.SubscribeTimestamp = polAsSubscribe.TimeStamp.HasValue ? polAsSubscribe.TimeStamp.Value : 0; q.TechnicalPremium = polAsSubscribe.TechPrm.HasValue ? polAsSubscribe.TechPrm.Value : 0; q.TechnicalPricingMethod = polAsSubscribe.Method; q.TechnicalPricingPremiumPctgAmt = polAsSubscribe.PctgAmt; q.Description = polAsSubscribe.PolDsc; }
public async Task CreateListUpdateDelete() { Environment.SetEnvironmentVariable("AZURE_TEST_MODE", "Playback"); using (MockContext context = MockContext.Start(this.GetType().FullName)) { var testBase = new ApiManagementTestBase(context); testBase.TryCreateApiManagementService(); // test tenant policy var globalPolicy = testBase.client.Policy.Get(testBase.rgName, testBase.serviceName); // set policy var policyDoc = XDocument.Parse(globalPolicy.Value); var policyContract = new PolicyContract(policyDoc.ToString()); try { var globalPolicyResponse = testBase.client.Policy.CreateOrUpdate( testBase.rgName, testBase.serviceName, policyContract); Assert.NotNull(globalPolicyResponse); // get policy to check it was added var getPolicyResponse = await testBase.client.Policy.GetAsync( testBase.rgName, testBase.serviceName); Assert.NotNull(getPolicyResponse); Assert.NotNull(getPolicyResponse.Value); // get the policy etag var globalPolicyTag = await testBase.client.Policy.GetEntityTagAsync( testBase.rgName, testBase.serviceName); Assert.NotNull(globalPolicyTag); Assert.NotNull(globalPolicyTag.ETag); // remove policy testBase.client.Policy.Delete( testBase.rgName, testBase.serviceName, globalPolicyTag.ETag); // get policy to check it was removed try { testBase.client.Policy.Get( testBase.rgName, testBase.serviceName); } catch (ErrorResponseException ex) { Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode); } } finally { testBase.client.Policy.CreateOrUpdate( testBase.rgName, testBase.serviceName, policyContract); } // test api policy // there should be 'Echo API' with no policy var getApiResponse = testBase.client.Api.ListByService( testBase.rgName, testBase.serviceName, null); var api = getApiResponse.Single(); try { testBase.client.ApiPolicy.Get( testBase.rgName, testBase.serviceName, api.Id); } catch (ErrorResponseException ex) { Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode); } // set policy policyDoc = XDocument.Parse(ApiValid); var setResponse = testBase.client.ApiPolicy.CreateOrUpdate( testBase.rgName, testBase.serviceName, api.Name, new PolicyContract(policyDoc.ToString()), "*"); Assert.NotNull(setResponse); // get policy to check it was added var getApiPolicy = await testBase.client.ApiPolicy.GetAsync( testBase.rgName, testBase.serviceName, api.Name); Assert.NotNull(getApiPolicy); Assert.NotNull(getApiPolicy.Value); // get the api policy tag var apiPolicyTag = await testBase.client.ApiPolicy.GetEntityTagAsync( testBase.rgName, testBase.serviceName, api.Name); Assert.NotNull(apiPolicyTag); Assert.NotNull(apiPolicyTag.ETag); // remove policy testBase.client.ApiPolicy.Delete( testBase.rgName, testBase.serviceName, api.Name, apiPolicyTag.ETag); // get policy to check it was removed try { testBase.client.ApiPolicy.Get( testBase.rgName, testBase.serviceName, api.Name); } catch (ErrorResponseException ex) { Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode); } // test api operation policy var getOperationResponse = testBase.client.ApiOperation.ListByApi( testBase.rgName, testBase.serviceName, api.Name, null); var operation = getOperationResponse.First(op => op.DisplayName.Equals("Modify Resource", StringComparison.OrdinalIgnoreCase)); try { testBase.client.ApiOperationPolicy.Get( testBase.rgName, testBase.serviceName, api.Name, operation.Name); } catch (ErrorResponseException ex) { Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode); } // set policy policyDoc = XDocument.Parse(OperationValid); setResponse = testBase.client.ApiOperationPolicy.CreateOrUpdate( testBase.rgName, testBase.serviceName, api.Name, operation.Name, new PolicyContract(policyDoc.ToString()), "*"); Assert.NotNull(setResponse); // get policy to check it was added var getOperationPolicy = await testBase.client.ApiOperationPolicy.GetAsync( testBase.rgName, testBase.serviceName, api.Name, operation.Name); Assert.NotNull(getOperationPolicy); Assert.NotNull(getOperationPolicy.Value); // get operation policy tag var operationPolicyTag = await testBase.client.ApiOperationPolicy.GetEntityTagAsync( testBase.rgName, testBase.serviceName, api.Name, operation.Name); Assert.NotNull(operationPolicyTag); Assert.NotNull(operationPolicyTag.ETag); // remove policy testBase.client.ApiOperationPolicy.Delete( testBase.rgName, testBase.serviceName, api.Name, operation.Name, operationPolicyTag.ETag); // get policy to check it was removed try { testBase.client.ApiOperationPolicy.Get( testBase.rgName, testBase.serviceName, api.Name, operation.Name); } catch (ErrorResponseException ex) { Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode); } // test product policy // get 'Unlimited' product var getProductResponse = testBase.client.Product.ListByService( testBase.rgName, testBase.serviceName, new Microsoft.Rest.Azure.OData.ODataQuery <ProductContract> { Filter = "name eq 'Unlimited'" }); var product = getProductResponse.Single(); // get product policy try { testBase.client.ProductPolicy.Get( testBase.rgName, testBase.serviceName, product.Name); } catch (ErrorResponseException ex) { Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode); } // set policy policyDoc = XDocument.Parse(ProductValid); setResponse = testBase.client.ProductPolicy.CreateOrUpdate( testBase.rgName, testBase.serviceName, product.Name, new PolicyContract(value: policyDoc.ToString())); Assert.NotNull(setResponse); // get policy to check it was added var getProductPolicy = await testBase.client.ProductPolicy.GetAsync( testBase.rgName, testBase.serviceName, product.Name); Assert.NotNull(getProductPolicy); Assert.NotNull(getProductPolicy.Value); // get product policy tag var productPolicyTag = await testBase.client.ProductPolicy.GetEntityTagAsync( testBase.rgName, testBase.serviceName, product.Name); Assert.NotNull(productPolicyTag); Assert.NotNull(productPolicyTag.ETag); // remove policy testBase.client.ProductPolicy.Delete( testBase.rgName, testBase.serviceName, product.Name, productPolicyTag.ETag); // get policy to check it was removed try { testBase.client.ProductPolicy.Get( testBase.rgName, testBase.serviceName, product.Name); } catch (ErrorResponseException ex) { Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode); } } }
/// <summary> /// Creates or updates the global policy configuration of the Api Management /// service. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='serviceName'> /// The name of the API Management service. /// </param> /// <param name='parameters'> /// The policy contents to apply. /// </param> public static PolicyContract CreateOrUpdate(this IPolicyOperations operations, string resourceGroupName, string serviceName, PolicyContract parameters) { return(operations.CreateOrUpdateAsync(resourceGroupName, serviceName, parameters).GetAwaiter().GetResult()); }
/// <summary> /// Update the policy configuration. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='policy'> /// The policy configuration. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <PolicyContract> UpdateAsync(this IPolicy operations, PolicyContract policy, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateWithHttpMessagesAsync(policy, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Update the policy configuration. /// </summary> /// <param name='policy'> /// The policy configuration. /// </param> /// <param name='customHeaders'> /// Headers that will be added to request. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> /// <exception cref="HttpOperationException"> /// Thrown when the operation returned an invalid status code /// </exception> /// <exception cref="SerializationException"> /// Thrown when unable to deserialize the response /// </exception> /// <exception cref="ValidationException"> /// Thrown when a required parameter is null /// </exception> /// <exception cref="System.ArgumentNullException"> /// Thrown when a required parameter is null /// </exception> /// <return> /// A response object containing the response body and response headers. /// </return> public async Task <HttpOperationResponse <PolicyContract> > UpdateWithHttpMessagesAsync(PolicyContract policy, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.Endpoint == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); } if (policy == null) { throw new ValidationException(ValidationRules.CannotBeNull, "policy"); } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; if (_shouldTrace) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("policy", policy); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri; var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "configurations/policy"; _url = _url.Replace("{Endpoint}", Client.Endpoint); // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; _httpRequest.Method = new HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (customHeaders != null) { foreach (var _header in customHeaders) { if (_httpRequest.Headers.Contains(_header.Key)) { _httpRequest.Headers.Remove(_header.Key); } _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); } } // Serialize Request string _requestContent = null; if (policy != null) { _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(policy, Client.SerializationSettings); _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials if (Client.Credentials != null) { cancellationToken.ThrowIfCancellationRequested(); await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); } // Send Request if (_shouldTrace) { ServiceClientTracing.SendRequest(_invocationId, _httpRequest); } cancellationToken.ThrowIfCancellationRequested(); _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); if (_shouldTrace) { ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); } HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; if ((int)_statusCode != 200) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); if (_httpResponse.Content != null) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); } else { _responseContent = string.Empty; } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); } _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw ex; } // Create Result var _result = new HttpOperationResponse <PolicyContract>(); _result.Request = _httpRequest; _result.Response = _httpResponse; // Deserialize Response if ((int)_statusCode == 200) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject <PolicyContract>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); } return(_result); }
public void SynchroniseQuote_ExpectException() { // Assign var quote = new Quote(); var policyContract = new PolicyContract {AccYr = "29/12/1976"}; // Act SubmissionModuleHelpers.SynchroniseQuote(quote, policyContract); // Assert Assert.AreEqual(quote.AccountYear, policyContract.AccYr); }
/// <summary> /// Update the policy configuration. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='policy'> /// The policy configuration. /// </param> public static PolicyContract Update(this IPolicy operations, PolicyContract policy) { return(operations.UpdateAsync(policy).GetAwaiter().GetResult()); }
public static CreateQuoteResponse CreateSubscribeRecord(Quote q, Submission s, ILogHandler logHandler, IPolicyService subsribeService) { var insuredList = new InsuredCollection(); if (q.AdditionalInsuredList != null) { insuredList.AddRange(q.AdditionalInsuredList .Select(insured => new Insured { AddlInsdId = insured.InsuredId, AddlInsdNm = insured.InsuredId == 0 ? insured.InsuredName : null, AddlInsdTy = insured.InsuredType })); } var policyContract = new PolicyContract { AccYr = q.AccountYear.ToString(), BenchPrm = q.BenchmarkPremium, BindSt = q.TechnicalPricingBindStatus, BkrNo = "???", // TODO - not referenced in CreateQuote sp BkrPsu = q.BrokerPseudonym, // No validation carried out in service validation sp BkrSeqId = q.BrokerSequenceId, Brokerage = q.Brokerage, COB = q.COBId, DeclineReason = q.DeclinatureReason, DOM = q.Domicile, EntSt = q.EntryStatus, ExpyDt = (q.ExpiryDate.HasValue) ? q.ExpiryDate.Value.ToString("yyyyMMdd") : null, ExsAmt = q.ExcessAmount, FacyPolId = (String.IsNullOrEmpty(q.RenPolId) ? q.FacilityRef : String.Empty), LdrNo = q.LeaderNo, Ldr = q.Leader, IncpDt = (q.InceptionDate.HasValue) ? q.InceptionDate.Value.ToString("yyyyMMdd") : null, InsdId = q.InsuredId, InsdNm = q.InsuredName, AddlInsuredCollection = insuredList, LmtAmt = q.LimitAmount, LmtCcy = q.LimitCCY, MOA = q.MOA, OrigOff = q.OriginatingOfficeId, PolTy = q.PolicyType, PricingCcy = q.Currency, RenPolId = q.RenPolId, Status = q.SubmissionStatus, TechPrm = q.TechnicalPremium, UnitPsu = "AGY", Uwr = q.UnderwriterCode, ExsCcy = q.ExcessCCY, Method = q.TechnicalPricingMethod, NonLonBkr = q.NonLondonBrokerCode, PctgAmt = q.TechnicalPricingPremiumPctgAmt, TechPmTy = "TechPm", // TODO - not referenced in CreateQuote sp PolDsc = q.Description, // These are the fields required for edit only TimeStamp = q.SubscribeTimestamp, PolId = q.SubscribeReference, // PolAnlyCd // TODO: Update this win value from form. WordReqd = (string.IsNullOrEmpty(q.WordingRequired)) ? "" : q.WordingRequired, AggsReqd = (string.IsNullOrEmpty(q.AggsRequired)) ? "" : q.AggsRequired, FSA_Class = (string.IsNullOrEmpty(q.FSAClass)) ? "" : q.FSAClass, CtcNm = q.BrokerContact, //CtcTelNo = q.BrokerContactPhone, //CtcEmail = q.BrokerContactEmail }; if (q.QuoteExpiryDate != null) { policyContract.SettDueDt = SetSettlementDueDate(q.QuoteExpiryDate.Value, s.ExpiryDateOffset, q.InceptionDate); } if (!string.IsNullOrEmpty(q.BrokerContactPhone)) { policyContract.CtcTelNo = q.BrokerContactPhone; } if (!string.IsNullOrEmpty(q.BrokerContactEmail)) { policyContract.CtcEmail = q.BrokerContactEmail; } if (q.RenewalRate.HasValue) { policyContract.RenewalRate = q.RenewalRate; } if (q.RenewalConditions.HasValue) { policyContract.RenewalConditions = q.RenewalConditions; } if (q.RenewalDeductibles.HasValue) { policyContract.RenewalDeductibles = q.RenewalDeductibles; } if (q.RenewalExposure.HasValue) { policyContract.RenewalExposurePctg = q.RenewalExposure; } if (q.RenewalBase.HasValue) { policyContract.RenewalBase = q.RenewalBase; } if (q.RenewalFull.HasValue) { policyContract.RenewalFull = q.RenewalFull; } var createQuoteResponse = subsribeService.CreateQuote(new CreateQuoteRequest { objPolicyContract = policyContract }); if (createQuoteResponse.CreateQuoteResult.ErrorInfo == null) { q.SubscribeReference = createQuoteResponse.objInfoCollection.PolId; var doc = new XmlDocument(); doc.LoadXml(createQuoteResponse.CreateQuoteResult.OutputXml); var subscribeTimestamp = default(long); q.SubscribeTimestamp = long.TryParse(doc.GetElementsByTagName("TimeStamp")[0].InnerText, out subscribeTimestamp) ? subscribeTimestamp : 0; SyncQuoteCreateAndUpdate(s, q, subsribeService); } else { logHandler.WriteLog(createQuoteResponse.CreateQuoteResult.ErrorInfo.ErrorXML, LogSeverity.Error, LogCategory.BusinessComponent); throw new ApplicationException( string.IsNullOrEmpty(createQuoteResponse.CreateQuoteResult.ErrorInfo.Description) ? ParseDetailedError(createQuoteResponse.CreateQuoteResult.ErrorInfo.DetailedDescription) : createQuoteResponse.CreateQuoteResult.ErrorInfo.Description); } return(createQuoteResponse); }
/// <summary> /// Update the policy configuration. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='policy'> /// The policy configuration. /// </param> /// <param name='customHeaders'> /// Headers that will be added to request. /// </param> public static HttpOperationResponse <PolicyContract> UpdateWithHttpMessages(this IPolicy operations, PolicyContract policy, Dictionary <string, List <string> > customHeaders = null) { return(operations.UpdateWithHttpMessagesAsync(policy, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult()); }
public static bool QuoteValuesMatchSubscribePolicy(PolicyContract polAsSubscribe, Quote q, Submission s) { // Is this most efficient, or are separate if statements better? // For debugging this has been split out, it is hard to debug if all one line of && evaluations var retVal = true; if (polAsSubscribe.AccYr != q.AccountYear.ToString()) { retVal = false; } else if (polAsSubscribe.BindSt != q.TechnicalPricingBindStatus) { retVal = false; } else if (polAsSubscribe.BkrPsu != q.BrokerPseudonym) { retVal = false; } else if (polAsSubscribe.BkrSeqId != q.BrokerSequenceId) { retVal = false; } else if (polAsSubscribe.COB != q.COBId) { retVal = false; } else if (polAsSubscribe.CtcNm != q.BrokerContact) { retVal = false; } else if (polAsSubscribe.DeclineReason != q.DeclinatureReason) { retVal = false; } else if (polAsSubscribe.DOM != q.Domicile) { retVal = false; } else if (polAsSubscribe.EntSt != q.EntryStatus) { retVal = false; } else if (polAsSubscribe.ExsCcy != q.ExcessCCY) { retVal = false; } else if (polAsSubscribe.FacyPolId != q.FacilityRef) { retVal = false; } else if (polAsSubscribe.InsdId != q.InsuredId) { retVal = false; } else if (polAsSubscribe.InsdNm != q.InsuredName) { retVal = false; } else if (polAsSubscribe.LmtCcy != q.LimitCCY) { retVal = false; } else if (polAsSubscribe.Method != q.TechnicalPricingMethod) { retVal = false; } else if (polAsSubscribe.MOA != q.MOA) { retVal = false; } else if (polAsSubscribe.FSA_Class != q.FSAClass) { retVal = false; } else if (polAsSubscribe.AggsReqd != q.AggsRequired) { retVal = false; } else if (polAsSubscribe.WordReqd != q.WordingRequired) { retVal = false; } else if (polAsSubscribe.NonLonBkr != q.NonLondonBrokerCode) { retVal = false; } else if (polAsSubscribe.OrigOff != q.OriginatingOfficeId) { retVal = false; } else if (polAsSubscribe.PctgAmt != q.TechnicalPricingPremiumPctgAmt) { retVal = false; } else if (polAsSubscribe.PolId != q.SubscribeReference) { retVal = false; } else if (polAsSubscribe.PolTy != q.PolicyType) { retVal = false; } else if (polAsSubscribe.PricingCcy != q.Currency) { retVal = false; } else if (polAsSubscribe.RenPolId != q.RenPolId) { retVal = false; } else if (polAsSubscribe.Status != q.SubmissionStatus) { retVal = false; } else if (polAsSubscribe.Uwr != q.UnderwriterCode) { retVal = false; } else if ((polAsSubscribe.BenchPrm.HasValue) && (polAsSubscribe.BenchPrm.Value != q.BenchmarkPremium)) { retVal = false; } else if ((!polAsSubscribe.BenchPrm.HasValue) && (q.BenchmarkPremium != 0)) { retVal = false; } else if ((polAsSubscribe.TechPrm.HasValue) && (polAsSubscribe.TechPrm.Value != q.TechnicalPremium)) { retVal = false; } else if ((!polAsSubscribe.TechPrm.HasValue) && (q.TechnicalPremium != 0)) { retVal = false; } else if ((polAsSubscribe.Brokerage.HasValue) && (polAsSubscribe.Brokerage.Value != q.Brokerage)) { retVal = false; } else if ((!polAsSubscribe.Brokerage.HasValue) && (q.Brokerage.HasValue) && (q.Brokerage != 0)) { retVal = false; } else if ((q.ExpiryDate.HasValue) && (polAsSubscribe.ExpyDt != q.ExpiryDate.Value.ToString("yyyyMMdd"))) { retVal = false; } else if ((!q.ExpiryDate.HasValue) && (!string.IsNullOrEmpty(polAsSubscribe.ExpyDt))) { retVal = false; } else if ((q.InceptionDate.HasValue) && (polAsSubscribe.IncpDt != q.InceptionDate.Value.ToString("yyyyMMdd"))) { retVal = false; } else if ((!q.InceptionDate.HasValue) && (!string.IsNullOrEmpty(polAsSubscribe.IncpDt))) { retVal = false; } else if (q.QuoteExpiryDate.HasValue && polAsSubscribe.SettDueDt != SetSettlementDueDate(q.QuoteExpiryDate.Value, s.ExpiryDateOffset, q.InceptionDate)) { retVal = false; } else if ((polAsSubscribe.ExsAmt.HasValue) && (polAsSubscribe.ExsAmt.Value != q.ExcessAmount)) { retVal = false; } else if ((!polAsSubscribe.ExsAmt.HasValue) && (q.ExcessAmount != 0)) { retVal = false; } else if ((polAsSubscribe.LmtAmt.HasValue) && (polAsSubscribe.LmtAmt.Value != q.LimitAmount)) { retVal = false; } else if ((!polAsSubscribe.LmtAmt.HasValue) && (q.LimitAmount != 0)) { retVal = false; } return(retVal); }