Skip to content

Commit

Permalink
fix method rename and new client version
Browse files Browse the repository at this point in the history
  • Loading branch information
katerina20 committed Jan 17, 2024
1 parent 3b61f20 commit 9c69b66
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void act(Outputter out, ProjectProperties properties, ProjectClient clien
out.println(SKIPPED.withIcon(RESOURCE_BUNDLE.getString("message.no_file_string_project")));
return;
}
String filePath = Utils.unixPath(Utils.sepAtStart(file));
String filePath = Utils.toUnixPath(Utils.sepAtStart(file));
List<FileInfo> projectFiles = project.getFileInfos();
FileInfo foundFile = projectFiles.stream()
.filter(f -> Objects.equals(filePath, f.getPath()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void act(Outputter out, ProjectProperties properties, ProjectClient clien
return;
}

String filePath = Utils.unixPath(Utils.sepAtStart(file));
String filePath = Utils.toUnixPath(Utils.sepAtStart(file));
FileInfo foundFile = project.getFileInfos().stream()
.filter(f -> Objects.equals(filePath, f.getPath()))
.findFirst()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void act(Outputter out, ProjectProperties properties, ProjectClient clien

Language language = project.findLanguageById(languageId, true)
.orElseThrow(() -> new RuntimeException(String.format(RESOURCE_BUNDLE.getString("error.language_not_exist"), languageId)));
String sourcePath = Utils.unixPath(Utils.sepAtStart(file));
String sourcePath = Utils.toUnixPath(Utils.sepAtStart(file));
FileInfo sourceFileInfo = project.getFileInfos().stream()
.filter(fi -> Objects.equals(sourcePath, fi.getPath()))
.findFirst()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void act(Outputter out, ProjectProperties properties, ProjectClient clien
if (Objects.equals(Type.FILES_BASED, project.getType())) {
if (Objects.isNull(dest))
throw new RuntimeException(String.format(RESOURCE_BUNDLE.getString("error.file.dest_required"), languageId));
String sourcePath = Utils.unixPath(Utils.sepAtStart(dest));
String sourcePath = Utils.toUnixPath(Utils.sepAtStart(dest));
FileInfo sourceFileInfo = project.getFileInfos().stream()
.filter(fi -> Objects.equals(sourcePath, fi.getPath()))
.findFirst()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void testDelete() {
when(client.downloadFullProject())
.thenReturn(build);

NewAction<ProjectProperties, ProjectClient> action = new FileDeleteAction("first.po");
NewAction<ProjectProperties, ProjectClient> action = new FileDeleteAction("/first.po");
action.act(Outputter.getDefault(), pb, client);

verify(client).downloadFullProject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
import com.crowdin.cli.properties.helper.TempProject;
import com.crowdin.cli.utils.Utils;
import com.crowdin.client.projectsgroups.model.Type;
import com.crowdin.client.sourcefiles.model.FileInfo;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.net.URL;
import java.util.Collections;

import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
Expand All @@ -42,10 +44,15 @@ public void testDownload() {
.setBasePath(project.getBasePath());
PropertiesWithFiles pb = pbBuilder.build();
ProjectClient client = mock(ProjectClient.class);
CrowdinProjectFull build = mock(CrowdinProjectFull.class);
URL urlMock = MockitoUtils.getMockUrl(getClass());
CrowdinProjectFull build = ProjectBuilder.emptyProject(Long.parseLong(pb.getProjectId()))
.addFile("/first.po", "gettext", 101L, null, null, null).build();
build.setType(Type.FILES_BASED);
FileInfo fileInfo = new FileInfo();
fileInfo.setPath("/first.po");
fileInfo.setName("first.po");
fileInfo.setId(101L);
when(build.getType()).thenReturn(Type.FILES_BASED);
when(build.isManagerAccess()).thenReturn(true);
when(build.getFileInfos()).thenReturn(Collections.singletonList(fileInfo));
when(client.downloadFullProject())
.thenReturn(build);
when(client.downloadFile(eq(101L)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void testDownloadTranslation() {
when(client.buildProjectFileTranslation(eq(101L), eq(request)))
.thenReturn(urlMock);

NewAction<ProjectProperties, ProjectClient> action = new FileDownloadTranslationAction("first.po", "ua", "first.po");
NewAction<ProjectProperties, ProjectClient> action = new FileDownloadTranslationAction("/first.po", "ua", "first.po");
action.act(Outputter.getDefault(), pb, client);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void testUploadTranslation_FileBasedProject() throws ResponseException {
when(client.uploadStorage(eq("first_uk.po"), any()))
.thenReturn(1L);

NewAction<ProjectProperties, ProjectClient> action = new FileUploadTranslationAction(fileToUpload, null, "first.po", "ua", false);
NewAction<ProjectProperties, ProjectClient> action = new FileUploadTranslationAction(fileToUpload, null, "/first.po", "ua", false);
action.act(Outputter.getDefault(), pb, client);

verify(client).downloadFullProject(any());
Expand Down
2 changes: 1 addition & 1 deletion versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ version.commons-cli..commons-cli=1.5.0

version.com.h3xstream.findsecbugs..findsecbugs-plugin=1.12.0

version.com.github.crowdin..crowdin-api-client-java=1.13.0
version.com.github.crowdin..crowdin-api-client-java=1.14.0

plugin.org.asciidoctor.jvm.convert=3.3.2

Expand Down

0 comments on commit 9c69b66

Please sign in to comment.