@@ -5,6 +5,7 @@ import akka.http.scaladsl.testkit.ScalatestRouteTest
5
5
import cromwell .pipeline .datastorage .dao .utils .{ TestProjectUtils , TestUserUtils }
6
6
import cromwell .pipeline .datastorage .dto ._
7
7
import cromwell .pipeline .datastorage .dto .auth .AccessTokenContent
8
+ import cromwell .pipeline .model .wrapper .ProjectConfigurationId
8
9
import cromwell .pipeline .service .ProjectConfigurationService .Exceptions .{ InternalError , NotFound , ValidationError }
9
10
import cromwell .pipeline .service .{ ProjectConfigurationService , VersioningException }
10
11
import cromwell .pipeline .utils .URLEncoderUtils
@@ -46,21 +47,19 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit
46
47
47
48
" return success for update configuration" in {
48
49
when(configurationService.addConfiguration(configuration, accessToken.userId)).thenReturn(Future .unit)
49
- Put (s " /projects/ ${projectId.value}/configurations " , configurationAdditionRequest) ~> configurationController
50
- .route(
51
- accessToken
52
- ) ~> check {
50
+ Put (s " /projects/ $projectId/configurations " , configurationAdditionRequest) ~> configurationController.route(
51
+ accessToken
52
+ ) ~> check {
53
53
status shouldBe StatusCodes .NoContent
54
54
}
55
55
}
56
56
57
57
" return InternalServerError when failure update configuration" in {
58
58
val error = InternalError (" Something went wrong" )
59
59
when(configurationService.addConfiguration(configuration, accessToken.userId)).thenReturn(Future .failed(error))
60
- Put (s " /projects/ ${projectId.value}/configurations " , configurationAdditionRequest) ~> configurationController
61
- .route(
62
- accessToken
63
- ) ~> check {
60
+ Put (s " /projects/ $projectId/configurations " , configurationAdditionRequest) ~> configurationController.route(
61
+ accessToken
62
+ ) ~> check {
64
63
status shouldBe StatusCodes .InternalServerError
65
64
entityAs[String ] shouldBe " Something went wrong"
66
65
}
@@ -69,10 +68,9 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit
69
68
" return NotFound when failure find project to update configuration" in {
70
69
when(configurationService.addConfiguration(configuration, accessToken.userId))
71
70
.thenReturn(Future .failed(NotFound ()))
72
- Put (s " /projects/ ${projectId.value}/configurations " , configurationAdditionRequest) ~> configurationController
73
- .route(
74
- accessToken
75
- ) ~> check {
71
+ Put (s " /projects/ $projectId/configurations " , configurationAdditionRequest) ~> configurationController.route(
72
+ accessToken
73
+ ) ~> check {
76
74
status shouldBe StatusCodes .NotFound
77
75
}
78
76
}
@@ -82,18 +80,18 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit
82
80
" return configuration by existing project id" in {
83
81
when(configurationService.getLastByProjectId(projectId, accessToken.userId))
84
82
.thenReturn(Future .successful(configuration))
85
- Get (s " /projects/ ${ projectId.value} /configurations " ) ~> configurationController.route(accessToken) ~> check {
83
+ Get (s " /projects/ $projectId/configurations " ) ~> configurationController.route(accessToken) ~> check {
86
84
status shouldBe StatusCodes .OK
87
85
entityAs[ProjectConfiguration ] shouldBe configuration
88
86
}
89
87
}
90
88
91
89
" return Configuration not found message" in {
92
90
when(configurationService.getLastByProjectId(projectId, accessToken.userId))
93
- .thenReturn(Future .failed(NotFound (s " There is no configuration with project_id: ${ projectId.value} " )))
94
- Get (s " /projects/ ${ projectId.value} /configurations " ) ~> configurationController.route(accessToken) ~> check {
91
+ .thenReturn(Future .failed(NotFound (s " There is no configuration with project_id: $projectId" )))
92
+ Get (s " /projects/ $projectId/configurations " ) ~> configurationController.route(accessToken) ~> check {
95
93
status shouldBe StatusCodes .NotFound
96
- entityAs[String ] shouldBe s " There is no configuration with project_id: ${ projectId.value} "
94
+ entityAs[String ] shouldBe s " There is no configuration with project_id: $projectId"
97
95
}
98
96
}
99
97
}
@@ -103,15 +101,15 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit
103
101
104
102
" return success for deactivate configuration" in {
105
103
when(configurationService.deactivateLastByProjectId(projectId, accessToken.userId)).thenReturn(Future .unit)
106
- Delete (s " /projects/ ${ projectId.value} /configurations " ) ~> configurationController.route(accessToken) ~> check {
104
+ Delete (s " /projects/ $projectId/configurations " ) ~> configurationController.route(accessToken) ~> check {
107
105
status shouldBe StatusCodes .NoContent
108
106
}
109
107
}
110
108
111
109
" return InternalServerError when failure deactivate configuration" in {
112
110
when(configurationService.deactivateLastByProjectId(projectId, accessToken.userId))
113
111
.thenReturn(Future .failed(error))
114
- Delete (s " /projects/ ${ projectId.value} /configurations " ) ~> configurationController.route(accessToken) ~> check {
112
+ Delete (s " /projects/ $projectId/configurations " ) ~> configurationController.route(accessToken) ~> check {
115
113
status shouldBe StatusCodes .InternalServerError
116
114
entityAs[String ] shouldBe " Something went wrong"
117
115
}
@@ -120,7 +118,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit
120
118
" return NotFound when failure find project to deactivate configuration" in {
121
119
when(configurationService.deactivateLastByProjectId(projectId, accessToken.userId))
122
120
.thenReturn(Future .failed(NotFound ()))
123
- Delete (s " /projects/ ${ projectId.value} /configurations " ) ~> configurationController.route(accessToken) ~> check {
121
+ Delete (s " /projects/ $projectId/configurations " ) ~> configurationController.route(accessToken) ~> check {
124
122
status shouldBe StatusCodes .NotFound
125
123
}
126
124
}
@@ -131,7 +129,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit
131
129
" return configuration for file" in {
132
130
when(configurationService.buildConfiguration(projectId, path, versionOption, accessToken.userId))
133
131
.thenReturn(Future .successful(configuration))
134
- Get (s " /projects/ ${ projectId.value} /configurations/files/ $pathString?version= $versionString" ) ~>
132
+ Get (s " /projects/ $projectId/configurations/files/ $pathString?version= $versionString" ) ~>
135
133
configurationController.route(accessToken) ~> check {
136
134
status shouldBe StatusCodes .OK
137
135
entityAs[ProjectConfiguration ] shouldBe configuration
@@ -141,7 +139,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit
141
139
" return failed for Bad request" in {
142
140
when(configurationService.buildConfiguration(projectId, path, versionOption, accessToken.userId))
143
141
.thenReturn(Future .failed(VersioningException .HttpException (" Bad request" )))
144
- Get (s " /projects/ ${ projectId.value} /configurations/files/ $pathString?version= $versionString" ) ~>
142
+ Get (s " /projects/ $projectId/configurations/files/ $pathString?version= $versionString" ) ~>
145
143
configurationController.route(accessToken) ~> check {
146
144
status shouldBe StatusCodes .InternalServerError
147
145
entityAs[String ] shouldBe " Bad request"
@@ -151,7 +149,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit
151
149
" return failed for invalid file" in {
152
150
when(configurationService.buildConfiguration(projectId, path, versionOption, accessToken.userId))
153
151
.thenReturn(Future .failed(ValidationError (List (" invalid some field" ).mkString(" ," ))))
154
- Get (s " /projects/ ${ projectId.value} /configurations/files/ $pathString?version= $versionString" ) ~>
152
+ Get (s " /projects/ $projectId/configurations/files/ $pathString?version= $versionString" ) ~>
155
153
configurationController.route(accessToken) ~> check {
156
154
status shouldBe StatusCodes .UnprocessableEntity
157
155
entityAs[String ] shouldBe " invalid some field"
0 commit comments