void shouldDownloadDocument()

in digital-document-service/src/it/java/com/epam/digital/data/platform/dgtldcmnt/controller/DocumentControllerIT.java [166:187]


  void shouldDownloadDocument() throws Exception {
    DocumentMetadataDto documentMetadataDto = uploadFile(filename, contentType, data,
        createDocumentContextDto());
    var id = documentMetadataDto.getId();

    var uriBuilder = UriComponentsBuilder.newInstance().pathSegment("documents")
        .pathSegment(rootProcessInstanceId)
        .pathSegment(taskId)
        .pathSegment(fieldName)
        .pathSegment(id);
    var request = get(uriBuilder.toUriString()).accept(MediaType.APPLICATION_JSON_VALUE);
    request.header(JwtAuthenticationFilter.AUTHORIZATION_HEADER, accessToken);
    var response = mockMvc.perform(request)
        .andExpect(status().isOk())
        .andReturn()
        .getResponse();

    assertThat(response).isNotNull();
    assertThat(response.getContentType()).isEqualTo(contentType);
    assertThat(response.getContentAsByteArray()).isEqualTo(data);
    assertThat(response.getHeader("Content-Disposition")).contains(filename);
  }