test_class.declarator: demoService
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private DemoService demoService;
test_class.type: DemoService
test_class.var_name: demoService
test_class.declarator: controller
test_class.modifier: @InjectMocks
      private
test_class.original_string: @InjectMocks
      private DataSetDownloadController controller;
test_class.type: DataSetDownloadController
test_class.var_name: controller
test_class.file: optaweb-vehicle-routing-backend/src/test/java/org/optaweb/vehiclerouting/plugin/websocket/DataSetDownloadControllerTest.java
test_class.identifier: DataSetDownloadControllerTest
test_case.body: @Test
      void export() throws IOException {
          // arrange
          String msg = "dummy string";
          when(demoService.exportDataSet()).thenReturn(msg);
  
          // act
          ResponseEntity<Resource> responseEntity = controller.exportDataSet();
  
          // assert
          assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
          HttpHeaders headers = responseEntity.getHeaders();
          // String.length() works here because the message is ASCII
          assertThat(headers.getContentLength()).isEqualTo(msg.length());
          assertThat(headers.getContentType()).isNotNull();
          assertThat(headers.getContentType().toString()).isEqualToIgnoringWhitespace("text/x-yaml;charset=UTF-8");
          assertThat(headers.getContentDisposition()).isNotNull();
          String contentDisposition = headers.getContentDisposition().toString();
          assertThat(contentDisposition)
                  .startsWith("attachment;")
                  .containsPattern("; *filename=\".*\\.yaml\"");
      }
test_case.class_method_signature: DataSetDownloadControllerTest.export()
test_case.full_signature: @Test void export()
test_case.identifier: export
test_case.invocations: thenReturn when exportDataSet exportDataSet isEqualTo assertThat getStatusCode getHeaders isEqualTo assertThat getContentLength length isNotNull assertThat getContentType isEqualToIgnoringWhitespace assertThat toString getContentType isNotNull assertThat getContentDisposition toString getContentDisposition containsPattern startsWith assertThat
test_case.modifiers: @Test
test_case.parameters: ()
test_case.return: void
test_case.signature: void export()
focal_class.declarator: demoService
focal_class.modifier: private final
focal_class.original_string: private final DemoService demoService;
focal_class.type: DemoService
focal_class.var_name: demoService
focal_class.file: optaweb-vehicle-routing-backend/src/main/java/org/optaweb/vehiclerouting/plugin/websocket/DataSetDownloadController.java
focal_class.identifier: DataSetDownloadController
focal_class.class_method_signature: DataSetDownloadController.DataSetDownloadController(DemoService demoService)
focal_class.full_signature:   DataSetDownloadController(DemoService demoService)
focal_class.identifier: DataSetDownloadController
focal_class.parameters: (DemoService demoService)
focal_class.signature:  DataSetDownloadController(DemoService demoService)
focal_class.class_method_signature: DataSetDownloadController.exportDataSet()
focal_class.full_signature: @GetMapping(value = "/dataset/export") @ResponseBody public ResponseEntity<Resource> exportDataSet()
focal_class.identifier: exportDataSet
focal_class.modifiers: @GetMapping(value = "/dataset/export") @ResponseBody public
focal_class.parameters: ()
focal_class.return: ResponseEntity<Resource>
focal_class.signature: ResponseEntity<Resource> exportDataSet()
focal_method.body: @GetMapping(value = "/dataset/export")
      @ResponseBody
      public ResponseEntity<Resource> exportDataSet() throws IOException {
          String dataSet = demoService.exportDataSet();
          byte[] dataSetBytes = dataSet.getBytes(StandardCharsets.UTF_8);
          try (InputStream is = new ByteArrayInputStream(dataSetBytes)) {
              HttpHeaders headers = new HttpHeaders();
              ContentDisposition attachment = ContentDisposition.builder("attachment")
                      .filename("vrp_data_set.yaml")
                      .build();
              headers.setContentDisposition(attachment);
              return ResponseEntity.ok()
                      .headers(headers)
                      .contentLength(dataSetBytes.length)
                      .contentType(new MediaType("text", "x-yaml", StandardCharsets.UTF_8))
                      .body(new InputStreamResource(is));
          }
      }
focal_method.class_method_signature: DataSetDownloadController.exportDataSet()
focal_method.full_signature: @GetMapping(value = "/dataset/export") @ResponseBody public ResponseEntity<Resource> exportDataSet()
focal_method.identifier: exportDataSet
focal_method.invocations: exportDataSet getBytes build filename builder setContentDisposition body contentType contentLength headers ok
focal_method.modifiers: @GetMapping(value = "/dataset/export") @ResponseBody public
focal_method.parameters: ()
focal_method.return: ResponseEntity<Resource>
focal_method.signature: ResponseEntity<Resource> exportDataSet()