This commit is contained in:
2026-02-24 10:21:40 -08:00
parent 17c647b4cd
commit 6c18ae4b77

View File

@@ -9,135 +9,156 @@ namespace raven_integration
{ {
public class PickListAllTests public class PickListAllTests
{ {
//NOTE: in order not to interfere in each other will use Widget picklist to test with standard unmodified picklist template //NOTE: in order not to interfere in each other will use Project picklist to test with standard unmodified picklist template
//and will use User pick-list to test the template functionality //and will use Customer pick-list to test the template functionality
/// <summary> /// <summary>
/// Test all Template editing related routes /// Test all Template editing related routes
/// </summary> /// </summary>
[Fact] [Fact]
public async Task UserPickListTemplatesOps() public async Task CustomerPickListTemplatesOps()
{ {
//NOTE: Due to there being only one possible template per type, this test will need to test ALL potential tests in one function //NOTE: Due to there being only one possible template per type, this test will need to test ALL potential tests in one function
//and only for the User picklist in order to not step over other potential tests running in parallel //and only for the Customer picklist in order to not step over other potential tests running in parallel
//REPLACE USER TEMPLATE //Customer by default in sample data does not include account number so add that field for this test
//should not break anything else
//Customer TEMPLATE
//default template in eval data does not include account number
// {
// "id": 8,
// "template": "[{\"fld\":\"customername\"},{\"fld\":\"CustomerPhone1\"},{\"fld\":\"CustomerAccountNumber\"}]"
// }
const int AY_OBJECT_TYPE_CUSTOMER = 8;
dynamic d = new JObject(); dynamic d = new JObject();
d.Id = 3;//User type
//custom template, only one field employee number d.Id = AY_OBJECT_TYPE_CUSTOMER;//Customer type
//custom template, add customer account number
dynamic dTemplateArray = new JArray(); dynamic dTemplateArray = new JArray();
dynamic df = new JObject(); dynamic df = new JObject();
df.fld = "useremployeenumber"; df.fld = "customername";
dTemplateArray.Add(df); dTemplateArray.Add(df);
df = new JObject();
df.fld = "CustomerPhone1";
dTemplateArray.Add(df);
df = new JObject();
df.fld = "CustomerAccountNumber";
dTemplateArray.Add(df);
d.Template = dTemplateArray.ToString(Newtonsoft.Json.Formatting.None); d.Template = dTemplateArray.ToString(Newtonsoft.Json.Formatting.None);
//replace the User template at the server //replace the Customer template at the server
ApiResponse a = await Util.PostAsync("pick-list/template", await Util.GetTokenAsync("BizAdmin"), d.ToString(Newtonsoft.Json.Formatting.None)); ApiResponse a = await Util.PostAsync("pick-list/template", await Util.GetTokenAsync("BizAdmin"), d.ToString(Newtonsoft.Json.Formatting.None));
Util.ValidateHTTPStatusCode(a, 204); Util.ValidateHTTPStatusCode(a, 204);
//RETRIEVE //RETRIEVE
//Get one //Get one
a = await Util.GetAsync("pick-list/template/3/", await Util.GetTokenAsync("BizAdmin")); a = await Util.GetAsync($"pick-list/template/{AY_OBJECT_TYPE_CUSTOMER}/", await Util.GetTokenAsync("BizAdmin"));
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
//assert contains ONE record ONLY and it's the one we set //assert contains three records ONLY and the one we added
var templateArray = JArray.Parse(a.ObjectResponse["data"]["template"].Value<string>()); var templateArray = JArray.Parse(a.ObjectResponse["data"]["template"].Value<string>());
templateArray.Count.Should().Be(1); templateArray.Count.Should().Be(3);
templateArray[0]["fld"].Value<string>().Should().Be("useremployeenumber"); templateArray[2]["fld"].Value<string>().Should().Be("CustomerAccountNumber");
// {
// "id": 0,
// "concurrency": 0,
// "name": "ATestCustomer",
// "active": true,
// "notes": null,
// "wiki": null,
// "customFields": "{}",
// "tags": [],
// "webAddress": null,
// "alertNotes": null,
// "billHeadOffice": false,
// "headOfficeId": null,
// "techNotes": null,
// "accountNumber": "AUniqueAccountNumber",
// "contractId": null,
// "contractExpires": null,
// "phone1": null,
// "phone2": null,
// "phone3": null,
// "phone4": null,
// "phone5": null,
// "emailAddress": null,
// "postAddress": null,
// "postCity": null,
// "postRegion": null,
// "postCountry": null,
// "postCode": null,
// "address": null,
// "city": null,
// "region": null,
// "country": null,
// "addressPostal": null,
// "latitude": null,
// "longitude": null
// }
//CONFIRM THE CUSTOM PICKLIST TEMPLATE WORKS PROPERLY //CONFIRM THE CUSTOM PICKLIST TEMPLATE WORKS PROPERLY
//MAKE THE TEST USERS //MAKE THE TEST Customer
//First make a unique string for this iteration of this test only //make a unique string for this iteration of this test only
var UniquePhrase = Util.Uniquify("pick").Replace(" ", ""); var UniquePhrase = Util.Uniquify("pick").Replace(" ", "");
d = new JObject(); d = new JObject();
d.name = Util.Uniquify("UserPickListTemplatesOps") + UniquePhrase; d.name = Util.Uniquify("CustomerPickListTemplatesOps") + UniquePhrase;
d.active = true; d.active = true;
d.login = Util.Uniquify("LOGIN"); d.accountNumber = UniquePhrase;
d.password = Util.Uniquify("PASSWORD"); // d.login = Util.Uniquify("LOGIN");
d.roles = 0;//norole // d.password = Util.Uniquify("PASSWORD");
// d.roles = 0;//norole
d.userType = 3;//non scheduleable // d.userType = 3;//non scheduleable
//Required by form custom rules // //Required by form custom rules
d.notes = "notes"; // d.notes = "notes";
d.customFields = Util.UserRequiredCustomFieldsJsonString(); //d.customFields = Util.UserRequiredCustomFieldsJsonString();
a = await Util.PostAsync("User", await Util.GetTokenAsync("superuser", "l3tm3in"), d.ToString()); a = await Util.PostAsync("Customer", await Util.GetTokenAsync("superuser", "l3tm3in"), d.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long InNameId = a.ObjectResponse["data"]["id"].Value<long>(); long ExpectedObjectId = a.ObjectResponse["data"]["id"].Value<long>();
d = new JObject();
d.name = Util.Uniquify("UserPickListTemplatesOps");
d.employeeNumber = UniquePhrase;
d.login = Util.Uniquify("LOGIN");
d.password = Util.Uniquify("PASSWORD");
d.roles = 0;//norole
d.userType = 3;//non scheduleable
d.active = true;
//Required by form custom rules
d.notes = "notes";
d.customFields = Util.UserRequiredCustomFieldsJsonString();
a = await Util.PostAsync("User", await Util.GetTokenAsync("superuser", "l3tm3in"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
long InEmployeeNumberId = a.ObjectResponse["data"]["id"].Value<long>();
//GET PICKLIST FOR unique phrase query sb only employee number due to custom template //GET PICKLIST FOR unique phrase query sb only employee number due to custom template
a = await Util.GetAsync("pick-list/list?ayaType=3&query=" + UniquePhrase, await Util.GetTokenAsync("BizAdmin")); a = await Util.PostAsync("pick-list/list", await Util.GetTokenAsync("BizAdmin"),$"{{\"ayaType\":8,\"query\":\"{UniquePhrase}\"}}");
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
var pickList = ((JArray)a.ObjectResponse["data"]); var pickList = ((JArray)a.ObjectResponse["data"]);
pickList.Count.Should().Be(1); pickList.Count.Should().Be(1);
pickList[0]["id"].Value<long>().Should().Be(InEmployeeNumberId); pickList[0]["id"].Value<long>().Should().Be(ExpectedObjectId);
//custom template, only one field user name //DELETE TEST CUSTOMER NO LONGER NEEDED
d = new JObject(); a = await Util.DeleteAsync("User/" + ExpectedObjectId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
d.Id = 3;//User type
dTemplateArray = new JArray();
df = new JObject();
df.fld = "username";
dTemplateArray.Add(df);
d.Template = dTemplateArray.ToString(Newtonsoft.Json.Formatting.None);
//replace the User template at the server
a = await Util.PostAsync("pick-list/template", await Util.GetTokenAsync("BizAdmin"), d.ToString(Newtonsoft.Json.Formatting.None));
Util.ValidateHTTPStatusCode(a, 204);
//GET PICKLIST FOR unique phrase query sb only user name field due to custom template
a = await Util.GetAsync("pick-list/list?ayaType=3&query=" + UniquePhrase, await Util.GetTokenAsync("BizAdmin"));
//"select auser.id as plId, auser.active as plActive, concat_ws(' ', auser.name) as plname from auser where auser.active = true and ((auser.name like '%pick1584556347748%')) order by auser.name limit 100"
Util.ValidateDataReturnResponseOk(a);
pickList = ((JArray)a.ObjectResponse["data"]);
pickList.Count.Should().Be(1);
pickList[0]["id"].Value<long>().Should().Be(InNameId);
//DELETE TEST USERS NO LONGER NEEDED
a = await Util.DeleteAsync("User/" + InNameId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
Util.ValidateHTTPStatusCode(a, 204);
a = await Util.DeleteAsync("User/" + InEmployeeNumberId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
Util.ValidateHTTPStatusCode(a, 204); Util.ValidateHTTPStatusCode(a, 204);
// RESET TEMPLATE TO DEFAULT // RESET TEMPLATE TO DEFAULT
a = await Util.DeleteAsync("pick-list/template/3/", await Util.GetTokenAsync("BizAdmin")); //Note deleting causes server to replace with default
a = await Util.DeleteAsync($"pick-list/template/{AY_OBJECT_TYPE_CUSTOMER}/", await Util.GetTokenAsync("BizAdmin"));
Util.ValidateHTTPStatusCode(a, 204); Util.ValidateHTTPStatusCode(a, 204);
//RETRIEVE (Confirm it's back to default) //RETRIEVE (Confirm it's back to default)
//Get one //Get one
a = await Util.GetAsync("pick-list/template/3/", await Util.GetTokenAsync("BizAdmin")); a = await Util.GetAsync($"pick-list/template/{AY_OBJECT_TYPE_CUSTOMER}/", await Util.GetTokenAsync("BizAdmin"));
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
//assert contains default template record ONLY and it's the one we set //assert contains default template record ONLY and it's the one we set
templateArray = JArray.Parse(a.ObjectResponse["data"]["template"].Value<string>()); templateArray = JArray.Parse(a.ObjectResponse["data"]["template"].Value<string>());
templateArray.Count.Should().Be(3); templateArray.Count.Should().Be(2);
templateArray[0]["fld"].Value<string>().Should().Be("username"); templateArray[0]["fld"].Value<string>().Should().Be("customername");
//Now test error conditions.... //Now test error conditions....
//BAD FIELD NAME VALIDATION ERROR //BAD FIELD NAME VALIDATION ERROR
d = new JObject(); d = new JObject();
d.Id = 3;//User type d.Id = AY_OBJECT_TYPE_CUSTOMER;
//template, simple test, nothing fancy //template, simple test, nothing fancy
dTemplateArray = new JArray(); dTemplateArray = new JArray();
df = new JObject(); df = new JObject();
@@ -155,10 +176,10 @@ namespace raven_integration
//template, simple test, nothing fancy //template, simple test, nothing fancy
dTemplateArray = new JArray(); dTemplateArray = new JArray();
df = new JObject(); df = new JObject();
df.fld = "useremployeenumber"; df.fld = "customername";
dTemplateArray.Add(df); dTemplateArray.Add(df);
d.Template = dTemplateArray.ToString(Newtonsoft.Json.Formatting.None); d.Template = dTemplateArray.ToString(Newtonsoft.Json.Formatting.None);
//replace the User template at the server //replace the template at the server
a = await Util.PostAsync("pick-list/template", await Util.GetTokenAsync("BizAdmin"), d.ToString(Newtonsoft.Json.Formatting.None)); a = await Util.PostAsync("pick-list/template", await Util.GetTokenAsync("BizAdmin"), d.ToString(Newtonsoft.Json.Formatting.None));
//"{\"error\":{\"code\":\"2200\",\"details\":[{\"message\":\"Template array item 0, fld property value \\\"DOES_NOT_EXIST\\\" is not a valid value for AyaType specified\",\"target\":\"Template\",\"error\":\"2203\"}],\"message\":\"Object did not pass validation\"}}" //"{\"error\":{\"code\":\"2200\",\"details\":[{\"message\":\"Template array item 0, fld property value \\\"DOES_NOT_EXIST\\\" is not a valid value for AyaType specified\",\"target\":\"Template\",\"error\":\"2203\"}],\"message\":\"Object did not pass validation\"}}"
Util.ValidateErrorCodeResponse(a, 2200, 400); Util.ValidateErrorCodeResponse(a, 2200, 400);
@@ -167,11 +188,11 @@ namespace raven_integration
//RIGHTS ISSUE, //RIGHTS ISSUE,
//currently only BizAdmin can change a picklist template //currently only BizAdmin can change a picklist template
d = new JObject(); d = new JObject();
d.Id = 3;//User d.Id = AY_OBJECT_TYPE_CUSTOMER;
//template, simple test, nothing fancy //template, simple test, nothing fancy
dTemplateArray = new JArray(); dTemplateArray = new JArray();
df = new JObject(); df = new JObject();
df.fld = "useremployeenumber"; df.fld = "customername";
dTemplateArray.Add(df); dTemplateArray.Add(df);
d.Template = dTemplateArray.ToString(Newtonsoft.Json.Formatting.None); d.Template = dTemplateArray.ToString(Newtonsoft.Json.Formatting.None);
//ERROR NO RIGHTS USER //ERROR NO RIGHTS USER
@@ -181,7 +202,7 @@ namespace raven_integration
//EMPTY TEMPLATE VALIDATION ERROR //EMPTY TEMPLATE VALIDATION ERROR
d = new JObject(); d = new JObject();
d.Id = 3;//User d.Id = AY_OBJECT_TYPE_CUSTOMER;
d.Template = "";//<-- ERROR no template d.Template = "";//<-- ERROR no template
a = await Util.PostAsync("pick-list/template", await Util.GetTokenAsync("BizAdmin"), d.ToString(Newtonsoft.Json.Formatting.None)); a = await Util.PostAsync("pick-list/template", await Util.GetTokenAsync("BizAdmin"), d.ToString(Newtonsoft.Json.Formatting.None));
Util.ValidateErrorCodeResponse(a, 2200, 400); Util.ValidateErrorCodeResponse(a, 2200, 400);
@@ -190,10 +211,10 @@ namespace raven_integration
//MALFORMED TEMPLATE JSON ERROR //MALFORMED TEMPLATE JSON ERROR
d = new JObject(); d = new JObject();
d.Id = 3;//User type d.Id = AY_OBJECT_TYPE_CUSTOMER;
dTemplateArray = new JArray(); dTemplateArray = new JArray();
df = new JObject(); df = new JObject();
df.fld = "useremployeenumber"; df.fld = "customername";
dTemplateArray.Add(df); dTemplateArray.Add(df);
string sTemplate = dTemplateArray.ToString(Newtonsoft.Json.Formatting.None); string sTemplate = dTemplateArray.ToString(Newtonsoft.Json.Formatting.None);
d.Template = sTemplate.Substring(2);//<-- ERROR missing first two characters of json template array d.Template = sTemplate.Substring(2);//<-- ERROR missing first two characters of json template array
@@ -216,7 +237,7 @@ namespace raven_integration
//assert contains at least two records (as we only have two at time of writing this test) //assert contains at least two records (as we only have two at time of writing this test)
var templateList = ((JArray)a.ObjectResponse["data"]); var templateList = ((JArray)a.ObjectResponse["data"]);
templateList.Count.Should().BeGreaterThan(1); templateList.Count.Should().BeGreaterThan(1);
templateList[0]["id"].Value<long>().Should().Be(2);//first one should be a widget templateList[0]["id"].Value<long>().Should().Be(2);//first one should be a user
} }
@@ -237,13 +258,13 @@ namespace raven_integration
/// <summary> /// <summary>
/// test get picklist for widget without query /// test get picklist for user without query
/// </summary> /// </summary>
[Fact] [Fact]
public async Task FetchWidgetPickListNoQuery() public async Task FetchUserPickListNoQuery()
{ {
//RETRIEVE WIDGET PICKLIST no filter //RETRIEVE USER PICKLIST no filter
ApiResponse a = await Util.GetAsync("pick-list/list?ayaType=2", await Util.GetTokenAsync("BizAdmin")); ApiResponse a = await Util.GetAsync("pick-list/list?ayaType=3", await Util.GetTokenAsync("BizAdmin"));
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
//assert contains 100 records (current picklist maximum count) //assert contains 100 records (current picklist maximum count)
var pickList = ((JArray)a.ObjectResponse["data"]); var pickList = ((JArray)a.ObjectResponse["data"]);
@@ -255,7 +276,7 @@ namespace raven_integration
/// test get picklist for single predefined value only /// test get picklist for single predefined value only
/// </summary> /// </summary>
[Fact] [Fact]
public async Task FetchWidgetPickListPreDefined() public async Task FetchUserPickListPreDefined()
{ {
//fetch the SuperUser account which always exists //fetch the SuperUser account which always exists
ApiResponse a = await Util.GetAsync("pick-list/list?ayaType=3&preId=1", await Util.GetTokenAsync("BizAdmin")); ApiResponse a = await Util.GetAsync("pick-list/list?ayaType=3&preId=1", await Util.GetTokenAsync("BizAdmin"));
@@ -269,41 +290,43 @@ namespace raven_integration
/// <summary> /// <summary>
/// test get picklist for widget with basic autocomplete query only /// test get picklist for user with basic autocomplete query only
/// </summary> /// </summary>
[Fact] [Fact]
public async Task FetchWidgetPickListAutoComplete() public async Task FetchUserPickListAutoComplete()
{ {
//make key widget //make key user
var WidgetNameStart = "FetchWidgetPickListAutoComplete_a1b2c3"; var UserNameStart = "FetchUserPickListAutoComplete_a1b2c3";
long IncludedWidgetId = 0; long IncludedUserId = 0;
//CREATE TEST WIDGETS //CREATE TEST USERS
//included widget //included user
dynamic w = new JObject(); dynamic w = new JObject();
w.name = Util.Uniquify(WidgetNameStart); w.name = Util.Uniquify(UserNameStart);
w.customFields = Util.WidgetRequiredCustomFieldsJsonString(); w.customFields = Util.UserRequiredCustomFieldsJsonString();
w.notes = "blah"; w.notes = "blah";
w.active = true; w.active = true;
w.usertype = 1; w.usertype = 1;
w.dollarAmount = 555.55; //w.dollarAmount = 555.55;
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString()); ApiResponse a = await Util.PostAsync("user", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
IncludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>(); IncludedUserId = a.ObjectResponse["data"]["id"].Value<long>();
//RETRIEVE WIDGET PICKLIST with name filter //RETRIEVE USER PICKLIST with name filter
a = await Util.GetAsync("pick-list/list?ayaType=2&query=a1b2c3", await Util.GetTokenAsync("BizAdmin")); //a = await Util.GetAsync("pick-list/list?ayaType=3&query=a1b2c3", await Util.GetTokenAsync("BizAdmin"));
a = await Util.PostAsync("pick-list/list", await Util.GetTokenAsync("BizAdmin"), "{ \"ayaType\": 3, \"query\": \"a1b\", \"listVariant\": \"inside\"}");
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
var pickList = ((JArray)a.ObjectResponse["data"]); var pickList = ((JArray)a.ObjectResponse["data"]);
pickList.Count.Should().BeGreaterThan(0); pickList.Count.Should().BeGreaterThan(0);
pickList[0]["name"].Value<string>().Should().Contain("_a1b2c3"); pickList[0]["name"].Value<string>().Should().Contain("_a1b2c3");
//DELETE WIDGETS //DELETE USERS
a = await Util.DeleteAsync("widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdmin")); a = await Util.DeleteAsync("user/" + IncludedUserId.ToString(), await Util.GetTokenAsync("BizAdmin"));
Util.ValidateHTTPStatusCode(a, 204); Util.ValidateHTTPStatusCode(a, 204);
} }
@@ -312,17 +335,17 @@ namespace raven_integration
/// ///
/// </summary> /// </summary>
[Fact] [Fact]
public async Task FetchWidgetPickListTags() public async Task FetchUserPickListTags()
{ {
//make key widget //make key user
var WidgetNameStart = "FetchWidgetPickListTags"; var UserNameStart = "FetchUserPickListTags";
long IncludedWidgetId = 0; long IncludedUserId = 0;
//CREATE TEST WIDGETS //CREATE TEST USERS
//included widget //included user
dynamic w = new JObject(); dynamic w = new JObject();
w.name = Util.Uniquify(WidgetNameStart); w.name = Util.Uniquify(UserNameStart);
w.customFields = Util.WidgetRequiredCustomFieldsJsonString(); w.customFields = Util.UserRequiredCustomFieldsJsonString();
w.notes = "blah"; w.notes = "blah";
w.active = true; w.active = true;
w.usertype = 1; w.usertype = 1;
@@ -333,80 +356,80 @@ namespace raven_integration
InclusiveTagsArray.Add("plblue"); InclusiveTagsArray.Add("plblue");
w.tags = InclusiveTagsArray; w.tags = InclusiveTagsArray;
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString()); ApiResponse a = await Util.PostAsync("user", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
IncludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>(); IncludedUserId = a.ObjectResponse["data"]["id"].Value<long>();
//RETRIEVE WIDGET PICKLIST with name filter //RETRIEVE USER PICKLIST with name filter
a = await Util.GetAsync("pick-list/list?ayaType=2&query=..lblu", await Util.GetTokenAsync("BizAdmin")); a = await Util.GetAsync("pick-list/list?ayaType=3&query=..lblu", await Util.GetTokenAsync("BizAdmin"));
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
var pickList = ((JArray)a.ObjectResponse["data"]); var pickList = ((JArray)a.ObjectResponse["data"]);
pickList.Count.Should().Be(1); pickList.Count.Should().Be(1);
pickList[0]["id"].Value<long>().Should().Be(IncludedWidgetId); pickList[0]["id"].Value<long>().Should().Be(IncludedUserId);
//DELETE WIDGETS //DELETE USERS
a = await Util.DeleteAsync("widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdmin")); a = await Util.DeleteAsync("user/" + IncludedUserId.ToString(), await Util.GetTokenAsync("BizAdmin"));
Util.ValidateHTTPStatusCode(a, 204); Util.ValidateHTTPStatusCode(a, 204);
} }
/// <summary> /// <summary>
/// test get picklist for widget with basic autocomplete query only /// test get picklist for user with basic autocomplete query only
/// </summary> /// </summary>
[Fact] [Fact]
public async Task FetchWidgetPickListInactiveActive() public async Task FetchUserPickListInactiveActive()
{ {
//make key widget //make key user
var WidgetNameStart = "FetchWidgetPickListInactiveActive"; var UserNameStart = "FetchUserPickListInactiveActive";
List<long> ActiveWidgetIdList = new List<long>(); List<long> ActiveUserIdList = new List<long>();
List<long> NotActiveWidgetIdList = new List<long>(); List<long> NotActiveUserIdList = new List<long>();
//CREATE 4 TEST WIDGETS //CREATE 4 TEST USERS
//two active and two non active //two active and two non active
//first active widget //first active user
dynamic w = new JObject(); dynamic w = new JObject();
w.name = Util.Uniquify(WidgetNameStart); w.name = Util.Uniquify(UserNameStart);
w.customFields = Util.WidgetRequiredCustomFieldsJsonString(); w.customFields = Util.UserRequiredCustomFieldsJsonString();
w.notes = "blah"; w.notes = "blah";
w.active = true; w.active = true;
w.usertype = 1; w.usertype = 1;
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString()); ApiResponse a = await Util.PostAsync("user", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
ActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>()); ActiveUserIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());
//second active widget //second active user
w.name = Util.Uniquify(WidgetNameStart); w.name = Util.Uniquify(UserNameStart);
a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString()); a = await Util.PostAsync("user", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
ActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>()); ActiveUserIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());
//first NON active widget //first NON active user
w.name = Util.Uniquify(WidgetNameStart); w.name = Util.Uniquify(UserNameStart);
w.active = false; w.active = false;
a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString()); a = await Util.PostAsync("user", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
NotActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>()); NotActiveUserIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());
//second NON active widget //second NON active user
w.name = Util.Uniquify(WidgetNameStart); w.name = Util.Uniquify(UserNameStart);
w.active = false; w.active = false;
a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString()); a = await Util.PostAsync("user", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
NotActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>()); NotActiveUserIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());
//CONFIRM BOTH INACTIVE AND ACTIVE //CONFIRM BOTH INACTIVE AND ACTIVE
a = await Util.GetAsync("pick-list/list?ayaType=2&query=ickListInactiveAct&inactive=true", await Util.GetTokenAsync("BizAdmin")); a = await Util.GetAsync("pick-list/list?ayaType=3&query=ickListInactiveAct&inactive=true", await Util.GetTokenAsync("BizAdmin"));
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
var pickList = ((JArray)a.ObjectResponse["data"]); var pickList = ((JArray)a.ObjectResponse["data"]);
//assert contains at least two records //assert contains at least two records
@@ -415,17 +438,17 @@ namespace raven_integration
int nInactiveMatches = 0; int nInactiveMatches = 0;
foreach (JObject o in pickList) foreach (JObject o in pickList)
{ {
if (ActiveWidgetIdList.Contains(o["id"].Value<long>())) if (ActiveUserIdList.Contains(o["id"].Value<long>()))
nActiveMatches++; nActiveMatches++;
if (NotActiveWidgetIdList.Contains(o["id"].Value<long>())) if (NotActiveUserIdList.Contains(o["id"].Value<long>()))
nInactiveMatches++; nInactiveMatches++;
} }
nActiveMatches.Should().Be(ActiveWidgetIdList.Count); nActiveMatches.Should().Be(ActiveUserIdList.Count);
nInactiveMatches.Should().Be(NotActiveWidgetIdList.Count); nInactiveMatches.Should().Be(NotActiveUserIdList.Count);
//CONFIRM ACTIVE ONLY //CONFIRM ACTIVE ONLY
a = await Util.GetAsync("pick-list/list?ayaType=2&query=ickListInactiveAct", await Util.GetTokenAsync("BizAdmin")); a = await Util.GetAsync("pick-list/list?ayaType=3&query=ickListInactiveAct", await Util.GetTokenAsync("BizAdmin"));
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
pickList = ((JArray)a.ObjectResponse["data"]); pickList = ((JArray)a.ObjectResponse["data"]);
//assert contains at least two records //assert contains at least two records
@@ -434,24 +457,24 @@ namespace raven_integration
nInactiveMatches = 0; nInactiveMatches = 0;
foreach (JObject o in pickList) foreach (JObject o in pickList)
{ {
if (ActiveWidgetIdList.Contains(o["id"].Value<long>())) if (ActiveUserIdList.Contains(o["id"].Value<long>()))
nActiveMatches++; nActiveMatches++;
if (NotActiveWidgetIdList.Contains(o["id"].Value<long>())) if (NotActiveUserIdList.Contains(o["id"].Value<long>()))
nInactiveMatches++; nInactiveMatches++;
} }
nActiveMatches.Should().Be(ActiveWidgetIdList.Count); nActiveMatches.Should().Be(ActiveUserIdList.Count);
nInactiveMatches.Should().Be(0); nInactiveMatches.Should().Be(0);
//DELETE WIDGETS //DELETE USERS
foreach (long l in ActiveWidgetIdList) foreach (long l in ActiveUserIdList)
{ {
a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdmin")); a = await Util.DeleteAsync("user/" + l.ToString(), await Util.GetTokenAsync("BizAdmin"));
Util.ValidateHTTPStatusCode(a, 204); Util.ValidateHTTPStatusCode(a, 204);
} }
foreach (long l in NotActiveWidgetIdList) foreach (long l in NotActiveUserIdList)
{ {
a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdmin")); a = await Util.DeleteAsync("user/" + l.ToString(), await Util.GetTokenAsync("BizAdmin"));
Util.ValidateHTTPStatusCode(a, 204); Util.ValidateHTTPStatusCode(a, 204);
} }
} }