File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed 
x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/llama/response Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ /* 
2+  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one 
3+  * or more contributor license agreements. Licensed under the Elastic License 
4+  * 2.0; you may not use this file except in compliance with the Elastic License 
5+  * 2.0. 
6+  */ 
7+ 
8+ package  org .elasticsearch .xpack .inference .services .llama .response ;
9+ 
10+ import  org .apache .http .HttpResponse ;
11+ import  org .elasticsearch .test .ESTestCase ;
12+ import  org .elasticsearch .xpack .inference .external .http .HttpResult ;
13+ 
14+ import  java .nio .charset .StandardCharsets ;
15+ 
16+ import  static  org .mockito .Mockito .mock ;
17+ 
18+ public  class  LlamaErrorResponseTests  extends  ESTestCase  {
19+ 
20+     public  static  final  String  ERROR_RESPONSE_JSON  = """ 
21+         { 
22+             "error": "A valid user token is required" 
23+         } 
24+         """ ;
25+ 
26+     public  void  testFromResponse () {
27+         var  errorResponse  = LlamaErrorResponse .fromResponse (
28+             new  HttpResult (mock (HttpResponse .class ), ERROR_RESPONSE_JSON .getBytes (StandardCharsets .UTF_8 ))
29+         );
30+         assertNotNull (errorResponse );
31+         assertEquals (ERROR_RESPONSE_JSON , errorResponse .getErrorMessage ());
32+     }
33+ 
34+ }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments