Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cerebro
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
cerebro
Commits
c98572c0
Commit
c98572c0
authored
9 years ago
by
Leonardo Menezes
Browse files
Options
Downloads
Patches
Plain Diff
added test to GetIndexMappingController
parent
4b7e460d
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/GetIndexMappingController.scala
+1
-1
1 addition, 1 deletion
app/controllers/GetIndexMappingController.scala
conf/routes
+1
-1
1 addition, 1 deletion
conf/routes
test/controllers/GetIndexMappingControllerSpec.scala
+51
-0
51 additions, 0 deletions
test/controllers/GetIndexMappingControllerSpec.scala
with
53 additions
and
2 deletions
app/controllers/GetIndexMapping.scala
→
app/controllers/GetIndexMapping
Controller
.scala
+
1
−
1
View file @
c98572c0
package
controllers
class
GetIndexMapping
extends
ElasticActionController
{
class
GetIndexMapping
Controller
extends
ElasticActionController
{
def
processElasticRequest
=
(
request
,
client
)
=>
client
.
getIndexMapping
(
request
.
get
(
"index"
),
request
.
host
)
...
...
This diff is collapsed.
Click to expand it.
conf/routes
+
1
−
1
View file @
c98572c0
...
...
@@ -16,7 +16,7 @@ POST /apis/clear_indices_cache @controllers.ClearIndexCacheControl
POST /apis/refresh_indices @controllers.RefreshIndexController.execute
POST /apis/delete_indices @controllers.DeleteIndexController.execute
POST /apis/get_index_settings @controllers.GetIndexSettings.execute
POST /apis/get_index_mapping @controllers.GetIndexMapping.execute
POST /apis/get_index_mapping @controllers.GetIndexMapping
Controller
.execute
POST /apis/update_cluster_settings @controllers.PutClusterSettings.execute
POST /apis/get_node_stats @controllers.NodeStatsController.execute
POST /apis/disable_shard_allocation @controllers.DisableShardAllocationController.execute
...
...
This diff is collapsed.
Click to expand it.
test/controllers/GetIndexMappingControllerSpec.scala
0 → 100644
+
51
−
0
View file @
c98572c0
package
controllers
import
elastic.
{
ElasticResponse
,
ElasticClient
}
import
exceptions.MissingRequiredParamException
import
models.CerebroRequest
import
org.specs2.Specification
import
org.specs2.mock.Mockito
import
play.api.libs.json.Json
import
play.api.test.FakeApplication
import
scala.concurrent.duration.Duration
import
scala.concurrent.
{
Await
,
Future
}
object
GetIndexMappingControllerSpec
extends
Specification
with
Mockito
{
def
is
=
s2
"""
GetIndexMappingController should ${step(play.api.Play.start(FakeApplication()))}
invoke getIndexMapping $getIndexMapping
should throw exception if index param is missing $missingIndex
${step(play.api.Play.stop(FakeApplication()))}
"""
val
controller
=
new
GetIndexMappingController
def
getIndexMapping
=
{
val
expectedResponse
=
Json
.
parse
(
"""
|{
| "someIndex": {
| "mappings": {}
| }
|}
"""
.
stripMargin
)
val
body
=
Json
.
obj
(
"host"
->
"somehost"
,
"index"
->
"someIndex"
)
val
client
=
mock
[
ElasticClient
]
client
.
getIndexMapping
(
"someIndex"
,
"somehost"
)
returns
Future
.
successful
(
ElasticResponse
(
200
,
expectedResponse
))
val
response
=
Await
.
result
(
controller
.
processElasticRequest
(
CerebroRequest
(
body
),
client
),
Duration
(
"1s"
))
there
was
one
(
client
).
getIndexMapping
(
"someIndex"
,
"somehost"
)
response
.
body
mustEqual
expectedResponse
response
.
status
mustEqual
200
}
def
missingIndex
=
{
val
body
=
Json
.
obj
(
"host"
->
"somehost"
)
val
client
=
mock
[
ElasticClient
]
controller
.
processElasticRequest
(
CerebroRequest
(
body
),
client
)
must
throwA
[
MissingRequiredParamException
]
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment