10
10
package org .eclipse .sw360 .rest .resourceserver .restdocs ;
11
11
12
12
import org .apache .thrift .TException ;
13
+ import org .eclipse .sw360 .datahandler .resourcelists .ResourceClassNotFoundException ;
13
14
import org .eclipse .sw360 .datahandler .thrift .RequestStatus ;
14
15
import org .eclipse .sw360 .datahandler .thrift .vendors .Vendor ;
15
16
import org .eclipse .sw360 .datahandler .thrift .components .Release ;
36
37
import static org .springframework .restdocs .payload .PayloadDocumentation .fieldWithPath ;
37
38
import static org .springframework .restdocs .payload .PayloadDocumentation .requestFields ;
38
39
import static org .springframework .restdocs .payload .PayloadDocumentation .responseFields ;
40
+ import static org .springframework .restdocs .request .RequestDocumentation .*;
39
41
import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .*;
40
42
import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
41
43
import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .patch ;
42
- import static org .springframework .restdocs .request .RequestDocumentation .parameterWithName ;
43
- import static org .springframework .restdocs .request .RequestDocumentation .queryParameters ;
44
44
45
45
@ RunWith (SpringJUnit4ClassRunner .class )
46
46
public class VendorSpecTest extends TestRestDocsSpecBase {
@@ -58,7 +58,7 @@ public class VendorSpecTest extends TestRestDocsSpecBase {
58
58
private Vendor vendor3 ;
59
59
60
60
@ Before
61
- public void before () throws TException {
61
+ public void before () throws TException , ResourceClassNotFoundException {
62
62
vendor = new Vendor ();
63
63
vendor .setId ("876876776" );
64
64
vendor .setFullname ("Google Inc." );
@@ -99,6 +99,7 @@ public void before() throws TException{
99
99
100
100
given (this .vendorServiceMock .getAllReleaseList (eq (vendor .getId ()))).willReturn (releases );
101
101
given (this .vendorServiceMock .getVendors ()).willReturn (vendorList );
102
+ given (this .vendorServiceMock .mergeVendors (eq (vendor .getId ()),eq (vendor2 .getId ()), any (), any ())).willReturn (RequestStatus .SUCCESS );
102
103
given (this .vendorServiceMock .vendorUpdate (any (), any (), any ())).willReturn (RequestStatus .SUCCESS );
103
104
given (this .vendorServiceMock .getVendorById (eq (vendor .getId ()))).willReturn (vendor );
104
105
given (this .vendorServiceMock .deleteVendorByid (any (), any ())).willReturn (RequestStatus .SUCCESS );
@@ -235,4 +236,27 @@ public void should_document_get_export_vendor() throws Exception{
235
236
.andExpect (status ().isOk ())
236
237
.andDo (this .documentationHandler .document ());
237
238
}
239
+
240
+ @ Test
241
+ public void should_document_merge_vendor () throws Exception {
242
+ mockMvc .perform (patch ("/api/vendors/mergeVendors" )
243
+ .contentType (MediaTypes .HAL_JSON )
244
+ .content (this .objectMapper .writeValueAsString (vendor ))
245
+ .header ("Authorization" , TestHelper .generateAuthHeader (testUserId , testUserPassword ))
246
+ .param ("mergeTargetId" , "87654321" )
247
+ .param ("mergeSourceId" , "17653524" )
248
+ .accept (MediaTypes .HAL_JSON ))
249
+ .andExpect (status ().isOk ())
250
+ .andDo (this .documentationHandler .document (
251
+ queryParameters (
252
+ parameterWithName ("mergeSourceId" ).description ("Id of a source vendor to merge" ),
253
+ parameterWithName ("mergeTargetId" ).description ("Id of a target vendor to merge" )
254
+ ),
255
+ requestFields (
256
+ fieldWithPath ("fullName" ).description ("The full name of the vendor" ),
257
+ fieldWithPath ("shortName" ).description ("The short name of the vendor" ),
258
+ fieldWithPath ("url" ).description ("The vendor's home page URL" ),
259
+ fieldWithPath ("type" ).description ("The type of document" )
260
+ )));
261
+ }
238
262
}
0 commit comments