public static PrivateData <List <int> > PrepareProcessRecords(int numberOfRecords, int firstRef, int secondeRef, PrivateData <List <int> > processPhaseOption, PrivateData <int> endFlagId, HrbcRecordCreator refRecordsCreator) { return(new PrivateData <List <int> >( (session, test) => { return Task.Run(() => { var result = new List <int>(); var fieldHandler = new FieldManager(); var fields = fieldHandler.GetFieldGuid(ResourceFields.RequireFields[TestCoreFramework.Enums.ResourceType.Process].Append("P_Close"), new[] { TestCoreFramework.Enums.ResourceType.Process }) .Result.Result.ToDictionary(x => $"{char.ToUpper(x.Resource[0]) + x.Resource.Substring(1)}.{x.Alias}", x => (int)UuidUtil.GetId(x.Id)); var recordHandler = new RecordManager(); var request = RecordRequestComposer.ComposeCreateRequest(); for (int i = 0; i < numberOfRecords; i++) { request = request.Append(TestCoreFramework.Enums.ResourceType.Process, CreateResourceRequiredFieldData(fields, ((i % 3) == 0), endFlagId.Data, 1, ((i % 3) == 1) ? processPhaseOption.Data.Last() : processPhaseOption.Data.First(), i, ((i % 2) == 0) ? firstRef : secondeRef, refRecordsCreator)); } var response = recordHandler.WriteRecords(request.Result); PrAssume.That(response, PrIs.SuccessfulResponse()); PrAssume.That(response.Result, PrIs.Not.Null); PrAssume.That(response.Result.Ids[0][0], PrIs.Not.Null); result = response.Result.Ids.Select(id => id[0]).ToList(); return result; }); }, (session, test, res) => Task.Run(() => { var recordHandler = new RecordManager(); recordHandler.DeleteRecords( RecordRequestComposer.ComposeDeleteRequest(TestCoreFramework.Enums.ResourceType.Process, res)); }))); }
public static PrivateData <object> PrepareReferenceField(List <ResourceId> resources, HrbcFieldCreator fieldsCreator, int indexReferenceField, Dictionary <ResourceId, Dictionary <ResourceId, Guid> > guidsForUpdate) { return(new PrivateData <object>( (session, test) => { return Task.Run <object>(() => { var handler = new FieldManager(); var guids = new Dictionary <ResourceId, Guid>(); foreach (var resource in resources) { foreach (var refResource in Defines.ReferenceResource[resource]) { var response = handler.CreateField(resource, new Dictionary <string, object> { [Properties.PropertyName.SType.GetEnumStringValue()] = Defines.FieldTypeApi, [Properties.PropertyName.Label.GetEnumStringValue()] = CommonMapperValue.LabelMapperValue[Properties.Label.Min], [Properties.PropertyName.Field.GetEnumStringValue()] = UuidUtil.GetId(fieldsCreator.Data[$"{refResource}-{FieldType.Mail.ToString()}-{indexReferenceField}"].Guid) }); PrAssume.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK)); guids[refResource] = response.Result.Id; } guidsForUpdate[resource] = guids; } return new object(); }); }, (session, test, res) => Task.Run(() => { //Clearn up CommonHelpers.DeleteField(guidsForUpdate.Values.SelectMany(x => x.Select(y => y.Value))); }))); }
public static PrivateData <int> GetMailServer() { return(new PrivateData <int>( (session, test) => { return Task.Run(() => { var handler = new DefaultManager(); var request = new Dictionary <string, object>(); ValidIncomingMapperValue[Valid.Porters](request, Server); ValidIncomingMapperValue[Valid.POP3Port](request, Port); ValidIncomingMapperValue[Valid.Zero](request, Ssl); ValidIncomingMapperValue[Valid.POP3Protocol](request, Protocol); var response = handler.Send <CreateMailServerResponse>(MailServer.Server, request.ToJson(), HttpMethod.POST); PrAssume.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create mail server"); return response.Result.Id; }); }, (session, test, res) => Task.Run(() => { var handler = new DefaultManager(); var deleteRequest = new Dictionary <string, object>() { [MailServerTestData.Id] = res }; var delete = handler.Send <object>(MailServer.Server, deleteRequest.ToJson(), HttpMethod.DELETE); PrAssert.That(delete, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent), "Can not delete mail server"); }))); }
public static PrivateData <object> GetPhaseOptionCustomFixture() { return(new PrivateData <object>( (session, test) => { return Task.Run(() => { var optionHandler = new OptionManager(); foreach (ResourceId resource in Enum.GetValues(typeof(ResourceId)).Cast <ResourceId>().Except(new[] { ResourceId.None, ResourceId.Contract })) { var response = optionHandler.SearchOption($"Option.P_{resource}Phase"); var requestDic = CreatePhaseRequest(response.Result.Single().Type, $"My {resource}", response.Result.Single().Id); var result = optionHandler.CreateOption(requestDic); PrAssume.That(result, PrIs.SuccessfulResponse(), "Cannot prepare option"); result.Result.Single(); ValidPhaseIdMapper[resource] = new Dictionary <ValidPhaseId, int>(); ValidPhaseIdMapper[resource][ValidPhaseId.PhaseId] = response.Result.Single().Id; ValidPhaseIdMapper[resource][ValidPhaseId.ChildId] = result.Result.Single().Id; ValidPhaseIdMapper[resource][ValidPhaseId.GrandChildId] = result.Result.Single().Children.Single().Id; } return new object(); }); }, (session, test, res) => Task.Run(() => { var optionHandler = new OptionManager(); foreach (ResourceId resource in Enum.GetValues(typeof(ResourceId)).Cast <ResourceId>().Except(new[] { ResourceId.None, ResourceId.Contract })) { var deleteResponse = optionHandler.DeleteOption(ValidPhaseIdMapper[resource][ValidPhaseId.GrandChildId]); PrAssume.That(deleteResponse, PrIs.SuccessfulResponse()); deleteResponse = optionHandler.DeleteOption(ValidPhaseIdMapper[resource][ValidPhaseId.ChildId]); PrAssume.That(deleteResponse, PrIs.SuccessfulResponse()); } }))); }
public static List <int> GetFlow(int id, Flow flow) { var handler = new OptionManager(); var response = handler.SearchOption(id); PrAssume.That(response, PrIs.SuccessfulResponse()); var result = new List <int>(); result.Add(id); result.AddRange(response.Result.Single().Children.Select(c => c.Id)); switch (flow) { case Flow.OneId: return(result.Take(1).ToList()); case Flow.TwoId: return(result.Take(2).ToList()); case Flow.ThreeId: return(result.Take(3).ToList()); case Flow.AllId: return(result); default: return(result); } }
public static PrivateData <Dictionary <int, List <SublistMenuHandlingComponent.DataContract.Value> > > GetValueList() { return(new PrivateData <Dictionary <int, List <SublistMenuHandlingComponent.DataContract.Value> > >( (session, test) => { return Task.Run(() => { var result = new Dictionary <int, List <SublistMenuHandlingComponent.DataContract.Value> >(); var defaulthandler = new DefaultManager(); var allMenus = defaulthandler.SendAsync <MenusResponseData>(SublistMenuTestData.MenusEndPoint, new Dictionary <string, string>(), HttpMethod.GET).Result; PrAssume.That(allMenus, PrIs.SuccessfulResponse()); foreach (var menuId in allMenus.Result.Values.Select(value => value.Value.Id)) { var handler = new HrbcSublistManager(); var sublists = handler.SublistsMenu <SublistsMenuResponse>(new Dictionary <string, string> { ["menu_id"] = menuId.ToString() }, HttpMethod.GET.ToNetHttpMethod()); PrAssume.That(sublists, PrIs.SuccessfulResponse()); result.Add(menuId, sublists.Result.Values.Select(sublist => sublist.Value).ToList()); } return result; }); }, (session, test, res) => Task.Run(() => { }))); }
private int UploadFile(Dictionary <string, string> urlParameters, string endpoint, string filePath, string fileName = null) { fileName = fileName ?? filePath.Split('/').Last(); var fileBytes = System.IO.File.ReadAllBytes(System.IO.Path.Combine(Util.GetTestDirectory(), filePath)); if (!Connection.IsAuthenticated) { Connection.Authenticate(); } var token = Connection.GetCookieValue("YII_CSRF_TOKEN").Split(new[] { "%22" }, StringSplitOptions.RemoveEmptyEntries)[1]; var multipartData = new List <MultipartFormContentItem> { new MultipartFormContentItem { Content = token, Name = "YII_CSRF_TOKEN" }, new MultipartFormContentItem { Content = fileBytes, FileName = fileName, Name = "files" } }; using (LogHelper.LoggerForCurrentTest.EnterReproStep("Uploading a file using legacy PHP endpoint")) { var parsedResponse = ProcessResponseWithContent <FileUploadLegacyResponse>(Connection.SendAsync(endpoint, urlParameters, multipartData, HttpMethod.Post).Result); PrAssume.That(parsedResponse, PrIs.SuccessfulResponse(), "Failed to upload file -- the response from the server was not successful"); PrAssume.That(parsedResponse.Result.Status, PrIs.EqualTo("success").Or.EqualTo("Success"), "Failed to upload file -- the response status was not 'success'"); PrAssume.That(parsedResponse.Result.Error, PrIs.Null, $"Error when uploading file: {parsedResponse.Result.Error}"); return(Convert.ToInt32(GetIdRegex.Match(parsedResponse.Result.Script).Groups["id"].Value)); } }
private void CreateConfigurationService(string service, string id, string body) { var handler = new ConfigurationServiceManager(); var response = handler.ConfigurationService <object>(service, id, body, System.Net.Http.HttpMethod.Put); PrAssume.That(response, PrIs.SuccessfulResponse()); }
public void ReadRecordForDeletedResourceTest() { PrivateApiResponse <RecordsHandlingComponent.DataContract.RecordsCreateOrDeleteResponseItem> recordResponse = null; var recordHandler = new RecordManager(); var fieldHandler = new FieldManager(); var fields = fieldHandler.GetFieldGuid(new[] { "P_Name", "P_Owner" }, new[] { Porters.TestCoreFramework.Enums.ResourceType.Client }) .Result.Result.ToDictionary(x => $"{char.ToUpper(x.Resource[0]) + x.Resource.Substring(1)}.{x.Alias}", x => (int)UuidUtil.GetId(x.Id)); var request = RecordRequestComposer.ComposeCreateRequest() .Append(item => item.ForResource(Porters.TestCoreFramework.Enums.ResourceType.Client) .WithField(fields["Client.P_Name"], "TestName") .WithField(fields["Client.P_Owner"], 1)); recordResponse = recordHandler.WriteRecords(request.Result); PrAssume.That(recordResponse, PrIs.SuccessfulResponse()); var fileHandler = new FileStorageManager(); var fileRecordUploadResponse = fileHandler.Upload(GenerateUploadFileRequest(recordId: recordResponse.Result.Ids[0][0].ToString())); PrAssume.That(fileRecordUploadResponse, PrIs.SuccessfulResponse()); var recordDeleteResponse = recordHandler.DeleteRecords(RecordRequestComposer.ComposeDeleteRequest(Porters.TestCoreFramework.Enums.ResourceType.Client, recordResponse.Result.Ids.SelectMany(x => x))); PrAssume.That(recordDeleteResponse, PrIs.SuccessfulResponse()); var fileRecordReadResponse = fileHandler.Read(fileRecordUploadResponse.Result.Id); PrAssert.That(fileRecordReadResponse, PrIs.ErrorResponse()); }
public void UploadSeveralFilesToSameRecordTest() { const int filesNumber = 50; var fileIdsList = new List <string>(); var handler = new FileStorageManager(); using (LogHelper.LoggerForCurrentTest.EnterReproStep($"Uploading {filesNumber} files")) { for (var i = 0; i < filesNumber; i++) { //upload a file of 1MB size var response = handler.Upload(GenerateUploadFileRequest(content: TestContext.CurrentContext.Random.GetString(1 << 20))); PrAssume.That(response, PrIs.SuccessfulResponse(), $"File #{i} was not uploaded successfully"); fileIdsList.Add(response.Result.Id); } } using (LogHelper.LoggerForCurrentTest.EnterReproStep($"Reading {filesNumber} files")) { foreach (var id in fileIdsList) { var response = handler.Read(id); PrAssert.That(response, PrIs.SuccessfulResponse()); } } using (LogHelper.LoggerForCurrentTest.EnterReproStep($"Deleting {filesNumber} files")) { foreach (var id in fileIdsList) { var response = handler.Delete(id); PrAssert.That(response, PrIs.SuccessfulResponse()); } } }
public static List <long> SortedProcessDataList(List <int> listResult, string orderField, string orderType, FieldType fieldType) { var recordHandler = new RecordManager(); var res = recordHandler.ReadRecords( RecordRequestComposer.ComposeReadRequest() .ForResource(Porters.TestCoreFramework.Enums.ResourceType.Process) .WithIds(listResult.ToArray()) .Fields(ProcessClose, ProcessId, ProcessPhase, ProcessPhaseDate, ProcessUpdateDate, ProcessRegistrationDate, ProcessExpectedClosingDate, ProcessExpectedSalesAmount, orderField) .Result); PrAssume.That(res, PrIs.SuccessfulResponse(), "Can not read Process records"); var result = GetDataList(res.Result.Items, orderField, fieldType).OrderBy(item => item.Close).ThenByDescending(item => item.Phase).ThenByDescending(item => item.PhaseDate); var sortedList = new List <ProcessData>(); if (orderField != ProcessId && orderField != string.Empty) { sortedList = ((orderType == "asc") ? result.ThenBy(item => item.OrderField) : result.ThenByDescending(item => item.OrderField)) .ThenByDescending(item => item.Id).ToList(); } else { sortedList = ((orderType == "asc") ? result.ThenBy(item => item.Id) : result.ThenByDescending(item => item.Id)).ToList(); } return(sortedList.Select(i => i.Id).ToList()); }
private static PrivateData <object> CreateTestUser() { return(new PrivateData <object>( (session, test) => { return Task.Run(() => { var request = new User { UserPName = "Test User", UserPMail = $"{Utils.RandomString(10)}@gmail.com", UserPPassword = "******", UserPStartDate = DateTime.Now.ToString("yyyy/MM/dd"), UserPLanguage = "en_us", UserPDeptId = "1001", UserPAdministrator = false }; var handler = new UserManager(); var result = handler.Execute <User>(request, HttpMethod.Post); PrAssume.That(result, PrIs.SuccessfulResponse(), "Create user is failed."); UserId = result.Result.UserPId; return new object(); }); }, (session, test, obj) => Task.Run(() => { }))); }
public static List <int> CreateNewUsers(int num) { List <int> userIds = new List <int>(); for (var i = 0; i < num; i++) { var activeUserRequest = new Dictionary <string, object>() { ["User.P_Name"] = "Test User", ["User.P_Mail"] = $"User{Utils.RandomString(5)}@gmail.com", ["User.P_Password"] = "******", ["User.P_StartDate"] = DateTime.Now.ToString("yyyy/MM/dd"), ["User.P_Language"] = "en_us", ["User.P_DeptId"] = "1001", ["User.P_Administrator"] = false, ["User.P_TosAgreementDate"] = string.Empty, ["User.P_NoticeReadDate"] = "2018/02/01 00:00:00" }; var handler = new UserManager(); var activeUserRequestResult = handler.Execute <User>(activeUserRequest, System.Net.Http.HttpMethod.Post); PrAssume.That(activeUserRequestResult, PrIs.SuccessfulResponse(), "Create active user is failed."); userIds.Add(activeUserRequestResult.Result.UserPId); } return(userIds); }
private static void SetAllowedRoleSetting(int value, HttpMethod httpMethod = HttpMethod.PUT) { using (var settingSetConnection = new AuthApiConnection(TestConfig.GetValueFromConfig("AuthCoreURL"))) { settingSetConnection.SuppressAuthentication = true; settingSetConnection.RegisterAuthHeader(_authConnection); var settingsReqeust = new DataContracts.Setting.SettingSetRequest { AllowedRolePwdLogin = value, ComnanyId = Convert.ToInt32(AuthenticationInfoProvider.Current.DefaultPartition), LoginUrl = "https://asdf.login.porters.jp/", SsoEnabled = true }; var response = (new DefaultManager(settingSetConnection)).Send(settingsReqeust, additionalSettings: new DefaultManager.AdditionalRequestSettings { UrlParameters = new Dictionary <string, string> { ["companyId"] = AuthenticationInfoProvider.Current.DefaultPartition }, HttpMethod = httpMethod }); PrAssume.That(response, PrIs.SuccessfulResponse().Or.HttpCode(409)); } }
public static PrivateData <Guid> PrepareUserField() { return(new PrivateData <Guid>( (session, test) => { return Task.Run(() => { var handler = new FieldManager(); var result = new Dictionary <ResourceId, Guid>(); var properties = new Dictionary <string, object> { ["s.type"] = (int)FieldType.Number, ["d.label.ja"] = "Test Number Field" };; var createResponse = handler.CreateField(ResourceId.Client, properties); PrAssume.That(createResponse, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create field"); return createResponse.Result.Id; }); }, (session, test, res) => Task.Run(() => { var handler = new FieldManager(); handler.DeleteField(res); }))); }
public static PrivateData <Dictionary <object, Guid> > PrepareTwoUserFieldInvalidCase(int numberFieldType, int indexCreated, int indexDeleted) { return(new PrivateData <Dictionary <object, Guid> >( (session, test) => { return Task.Run(() => { var handler = new FieldManager(); var result = new Dictionary <object, Guid>(); var properties = GenerateRequiredProperties(numberFieldType, Properties.Label.Max); foreach (ResourceId resource in Utils.Resources()) { var createResponse = handler.CreateField(resource, properties); PrAssume.That(createResponse, PrIs.SuccessfulResponse().And.HttpCode(HttpStatusCode.OK), "Can not Create field"); result.Add($"{resource}{indexCreated}", createResponse.Result.Id); var createSecondResponse = handler.CreateField(resource, properties); PrAssume.That(createSecondResponse, PrIs.SuccessfulResponse().And.HttpCode(HttpStatusCode.OK), "Can not Create field"); result.Add($"{resource}{indexDeleted}", createSecondResponse.Result.Id); var deleteResponse = handler.DeleteField(createSecondResponse.Result.Id); PrAssume.That(deleteResponse, PrIs.SuccessfulResponse().And.HttpCode(HttpStatusCode.NoContent), "Can not delete field"); } return result; }); }, (session, test, res) => Task.Run(() => { foreach (var item in res) { var handler = new FieldManager(); handler.DeleteField(item.Value); } }))); }
public static void BulkUpdateDateForRecordsCreator(HrbcRecordCreator RecordsCreator, string date, ValidTestCases testCase, int numRecords = 0) { var bulkManager = new BulkUpdateManager(); DateTime dateTime = DateTime.Parse(date); int plusMinutes = 0; foreach (ResourceId resource in Utils.Resources()) { for (var i = 0; i < numRecords; i++) { if (testCase == ValidTestCases.Less) { plusMinutes = -(numRecords - i); } else if (testCase == ValidTestCases.Greater) { plusMinutes = i; } var recordId = RecordsCreator.Data[$"{resource}{i}"].Id; var response = bulkManager.BulkUpdate <BulkUpdateResponse>(GetBulkUpdateContent(resource, new List <ulong> { recordId }, dateTime.AddMinutes(plusMinutes).ToString(SearchConstants.SearchApiFullDateTemplate)), System.Net.Http.HttpMethod.Post); PrAssume.That(response, PrIs.SuccessfulResponse()); if (GetBulkUpdateQueueStatus(response.Result.Id.ToString())) { continue; } } } }
public static bool GetBulkUpdateQueueStatus(string id, int second = 30, bool ignoredFail = true) { int i = 0; var bulkQueueManager = new BulkQueueManager(); do { var queueResponse = bulkQueueManager.BulkUpdateQueue <BulUpdateQueueResponse>(new Dictionary <string, string> { ["id"] = id }); PrAssume.That(queueResponse, PrIs.SuccessfulResponse()); if (queueResponse.Result.Status != "finished") { Thread.Sleep(1000); //sleep 1s } else { return(ignoredFail ? ignoredFail : queueResponse.Result.Log.Failed == 0 ? true : false); } i++; } while (i <= second); //waiting second return(false); }
public static PrivateData <Dictionary <ResourceId, Guid> > GenerateDeletedField(FieldType fieldType) { return(new PrivateData <Dictionary <ResourceId, Guid> >( (session, test) => { return Task.Run(() => { var handler = new FieldManager(); var dict = new Dictionary <ResourceId, Guid>(); var properties = GenerateProperties(fieldType); foreach (ResourceId resourceId in Utils.Resources()) { // Create field var response = handler.CreateField(resourceId, properties); PrAssume.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create user define field"); dict[resourceId] = response.Result.Id; // Delete field var result = DeleteField(new[] { response.Result.Id }); PrAssume.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent), "Can not delete user define field"); } return dict; }); }, (session, test, res) => Task.Run(() => { }))); }
public static PrivateData <int> GenerateDeletedOptionId() { return(new PrivateData <int>( (session, test) => { return Task.Run(() => { var handler = new OptionManager(); // Create Option var request = new Dictionary <string, object> { ["name"] = "DeletedOption", ["parent_id"] = 0, ["enabled"] = 1, ["sort"] = 1, ["type"] = 0, }; var response = handler.CreateOption(request); PrAssume.That(response, PrIs.SuccessfulResponse(), "Can not create option."); // Delete Option var optionId = response.Result.FirstOrDefault().Id; var result = handler.DeleteOption(optionId); PrAssume.That(result, PrIs.SuccessfulResponse(), "Can not delete option."); return optionId; }); }, (session, test, res) => Task.Run(() => { }))); }
public static PrivateData <Dictionary <object, Guid> > PrepareTwoUserField(int numberFieldType) { return(new PrivateData <Dictionary <object, Guid> >( (session, test) => { return Task.Run(() => { var handler = new FieldManager(); var result = new Dictionary <object, Guid>(); var properties = GenerateRequiredProperties(numberFieldType, Properties.Label.Max, FileType.Bmp); HeightMapperValue[Properties.Height.Max](properties); foreach (ResourceId resource in Utils.Resources()) { for (int i = 0; i < 2; i++) { var createResponse = handler.CreateField(resource, properties); PrAssume.That(createResponse, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create field"); result.Add($"{resource}{i}", createResponse.Result.Id); } } return result; }); }, (session, test, res) => Task.Run(() => { foreach (var item in res) { var handler = new FieldManager(); handler.DeleteField(item.Value); } }))); }
public static PrivateData <Dictionary <ResourceId, List <Guid> > > GenerateApplicationFields(string alias, int count) { return(new PrivateData <Dictionary <ResourceId, List <Guid> > >( (session, test) => { return Task.Run(() => { var handler = new FieldManager(); var dict = new Dictionary <ResourceId, List <Guid> >(); foreach (ResourceId resourceId in Utils.Resources()) { var listGuids = new List <Guid>(); for (int i = 1; i <= count; i++) { var response = handler.GetFieldGuid(new[] { $"{alias}{i}" }, new[] { resourceId }); PrAssume.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not get application field"); PrAssume.That(response.Result.Result.Count, PrIs.GreaterThan(0), "Can not get field details"); var fields = response.Result.Result.Select(x => x.Id); listGuids.Add(fields.FirstOrDefault()); } dict.Add(resourceId, listGuids); } return dict; }); }, (session, test, res) => Task.Run(() => { }))); }
public void ValidGetCustomActionTest(CustomActionTestData.ValidUrl url, CustomActionTestData.ValidLabel validLabel, CustomActionTestData.ValidLabelValue validLabelValue, CustomActionTestData.ValidPlaceValue validPlaceValue) { var createRequest = CreateCustomActionTests.GetCreateRequest(CustomActionTestData.ValidUrlMapper[url], CustomActionTestData.ValidLabelMapper[validLabel](CustomActionTestData.ValidLabelValueMapper[validLabelValue]), CustomActionTestData.ValidPlaceValueMapper[validPlaceValue]); var hanlder = new CustomActionManager(); var response = hanlder.CustomAction <CreateCustomActionResponse>(createRequest, HttpMethod.POST.ToNetHttpMethod()); if (validLabel == CustomActionTestData.ValidLabel.BothEnJa) { PrAssume.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create custom action"); var allCustomAction = hanlder.GetAllCustomActions(); CreateCustomActionTests.DeleteCustomAction(response.Result.Id); PrAssert.That(allCustomAction.Result[response.Result.Id].Url, PrIs.EqualTo(CustomActionTestData.ValidUrlMapper[url]), "The url is not as expected"); PrAssert.That(allCustomAction.Result[response.Result.Id].Label.EnUs.Value, PrIs.EqualTo(CustomActionTestData.ValidLabelValueMapper[validLabelValue][CustomActionTestData.ValueParam]), "The En label value is not as expected"); PrAssert.That(allCustomAction.Result[response.Result.Id].Label.Ja.Value, PrIs.EqualTo(CustomActionTestData.ValidLabelValueMapper[validLabelValue][CustomActionTestData.ValueParam]), "The Ja label value is not as expected"); if (validLabelValue != CustomActionTestData.ValidLabelValue.MissingDefaultStringWithSpace && validLabelValue != CustomActionTestData.ValidLabelValue.MissingDefaultStringNoSpace) { PrAssert.That(allCustomAction.Result[response.Result.Id].Label.Ja.Default, PrIs.EqualTo(CustomActionTestData.ValidLabelValueMapper[validLabelValue][CustomActionTestData.DefaultParam]), "The Ja label default is not as expected"); PrAssert.That(allCustomAction.Result[response.Result.Id].Label.EnUs.Default, PrIs.EqualTo(CustomActionTestData.ValidLabelValueMapper[validLabelValue][CustomActionTestData.DefaultParam]), "The En label default is not as expected"); } } else { PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Create custom action Successfully"); } }
public static PrivateData <int> GetBulkUpdate(int numbRecords, int numRecordsEachCase, HrbcRecordCreator recordsCreator, string fieldValue, TestCoreFramework.Enums.FieldType type, HrbcFieldCreator fieldCreator) { return(new PrivateData <int>( (session, test) => { return Task.Run(() => { foreach (var resource in Enum.GetValues(typeof(ResourceId)).Cast <ResourceId>().Except(new[] { ResourceId.None })) { var bulkManager = new BulkUpdateManager(); for (var i = 0; i < numbRecords - numRecordsEachCase; i++) { var recordId = recordsCreator.Data[$"{resource}{i}"].Id; var response = bulkManager.BulkUpdate <BulkUpdateResponse>(GetBulkUpdateContent(resource, new List <ulong> { recordId }, i, fieldValue, type, fieldCreator), System.Net.Http.HttpMethod.Post); PrAssume.That(response, PrIs.SuccessfulResponse()); if (GetBulkUpdateQueueStatus(response.Result.Id.ToString())) { continue; } } } return 0; }); }, (session, test, res) => Task.Run(() => { }))); }
public void ValidLayoutSpecialGetSublistsMenuTest(ResourceId resourceId, bool isCustomMenu, SublistMenuTestData.EnableDisableValue enabledisable) { var handler = new HrbcSublistManager(); var menuId = isCustomMenu ? SublistMenuTestData.ValidMenuIdMapper[resourceId] : SublistMenuTestData.MenuId[resourceId]; var request = SublistMenuTestData.GetSublistMenuLayoutRequest(menuId, new List <int>(), new List <int>()); SublistMenuTestData.ValidEnableDisableMapper[enabledisable](request, CurrentSublist.Data[menuId].Select(value => value.Id).ToList()); var response = handler.SublistMenuLayout <object>(request, HttpMethod.PUT.ToNetHttpMethod()); PrAssume.That(response, PrIs.SuccessfulResponse(), "Can not update sublist menu layout"); var getRequest = new Dictionary <string, string>() { ["menu_id"] = menuId.ToString() }; var sublists = handler.SublistsMenu <SublistsMenuResponse>(getRequest, HttpMethod.GET.ToNetHttpMethod()); PrAssert.That(sublists, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not get sublists menu"); var resultEnableList = sublists.Result.Values.Where(v => v.Value.Enabled == 1).Select(value => value.Value.Id); var resultDisableList = sublists.Result.Values.Where(v => v.Value.Enabled == 0).Select(value => value.Value.Id); foreach (var item in (IEnumerable <int>)request["enabled"]) { PrAssert.That(resultEnableList.Contains(item), "enabled is not as expected"); } foreach (var item in (IEnumerable <int>)request["disabled"]) { PrAssert.That(resultDisableList.Contains(item), "disabled is not as expected"); } }
public static PrivateData <Dictionary <ResourceId, CreatePhaseEntryResponse> > GetPreparedPhaseId(HrbcRecordCreator recordsCreator, PrivateData <Dictionary <ResourceId, OptionSearchResponse> > rootPhaseOption, int numberOfSet) { return(new PrivateData <Dictionary <ResourceId, CreatePhaseEntryResponse> >( (session, test) => { return Task.Run(() => { var handler = new DefaultManager(); var result = new Dictionary <ResourceId, CreatePhaseEntryResponse>(); var request = new Dictionary <string, object>() { [ParamCreate] = ValidPhaseEntryCreateTests.CreatePhaseEntryRequest(ResourceId.Client, numberOfSet, (int)ResourceId.Client, recordsCreator, rootPhaseOption.Data, PhaseEntryTestData.ValidPhaseOption.PhaseOptionId, PhaseEntryTestData.validDateMapper[PhaseEntryTestData.ValidPhaseDate.Now], PhaseEntryTestData.ValidPhaseMemo.RandomString) }.ToJson(); PrAssume.That(request, PrIs.Not.EqualTo(string.Empty)); var createResponse = handler.SendAsync <CreatePhaseEntryResponse>(PhaseEntryTestData.PhaseEntryApi, request, HttpMethod.POST).Result; PrAssume.That(createResponse, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not Create Phase Entry"); PrAssume.That(createResponse.Result.Data.Count, PrIs.EqualTo(numberOfSet), "Number of created phases is not as expected"); result.Add(ResourceId.Client, createResponse.Result); return result; }); }, (session, test, res) => Task.Run(() => { foreach (var item in res) { ValidPhaseEntryCreateTests.DeletePhaseId(item.Value.Data); } }))); }
public void InvalidUpdateSystemField(FieldType fieldType, string fieldName, CreateUpdateTestData.InvalidProperty invalidValue) { var fieldHandler = new FieldManager(); var fieldResponse = fieldHandler.GetFieldDetails(fieldName); PrAssume.That(fieldResponse, PrIs.SuccessfulResponse(), $"Cannot read field {fieldName}"); var properties = new Dictionary <string, object>(); var deletedField = UuidUtil.GetId(PreparedDeletedFieldId.Data[CommonHelpers.Resources.FirstOrDefault()]); var deletedOption = PreparedDeletedOptionId.Data; CreateUpdateTestData.InvalidPropertyValueMapper[invalidValue](properties, deletedField, deletedOption); var updateParam = new Dictionary <string, object> { [Properties.Parameters.Resource.GetEnumStringValue()] = fieldName.Split('.')[0].ToLower(), [Properties.Parameters.Properties.GetEnumStringValue()] = properties }; var request = NumberHelpers.GenerateRequestUpdate(fieldResponse.Result.Values.Keys.First().ToString(), updateParam); var handler = new DefaultManager(); var response = handler.Send <object>(FieldManager.FieldHandlingRelativeUrl, request.ToJson(), HttpMethod.PUT); if (fieldType == FieldType.Telephone && invalidValue == CreateUpdateTestData.InvalidProperty.TelWithString) { PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent), "Not able update Field"); } else if (fieldType == FieldType.Mail && (invalidValue == CreateUpdateTestData.InvalidProperty.MailWithout || invalidValue == CreateUpdateTestData.InvalidProperty.MailWithoutDomain || invalidValue == CreateUpdateTestData.InvalidProperty.MailWithoutDot || invalidValue == CreateUpdateTestData.InvalidProperty.MailWithoutName || invalidValue == CreateUpdateTestData.InvalidProperty.LeadingDot)) { PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent), "Not able update Field"); } else { PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Still able update Field"); } }
public void InvalidJsonInRefreshTokenRequestTest(JsonTransformationType jsonTransformationType) { var tokenGetRequest = new GetTokenRequest { ExpiresIn = 600, ExtPayload = new { sessionId = "qwer123" }, InvalidAfter = 10800, Method = "password", Service = "HRBC", Credentials = new GetTokenRequest.CredentialsType { CompanyId = AuthenticationInfoProvider.Current.DefaultCompanyName, UserId = AuthenticationInfoProvider.Current.DefaultUserLogin, Password = AuthenticationInfoProvider.Current.DefaultUserPassword } }; var tokenGetResponse = (new DefaultManager(_testConnection)).Send <GetTokenResponse>(tokenGetRequest); PrAssume.That(tokenGetResponse, PrIs.SuccessfulResponse(), "Failed to get a token for token refresh operation."); var request = new RefreshTokenRequest { ExpiresIn = 600, InvalidAfter = 10800, Token = tokenGetResponse.Result.Token }; PerformTest(tokenGetRequest, jsonTransformationType, CommonConstants.TokenRefreshUrl); }
private static void BulkUpdateByReplaceFilter() { var handler = new BulkUpdateManager(); var response = handler.BulkUpdate <BulkUpdateResponse>(GetBulkUpdateContent(Filters.Replace), HttpMethod.Post); PrAssume.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK)); PrAssume.That(SearchHelpers.GetBulkUpdateQueueStatus(response.Result.Id.ToString(), 30, false)); }
public static FileRegisterResponse RegistFile(object request) { var fileManager = new FileApiManager(APIMapper[APITypes.Register]); var result = fileManager.Execute <FileRegisterResponse>(request, HttpMethod.POST.ToNetHttpMethod()); PrAssume.That(result, PrIs.SuccessfulResponse(), "Can not regist file."); return(result.Result); }