-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/marketplace deletion #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
636cc1c
Add marketplace api client.
27682ee
Add marketplace api client.
2c9e956
Remove unused var.
6ee3a28
Fix sonarqube complaints.
cf25bfb
Add delete component functionality - not finished.
3abe777
Merge branch 'develop' into feature/real-marketplace-components-api-u…
0e72bc9
Add delete component functionality - not finished.
4138b18
Implement component existence check and exception handling for duplic…
angelmp01 911780e
Add API endpoint to retrieve extended information of a project compon…
angelmp01 3d708a6
Update getComponent to call the new endpoint.
05fa84f
Implement On-Behalf-Of (OBO) token exchange functionality and enhance…
angelmp01 db955b7
Fix github comments.
05a1abf
Refactor exception handling in getProjectComponent to use ComponentNo…
angelmp01 3a7c372
Add ComponentBadRequestException and enhance exception handling for b…
angelmp01 2febcc7
Remove unused workflow, odsNamespace, and quickstarterRepository fiel…
angelmp01 5dff575
Fix test.
d899671
Merge remote-tracking branch 'origin/feature/real-marketplace-compone…
14c7d6b
Add delete service and controller.
d44279d
Add tests.
b9bec95
Update delete with latest API changes.
31139b6
Update delete with latest API changes.
937171f
Merge branch 'develop' into feature/marketplace-deletion
ad2e7fa
Fixes after the merge with develop.
c95e565
Fix test.
84e6fbf
Update log message.
b01b11c
Fix code analysis findings.
0d678e6
Fix code analysis findings.
5dc0734
Fix PR review findings.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
api-project-component-v0/openapi/api-project-component-v0-internal.yaml
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| openapi: 3.0.3 | ||
| info: | ||
| title: ODS API Server | ||
| description: API documentation for ODS (Open DevStack) API Service | ||
| contact: | ||
| name: ODS Team | ||
| version: v0.0.1 | ||
| servers: | ||
| - url: http://{baseurl}/api/pub/v1 | ||
| variables: | ||
| baseurl: | ||
| default: localhost:8080 | ||
| description: Development environment | ||
| tags: | ||
| - name: Project Components Internal | ||
| description: API for managing project components with extended methods | ||
|
|
||
| paths: | ||
| /projects/{projectId}/components/{componentId}: | ||
| delete: | ||
| tags: | ||
| - Project Components Internal | ||
| summary: Delete component information | ||
| operationId: deleteProjectComponent | ||
| description: Deletes a specific component | ||
| parameters: | ||
| - name: projectId | ||
| in: path | ||
| required: true | ||
| description: Project key | ||
| schema: | ||
| type: string | ||
| pattern: "^[A-Z]{2}[A-Z0-9]{1,8}$" | ||
| minLength: 3 | ||
| maxLength: 10 | ||
| - name: componentId | ||
| in: path | ||
| required: true | ||
| description: Component id | ||
| schema: | ||
| type: string | ||
| minLength: 2 | ||
| maxLength: 52 | ||
| pattern: "^[a-z]+(-?[a-z0-9]+)*$" | ||
| responses: | ||
| "204": | ||
| description: Project component properly deleted or no component found for the provided componentId. | ||
| "400": | ||
| description: Bad request. | ||
| "401": | ||
| description: Invalid credentials on the request. | ||
| "403": | ||
| description: Insufficient permissions for the client to access the resource. | ||
| "500": | ||
| description: Server error. | ||
|
|
||
| components: | ||
| securitySchemes: | ||
| basicAuth: | ||
| type: http | ||
| scheme: basic | ||
| bearerAuth: | ||
| type: http | ||
| scheme: bearer | ||
| bearerFormat: JWT | ||
|
|
||
This file contains hidden or 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
29 changes: 29 additions & 0 deletions
29
...a/org/opendevstack/apiservice/project/controller/ProjectComponentsInternalController.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package org.opendevstack.apiservice.project.controller; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.opendevstack.apiservice.project.api.ProjectComponentsInternalApi; | ||
| import org.opendevstack.apiservice.project.facade.ComponentsFacade; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RestController | ||
| @AllArgsConstructor | ||
| @Slf4j | ||
| @RequestMapping(ProjectComponentsInternalController.API_BASE_PATH) | ||
| public class ProjectComponentsInternalController implements ProjectComponentsInternalApi { | ||
|
|
||
| public static final String API_BASE_PATH = "/api/pub/v1"; | ||
|
|
||
| private final ComponentsFacade componentsFacade; | ||
|
|
||
| @Override | ||
| public ResponseEntity<Void> deleteProjectComponent(String projectId, String componentId) { | ||
| componentsFacade.deleteProjectComponent(projectId, componentId); | ||
| log.info("Deleted component with id '{}' for project '{}'", componentId, projectId); | ||
| return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); | ||
| } | ||
|
|
||
| } |
This file contains hidden or 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
12 changes: 12 additions & 0 deletions
12
...c/main/java/org/opendevstack/apiservice/project/exception/ComponentDeletionException.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package org.opendevstack.apiservice.project.exception; | ||
|
|
||
| public class ComponentDeletionException extends RuntimeException { | ||
|
|
||
| public ComponentDeletionException(String message) { | ||
| super(message); | ||
| } | ||
|
|
||
| public ComponentDeletionException(String message, Exception e) { | ||
| super(message, e); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
64 changes: 64 additions & 0 deletions
64
...g/opendevstack/apiservice/project/controller/ProjectComponentsInternalControllerTest.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| package org.opendevstack.apiservice.project.controller; | ||
|
|
||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.mockito.Mock; | ||
| import org.mockito.MockitoAnnotations; | ||
| import org.opendevstack.apiservice.project.exception.ComponentDeletionException; | ||
| import org.opendevstack.apiservice.project.facade.ComponentsFacade; | ||
|
valituguran marked this conversation as resolved.
|
||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
| import static org.mockito.ArgumentMatchers.anyString; | ||
| import static org.mockito.Mockito.doThrow; | ||
| import static org.mockito.Mockito.verify; | ||
|
|
||
| class ProjectComponentsInternalControllerTest { | ||
|
|
||
| @Mock | ||
| private ComponentsFacade componentsFacade; | ||
|
|
||
| private ProjectComponentsInternalController projectComponentsInternalController; | ||
|
|
||
| private AutoCloseable openMocks; | ||
|
|
||
| @BeforeEach | ||
| void setup() { | ||
| openMocks = MockitoAnnotations.openMocks(this); | ||
| projectComponentsInternalController = new ProjectComponentsInternalController(componentsFacade); | ||
| } | ||
|
|
||
| @AfterEach | ||
| void tearDown() throws Exception { | ||
| openMocks.close(); | ||
| } | ||
|
|
||
| @Test | ||
| void delete_project_component_returns_no_content_when_component_delete_works() { | ||
| String projectId = "projectId"; | ||
| String componentId = "test-component-delete"; | ||
|
|
||
| ResponseEntity<Void> response = projectComponentsInternalController.deleteProjectComponent(projectId, componentId); | ||
|
|
||
| assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT); | ||
| assertThat(response.getBody()).isNull(); | ||
| verify(componentsFacade).deleteProjectComponent(projectId, componentId); | ||
| } | ||
|
|
||
| @Test | ||
| void delete_project_component_throws_exception_when_component_delete_api_throws_exception() { | ||
| String projectId = "projectId"; | ||
| String componentId = "test-component-delete"; | ||
|
|
||
| doThrow(new ComponentDeletionException("test exception")) | ||
| .when(componentsFacade).deleteProjectComponent(anyString(), anyString()); | ||
|
|
||
| assertThrows(ComponentDeletionException.class, () -> | ||
| projectComponentsInternalController.deleteProjectComponent(projectId, componentId) | ||
| ); | ||
| verify(componentsFacade).deleteProjectComponent(projectId, componentId); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.