Skip to content

Commit

Permalink
resource api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-zinchenko committed Dec 26, 2024
1 parent 54c97a0 commit 02cbbf8
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.epam.aidial.core.server.controller;


import com.epam.aidial.core.config.Application;
import com.epam.aidial.core.config.Config;
import com.epam.aidial.core.config.Deployment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.vertx.core.http.HttpMethod;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.concurrent.ThreadLocalRandom;
Expand Down Expand Up @@ -319,4 +320,83 @@ void testHeartbeat() {
assertTrue(events.takeHeartbeat(2, TimeUnit.SECONDS));
}
}

@Test
void testApplicationWithTypeSchemaCreation_files_ok() {
Response response = upload(HttpMethod.PUT,"/v1/files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/test_file1.txt",null, """
Test1
""");

Assertions.assertEquals(200, response.status());

response = upload(HttpMethod.PUT,"/v1/files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/test_file2.txt",null, """
Test2
""");

Assertions.assertEquals(200, response.status());

response = send(HttpMethod.PUT,"/v1/applications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/test_app_files",null, """
{
"displayName": "test_app",
"customAppSchemaId": "https://mydial.somewhere.com/custom_application_schemas/specific_application_type",
"property1": "test property1",
"property2": "test property2",
"property3": [
"files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/test_file1.txt",
"files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/test_file2.txt"
],
"userRoles": [
"Admin"
],
"forwardAuthToken": true,
"iconUrl": "https://mydial.somewhere.com/app-icon.svg",
"description": "My application description"
}
""");
Assertions.assertEquals(200, response.status());
}

@Test
void testApplicationWithTypeSchemaCreation_fail() {
Response response = send(HttpMethod.PUT,"/v1/applications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/test_app_folder",null, """
{
"displayName": "test_app",
"customAppSchemaId": "https://mydial.somewhere.com/custom_application_schemas/specific_application_type",
"property1": "test property1",
"property2": "test property2",
"property3": [
"files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/unexisting_folder/unexisting_file.txt"
],
"userRoles": [
"Admin"
],
"forwardAuthToken": true,
"iconUrl": "https://mydial.somewhere.com/app-icon.svg",
"description": "My application description"
}
""");
Assertions.assertEquals(400, response.status());
}

@Test
void testApplicationWithTypeSchemaCreation_folder_ok() {
Response response = send(HttpMethod.PUT,"/v1/applications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/test_app",null, """
{
"displayName": "test_app",
"customAppSchemaId": "https://mydial.somewhere.com/custom_application_schemas/specific_application_type",
"property1": "test property1",
"property2": "test property2",
"property3": [
"files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/xyz/"
],
"userRoles": [
"Admin"
],
"forwardAuthToken": true,
"iconUrl": "https://mydial.somewhere.com/app-icon.svg",
"description": "My application description"
}
""");
Assertions.assertEquals(200, response.status());
}
}
45 changes: 44 additions & 1 deletion server/src/test/resources/aidial.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,48 @@
"rate_limited_route": {}
}
}
}
},
"applicationTypeSchemas": [
{
"$schema": "https://dial.epam.com/application_type_schemas/schema#",
"$id": "https://mydial.somewhere.com/custom_application_schemas/specific_application_type",
"dial:applicationTypeEditorUrl": "https://mydial.somewhere.com/custom_application_schemas/schema",
"dial:applicationTypeDisplayName": "Specific Application Type",
"dial:applicationTypeCompletionEndpoint": "http://specific_application_service/opeani/v1/completion",
"properties": {
"property1": {
"title": "Property 1",
"type": "string",
"dial:meta": {
"dial:propertyKind": "client",
"dial:propertyOrder": 1
}
},
"property2": {
"title": "Property 2",
"type": "string",
"dial:meta": {
"dial:propertyKind": "server",
"dial:propertyOrder": 2
}
},
"property3": {
"type": "array",
"items": {
"type": "string",
"format": "dial-file-encoded",
"dial:file": true
},
"dial:meta": {
"dial:propertyKind": "server",
"dial:propertyOrder": 3
}
}
},
"required": [
"property1",
"property2"
]
}
]
}

0 comments on commit 02cbbf8

Please sign in to comment.