Skip to content

Commit

Permalink
spacing and formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
arinkulshi-skylight committed Nov 26, 2024
1 parent de43919 commit f9ae4e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package gov.cdc.ReportVision.controllers;



import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;

Expand Down Expand Up @@ -48,7 +50,6 @@ public ResponseEntity<?> imageToText(
requestEntity,
String.class
);
System.out.println(response.getBody());
return ResponseEntity.status(response.getStatusCode())
.headers(response.getHeaders())
.body(response.getBody());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;


import java.util.Base64;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;


@SpringBootTest
Expand Down Expand Up @@ -119,17 +119,17 @@ public void testImageToTextWithUnsupportedImageFormat() throws Exception {
String url = invocation.getArgument(0);
HttpEntity<?> requestEntity = invocation.getArgument(2);

// If the source_image param is invalid

if (requestEntity.getBody().toString().contains("this_is_not_a_valid_base64_encoded_string")) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Invalid Base64 encoding");
}

// If labels contain an invalid color value

if (requestEntity.getBody().toString().contains("invalid-color")) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Invalid label format");
}

// Otherwise, return a valid response

return new ResponseEntity<>("{\"text\": \"Extracted text from image\"}", HttpStatus.OK);
});

Expand Down

0 comments on commit f9ae4e4

Please sign in to comment.