Exemplo n.º 1
0
        public void GetAssetDetails(int pageNumber = 1)
        {
            GetToken(false);
            if (pageNumber == 1)
            {
                CustomHeaders.Add(CustomerUid, CustomerUID.ToString());
            }

            try
            {
                LogResult.Report(Log, "log_ForInfo", "GetAssetDetails-AssetSettings: Starts");
                if (queryString == null && endPoint == null)
                {
                    queryString = "?PageNumber=" + Convert.ToString(pageNumber) + "&PageSize=" + Convert.ToString(getAssetSettingsRequest.PageSize) + "&sortcolumn=" + Convert.ToString(getAssetSettingsRequest.SortColumn);
                    endPoint    = AssetServiceConfig.AssetSettingsEndPoint + queryString;
                }

                LogResult.Report(Log, "log_ForInfo", "Get URL: " + endPoint);
                ResponseJSON = RestClientUtil.DoHttpRequest(endPoint, HeaderSettings.GetMethod, AccessToken, HeaderSettings.JsonMediaType, null, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, CustomHeaders);
                LogResult.Report(Log, "log_ForInfo", "GetAssetDetails-AssetSettings: Ends ");
            }
            catch (Exception e)
            {
            }
        }
Exemplo n.º 2
0
        public static bool ValidateDB(int expectedResult)
        {
            List <AccountHierarchyDBComparisonClass> AccountHierarchyQueryResult = new List <AccountHierarchyDBComparisonClass>();
            //WaitForDB();
            bool   dbResult = false;
            string query    = string.Empty;
            //int expectedResult = 1;
            string rootNodeUID = AccountHierarchyServiceSteps.parentUID[0].ToString().Replace("-", "");

            query = string.Format(DBQueries.AccountHierarchyCountByRootNodeUID, rootNodeUID);

            LogResult.Report(Log, "log_ForInfo", "Query: " + query);

            List <string> queryResults = GetSQLResults(query);

            if (queryResults.Count != 0)
            {
                if (queryResults[0] != "")
                {
                    LogResult.Report(Log, "log_ForInfo", "Expected Value: " + expectedResult.ToString() + ", Actual Value: " + queryResults[0]);
                    dbResult = queryResults[0].Equals(expectedResult.ToString());
                }
                if (dbResult == false)
                {
                    LogResult.Report(Log, "log_ForError", "DB Verification Failed");
                    return(false);
                }
            }
            else
            {
                LogResult.Report(Log, "log_ForError", "No Rows Returned From DB");
            }
            return(dbResult);
        }
Exemplo n.º 3
0
        public void VerifyResponseSortedByAssetSN()
        {
            List <string>            responseSerialNumbers = new List <string>();
            List <string>            sortedSerialNumbers   = new List <string>();
            AssetDeviceResponseModel response;

            try
            {
                response = JsonConvert.DeserializeObject <AssetDeviceResponseModel>(ResponseString);
            }
            catch (Exception e)
            {
                LogResult.Report(Log, "log_ForError", "Got Error While DeSerializing JSON Object", e);
                throw new Exception("Got Error While DeSerializing JSON Object");
            }

            Assert.AreEqual(1, response.PageNumber);

            foreach (AssetDevice assetdevice in response.AssetDevices)
            {
                responseSerialNumbers.Add(assetdevice.AssetSerialNumber);
                sortedSerialNumbers.Add(assetdevice.AssetSerialNumber);
            }

            sortedSerialNumbers.Sort();

            Assert.IsTrue(responseSerialNumbers.SequenceEqual(sortedSerialNumbers), "Verify the Asset list is sorted based on Asset Serial Number");
        }
Exemplo n.º 4
0
        public static void InitializeKafkaConsumer(IHandler handler)
        {
            CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
            ConsumerSettings        settings = null;

            settings = new ConsumerSettings()
            {
                GroupName    = "CustomerServiceAutomation",
                TopicName    = CustomerServiceConfig.CustomerServiceTopic,
                KafkaUri     = KafkaUri,
                AutoCommit   = true,
                BatchRead    = false,
                ReadAsync    = true,
                ReadFromEnd  = false,
                MaxQueueSize = 50000,
                MaxBatchSize = 2000
            };

            if (KafkaDriver.Equals(RPL))
            {
                CommonConsumer = new RPLConsumer();
            }
            else if (KafkaDriver.Equals(MISAKAI))
            {
                CommonConsumer = new MisakaiConsumer();
            }
            else
            {
                CommonConsumer = new JavaConsumer();
            }

            LogResult.Report(Log, "log_ForInfo", "Kafka Consumer Initialized For " + "Topic: " + CustomerServiceConfig.CustomerServiceTopic);
            KafkaConsumer = Task.Factory.StartNew(() => CommonConsumer.StartConsuming(handler, settings, cancellationTokenSource.Token));
        }
