Beispiel #1
0
        public void WhenIPostInValidCustomerListWebApiGetUserCustomerListRequest(string invalidAccessToken)
        {
            string accessToken = InputGenerator.GetValue(invalidAccessToken);

            ResponseString = RestClientUtil.DoInvalidHttpRequest(CustomerListConfig.CustomerListWebAPI, HeaderSettings.GetMethod, accessToken,
                                                                 HeaderSettings.JsonMediaType, null, HttpStatusCode.Unauthorized, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
        }
Beispiel #2
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");
            }
        }
Beispiel #3
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);
        }
Beispiel #4
0
 public void PostInValidDeleteRequestToService(string customerUid, string actionUtc, string contentType, HttpStatusCode actualResponse)
 {
     try
     {
         string accessToken = CustomerServiceConfig.GetValidUserAccessToken();
         LogResult.Report(Log, "log_ForInfo", "Posting the request with Valid Values: " + customerUid);
         ResponseString = RestClientUtil.DoInvalidHttpRequest(string.Format("{0}?CustomerUID={1}&ActionUTC={2}", CustomerServiceConfig.CustomerServiceEndpoint, customerUid, actionUtc),
                                                              HeaderSettings.DeleteMethod, accessToken,
                                                              contentType, null, actualResponse, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
     }
     catch (Exception e)
     {
         LogResult.Report(Log, "log_ForError", "Got Error While Posting Data To Customer Service", e);
         throw new Exception(e + " Got Error While Posting Data To Customer Service");
     }
 }
Beispiel #5
0
        public void PostInValidUpdateRequestToService(string contentType, HttpStatusCode actualResponse)
        {
            string requestString = JsonConvert.SerializeObject(InvalidUpdateCustomerModel);

            try
            {
                string accessToken = CustomerServiceConfig.GetValidUserAccessToken();
                LogResult.Report(Log, "log_ForInfo", "Posting the request with Valid Values: " + requestString);
                ResponseString = RestClientUtil.DoInvalidHttpRequest(CustomerServiceConfig.CustomerServiceEndpoint, HeaderSettings.PutMethod, accessToken,
                                                                     contentType, requestString, actualResponse, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
            }
            catch (Exception e)
            {
                LogResult.Report(Log, "log_ForError", "Got Error While Posting Data To Customer Service", e);
                throw new Exception(e + " Got Error While Posting Data To Customer Service");
            }
        }
Beispiel #6
0
        public void InvalidPutRequest()
        {
            var requestString = JsonConvert.SerializeObject(CreateproductivityTargetsRequest);

            try
            {
                GetToken();
                LogResult.Report(Log, "log_ForInfo", "Create Asset Productivity: Starts");
                var ProductivityResponse = RestClientUtil.DoInvalidHttpRequest(AssetServiceConfig.CreateProductivityDetailsEndpoint, HeaderSettings.PutMethod, AccessToken,
                                                                               HeaderSettings.JsonMediaType, requestString, HttpStatusCode.BadRequest, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, null);
                CreateProductitvityResponse = JsonConvert.DeserializeObject <ProductivityTargetsResponseModel>(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");
            }
        }
Beispiel #7
0
        public void GetAssetDeviceList(string searchType = null, string pageNo = null, string pageSize = null)
        {
            createAssetEvent = AssetServiceSteps.assetServiceSupport.CreateAssetModel;
            string searchString = string.Empty;
            string requestType  = string.Empty;

            if (searchType == "AssetSN")
            {
                searchString = createAssetEvent.SerialNumber;
            }
            else if (searchType == "AssetName")
            {
                searchString = createAssetEvent.AssetName;
            }
            else if (searchType == "DeviceSN")
            {
                searchString = CreateDeviceModel.DeviceSerialNumber;
            }
            else if (searchType == "AssetSNSorting" || searchType == "Valid")
            {
                searchString = validSearchString;
            }
            else if (searchType == "Wrong")
            {
                searchString = wrongSearchString;
            }
            else
            {
                searchString = searchType;
            }

            if (pageNo == "Valid")
            {
                pageNo = validPageNo;
            }
            else if (pageNo == "Invalid")
            {
                pageNo      = invalidPageNo;
                requestType = "Invalid";
            }
            else if (pageNo == "Wrong")
            {
                pageNo = wrongPageNo;
            }
            else if (pageNo == "0" || pageNo == "-1")
            {
                requestType = "Invalid";
            }

            if (pageSize == "Valid")
            {
                pageSize = validPageSize;
            }
            else if (pageSize == "Invalid")
            {
                pageSize    = invalidPageSize;
                requestType = "Invalid";
            }
            else if (pageSize == "Wrong")
            {
                pageSize = wrongPageSize;
            }
            else if (pageSize == "0" || pageSize == "-1")
            {
                requestType = "Invalid";
            }


            string parameters = string.Empty;

            if (searchString != null && pageNo == null && pageSize == null)
            {
                parameters = "?" + AssetServiceConfig.SearchString + "=" + searchString;
            }
            else if (searchString == null && pageNo != null && pageSize == null)
            {
                parameters = "?" + AssetServiceConfig.PageNo + "=" + pageNo;
            }
            else if (searchString == null && pageNo == null && pageSize != null)
            {
                parameters = "?" + AssetServiceConfig.PageSize + "=" + pageSize;
            }
            else if (searchString != null && pageNo != null && pageSize == null)
            {
                parameters = "?" + AssetServiceConfig.SearchString + "=" + searchString + "&" + AssetServiceConfig.PageNo + "=" + pageNo;
            }
            else if (searchString != null && pageNo == null && pageSize != null)
            {
                parameters = "?" + AssetServiceConfig.SearchString + "=" + searchString + "&" + AssetServiceConfig.PageSize + "=" + pageSize;
            }
            else if (searchString == null && pageNo != null && pageSize != null)
            {
                parameters = "?" + AssetServiceConfig.PageNo + "=" + pageNo + "&" + AssetServiceConfig.PageSize + "=" + pageSize;
            }
            else if (searchString != null && pageNo != null && pageSize != null)
            {
                parameters = "?" + AssetServiceConfig.SearchString + "=" + searchString + "&" + AssetServiceConfig.PageNo + "=" + pageNo + "&" + AssetServiceConfig.PageSize + "=" + pageSize;
            }
            else if (searchString == null && pageNo == null && pageSize == null)
            {
                parameters = "";
            }

            try
            {
                string accessToken = AssetServiceConfig.GetValidUserAccessToken();
                LogResult.Report(Log, "log_ForInfo", "Getting the AssetDetail Values:");
                if (requestType == "Invalid")
                {
                    ResponseString = RestClientUtil.DoInvalidHttpRequest(AssetServiceConfig.AssetSearchEndpoint + parameters, HeaderSettings.GetMethod, accessToken,
                                                                         HeaderSettings.JsonMediaType, null, HttpStatusCode.BadRequest, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
                }
                else
                {
                    ResponseString = RestClientUtil.DoHttpRequest(AssetServiceConfig.AssetSearchEndpoint + parameters, HeaderSettings.GetMethod, accessToken,
                                                                  HeaderSettings.JsonMediaType, null, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType);
                }
            }
            catch (Exception e)
            {
                LogResult.Report(Log, "log_ForError", "Got Error While Getting Data from Asset Device Search Service", e);
                throw new Exception(e + " Got Error While Getting Data from Asset Device Search Service");
            }
        }