This commit is contained in:
@@ -20,7 +20,7 @@ namespace raven_integration
|
|||||||
public async void ObjectLogWorks()
|
public async void ObjectLogWorks()
|
||||||
{
|
{
|
||||||
//CRUD a widget and confirm it logs properly
|
//CRUD a widget and confirm it logs properly
|
||||||
//http://localhost:7575/api/v8.0/EventLog/UserLog?AyType=3&AyId=1
|
//http://localhost:7575/api/v8.0/EventLog/UserLog?AyType=3&AyId=1
|
||||||
//http://localhost:7575/api/v8.0/EventLog/ObjectLog?AyType=2&AyId=242
|
//http://localhost:7575/api/v8.0/EventLog/ObjectLog?AyType=2&AyId=242
|
||||||
//http://localhost:7575/api/v8.0/EventLog/UserLog?AyType=3&AyId=1&StartDate=2018-08-23&EndDate=2018-08-24
|
//http://localhost:7575/api/v8.0/EventLog/UserLog?AyType=3&AyId=1&StartDate=2018-08-23&EndDate=2018-08-24
|
||||||
|
|
||||||
@@ -35,6 +35,13 @@ namespace raven_integration
|
|||||||
Util.ValidateDataReturnResponseOk(r2);
|
Util.ValidateDataReturnResponseOk(r2);
|
||||||
long w2Id = r2.ObjectResponse["result"]["id"].Value<long>();
|
long w2Id = r2.ObjectResponse["result"]["id"].Value<long>();
|
||||||
|
|
||||||
|
ApiResponse EventLogResponse = await Util.GetAsync($"EventLog/ObjectLog?AyType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||||
|
((JArray)EventLogResponse.ObjectResponse["result"]).Count.Should().Be(1);//only one event so far
|
||||||
|
EventLogResponse.ObjectResponse["result"][0]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||||
|
EventLogResponse.ObjectResponse["result"][0]["userId"].Should().NotBeNull();
|
||||||
|
EventLogResponse.ObjectResponse["result"][0]["event"].Value<int>().Should().Be(1);//AyEvent 1 = created
|
||||||
|
EventLogResponse.ObjectResponse["result"][0]["textra"].Should().BeNullOrEmpty();
|
||||||
|
|
||||||
//RETRIEVE
|
//RETRIEVE
|
||||||
|
|
||||||
@@ -43,13 +50,21 @@ namespace raven_integration
|
|||||||
Util.ValidateDataReturnResponseOk(r3);
|
Util.ValidateDataReturnResponseOk(r3);
|
||||||
r3.ObjectResponse["result"]["name"].Value<string>().Should().Be(w.name.ToString());
|
r3.ObjectResponse["result"]["name"].Value<string>().Should().Be(w.name.ToString());
|
||||||
|
|
||||||
|
EventLogResponse = await Util.GetAsync($"EventLog/ObjectLog?AyType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||||
|
((JArray)EventLogResponse.ObjectResponse["result"]).Count.Should().Be(2);
|
||||||
|
EventLogResponse.ObjectResponse["result"][1]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||||
|
EventLogResponse.ObjectResponse["result"][1]["userId"].Should().NotBeNull();
|
||||||
|
EventLogResponse.ObjectResponse["result"][1]["event"].Value<int>().Should().Be(2);//AyEvent 2 = retrieved
|
||||||
|
EventLogResponse.ObjectResponse["result"][1]["textra"].Should().BeNullOrEmpty();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//UPDATE
|
//UPDATE
|
||||||
//PUT
|
//PUT
|
||||||
|
|
||||||
//update w2id
|
//update w2id
|
||||||
w.name = Util.Uniquify("UPDATED VIA PUT SECOND TEST WIDGET");
|
w.name = Util.Uniquify("UPDATED VIA PUT EVENTLOG TEST WIDGET");
|
||||||
w.OwnerId = 1;
|
w.OwnerId = 1;
|
||||||
w.concurrencyToken = r2.ObjectResponse["result"]["concurrencyToken"].Value<uint>();
|
w.concurrencyToken = r2.ObjectResponse["result"]["concurrencyToken"].Value<uint>();
|
||||||
ApiResponse PUTTestResponse = await Util.PutAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"), w.ToString());
|
ApiResponse PUTTestResponse = await Util.PutAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"), w.ToString());
|
||||||
@@ -61,29 +76,29 @@ namespace raven_integration
|
|||||||
checkPUTWorked.ObjectResponse["result"]["name"].Value<string>().Should().Be(w.name.ToString());
|
checkPUTWorked.ObjectResponse["result"]["name"].Value<string>().Should().Be(w.name.ToString());
|
||||||
uint concurrencyToken = PUTTestResponse.ObjectResponse["result"]["concurrencyToken"].Value<uint>();
|
uint concurrencyToken = PUTTestResponse.ObjectResponse["result"]["concurrencyToken"].Value<uint>();
|
||||||
|
|
||||||
//PATCH
|
EventLogResponse = await Util.GetAsync($"EventLog/ObjectLog?AyType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||||
var newName = Util.Uniquify("UPDATED VIA PATCH SECOND TEST WIDGET");
|
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||||
string patchJson = "[{\"value\": \"" + newName + "\",\"path\": \"/name\",\"op\": \"replace\"}]";
|
((JArray)EventLogResponse.ObjectResponse["result"]).Count.Should().Be(4);
|
||||||
ApiResponse PATCHTestResponse = await Util.PatchAsync("Widget/" + w2Id.ToString() + "/" + concurrencyToken.ToString(), await Util.GetTokenAsync("InventoryFull"), patchJson);
|
EventLogResponse.ObjectResponse["result"][2]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||||
Util.ValidateHTTPStatusCode(PATCHTestResponse, 200);
|
EventLogResponse.ObjectResponse["result"][2]["userId"].Should().NotBeNull();
|
||||||
|
EventLogResponse.ObjectResponse["result"][2]["event"].Value<int>().Should().Be(3);//AyEvent 3 = Modified
|
||||||
|
EventLogResponse.ObjectResponse["result"][2]["textra"].Should().BeNullOrEmpty();
|
||||||
|
|
||||||
//check PATCH worked
|
|
||||||
ApiResponse checkPATCHWorked = await Util.GetAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"));
|
|
||||||
Util.ValidateNoErrorInResponse(checkPATCHWorked);
|
|
||||||
checkPATCHWorked.ObjectResponse["result"]["name"].Value<string>().Should().Be(newName);
|
|
||||||
|
|
||||||
//DELETE
|
//DELETE
|
||||||
ApiResponse DELETETestResponse = await Util.DeleteAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"));
|
ApiResponse DELETETestResponse = await Util.DeleteAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"));
|
||||||
Util.ValidateHTTPStatusCode(DELETETestResponse, 204);
|
Util.ValidateHTTPStatusCode(DELETETestResponse, 204);
|
||||||
|
|
||||||
|
//All events should be cleared up on deletion with the sole exception of the deleted event
|
||||||
|
EventLogResponse = await Util.GetAsync($"EventLog/ObjectLog?AyType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||||
|
((JArray)EventLogResponse.ObjectResponse["result"]).Count.Should().Be(1);
|
||||||
|
EventLogResponse.ObjectResponse["result"][0]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||||
|
EventLogResponse.ObjectResponse["result"][0]["userId"].Should().NotBeNull();
|
||||||
|
EventLogResponse.ObjectResponse["result"][0]["event"].Value<int>().Should().Be(0);//AyEvent 0 = deleted
|
||||||
|
EventLogResponse.ObjectResponse["result"][0]["textra"].Value<string>().Should().Be(w.name.ToString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ApiTextResponse t = await Util.GetTextResultAsync("EventLog/", await Util.GetTokenAsync("BizAdminFull"));
|
|
||||||
Util.ValidateHTTPStatusCode(t, 200);
|
|
||||||
t.TextResponse.Should().Contain("|INFO|");//assumes any log will have at least one INFO log item in it
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==================================================
|
//==================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user