Exemplo n.º 5
0
        public void RetrieveAssetSettings()
        {
            string requestString = string.Empty;
            string asset         = string.Empty;
            var    count         = 1;

            foreach (var assetTarget in createAssetSettingsRequest.assetTargetSettings)
            {
                Convert.ToString(createAssetSettingsRequest.assetTargetSettings.Select(a => a.assetUid));

                asset = "\"" + asset + "\",";
                count = count + 1;
            }
            requestString = "[" + asset + "]";
            if (count == 1)
            {
                requestString.Trim(',');
            }

            GetToken();
            LogResult.Report(Log, "log_ForInfo", "Retrieve Asset Settings: Starts");
            var retrieveAssetSettingsUrl = @"https://api-stg.trimble.com/t/trimble.com/vss-dev-assetservice/1.0/assetsettings/targets/retrieve?" + Convert.ToString(createAssetSettingsRequest.assetTargetSettings.Select(a => a.startDate)) +
                                           "&" + Convert.ToString(createAssetSettingsRequest.assetTargetSettings.Select(a => a.endDate));
            var RetrieveAssetResponse = RestClientUtil.DoHttpRequest(retrieveAssetSettingsUrl, HeaderSettings.PostMethod, AccessToken,
                                                                     HeaderSettings.JsonMediaType, requestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, null);

            RetrieveAssetSettingsResponse = JsonConvert.DeserializeObject <RetrieveAssetSettingsResponse>(RetrieveAssetResponse);
            LogResult.Report(Log, "log_ForInfo", "Retrieve Asset Settings: Ends");
        }
Exemplo n.º 6
0
 public void VerifyErrorResponse(string ErrorMessage)
 {
     try
     {
         CustomerServiceErrorResponseModel error = JsonConvert.DeserializeObject <CustomerServiceErrorResponseModel>(ResponseString);
         string resourceError = CustomerServiceMessages.ResourceManager.GetString(ErrorMessage);
         if (error.ModelState != null)
         {
             if (error.ModelState.CustomerName != null)
             {
                 Assert.AreEqual(resourceError, error.ModelState.CustomerName[0].ToString());
             }
             else if (error.ModelState.CustomerType != null)
             {
                 Assert.AreEqual(resourceError, error.ModelState.CustomerType[0].ToString());
             }
             else if (error.ModelState.BSSID != null)
             {
                 Assert.AreEqual(resourceError, error.ModelState.BSSID[0].ToString());
             }
             else if (error.ModelState.DealerNetwork != null)
             {
                 Assert.AreEqual(resourceError, error.ModelState.DealerNetwork[0].ToString());
             }
             else if (error.ModelState.NetworkDealerCode != null)
             {
                 Assert.AreEqual(resourceError, error.ModelState.NetworkDealerCode[0].ToString());
             }
             else if (error.ModelState.ActionUTC != null)
             {
                 Assert.AreEqual(resourceError, error.ModelState.ActionUTC[0].ToString());
             }
             else if (error.ModelState.NetworkCustomerCode != null)
             {
                 Assert.AreEqual(resourceError, error.ModelState.NetworkCustomerCode[0].ToString());
             }
             else if (error.ModelState.DealerAccountCode != null)
             {
                 Assert.AreEqual(resourceError, error.ModelState.DealerAccountCode[0].ToString());
             }
             else if (error.ModelState.CustomerUID != null)
             {
                 Assert.AreEqual(resourceError, error.ModelState.CustomerUID[0].ToString());
             }
             else
             {
                 Assert.AreEqual(CustomerServiceMessages.ResourceManager.GetString("ERR_Invalid"), error.Message);
             }
         }
         else
         {
             Assert.AreEqual(resourceError, error.Message);
         }
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Got Error While DeSerializing JSON Object", e);
         throw new Exception("Got Error While DeSerializing JSON Object");
     }
 }
