-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rest): Create new endpoint for schedule CVE and schedule attachm…
…ent deletion. Signed-off-by: Nikesh kumar <[email protected]>
- Loading branch information
Showing
4 changed files
with
259 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,9 @@ | |
|
||
import org.apache.thrift.TException; | ||
import org.eclipse.sw360.datahandler.thrift.RequestStatus; | ||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; | ||
|
||
import org.eclipse.sw360.datahandler.thrift.RequestSummary; | ||
import org.eclipse.sw360.datahandler.thrift.users.User; | ||
import org.eclipse.sw360.rest.resourceserver.TestHelper; | ||
import org.eclipse.sw360.rest.resourceserver.schedule.Sw360ScheduleService; | ||
|
@@ -40,23 +43,80 @@ public class ScheduleSpecTest extends TestRestDocsSpecBase { | |
@MockBean | ||
private Sw360ScheduleService scheduleServiceMock; | ||
|
||
private RequestSummary requestSummary = new RequestSummary(); | ||
|
||
@Before | ||
public void before() throws TException { | ||
|
||
User sw360User = new User(); | ||
sw360User.setId("123456789"); | ||
sw360User.setEmail("[email protected]"); | ||
sw360User.setFullname("John Doe"); | ||
given(this.userServiceMock.getUserByEmailOrExternalId("[email protected]")).willReturn(sw360User); | ||
given(this.scheduleServiceMock.cancelAllServices(any())).willReturn(RequestStatus.SUCCESS); | ||
given(this.scheduleServiceMock.scheduleCveSearch(any())).willReturn(requestSummary); | ||
given(this.scheduleServiceMock.cancelCveSearch(any())).willReturn(RequestStatus.SUCCESS); | ||
given(this.scheduleServiceMock.deleteAttachmentService(any())).willReturn(requestSummary); | ||
given(this.scheduleServiceMock.cancelDeleteAttachment(any())).willReturn(RequestStatus.SUCCESS); | ||
given(this.scheduleServiceMock.cancelAttachmentDeletionLocalFS(any())).willReturn(RequestStatus.SUCCESS); | ||
given(this.scheduleServiceMock.triggerCveSearch(any())).willReturn(RequestStatus.SUCCESS); | ||
|
||
} | ||
|
||
@Test | ||
public void should_document_cancel_all_schedule() throws Exception { | ||
mockMvc.perform(delete("/api/schedule/unscheduleAllServices") | ||
mockMvc.perform(post("/api/schedule/unscheduleAllServices") | ||
.header("Authorization", TestHelper.generateAuthHeader(testUserId, testUserPassword)) | ||
.accept(MediaTypes.HAL_JSON)) | ||
.andExpect(status().isAccepted()); | ||
} | ||
|
||
@Test | ||
public void should_document_schedule_cve_service() throws Exception { | ||
mockMvc.perform(post("/api/schedule/cveService") | ||
.header("Authorization", TestHelper.generateAuthHeader(testUserId, testUserPassword)) | ||
.accept(MediaTypes.HAL_JSON)) | ||
.andExpect(status().isOk()); | ||
.andExpect(status().isAccepted()); | ||
} | ||
|
||
@Test | ||
public void should_document_unschedule_cve_search() throws Exception { | ||
mockMvc.perform(post("/api/schedule/unscheduleCve") | ||
.header("Authorization", TestHelper.generateAuthHeader(testUserId, testUserPassword)) | ||
.accept(MediaTypes.HAL_JSON)) | ||
.andExpect(status().isAccepted()); | ||
} | ||
|
||
@Test | ||
public void should_document_schedule_service_from_local() throws Exception { | ||
mockMvc.perform(post("/api/schedule/deleteAttachment") | ||
.header("Authorization", TestHelper.generateAuthHeader(testUserId, testUserPassword)) | ||
.accept(MediaTypes.HAL_JSON)) | ||
.andExpect(status().isAccepted()); | ||
} | ||
|
||
@Test | ||
public void should_document_schedule_cve_search() throws Exception { | ||
mockMvc.perform(post("/api/schedule/cveSearch") | ||
.header("Authorization", TestHelper.generateAuthHeader(testUserId, testUserPassword)) | ||
.accept(MediaTypes.HAL_JSON)) | ||
.andExpect(status().isAccepted()); | ||
} | ||
|
||
@Test | ||
public void should_document_cancel_schedule_attachment() throws Exception { | ||
mockMvc.perform(post("/api/schedule/unScheduleDeleteAttachment") | ||
.header("Authorization", TestHelper.generateAuthHeader(testUserId, testUserPassword)) | ||
.accept(MediaTypes.HAL_JSON)) | ||
.andExpect(status().isAccepted()); | ||
} | ||
|
||
@Test | ||
public void should_document_delete_old_attachment_from_local() throws Exception { | ||
mockMvc.perform(post("/api/schedule/cancelAttachmentDeletion") | ||
.header("Authorization", TestHelper.generateAuthHeader(testUserId, testUserPassword)) | ||
.accept(MediaTypes.HAL_JSON)) | ||
.andExpect(status().isAccepted()); | ||
} | ||
|
||
} |