Skip to content

Commit

Permalink
added test case for listing multiple report definitions (opendistro-f…
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcui1225 authored and zhongnansu committed Jan 5, 2021
1 parent c8d98e0 commit 3b6fcc7
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,45 @@ class ReportDefinitionIT : PluginRestTestCase() {
)
Thread.sleep(100)
}

fun `test listing multiple report definitions`() {
val reportDefinitionRequest = constructReportDefinitionRequest()
val reportDefinitionResponse = executeRequest(
RestRequest.Method.POST.name,
"$BASE_REPORTS_URI/definition",
reportDefinitionRequest,
RestStatus.OK.status
)
val reportDefinitionId = reportDefinitionResponse.get("reportDefinitionId").asString
Assert.assertNotNull("reportDefinitionId should be generated", reportDefinitionId)
Thread.sleep(100)

val secondReportDefinitionRequest = constructReportDefinitionRequest(name = "new report definition")
val secondReportDefinitionResponse = executeRequest(
RestRequest.Method.POST.name,
"$BASE_REPORTS_URI/definition",
secondReportDefinitionRequest,
RestStatus.OK.status
)
val newReportDefinitionId = secondReportDefinitionResponse.get("reportDefinitionId").asString
Assert.assertNotNull("reportDefinitionId should be generated", newReportDefinitionId)
Thread.sleep(1000)
val listReportDefinitions = executeRequest(
RestRequest.Method.GET.name,
"$BASE_REPORTS_URI/definitions",
"",
RestStatus.OK.status
)
val totalHits = listReportDefinitions.get("totalHits").asInt
Assert.assertEquals(totalHits, 2)
val reportDefinitionsList = listReportDefinitions.get("reportDefinitionDetailsList").asJsonArray
Assert.assertEquals(
reportDefinitionId,
reportDefinitionsList[0].asJsonObject.get("id").asString
)
Assert.assertEquals(
newReportDefinitionId,
reportDefinitionsList[1].asJsonObject.get("id").asString
)
}
}

0 comments on commit 3b6fcc7

Please sign in to comment.