Exemplo n.º 7
0
        public void RetrieveProductivityDetails()
        {
            string requestString = string.Empty;

            requestString = JsonConvert.SerializeObject(CreateProductitvityResponse);
            requestString = requestString.Replace("\"assetUID\":", "");
            requestString = requestString.Replace("{", "");
            requestString = requestString.Replace("}", "");


            try
            {
                GetToken();
                LogResult.Report(Log, "log_ForInfo", "Create Asset Productivity: Starts");
                var ProductivityResponse = RestClientUtil.DoHttpRequest(AssetServiceConfig.RetrieveProductivityDetailsEndpoint + "?startdate=" + CreateproductivityTargetsRequest.assettargets.Select(a => a.startdate).FirstOrDefault() + "&enddate=" + CreateproductivityTargetsRequest.assettargets.Select(a => a.enddate).FirstOrDefault(), HeaderSettings.PostMethod, AccessToken,
                                                                        HeaderSettings.JsonMediaType, requestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, null);
                retrieveProductivityDetails = JsonConvert.DeserializeObject <RetrieveProductivityDetails>(ProductivityResponse);
                LogResult.Report(Log, "log_ForInfo", "Create Asset Productivity: Ends");
            }
            catch (Exception e)
            {
                LogResult.Report(Log, "log_ForError", "Exception Occured while creating asset settings" + CreateproductivityTargetsRequest.assettargets.Select(a => a.assetuid));
                throw new Exception("Exception Occured while creating asset productivity \n");
            }
        }
Exemplo n.º 8
0
 public void VerifyErrorResponse(string ErrorMessage)
 {
     try
     {
         CustomerRelationshipErrorResponseModel error = JsonConvert.DeserializeObject <CustomerRelationshipErrorResponseModel>(ResponseString);
         string resourceError = CustomerServiceMessages.ResourceManager.GetString(ErrorMessage);
         if (error.ModelState != null)
         {
             if (error.ModelState.createCustomerRelationshipEvent != null)
             {
                 Assert.AreEqual(resourceError, error.ModelState.createCustomerRelationshipEvent[0].ToString());
             }
             else
             {
                 Assert.AreEqual(CustomerServiceMessages.ResourceManager.GetString("ERR_Invalid"), error.Message);
             }
         }
         else
         {
             Assert.AreEqual(resourceError, error.Message);
         }
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Got Error While DeSerializing JSON Object", e);
         throw new Exception("Got Error While DeSerializing JSON Object");
     }
 }
Exemplo n.º 9
0
        public void AssociateAssetDevice()
        {
            Guid.TryParse(AssetUID, out AssetUidGuid);
            associateAssetDevice = new AssociateAssetDevice
            {
                DeviceUID   = defaultValidDeviceServiceCreateModel.DeviceUID,
                AssetUID    = AssetUidGuid,
                ReceivedUTC = DateTime.Now,
                ActionUTC   = DateTime.Now
            };
            var requestString = JsonConvert.SerializeObject(associateAssetDevice);

            try
            {
                GetToken(true);
                var response = RestClientUtil.DoHttpRequest(AssetServiceConfig.DeviceAssetAssociationEndpoint, HeaderSettings.PostMethod, AccessToken,
                                                            HeaderSettings.JsonMediaType, requestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, null);
                LogResult.Report(Log, "log_ForInfo", "Device Asset Association ends-Success ");
            }

            catch (Exception e)
            {
                LogResult.Report(Log, "log_ForError", "Exception Occured while associating asset to device" + "AssetUID-" + AssetUidGuid + "DeviceUID-" + defaultValidDeviceServiceCreateModel.DeviceUID);
                throw new Exception("Exception Occured while associating asset to device" + "AssetUID - " + AssetUidGuid + "DeviceUID - " + defaultValidDeviceServiceCreateModel.DeviceUID);
            }
        }
