99import org .opendevstack .component_provisioner .server .controllers .model .ProjectComponentStatus ;
1010import org .opendevstack .component_provisioner .server .controllers .model .awx .AwxResponse ;
1111import org .opendevstack .component_provisioner .server .facade .ProvisionResultsApiFacade ;
12+ import org .opendevstack .component_provisioner .server .model .CreateIncidentAction ;
1213import org .opendevstack .component_provisioner .server .model .CreateIncidentActionMother ;
1314import org .opendevstack .component_provisioner .server .model .NotifyProvisioningStatusUpdateRequest ;
1415import org .opendevstack .component_provisioner .server .model .ProvisionActionResponse ;
@@ -43,12 +44,14 @@ void givenAProvisionService_whenNotifyProvisioningCompletedIsCalled_thenReturnsO
4344 var status = ProjectComponentStatus .CREATED ;
4445 var componentId = "componentId" ;
4546 var catalogItemId = "catalogItemId" ;
47+ var catalogItemSlug = "catalogItemSlug" ;
4648 var componentUrl = "componentUrl" ;
4749 var accessToken = "accessToken" ;
4850
4951 var request = new NotifyProvisioningStatusUpdateRequest ();
5052 request .setComponentId (componentId );
5153 request .setCatalogItemId (catalogItemId );
54+ request .setCatalogItemSlug (catalogItemSlug );
5255 request .setComponentUrl (componentUrl );
5356
5457 when (authenticationProvider .getAccessToken ()).thenReturn (accessToken );
@@ -58,12 +61,12 @@ void givenAProvisionService_whenNotifyProvisioningCompletedIsCalled_thenReturnsO
5861
5962 // then
6063 assertEquals (HttpStatus .OK , response .getStatusCode ());
61- verify (provisionResultsApiFacade ).notifyProvisioningStatusUpdate (projectKey , status , componentId , catalogItemId , componentUrl , accessToken );
62- verify (provisionResultsApiFacade ).validate (projectKey , status .name ());
64+ verify (provisionResultsApiFacade ).notifyProvisioningStatusUpdate (projectKey , status , componentId , catalogItemId , catalogItemSlug , componentUrl , accessToken );
65+ verify (provisionResultsApiFacade ).validate (projectKey , status .name (), request );
6366 }
6467
6568 @ Test
66- void givenAProjectKey_AndAComponentId_whenDeleteProvisioningStatus_thenReturnsOk () {
69+ void givenAProjectKeyAndAComponentId_whenDeleteProvisioningStatusIsCalled_thenReturnsOk () {
6770 // given
6871 var projectKey = "project-key" ;
6972 var componentId = "componentId" ;
@@ -82,7 +85,7 @@ void givenAProjectKey_AndAComponentId_whenDeleteProvisioningStatus_thenReturnsOk
8285 }
8386
8487 @ Test
85- void givenAProjectKey_AndAComponentId_AndCreateIncidentAction_whenCreateIncident_thenReturnsOk () {
88+ void givenAProjectKeyAndAComponentIdAndCreateIncidentAction_whenCreateIncidentIsCalled_thenReturnsOk () {
8689 // given
8790 var projectKey = "project-key" ;
8891 var componentId = "componentId" ;
@@ -104,26 +107,26 @@ void givenAProjectKey_AndAComponentId_AndCreateIncidentAction_whenCreateIncident
104107 verify (provisionResultsApiFacade ).validate (projectKey , componentId , createIncidentAction );
105108 verify (provisionResultsApiFacade ).addSystemParametersToAction (projectKey , createIncidentAction );
106109 verify (provisionResultsApiFacade ).requestProvisionToAwx (projectKey , componentId , createIncidentAction );
107- verify (provisionResultsApiFacade ).notifyProvisioningStatusUpdate (eq (projectKey ), eq (ProjectComponentStatus .DELETING ), eq (componentId ), isNull (), isNull (), anyString ());
110+ verify (provisionResultsApiFacade ).notifyProvisioningStatusUpdate (eq (projectKey ), eq (ProjectComponentStatus .DELETING ), eq (componentId ), isNull (), isNull (), isNull (), anyString ());
108111 }
109112
110113 @ Test
111- void givenInvalidComponentId_whenCreateIncident_thenThrowsInvalidRestEntityException () {
114+ void givenInvalidComponentId_whenCreateIncidentIsCalled_thenThrowsInvalidRestEntityException () {
112115 // given
113116 String projectKey = "PRJ" ;
114117 String componentId = "" ;
115118
116119 var action = CreateIncidentActionMother .of ();
117120
118- doThrow (new InvalidRestEntityException ("project_key, component_id are required." )).when (provisionResultsApiFacade ).validate (any (), any (), any ());
121+ doThrow (new InvalidRestEntityException ("project_key, component_id are required." )).when (provisionResultsApiFacade ).validate (any (String . class ), any (String . class ), any (CreateIncidentAction . class ));
119122
120123 // when / then
121124 var ex = assertThrows (InvalidRestEntityException .class , () -> provisionResultsApiController .createIncident (projectKey , componentId , action ));
122125 assertThat (ex .getMessage ()).isEqualTo ("project_key, component_id are required." );
123126 }
124127
125128 @ Test
126- void givenAProjectKey_AndAComponentId_AndCreateIncidentAction_whenCreateIncident_AndComponentAlreadyInDeletingState_thenReturnsOk_andIgnoreAWXCall () {
129+ void givenAProjectKeyAndAComponentIdAndCreateIncidentAction_whenCreateIncidentIsCalledAndComponentAlreadyInDeletingState_thenReturnsOkAndIgnoreAWXCall () {
127130 // given
128131 var projectKey = "project-key" ;
129132 var componentId = "componentId" ;
@@ -143,7 +146,7 @@ void givenAProjectKey_AndAComponentId_AndCreateIncidentAction_whenCreateIncident
143146 }
144147
145148 @ Test
146- void givenInvalidStatus_whenNotifyProvisioningStatusUpdate_then400OrInvalidRestEntityException () {
149+ void givenInvalidStatus_whenNotifyProvisioningStatusUpdateIsCalled_thenThrowsInvalidRestEntityException () {
147150 // given
148151 var projectKey = "project-key" ;
149152 var invalidStatus = "NOT_A_STATUS" ;
@@ -152,7 +155,7 @@ void givenInvalidStatus_whenNotifyProvisioningStatusUpdate_then400OrInvalidRestE
152155 request .setCatalogItemId ("cat-1" );
153156 request .setComponentUrl ("http://example" );
154157
155- doThrow (new InvalidRestEntityException (exceptionMsg )).when (provisionResultsApiFacade ).validate (any (String .class ), any (String .class ));
158+ doThrow (new InvalidRestEntityException (exceptionMsg )).when (provisionResultsApiFacade ).validate (any (String .class ), any (String .class ), any ( NotifyProvisioningStatusUpdateRequest . class ) );
156159
157160 // when / then
158161 var exception = assertThrows (InvalidRestEntityException .class , () -> provisionResultsApiController .notifyProvisioningStatusUpdate (projectKey , invalidStatus , request ));
@@ -161,7 +164,7 @@ void givenInvalidStatus_whenNotifyProvisioningStatusUpdate_then400OrInvalidRestE
161164 }
162165
163166 @ Test
164- void givenLowercaseStatus_whenNotifyProvisioningStatusUpdate_thenEitherOkOrReject () {
167+ void givenLowercaseStatus_whenNotifyProvisioningStatusUpdateIsCalled_thenThrowsInvalidRestEntityException () {
165168 // given
166169 var projectKey = "project-key" ;
167170 var statusLowercase = "created" ;
@@ -170,7 +173,7 @@ void givenLowercaseStatus_whenNotifyProvisioningStatusUpdate_thenEitherOkOrRejec
170173 request .setCatalogItemId ("cat-1" );
171174 request .setComponentUrl ("http://example" );
172175
173- doThrow (new InvalidRestEntityException (exceptionMsg )).when (provisionResultsApiFacade ).validate (any (String .class ), any (String .class ));
176+ doThrow (new InvalidRestEntityException (exceptionMsg )).when (provisionResultsApiFacade ).validate (any (String .class ), any (String .class ), any ( NotifyProvisioningStatusUpdateRequest . class ) );
174177
175178 // when / then
176179 var exception = assertThrows (InvalidRestEntityException .class , () -> provisionResultsApiController .notifyProvisioningStatusUpdate (projectKey , statusLowercase , request ));
0 commit comments