@@ -67,6 +67,10 @@ public class AIApiTest extends TestClient {
6767 private static final String PROXY_CHAT = "%s/users/%d/ai/providers/%d/chat/completions" ;
6868 private static final String LIST_SUPPORTED_AI_PROVIDER_MODELS = "%s/users/%d/ai/providers/supported-models" ;
6969 private static final String AI_TRANSLATE_STRING = "%s/users/%d/ai/translate" ;
70+ private static final String AI_FILE_TRANSLATIONS = "%s/users/%d/ai/file-translations" ;
71+ private static final String AI_FILE_TRANSLATION = "%s/users/%d/ai/file-translations/%s" ;
72+ private static final String AI_FILE_TRANSLATION_DOWNLOAD = "%s/users/%d/ai/file-translations/%s/download" ;
73+ private static final String AI_FILE_TRANSLATION_STRINGS = "%s/users/%d/ai/file-translations/%s/translations" ;
7074
7175 @ Override
7276 public List <RequestMock > getMocks () {
@@ -108,7 +112,12 @@ public List<RequestMock> getMocks() {
108112 RequestMock .build (String .format (AI_PROMPT , this .url , userId , aiPromptId ), HttpPatch .METHOD_NAME , "api/ai/editPromptRequest.json" , "api/ai/promptResponse.json" ),
109113 RequestMock .build (String .format (PROXY_CHAT , this .url , userId , aiPromptId ), HttpPost .METHOD_NAME , "api/ai/proxyChatCompletionRequest.json" , "api/ai/proxyChatCompletionResponse.json" ),
110114 RequestMock .build (String .format (LIST_SUPPORTED_AI_PROVIDER_MODELS , this .url , userId ), HttpGet .METHOD_NAME , "api/ai/listSupportedAiProviderModels.json" ),
111- RequestMock .build (String .format (AI_TRANSLATE_STRING , this .url , userId ), HttpPost .METHOD_NAME , "api/ai/aiTranslateRequest.json" , "api/ai/aiTranslateResponse.json" )
115+ RequestMock .build (String .format (AI_TRANSLATE_STRING , this .url , userId ), HttpPost .METHOD_NAME , "api/ai/aiTranslateRequest.json" , "api/ai/aiTranslateResponse.json" ),
116+ RequestMock .build (String .format (AI_FILE_TRANSLATIONS , this .url , userId ), HttpPost .METHOD_NAME , "api/ai/addAiFileTranslationRequest.json" , "api/ai/aiFileTranslationResponse.json" ),
117+ RequestMock .build (String .format (AI_FILE_TRANSLATION , this .url , userId , jobIdentifier ), HttpGet .METHOD_NAME , "api/ai/aiFileTranslationResponse.json" ),
118+ RequestMock .build (String .format (AI_FILE_TRANSLATION , this .url , userId , jobIdentifier ), HttpDelete .METHOD_NAME ),
119+ RequestMock .build (String .format (AI_FILE_TRANSLATION_DOWNLOAD , this .url , userId , jobIdentifier ), HttpGet .METHOD_NAME , "api/ai/downloadAiFileTranslationResponse.json" ),
120+ RequestMock .build (String .format (AI_FILE_TRANSLATION_STRINGS , this .url , userId , jobIdentifier ), HttpGet .METHOD_NAME , "api/ai/downloadAiFileTranslationStringsResponse.json" )
112121 );
113122 }
114123
@@ -554,4 +563,59 @@ public void aiTranslateStringsTest() {
554563 assertEquals (2 , response .getData ().getTranslations ().size ());
555564 assertEquals ("Перекладений текст 1" , response .getData ().getTranslations ().get (0 ));
556565 }
566+
567+ @ Test
568+ public void addAiFileTranslationTest () {
569+ AiFileTranslationAddRequest request = new AiFileTranslationAddRequest ();
570+ request .setStorageId (123L );
571+ request .setSourceLanguageId ("en" );
572+ request .setTargetLanguageId ("uk" );
573+ request .setType ("xliff" );
574+ request .setParserVersion (1 );
575+ request .setTmIds (Collections .singletonList (123L ));
576+ request .setGlossaryIds (Collections .singletonList (456L ));
577+ request .setAiPromptId (789L );
578+ request .setAiProviderId (12L );
579+ request .setAiModelId ("gpt-4.1" );
580+ request .setInstructions (Collections .singletonList ("Keep a formal tone" ));
581+ request .setAttachmentIds (Collections .singletonList (123L ));
582+
583+ ResponseObject <AiFileTranslation > response = this .getAiApi ().addAiFileTranslation (userId , request );
584+ assertEquals (jobIdentifier , response .getData ().getIdentifier ());
585+ assertEquals (status , response .getData ().getStatus ());
586+ assertEquals (progress , response .getData ().getProgress ());
587+ assertEquals ("translate" , response .getData ().getAttributes ().getStage ());
588+ assertEquals ("en" , response .getData ().getAttributes ().getSourceLanguageId ());
589+ assertEquals ("uk" , response .getData ().getAttributes ().getTargetLanguageId ());
590+ }
591+
592+ @ Test
593+ public void getAiFileTranslationStatusTest () {
594+ ResponseObject <AiFileTranslation > response = this .getAiApi ().getAiFileTranslationStatus (userId , jobIdentifier );
595+ assertEquals (jobIdentifier , response .getData ().getIdentifier ());
596+ assertEquals (status , response .getData ().getStatus ());
597+ assertEquals ("file.pdf" , response .getData ().getAttributes ().getDownloadName ());
598+ assertEquals ("chrome" , response .getData ().getAttributes ().getDetectedType ());
599+ }
600+
601+ @ Test
602+ public void cancelAiFileTranslationTest () {
603+ this .getAiApi ().cancelAiFileTranslation (userId , jobIdentifier );
604+ }
605+
606+ @ Test
607+ public void downloadAiFileTranslationTest () {
608+ ResponseObject <DownloadLink > response = this .getAiApi ().downloadAiFileTranslation (userId , jobIdentifier );
609+ assertNotNull (response .getData ());
610+ assertNotNull (response .getData ().getUrl ());
611+ assertFalse (response .getData ().getUrl ().isEmpty ());
612+ }
613+
614+ @ Test
615+ public void downloadAiFileTranslationStringsTest () {
616+ ResponseObject <DownloadLink > response = this .getAiApi ().downloadAiFileTranslationStrings (userId , jobIdentifier );
617+ assertNotNull (response .getData ());
618+ assertNotNull (response .getData ().getUrl ());
619+ assertFalse (response .getData ().getUrl ().isEmpty ());
620+ }
557621}
0 commit comments