Exemplo n.º 10
0
 public void PostAssociateAssetDevice()
 {
     responseModel = null;
     //CustomHeaders = new Dictionary<string, string>();
     // if (string.IsNullOrEmpty(AccessToken))
     GetToken();
     try
     {
         string AssociateAssetDeviceRequestString = GetAssociateAssetDeviceRequestString();
         //CustomHeaders.Add(CustomerUid, CustomerUID);
         LogResult.Report(Log, "log_ForInfo", "Request string: " + AssociateAssetDeviceRequestString);
         LogResult.Report(Log, "log_ForInfo", "Post to URL: " + AssetServiceConfig.DeviceAssetAssociationEndpoint);
         ResponseString = RestClientUtil.DoHttpRequest(AssetServiceConfig.DeviceAssetAssociationEndpoint, HeaderSettings.PostMethod, AccessToken, HeaderSettings.JsonMediaType, AssociateAssetDeviceRequestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, CustomHeaders);
         LogResult.Report(Log, "log_ForInfo", "Response Recieved: " + ResponseString);
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Got Error While Getting Data From AlertsManager Service", e);
         throw new Exception(e + " Got Error While Getting Data From AlertsManager Service");
     }
     try
     {
         //responseModel = JsonConvert.DeserializeObject<ResponseModel>(ResponseString);
         LogResult.Report(Log, "log_ForInfo", "Deserialized the response");
     }
     catch (Exception e)
     {
         //LogResult.Report(Log, "log_ForError", "Got Error While DeSerializing JSON Object", e);
         throw new Exception(e + " Got Error While DeSerializing JSON Object");
     }
     //return responseModel;
 }
Exemplo n.º 11
0
 public MileageTargetAPIResponse PostMileageTargetRequest()
 {
     mileageTargetAPIRequest = null;
     //CustomHeaders = new Dictionary<string, string>();
     // if (string.IsNullOrEmpty(AccessToken))
     GetToken();
     try
     {
         string MileageTargetRequestString = GetRequestString();
         //CustomHeaders.Add(CustomerUid, CustomerUID);
         LogResult.Report(Log, "log_ForInfo", "Request string: " + MileageTargetRequestString);
         LogResult.Report(Log, "log_ForInfo", "Post to URL: " + AssetServiceConfig.FuelBurnRateAPI);
         ResponseString = RestClientUtil.DoHttpRequest(AssetServiceConfig.FuelBurnRateAPI, HeaderSettings.PostMethod, AccessToken, HeaderSettings.JsonMediaType, MileageTargetRequestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, CustomHeaders);
         LogResult.Report(Log, "log_ForInfo", "Response Recieved: " + ResponseString);
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Got Error While Getting Data From AlertsManager Service", e);
         throw new Exception(e + " Got Error While Getting Data From AlertsManager Service");
     }
     try
     {
         mileageTargetAPIResponse = JsonConvert.DeserializeObject <MileageTargetAPIResponse>(ResponseString);
         LogResult.Report(Log, "log_ForInfo", "Deserialized the response");
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Got Error While DeSerializing JSON Object", e);
         throw new Exception(e + " Got Error While DeSerializing JSON Object");
     }
     return(mileageTargetAPIResponse);
 }
Exemplo n.º 12
0
        public void GivenFuelBurntRateIsReadyToVerify(string testDescription)
        {
            string testName = string.Empty;

            testName = (ScenarioContext.Current.ScenarioInfo).Title.ToString() + "_" + testDescription;
            LogResult.Report(Log, "log_ForInfo", "Execution started for Test Scenario " + testName);
        }
Exemplo n.º 13
0
        public void PostFuelBurntRate(bool isvalid = true)
        {
            var requestString = JsonConvert.SerializeObject(fuelRequest);

            try
            {
                LogResult.Report(Log, "log_ForInfo", "Create Fuel Burnt rate: Starts");
                string accessToken = AssetServiceConfig.GetValidUserAccessToken();
                string response;
                SetCustomerUIDHeader(AssetServiceConfig.CustomerUID);
                if (isvalid)
                {
                    response = RestClientUtil.DoHttpRequest(AssetServiceConfig.FuelBurnRateAPI, HeaderSettings.PutMethod, accessToken, HeaderSettings.JsonMediaType, requestString,
                                                            HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, CustomHeaders);
                }
                else
                {
                    response = RestClientUtil.DoInvalidHttpRequest(AssetServiceConfig.FuelBurnRateAPI, HeaderSettings.PutMethod, accessToken, HeaderSettings.JsonMediaType, requestString,
                                                                   HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, CustomHeaders);
                }
                fuelResponse = JsonConvert.DeserializeObject <FuelBurntRateResponse>(response);
                LogResult.Report(Log, "log_ForInfo", "Create Fuel Burnt rate: Ends");
            }
            catch (Exception e)
            {
                LogResult.Report(Log, "log_ForError", "Exception Occured while creating fuel burnt rate " + e);
                throw new Exception("Exception Occured while creating  creating fuel burnt rate \n");
            }
        }
