public void ServerUrlWithTrailingSlash()
        {
            ws = new SonarWebService(downloader, "http://myhost:222/");

            downloader.Pages["http://myhost:222/api/profiles/list?language=cs&project=foo+bar"] = "[{\"name\":\"profile1\",\"language\":\"cs\",\"default\":true}]";
            string qualityProfile;
            bool result = ws.TryGetQualityProfile("foo bar", "cs", out qualityProfile);
            Assert.IsTrue(result);
            Assert.AreEqual("profile1", qualityProfile);

            downloader.Pages["http://myhost:222/api/profiles/index?language=cs&name=Sonar+way"] = "[{\"name\":\"Sonar way\",\"language\":\"cs\",\"default\":true}]";
            var expected1 = new List<string>();
            var actual1 = new List<string>(ws.GetActiveRuleKeys("Sonar way", "cs", "foo"));
            Assert.AreEqual(true, expected1.SequenceEqual(actual1));

            downloader.Pages["http://myhost:222/api/rules/search?f=internalKey&ps=" + int.MaxValue + "&repositories=fxcop"] = "{\"total\":2,\"p\":1,\"ps\":10,\"rules\":[{\"key\":\"fxcop:My_Own_FxCop_Rule\"},{\"key\":\"fxcop:UriParametersShouldNotBeStrings\",\"internalKey\":\"CA1054\"}]}";
            var expected2 = new Dictionary<string, string>();
            expected2["fxcop:My_Own_FxCop_Rule"] = null;
            expected2["fxcop:UriParametersShouldNotBeStrings"] = "CA1054";
            var actual2 = ws.GetInternalKeys("fxcop");

            Assert.AreEqual(true, expected2.Count == actual2.Count && !expected2.Except(actual2).Any());

            downloader.Pages["http://myhost:222/api/properties?resource=foo+bar"] = "[{\"key\": \"sonar.property1\",\"value\": \"value1\"},{\"key\": \"sonar.property2\",\"value\": \"value2\"}]";
            var expected3 = new Dictionary<string, string>();
            expected3["sonar.property1"] = "value1";
            expected3["sonar.property2"] = "value2";
            expected3["sonar.cs.msbuild.testProjectPattern"] = SonarProperties.DefaultTestProjectPattern;
            var actual3 = ws.GetProperties("foo bar", new TestLogger());

            Assert.AreEqual(true, expected3.Count == actual3.Count && !expected3.Except(actual3).Any());

            downloader.Pages["http://myhost:222/api/updatecenter/installed_plugins"] = "[{\"key\":\"visualstudio\",\"name\":\"...\",\"version\":\"1.2\"},{\"key\":\"csharp\",\"name\":\"C#\",\"version\":\"4.0\"}]";
            var expected4 = new List<string>();
            expected4.Add("visualstudio");
            expected4.Add("csharp");
            var actual4 = new List<string>(ws.GetInstalledPlugins());

            Assert.AreEqual(true, expected4.SequenceEqual(actual4));
        }
        public void GetInternalKeys()
        {
            downloader.Pages["http://myhost:222/api/rules/search?f=internalKey&ps=" + int.MaxValue + "&repositories=fxcop"] = "{\"total\":2,\"p\":1,\"ps\":10,\"rules\":[{\"key\":\"fxcop:My_Own_FxCop_Rule\"},{\"key\":\"fxcop:UriParametersShouldNotBeStrings\",\"internalKey\":\"CA1054\"}]}";
            var expected = new Dictionary<string, string>();
            expected["fxcop:My_Own_FxCop_Rule"] = null;
            expected["fxcop:UriParametersShouldNotBeStrings"] = "CA1054";
            var actual = ws.GetInternalKeys("fxcop");

            Assert.AreEqual(true, expected.Count == actual.Count && !expected.Except(actual).Any());
        }
        public void GetProperties()
        {
            downloader.Pages["http://myhost:222/api/properties?resource=foo+bar"] = "[{\"key\": \"sonar.property1\",\"value\": \"value1\"},{\"key\": \"sonar.property2\",\"value\": \"value2\"}]";
            var expected = new Dictionary<string, string>();
            expected["sonar.property1"] = "value1";
            expected["sonar.property2"] = "value2";
            expected["sonar.cs.msbuild.testProjectPattern"] = SonarProperties.DefaultTestProjectPattern;
            var actual = ws.GetProperties("foo bar", new TestLogger());

            Assert.AreEqual(true, expected.Count == actual.Count && !expected.Except(actual).Any());
        }
