This commit is contained in:
@@ -66,7 +66,7 @@ namespace raven_integration
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void BoolFiltersWork()
|
||||
public async void BoolOpEqualityFilterWorks()
|
||||
{
|
||||
|
||||
//OPS: equal to, not equal to
|
||||
@@ -185,6 +185,134 @@ namespace raven_integration
|
||||
Util.ValidateHTTPStatusCode(a, 204);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void BoolOpNotEqualFilterWorks()
|
||||
{
|
||||
|
||||
//OPS: equal to, not equal to
|
||||
//values: true, false
|
||||
|
||||
var WidgetNameStart = "BoolDataFilterTest";
|
||||
|
||||
List<long> ActiveWidgetIdList = new List<long>();
|
||||
List<long> NotActiveWidgetIdList = new List<long>();
|
||||
|
||||
//CREATE 4 TEST WIDGETS
|
||||
//two active and two non active
|
||||
|
||||
//first active widget
|
||||
dynamic w = new JObject();
|
||||
w.name = Util.Uniquify(WidgetNameStart);
|
||||
w.active = true;
|
||||
w.roles = 0;
|
||||
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
ActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());
|
||||
|
||||
//second active widget
|
||||
w.name = Util.Uniquify(WidgetNameStart);
|
||||
|
||||
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
ActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());
|
||||
|
||||
|
||||
//first NON active widget
|
||||
w.name = Util.Uniquify(WidgetNameStart);
|
||||
w.active = false;
|
||||
|
||||
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
NotActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());
|
||||
|
||||
//second NON active widget
|
||||
w.name = Util.Uniquify(WidgetNameStart);
|
||||
w.active = false;
|
||||
|
||||
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
NotActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());
|
||||
|
||||
|
||||
//CREATE FILTER
|
||||
dynamic d = new JObject();
|
||||
d.name = Util.Uniquify("Test BOOL DataFilter");
|
||||
// d.ownerId = 1L;
|
||||
d["public"] = true;
|
||||
d.listKey = "widget";
|
||||
|
||||
dynamic dfilter = new JArray();
|
||||
|
||||
//name starts with filter to constrict to widgets that this test block created only
|
||||
dynamic DataFilterNameStart = new JObject();
|
||||
DataFilterNameStart.fld = "name";
|
||||
DataFilterNameStart.op = OpStartsWith;
|
||||
DataFilterNameStart.value = WidgetNameStart;
|
||||
dfilter.Add(DataFilterNameStart);
|
||||
|
||||
//active bool test filter
|
||||
dynamic DataFilterActive = new JObject();
|
||||
DataFilterActive.fld = "active";
|
||||
DataFilterActive.op = OpNotEqual;
|
||||
DataFilterActive.value = true;
|
||||
dfilter.Add(DataFilterActive);
|
||||
|
||||
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||
|
||||
a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
|
||||
long DataFilterId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
//NOW FETCH WIDGET LIST WITH FILTER
|
||||
a = await Util.GetAsync($"Widget/listwidgets?Offset=0&Limit=999&DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
|
||||
//assert contains at least two records
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
|
||||
var v = ((JArray)a.ObjectResponse["data"]);
|
||||
List<long> IDInResultList = new List<long>();
|
||||
int nActiveMatches = 0;
|
||||
int nInactiveMatches = 0;
|
||||
foreach (JObject o in v)
|
||||
{
|
||||
if (ActiveWidgetIdList.Contains(o["id"].Value<long>()))
|
||||
nActiveMatches++;
|
||||
if (NotActiveWidgetIdList.Contains(o["id"].Value<long>()))
|
||||
nInactiveMatches++;
|
||||
}
|
||||
|
||||
nInactiveMatches.Should().Be(NotActiveWidgetIdList.Count);
|
||||
nActiveMatches.Should().Be(0);
|
||||
|
||||
//DELETE WIDGETS
|
||||
foreach (long l in ActiveWidgetIdList)
|
||||
{
|
||||
a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(a, 204);
|
||||
}
|
||||
|
||||
foreach (long l in NotActiveWidgetIdList)
|
||||
{
|
||||
a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(a, 204);
|
||||
}
|
||||
|
||||
//DELETE DATAFILTER
|
||||
a = await Util.DeleteAsync("DataFilter/" + DataFilterId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(a, 204);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//TODO: Re-run search and compare active v inactive opposite of above
|
||||
//TODO: //UPDATE FILTER TO LIMIT TO INACTIVE BY FLIPPING THE OP TO NOTEQUAL
|
||||
//SAVE AS ANOTHER FILTER (or possibly modify the original one) AND RETEST
|
||||
|
||||
Reference in New Issue
Block a user