Exemplo n.º 14
0
        public static void ProduceMessage(string message, string key = "")
        {
            PayloadMessage payloadMessage = new PayloadMessage
            {
                Value = message,
                Key   = key
            };

            switch (KafkaDriver)
            {
            case JAVA:
                Console.WriteLine("In JavaPublisher");
                LogResult.Report(Log, "log_ForInfo", "In JavaPublisher");
                if (JavaPublisher != null)
                {
                    JavaPublisher.Publish(payloadMessage);
                }
                else
                {
                    Console.WriteLine("Javapublisher is null " + JavaPublisher);
                    LogResult.Report(Log, "log_ForInfo", "Javapublisher is null" + JavaPublisher);
                }
                break;
            }
        }
Exemplo n.º 15
0
        private void WaitForKafkaResponseAfterDelete(bool isPositiveCase = true)
        {
            int i = 0;

            if (!isPositiveCase)
            {
                LogResult.Report(Log, "log_ForInfo", "Expecting No Response From Kafka");
            }
            else
            {
                LogResult.Report(Log, "log_ForInfo", "Waiting " + KafkaServicesConfig.InitialWaitingTimeForReceivingResponseInSeconds + " seconds For Kafka Response");
            }
            for (i = 0; i < KafkaServicesConfig.InitialWaitingTimeForReceivingResponseInSeconds; i++)
            {
                if (DeleteCustomerModel.CustomerUID != Guid.Empty)
                {
                    if (customerServiceDeleteResponse != null)
                    {
                        break;
                    }
                }
                Thread.Sleep(1000);
            }
            if (i >= KafkaServicesConfig.InitialWaitingTimeForReceivingResponseInSeconds && isPositiveCase)
            {
                LogResult.Report(Log, "log_ForError", "Got Error While Waiting For Kafka Response");
                throw new Exception("Got Error While Waiting For Kafka Response");
            }
        }
Exemplo n.º 16
0
 public void GivenCustomerAssetServiceIsReadyToVerify(string TestDescription)
 {
     //log the scenario info
     TestName = (ScenarioContext.Current.ScenarioInfo).Title + "_" + TestDescription;
     //TestName = TestDescription;
     LogResult.Report(Log, "log_ForInfo", "Execution started for Test Scenario" + TestName);
 }
Exemplo n.º 17
0
        public List <string> GetSQLResults(string queryString)
        {
            MySqlDataReader dataReader = null;
            List <string>   dbResult   = new List <string>();

            using (MySqlConnection mySqlConnection = new MySqlConnection(MySqlConnectionString))
            {
                try
                {
                    //Open connection
                    mySqlConnection.Open();
                    //Execute the SQL query
                    MySqlCommand mySqlCommand = new MySqlCommand(queryString, mySqlConnection);
                    //Read the results into a SqlDataReader and store in string variable for later reference
                    dataReader = mySqlCommand.ExecuteReader();
                    while (dataReader != null && dataReader.Read())
                    {
                        if (dataReader.HasRows)
                        {
                            for (int i = 0; i < dataReader.VisibleFieldCount; i++)
                            {
                                dbResult.Add(dataReader[i].ToString());
                            }
                        }
                        //dataReader.ToString();
                    }
                }
                catch (Exception e)
                {
                    LogResult.Report(Log, "log_ForError", "Got error while executing db query", e);
                    throw new InvalidDataException("Error Occurred while executing db query");
                }
            };
            return(dbResult);
        }
Exemplo n.º 18
0
 public void GivenSAVSubscriptionServiceIsReadyToVerify(string testDescription)
 {
     TestDescription = testDescription;
     TestName        = (ScenarioContext.Current.ScenarioInfo).Title + "_" + testDescription;
     //TestName = TestDescription;
     LogResult.Report(Log, "log_ForInfo", "Execution started for Test Scenario" + TestName);
     SubscriptionType.Add("Essentials");
 }
Exemplo n.º 19
0
 public static void DisposeConsumer()
 {
     if (KafkaDriver.Equals(RPL))
     {
         CommonConsumer.Dispose();
         LogResult.Report(Log, "log_ForInfo", "Kafka Consumer Disposed");
     }
 }