Esempio n. 4
0
        public override List<ClaimNameInvolvementDto> GetNameNIListForPayment()
        {
            //// This method is used to filter and fetch the name involvemnts for the payemnts
            //// Fetch the name involvements linked with driver and claimants and based on the claim Detail type set the list of valid payee's
            //// We are using mainly three dictionary to hold the NI's linked with Driver , linked with claimant and not linked claimnt
            //// if the Transaction source is not payment the return the NI's as per core functionality
            if (this.ClaimTransactionSource == (short)StaticValues.ClaimTransactionSource.Payment)
            {
                Dictionary<Guid, ClaimNameInvolvementDto> linkedClaimants = new Dictionary<Guid, ClaimNameInvolvementDto>();
                Dictionary<Guid, ClaimNameInvolvementDto> nonLinkedClaimants = new Dictionary<Guid, ClaimNameInvolvementDto>();
                Dictionary<Guid, ClaimNameInvolvementDto> linkedDriverAndVehicles = new Dictionary<Guid, ClaimNameInvolvementDto>();
                Dictionary<Guid, ClaimNameInvolvementDto> validClaimNameInvolvements = new Dictionary<Guid, ClaimNameInvolvementDto>();
                //// Get all the ClaimNameInvolvements of From Header
                Dictionary<Guid, ClaimNameInvolvementDto> headerNIs = this.GetClaimHeaderNameInvolvement(this.HeaderDto);
                Dictionary<Guid, ClaimNameInvolvementDto> claimNameInvolvements = base.GetNameNIListForPayment().ToDictionary(p => p.Data.DataId, p => p);
               
             
               
                IEnumerable<ClaimNameInvolvementDto> drivers = this.GetNameInvolvemntList(StaticValues.NameInvolvementType.Driver);
                IEnumerable<ClaimNameInvolvementDto> claimants = this.GetNameInvolvemntList(StaticValues.NameInvolvementType.AdditionalClaimant);
               
                ////Get the Claim Detail Id on which current payment is added
                Guid claimDetailID = (this.HeaderDto.InProgressClaimTransactionHeaders.First().ClaimTransactionGroups.First().Data as ClaimTransactionGroupData).ClaimDetailDataID;
                ClaimDetailDto claimDetail = this.HeaderDto.ClaimDetails.Where(cd => cd.Data.DataId == claimDetailID).FirstOrDefault();
                //// For AD Claim Detail Type
                if (claimDetail.ClaimDetailData.ClaimDetailTypeCode == AXAClaimConstants.CLAIMDETAILTYPE_AD)
                {
                    if (drivers != null)
                    {   //// Get all the Name Involvement linked with Driver
                        linkedDriverAndVehicles = this.GetNILinkedToDriver(drivers);
                    }

                    if (claimants != null)
                    {   //// Get all the Name Involvement linked with All Claimants and store them in NonLinkedClaimants list
                        nonLinkedClaimants = this.GetNonLinkedClaimantForADList(claimants); 
                    }

                    headerNIs = headerNIs.Except(nonLinkedClaimants).ToDictionary(p => p.Key , p => p.Value);
                    claimNameInvolvements = claimNameInvolvements.Where(c => c.Value.ClaimNameInvolvementData.NameInvolvementType != (short)StaticValues.NameInvolvementType.AdditionalClaimant).ToDictionary(c => c.Key, c => c.Value);        
                    validClaimNameInvolvements = claimNameInvolvements.Except(nonLinkedClaimants).ToDictionary(p => p.Key, p => p.Value);
                    headerNIs = headerNIs.Where(c => c.Value.ClaimNameInvolvementData.NameInvolvementType != (short)StaticValues.NameInvolvementType.AdditionalClaimant).ToDictionary(c => c.Key, c => c.Value);
                    
                    foreach (ClaimNameInvolvementDto cd in linkedDriverAndVehicles.Values)
                    {
                        if (!validClaimNameInvolvements.ContainsKey(cd.Data.DataId))
                        {
                            validClaimNameInvolvements.Add(cd.Data.DataId, cd);
                        }
                    }

                    foreach (ClaimNameInvolvementDto cd in headerNIs.Values)
                    {
                        if (!validClaimNameInvolvements.ContainsKey(cd.Data.DataId))
                        {
                            validClaimNameInvolvements.Add(cd.Data.DataId, cd);
                        }
                    }
                    
                                      
                    if (validClaimNameInvolvements != null)
                    {
                        //// Filter the NI on which payment is permitted and status is latest
                        validClaimNameInvolvements = validClaimNameInvolvements.Where(ni => (ni.Value.Data as IClaimNameInvolvementData).IsPaymentPermitted.GetValueOrDefault() && (ni.Value.Data as IClaimNameInvolvementData).NameInvolvementMaintenanceStatus == (short)StaticValues.ClaimNameInvolvementMaintenanceStatus.Latest).ToDictionary(p => p.Key, p => p.Value); 
                    }
                }
                else
                {
                    //// This Block will be executed for all ClaimDetails except  AD
                    if (drivers != null)
                    {
                        //// Get all the Name Involvement linked with Driver
                        linkedDriverAndVehicles = this.GetNILinkedToDriver(drivers);
                    }

                    if (claimants != null)
                    {
                        //// get all the NI's for other claimants 
                        nonLinkedClaimants = this.GetNonlinkedClaimantNIList(claimants, claimDetailID);
                        //// get all the NI's of the claimant on which payments is in progress
                        linkedClaimants = this.GetLinkedClaimantNIList(claimants, claimDetailID);
                    }

                    headerNIs = headerNIs.Except(nonLinkedClaimants).ToDictionary(p => p.Key, p => p.Value);
                    headerNIs = headerNIs.Except(linkedDriverAndVehicles).ToDictionary(p => p.Key, p => p.Value);
                    claimNameInvolvements = claimNameInvolvements.Where(c => c.Value.ClaimNameInvolvementData.NameInvolvementType != (short)StaticValues.NameInvolvementType.AdditionalClaimant).ToDictionary(c => c.Key, c => c.Value);        
                    validClaimNameInvolvements = claimNameInvolvements.Except(nonLinkedClaimants).ToDictionary(p => p.Key, p => p.Value);
                    validClaimNameInvolvements = validClaimNameInvolvements.Except(linkedDriverAndVehicles).ToDictionary(p => p.Key, p => p.Value);
                    headerNIs = headerNIs.Where(c => c.Value.ClaimNameInvolvementData.NameInvolvementType != (short)StaticValues.NameInvolvementType.AdditionalClaimant).ToDictionary(c => c.Key, c => c.Value);
                   
                    foreach (ClaimNameInvolvementDto cd in linkedClaimants.Values)
                    {
                        if (!validClaimNameInvolvements.ContainsKey(cd.Data.DataId))
                        {
                            validClaimNameInvolvements.Add(cd.Data.DataId, cd);
                        }
                    }

                    foreach (ClaimNameInvolvementDto cd in headerNIs.Values)
                    {
                        if (!validClaimNameInvolvements.ContainsKey(cd.Data.DataId))
                        {
                            validClaimNameInvolvements.Add(cd.Data.DataId, cd);
                        }
                    }
                    

                    if (validClaimNameInvolvements != null)
                    {
                        //// Filter the NI on which payment is permitted and status is latest
                        validClaimNameInvolvements = validClaimNameInvolvements.Where(ni => (ni.Value.Data as IClaimNameInvolvementData).IsPaymentPermitted.GetValueOrDefault() && (ni.Value.Data as IClaimNameInvolvementData).NameInvolvementMaintenanceStatus == (short)StaticValues.ClaimNameInvolvementMaintenanceStatus.Latest).ToDictionary(p => p.Key, p => p.Value); 
                    }
                }

                return validClaimNameInvolvements.Values.ToList();  
            }
            else
            {
                return base.GetNameNIListForPayment();
            }
        }