Skip to content

Commit

Permalink
feat : adds more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed May 6, 2024
1 parent fc59df3 commit d8a5350
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.learning.ai.llmragwithspringai.controller;

import com.learning.ai.llmragwithspringai.service.DataIndexerService;
import java.util.Map;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -29,7 +30,7 @@ public ResponseEntity<String> load(@RequestPart("file") MultipartFile multipartF
}

@GetMapping("count")
public long count() {
return dataIndexerService.count();
public Map<String, Long> count() {
return Map.of("count", dataIndexerService.count());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,21 @@ void uploadPdfContent() throws IOException {
.when()
.post("/api/data/v1/upload")
.then()
.statusCode(200);
.statusCode(200)
.log()
.all();
}

private File getFile(String fileName) throws IOException {
return new ClassPathResource(fileName).getFile();
@Test
@Order(2)
void uploadPdfContentCount() {
given().when()
.get("/api/data/v1/count")
.then()
.statusCode(200)
.body("count", is(1))
.log()
.all();
}

@Test
Expand All @@ -60,6 +70,20 @@ void testRag() {
.all();
}

@Test
@Order(102)
void testRag2() {
given().contentType(ContentType.JSON)
.body(new AIChatRequest("Did Rohit Sharma won ICC Mens T20 World Cup 2007 ?"))
.when()
.post("/api/ai/chat")
.then()
.statusCode(200)
.body("queryResponse", containsString("Yes"))
.log()
.all();
}

@Test
@Order(111)
void testEmptyQuery() {
Expand Down Expand Up @@ -115,4 +139,8 @@ void testSpecialCharactersInQuery() {
.body("violations[0].message", containsString("Invalid characters in query"))
.log();
}

private File getFile(String fileName) throws IOException {
return new ClassPathResource(fileName).getFile();
}
}

0 comments on commit d8a5350

Please sign in to comment.