Exemplo n.º 20
0
 public static void DisposePublisher()
 {
     if (KafkaDriver.Equals(RPL))
     {
         //RPLPublisher.Dispose();
         LogResult.Report(Log, "log_ForInfo", "Kafka Publisher Disposed");
     }
 }
Exemplo n.º 21
0
        public static void WaitForDB()
        {
            int InitialWaitingTimeForReceivingResponseInSeconds = int.Parse(ConfigurationManager.AppSettings["InitialWaitingTimeForReceivingResponseInSeconds"]);

            LogResult.Report(Log, "log_ForInfo", "Waiting " + InitialWaitingTimeForReceivingResponseInSeconds + " seconds for DB");
            for (int i = 1; i <= InitialWaitingTimeForReceivingResponseInSeconds; i++)
            {
                Thread.Sleep(1000);
            }
        }
Exemplo n.º 22
0
        public void GetDeviceTypeCustomerNull()
        {
            LogResult.Report(Log, "log_ForInfo", "GetDeviceTypeDetails: Starts for Customer" + CustomerUID);
            GetToken(false);
            CustomHeaders.Add(CustomerUid, "");
            var ResponseJSON = RestClientUtil.DoInvalidHttpRequest(AssetServiceConfig.GetDeviceType, HeaderSettings.GetMethod, AccessToken, HeaderSettings.JsonMediaType, null, HttpStatusCode.BadRequest, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, CustomHeaders);

            deviceTypeResponse = JsonConvert.DeserializeObject <DeviceTypeResponse>(ResponseJSON);
            LogResult.Report(Log, "log_ForInfo", "GetDeviceTypeDetails: Ends for Customer" + CustomerUID);
        }
Exemplo n.º 23
0
 public void ThenTheDeviceUpdatedDetailsMustBeStoredInMySqlDB()
 {
     try
     {
         Assert.IsTrue(deviceServiceSupport.ValidateDB("UpdateEvent"), "DB Verification failed");
         LogResult.Report(Log, "log_ForInfo", "DB Validation Successful\n");
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Got Error While Validating DB", e);
         throw new Exception(e + "Got Error While Validating DB\n");
     }
 }
Exemplo n.º 24
0
 public void GetAccountHierarchyByUserUID()
 {
     // AccountHierarchyByUserUIDResponseString
     try
     {
         LogResult.Report(Log, "log_ForInfo", "Performing Get Account Hierarchy By User UID");
         AccountHierarchyByUserUIDResponseString = RestClientUtil.DoHttpRequest(CustomerServiceConfig.AccountHierarchyByUserUIDEndPoint, HeaderSettings.GetMethod, accessToken, HeaderSettings.JsonMediaType, null, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Got Error While Performing Get Account Hierarchy By User UID", e);
         throw new Exception(e + " Got Error While Performing Get Account Hierarchy By User UID");
     }
 }
Exemplo n.º 25
0
        public bool ValidateDB()
        {
            string query;
            bool   dbResult = false;
            string DBResultCustomerUID;
            string DBResultStartDate;
            string DBResultEndDate;
            string DBResultSubscriptionSource;

            for (int i = 0; i < SAVSubscriptionDBValidation.Count(); i++)
            {
                MySqlDataReader dataReader = null;
                //List<string> dbResult = new List<string>();
                query = string.Format(SAVSubscriptionSqlQueries.SAVSubscriptionByAssetUID, SAVSubscriptionDBValidation[i].AssetUID.Replace("-", ""), SAVSubscriptionDBValidation[i].SubscriptionUID.Replace("-", ""));
                using (MySqlConnection mySqlConnection = new MySqlConnection(SubscriptionServiceConfig.MySqlConnection))
                {
                    try
                    {
                        //Open connection
                        mySqlConnection.Open();
                        //Execute the SQL query
                        MySqlCommand mySqlCommand = new MySqlCommand(query, mySqlConnection);
                        dataReader = mySqlCommand.ExecuteReader();
                        while (dataReader != null && dataReader.Read())
                        {
                            if (dataReader.HasRows)
                            {
                                DBResultCustomerUID        = dataReader[0].ToString();
                                DBResultStartDate          = dataReader[1].ToString();
                                DBResultEndDate            = dataReader[2].ToString();
                                DBResultSubscriptionSource = dataReader[3].ToString();

                                Assert.AreEqual(SAVSubscriptionDBValidation[i].CustomerUID.Replace("-", "").ToUpper(), DBResultCustomerUID, "Customer DB Validation Fail");
                                Assert.AreEqual(SAVSubscriptionDBValidation[i].StartDate, DBResultStartDate, "Start Date VAlidation Fail");
                                Assert.AreEqual(SAVSubscriptionDBValidation[i].EndDate, DBResultEndDate, "End Date Validation Fail");
                                Assert.AreEqual(SAVSubscriptionDBValidation[i].SubscriptionSource.ToString(), DBResultSubscriptionSource, "Subscription Source Validation Fail");

                                dbResult = true;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        LogResult.Report(SAVSubscriptionSteps.Log, "log_ForError", "Got error while executing db query", e);
                        return(dbResult);
                    }
                }
            }
            return(dbResult);
        }
Exemplo n.º 26
0
 public void PostAssociateAssetCustomer()
 {
     try
     {
         string AssociateAssetCustomerRequest = GetAssociateAssetCustomerRequestString();
         string AssociateAssetCustomer        = "https://api-stg.trimble.com/t/trimble.com/vss-dev-customerservice/1.0/AssociateCustomerAsset";
         var    Responsestring = RestClientUtil.DoHttpRequest(AssociateAssetCustomer, HeaderSettings.PostMethod, AccessToken, HeaderSettings.JsonMediaType, AssociateAssetCustomerRequest, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, null);
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Exception Occured while associating asset to device" + "AssetUID-" + createAssetEvent.AssetUID + "Customer-" + associateAssetCustomer.CustomerUID);
         throw new Exception("Exception Occured while associating asset to device" + "AssetUID-" + createAssetEvent.AssetUID + "Customer-" + associateAssetCustomer.CustomerUID);
     }
 }
Exemplo n.º 27
0
 public void GetToken()
 {
     {
         AccessToken = TokenService.GetAccessToken("https://identity-stg.trimble.com/token?grant_type=password&username=alagammai_annamalai%2b10035%40trimble.com&password=Sanjayalagi12%40", ConsumerKey, ConsumerSecret);
         if (!string.IsNullOrEmpty(AccessToken))
         {
             LogResult.Report(Log, "log_ForInfo", "AccessToken: " + AccessToken);
         }
         else
         {
             LogResult.Report(Log, "log_ForError", "AccessToken is empty or null");
             throw new Exception("AccessToken is empty or null\n");
         }
     }
 }
Exemplo n.º 28
0
        public void VerifyErrorResponse()
        {
            AssetDeviceErrorResponseModel response;

            try
            {
                response = JsonConvert.DeserializeObject <AssetDeviceErrorResponseModel>(ResponseString);
            }
            catch (Exception e)
            {
                LogResult.Report(Log, "log_ForError", "Got Error While DeSerializing JSON Object", e);
                throw new Exception("Got Error While DeSerializing JSON Object");
            }
            Assert.AreEqual("Invalid input", response.Message);
        }
Exemplo n.º 29
0
        public void VerifyInvalidResponse()
        {
            try
            {
                getAssetSettingsResponse = JsonConvert.DeserializeObject <GetAssetSettingsResponseModel>(ResponseJSON);
                var result = getAssetSettingsResponse.assetSettings.Find(x => x.assetUid == CreateAsset.AssetUID);
                Assert.AreEqual(null, result);
            }
            catch (Exception e)

            {
                LogResult.Report(Log, "log_ForError", "Exception Occured while  deserializing  getAssetSettingsResponse " + e);
                throw new Exception("Exception Occured while deserializing  getAssetSettingsResponse \n");
            }
        }
Exemplo n.º 30
0
 public string PostValidReadRequestToService(string accessToken)
 {
     try
     {
         LogResult.Report(Log, "log_ForInfo", "Reading the list of available geofences for the user accesstoken the request with Valid Values: " + accessToken);
         string ResponseString = RestClientUtil.DoHttpRequest(CustomerServiceConfig.CustomerServiceEndpoint + "/accounthierarchy", HeaderSettings.GetMethod, accessToken,
                                                              HeaderSettings.JsonMediaType, null, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
         return(ResponseString);
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Got Error While Posting Data To Geofence Service", e);
         throw new Exception(e + " Got Error While Posting Data To Geofence Service");
     }
 }