Skip to content

Commit

Permalink
cleanup resource/move api
Browse files Browse the repository at this point in the history
  • Loading branch information
artsiomkorzun committed Mar 15, 2024
1 parent 304e5f0 commit a76831f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class ControllerSelector {
private static final Pattern PUBLICATIONS = Pattern.compile("^/v1/ops/publication/(list|get|create|delete|approve|reject)$");
private static final Pattern PUBLICATION_RULES = Pattern.compile("^/v1/ops/publication/rule/list$");

private static final Pattern RESOURCE_OPERATIONS = Pattern.compile("^/v1/ops/resources/(move)$");
private static final Pattern RESOURCE_OPERATIONS = Pattern.compile("^/v1/ops/resource/(move)$");

private static final Pattern DEPLOYMENT_LIMITS = Pattern.compile("^/v1/deployments/([^/]+)/limits$");

Expand Down
20 changes: 10 additions & 10 deletions src/test/java/com/epam/aidial/core/ResourceOperationApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void testMoveResourceWorkflow() {
verifyJson(response, 200, CONVERSATION_BODY_1);

// verify move operation
response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """
response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """
{
"sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/conversation",
"destinationUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2"
Expand Down Expand Up @@ -54,7 +54,7 @@ void testMoveResourceWorkflowWhenDestinationResourceExists() {
verifyJson(response, 200, CONVERSATION_BODY_2);

// verify move operation
response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """
response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """
{
"sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/conversation",
"destinationUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2"
Expand All @@ -69,7 +69,7 @@ void testMoveResourceWorkflowWhenDestinationResourceExists() {
response = resourceRequest(HttpMethod.GET, "/folder2/conversation2");
verifyJson(response, 200, CONVERSATION_BODY_2);

response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """
response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """
{
"sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/conversation",
"destinationUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2",
Expand Down Expand Up @@ -124,7 +124,7 @@ void testMoveOperationCopySharedAccess() {
verify(response, 200, CONVERSATION_BODY_1);

// verify move operation
response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """
response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """
{
"sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/conversation",
"destinationUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2"
Expand Down Expand Up @@ -210,23 +210,23 @@ void testMoveOperationCopySharedAccess() {
@Test
void testMoveOperationErrors() {
// verify sourceUrl must be present
Response response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """
Response response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """
{
"destinationUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2"
}
""");
verify(response, 400);

// verify destinationUrl must be present
response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """
response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """
{
"sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/conversation"
}
""");
verify(response, 400);

// verify source and dest must be the same type
response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """
response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """
{
"sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/conversation",
"destinationUrl": "files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2"
Expand All @@ -235,7 +235,7 @@ void testMoveOperationErrors() {
verify(response, 400);

// verify source must belong to the user
response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """
response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """
{
"sourceUrl": "conversations/7G9WZNcoY26Vy9D7bEgbv6zqbJGfyDp9KZyEbJR4XMZt/folder/conversation",
"destinationUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2"
Expand All @@ -244,7 +244,7 @@ void testMoveOperationErrors() {
verify(response, 400);

// verify move do not support folders
response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """
response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """
{
"sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/",
"destinationUrl": "files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2"
Expand All @@ -253,7 +253,7 @@ void testMoveOperationErrors() {
verify(response, 400);

// verify sourceUrl do not exists
response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """
response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """
{
"sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/conversation",
"destinationUrl": "files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2"
Expand Down

0 comments on commit a76831f

Please sign in to comment.