Skip to content

Commit

Permalink
Renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
ShmElena committed Oct 1, 2024
1 parent 147c881 commit 8afbada
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.folio.dataexp.rest.resource.DownloadAuthorityApi;
import org.folio.dataexp.service.DownloadAuthorityService;
import org.folio.dataexp.service.DownloadRecordService;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
Expand All @@ -24,12 +24,12 @@ public class DownloadAuthorityController implements DownloadAuthorityApi {
private static final String UTF_FORMAT_POSTFIX = "-utf";
private static final String MARC8_FORMAT_POSTFIX = "-marc8";

private final DownloadAuthorityService downloadAuthorityService;
private final DownloadRecordService downloadRecordService;

@Override
public ResponseEntity<Resource> downloadAuthorityById(UUID authorityId, Boolean isUtf) {
var formatPostfix = Boolean.TRUE.equals(isUtf) ? UTF_FORMAT_POSTFIX : MARC8_FORMAT_POSTFIX;
ByteArrayResource resource = downloadAuthorityService.processAuthorityDownload(authorityId, isUtf, formatPostfix);
ByteArrayResource resource = downloadRecordService.processAuthorityDownload(authorityId, isUtf, formatPostfix);
String fileName = authorityId + formatPostfix + ".mrc";
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileName + "\"")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@Service
@AllArgsConstructor
@Log4j2
public class DownloadAuthorityService {
public class DownloadRecordService {

private final AuthorityExportStrategy authorityExportStrategy;
private final MappingProfileEntityRepository mappingProfileEntityRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.stream.Stream;
import lombok.SneakyThrows;
import org.folio.dataexp.BaseDataExportInitializer;
import org.folio.dataexp.service.DownloadAuthorityService;
import org.folio.dataexp.service.DownloadRecordService;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.springframework.boot.test.mock.mockito.MockBean;
Expand All @@ -22,7 +22,7 @@
class DownloadAuthorityControllerTest extends BaseDataExportInitializer {

@MockBean
private DownloadAuthorityService downloadAuthorityService;
private DownloadRecordService downloadRecordService;

@SneakyThrows
@ParameterizedTest
Expand All @@ -33,7 +33,7 @@ void downloadAuthorityById_whenNoUftProvided(Boolean isUtf) {
var expectedFileName = authorityId + formatPostfix + ".mrc";
var mockData = "some data".getBytes();
var mockResource = new ByteArrayResource(mockData);
when(downloadAuthorityService.processAuthorityDownload(authorityId, isUtf == null || isUtf, formatPostfix))
when(downloadRecordService.processAuthorityDownload(authorityId, isUtf == null || isUtf, formatPostfix))
.thenReturn(mockResource);

mockMvc.perform(MockMvcRequestBuilders
Expand All @@ -45,7 +45,7 @@ void downloadAuthorityById_whenNoUftProvided(Boolean isUtf) {
.andExpect(header().string(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + expectedFileName + "\""))
.andExpect(content().bytes(mockData));

verify(downloadAuthorityService).processAuthorityDownload(authorityId, isUtf == null || isUtf, formatPostfix);
verify(downloadRecordService).processAuthorityDownload(authorityId, isUtf == null || isUtf, formatPostfix);
}

private static Stream<Boolean> provideUtfFlags() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.core.io.ByteArrayResource;

class DownloadAuthorityTest extends BaseDataExportInitializer {
class DownloadRecordTest extends BaseDataExportInitializer {

@Autowired
private FolioS3Client s3Client;

@Autowired
private DownloadAuthorityService downloadAuthorityService;
private DownloadRecordService downloadRecordService;

@Autowired
private InputFileProcessor inputFileProcessor;
Expand All @@ -57,7 +57,7 @@ void init() {
void whenAuthorityIsMissing_downloadShouldFail() {
try (var context = new FolioExecutionContextSetter(folioExecutionContext)) {
Exception exception = assertThrows(DownloadRecordException.class, () -> {
downloadAuthorityService.processAuthorityDownload(LOCAL_MARC_AUTHORITY_UUID, true, "-utf");
downloadRecordService.processAuthorityDownload(LOCAL_MARC_AUTHORITY_UUID, true, "-utf");
});
assertEquals("Couldn't find authority in db for ID: 17eed93e-f9e2-4cb2-a52b-e9155acfc119",
exception.getMessage());
Expand All @@ -71,7 +71,7 @@ void whenMarcFileDoesntExist_generateFileAndSaveInS3(boolean isUtf, String postf
var filePath = "mod-data-export/download/4a090b0f-9da3-40f1-ab17-33d6a1e3abae-%s/4a090b0f-9da3-40f1-ab17-33d6a1e3abae-%s.mrc".formatted(postfix, postfix);
var expectedResult = new ByteArrayResource(fileContent.getBytes());

var actualResult = downloadAuthorityService.processAuthorityDownload(LOCAL_AUTHORITY_UUID, isUtf, postfix);
var actualResult = downloadRecordService.processAuthorityDownload(LOCAL_AUTHORITY_UUID, isUtf, postfix);

assertEquals(expectedResult, actualResult);
assertEquals(filePath, s3Client.list(filePath).get(0));
Expand All @@ -86,7 +86,7 @@ void whenMarcFileExists_retrieveItFromS3(boolean isUtf, String postfix, String f
s3Client.write(filePath, new BufferedInputStream(new ByteArrayInputStream(fileContent.getBytes())));
var expectedResult = new ByteArrayResource(fileContent.getBytes());

var actualResult = downloadAuthorityService.processAuthorityDownload(LOCAL_AUTHORITY_UUID, isUtf, postfix);
var actualResult = downloadRecordService.processAuthorityDownload(LOCAL_AUTHORITY_UUID, isUtf, postfix);

assertEquals(expectedResult, actualResult);
}
Expand Down

0 comments on commit 8afbada

Please sign in to comment.