This commit is contained in:
@@ -11,6 +11,8 @@ namespace raven_integration
|
||||
|
||||
/*
|
||||
|
||||
EVERY TYPE, EVERY OP
|
||||
|
||||
Using the widget object test all filtering options
|
||||
for all data types, all operation types
|
||||
|
||||
@@ -58,18 +60,8 @@ namespace raven_integration
|
||||
//
|
||||
/**
|
||||
|
||||
case FilterComparisonOperator.Equality:
|
||||
sb.Append("=");
|
||||
sb.Append(sValue);
|
||||
break;
|
||||
case FilterComparisonOperator.GreaterThan:
|
||||
sb.Append(">");
|
||||
sb.Append(sValue);
|
||||
break;
|
||||
case FilterComparisonOperator.GreaterThanOrEqualTo:
|
||||
sb.Append(">=");
|
||||
sb.Append(sValue);
|
||||
break;
|
||||
|
||||
|
||||
case FilterComparisonOperator.LessThan:
|
||||
sb.Append("<");
|
||||
sb.Append(sValue);
|
||||
@@ -88,9 +80,6 @@ namespace raven_integration
|
||||
public async void IntegerOpEqualityFilterWorks()
|
||||
{
|
||||
|
||||
//OPS: equal to, not equal to
|
||||
//values: true, false
|
||||
|
||||
var WidgetNameStart = "IntegerDataFilterTest";
|
||||
|
||||
long IncludedWidgetId = 0;
|
||||
@@ -104,7 +93,7 @@ namespace raven_integration
|
||||
w.name = Util.Uniquify(WidgetNameStart);
|
||||
w.active = true;
|
||||
w.roles = 0;
|
||||
w.count = 555;
|
||||
w.count = 5;
|
||||
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
@@ -112,14 +101,11 @@ namespace raven_integration
|
||||
|
||||
//Excluded widget
|
||||
w.name = Util.Uniquify(WidgetNameStart);
|
||||
w.count = 333;
|
||||
w.count = 3;
|
||||
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
|
||||
|
||||
|
||||
//CREATE FILTER
|
||||
dynamic d = new JObject();
|
||||
d.name = Util.Uniquify("Test INT DataFilter");
|
||||
@@ -141,6 +127,206 @@ namespace raven_integration
|
||||
dynamic FilterItem = new JObject();
|
||||
FilterItem.fld = "count";
|
||||
FilterItem.op = OpEquality;
|
||||
FilterItem.value = 5;
|
||||
dfilter.Add(FilterItem);
|
||||
|
||||
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 this test record
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
|
||||
var v = ((JArray)a.ObjectResponse["data"]);
|
||||
List<long> IDInResultList = new List<long>();
|
||||
int InclusiveMatchCount = 0;
|
||||
int ExclusiveMatchCount = 0;
|
||||
foreach (JObject o in v)
|
||||
{
|
||||
if (IncludedWidgetId == o["id"].Value<long>())
|
||||
InclusiveMatchCount++;
|
||||
if (ExcludedWidgetId == o["id"].Value<long>())//whups
|
||||
ExclusiveMatchCount++;
|
||||
}
|
||||
|
||||
InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
|
||||
ExclusiveMatchCount.Should().Be(0);
|
||||
|
||||
//DELETE WIDGETS
|
||||
a = await Util.DeleteAsync("Widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(a, 204);
|
||||
|
||||
a = await Util.DeleteAsync("Widget/" + ExcludedWidgetId.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);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void IntegerOpGreaterThanFilterWorks()
|
||||
{
|
||||
|
||||
var WidgetNameStart = "IntegerOpGreaterThanFilterWorks";
|
||||
|
||||
long IncludedWidgetId = 0;
|
||||
long ExcludedWidgetId = 0;
|
||||
|
||||
//CREATE TEST WIDGETS
|
||||
|
||||
//included widget
|
||||
dynamic w = new JObject();
|
||||
w.name = Util.Uniquify(WidgetNameStart);
|
||||
w.active = true;
|
||||
w.roles = 0;
|
||||
w.count = 55;
|
||||
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
IncludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
//Excluded widget
|
||||
w.name = Util.Uniquify(WidgetNameStart);
|
||||
w.count = -55;
|
||||
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
|
||||
//CREATE FILTER
|
||||
dynamic d = new JObject();
|
||||
d.name = Util.Uniquify("Test INT 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);
|
||||
|
||||
//inclusive test filter
|
||||
|
||||
dynamic FilterItem = new JObject();
|
||||
FilterItem.fld = "count";
|
||||
FilterItem.op = OpGreaterThan;
|
||||
FilterItem.value = 54;
|
||||
dfilter.Add(FilterItem);
|
||||
|
||||
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 this test record
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
|
||||
var v = ((JArray)a.ObjectResponse["data"]);
|
||||
List<long> IDInResultList = new List<long>();
|
||||
int InclusiveMatchCount = 0;
|
||||
int ExclusiveMatchCount = 0;
|
||||
foreach (JObject o in v)
|
||||
{
|
||||
if (IncludedWidgetId == o["id"].Value<long>())
|
||||
InclusiveMatchCount++;
|
||||
if (ExcludedWidgetId == o["id"].Value<long>())//whups
|
||||
ExclusiveMatchCount++;
|
||||
}
|
||||
|
||||
InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
|
||||
ExclusiveMatchCount.Should().Be(0);
|
||||
|
||||
//DELETE WIDGETS
|
||||
a = await Util.DeleteAsync("Widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(a, 204);
|
||||
|
||||
a = await Util.DeleteAsync("Widget/" + ExcludedWidgetId.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);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void IntegerOpGreaterThanOrEqualToFilterWorks()
|
||||
{
|
||||
|
||||
var WidgetNameStart = "IntegerOpGreaterThanOrEqualToFilterWorks";
|
||||
|
||||
long IncludedWidgetId = 0;
|
||||
long ExcludedWidgetId = 0;
|
||||
|
||||
//CREATE TEST WIDGETS
|
||||
|
||||
//included widget
|
||||
dynamic w = new JObject();
|
||||
w.name = Util.Uniquify(WidgetNameStart);
|
||||
w.active = true;
|
||||
w.roles = 0;
|
||||
w.count = 555;
|
||||
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
IncludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
//Excluded widget
|
||||
w.name = Util.Uniquify(WidgetNameStart);
|
||||
w.count = 554;
|
||||
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
|
||||
//CREATE FILTER
|
||||
dynamic d = new JObject();
|
||||
d.name = Util.Uniquify("IntegerOpGreaterThanOrEqualToFilterWorks");
|
||||
// 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);
|
||||
|
||||
//inclusive test filter
|
||||
|
||||
dynamic FilterItem = new JObject();
|
||||
FilterItem.fld = "count";
|
||||
FilterItem.op = OpGreaterThanOrEqualTo;
|
||||
FilterItem.value = 555;
|
||||
dfilter.Add(FilterItem);
|
||||
|
||||
@@ -152,7 +338,7 @@ namespace raven_integration
|
||||
long DataFilterId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
//NOW FETCH WIDGET LIST WITH FILTER
|
||||
a = await Util.GetAsync($"Widget/listwidgets?DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||
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);
|
||||
|
||||
@@ -189,7 +375,105 @@ namespace raven_integration
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void IntegerOpLessThanFilterWorks()
|
||||
{
|
||||
|
||||
var WidgetNameStart = "IntegerOpLessThanFilterWorks";
|
||||
|
||||
long IncludedWidgetId = 0;
|
||||
long ExcludedWidgetId = 0;
|
||||
|
||||
//CREATE TEST WIDGETS
|
||||
|
||||
//included widget
|
||||
dynamic w = new JObject();
|
||||
w.name = Util.Uniquify(WidgetNameStart);
|
||||
w.active = true;
|
||||
w.roles = 0;
|
||||
w.count = -5555;
|
||||
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
IncludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
//Excluded widget
|
||||
w.name = Util.Uniquify(WidgetNameStart);
|
||||
w.count = 5555;
|
||||
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
|
||||
//CREATE FILTER
|
||||
dynamic d = new JObject();
|
||||
d.name = Util.Uniquify("IntegerOpLessThanFilterWorks");
|
||||
// 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);
|
||||
|
||||
//inclusive test filter
|
||||
|
||||
dynamic FilterItem = new JObject();
|
||||
FilterItem.fld = "count";
|
||||
FilterItem.op = OpLessThan;
|
||||
FilterItem.value = 5555;
|
||||
dfilter.Add(FilterItem);
|
||||
|
||||
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 this test record
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
|
||||
var v = ((JArray)a.ObjectResponse["data"]);
|
||||
List<long> IDInResultList = new List<long>();
|
||||
int InclusiveMatchCount = 0;
|
||||
int ExclusiveMatchCount = 0;
|
||||
foreach (JObject o in v)
|
||||
{
|
||||
if (IncludedWidgetId == o["id"].Value<long>())
|
||||
InclusiveMatchCount++;
|
||||
if (ExcludedWidgetId == o["id"].Value<long>())//whups
|
||||
ExclusiveMatchCount++;
|
||||
}
|
||||
|
||||
InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
|
||||
ExclusiveMatchCount.Should().Be(0);
|
||||
|
||||
//DELETE WIDGETS
|
||||
a = await Util.DeleteAsync("Widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(a, 204);
|
||||
|
||||
a = await Util.DeleteAsync("Widget/" + ExcludedWidgetId.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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -284,7 +568,7 @@ namespace raven_integration
|
||||
long DataFilterId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
//NOW FETCH WIDGET LIST WITH FILTER
|
||||
a = await Util.GetAsync($"Widget/listwidgets?DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user