Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MARP-1731 Wrong documentation link for SNAPSHOT versions #264

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,7 @@
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.Enumeration;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
Expand Down Expand Up @@ -79,10 +71,11 @@ public String downloadAndUnzipFile(String url, boolean isForce) throws IOExcepti
return location;
}

private Path createTempFileFromUrlAndExtractToLocation(String url, String location,
public Path createTempFileFromUrlAndExtractToLocation(String url, String location,
nntthuy-axonivy marked this conversation as resolved.
Show resolved Hide resolved
boolean isForce) throws IOException {
File cacheFolder = new File(location);
if (cacheFolder.exists() && cacheFolder.isDirectory() && !isForce) {
if (cacheFolder.exists() && cacheFolder.isDirectory() && Objects.requireNonNull(
nntthuy-axonivy marked this conversation as resolved.
Show resolved Hide resolved
cacheFolder.listFiles()).length > 0 && !isForce) {
log.warn("Data is already in {}", location);
return null;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
nntthuy-axonivy marked this conversation as resolved.
Show resolved Hide resolved

@ExtendWith(MockitoExtension.class)
class FileDownloadServiceImplTest {
Expand All @@ -37,6 +38,14 @@ void testDownloadAndUnzipFileWithIssue() {
assertThrows(ResourceAccessException.class, () -> fileDownloadService.downloadAndUnzipFile(DOWNLOAD_URL, true));
}

@Test
void testCreateTempFileFromUrlAndExtractToLocation_ReturnsNull() throws IOException {
Path result = fileDownloadService.createTempFileFromUrlAndExtractToLocation(DOWNLOAD_URL, EXTRACT_DIR_LOCATION,
nntthuy-axonivy marked this conversation as resolved.
Show resolved Hide resolved
false);

assertNull(result);
}

@Test
void testSupportFunctions() throws IOException {
var mockFile = fileDownloadService.createFolder("unzip");
Expand Down Expand Up @@ -82,9 +91,9 @@ void testCreateFolderShouldNotThrowExceptionWhenIOExceptionOccurs() {
@Test
void deleteDirectory_shouldDeleteAllFilesAndDirectories() {
// Arrange
Path mockPath = Mockito.mock(Path.class);
Path file1 = Mockito.mock(Path.class);
Path file2 = Mockito.mock(Path.class);
Path mockPath = mock(Path.class);
Path file1 = mock(Path.class);
Path file2 = mock(Path.class);
Stream<Path> mockStream = Stream.of(file1, file2);

try (MockedStatic<Files> mockedFiles = Mockito.mockStatic(Files.class)) {
Expand Down
Loading