-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
src/test/java/com/crowdin/cli/commands/actions/AppListActionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.crowdin.cli.commands.actions; | ||
|
||
import com.crowdin.cli.client.ProjectClient; | ||
import com.crowdin.cli.commands.NewAction; | ||
import com.crowdin.cli.commands.Outputter; | ||
import com.crowdin.cli.properties.ProjectProperties; | ||
import com.crowdin.cli.properties.PropertiesWithFiles; | ||
import com.crowdin.client.applications.installations.model.ApplicationInstallation; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static org.mockito.Mockito.*; | ||
|
||
public class AppListActionTest { | ||
|
||
List<ApplicationInstallation> standardList = Arrays.asList(new ApplicationInstallation(), new ApplicationInstallation()); | ||
List<ApplicationInstallation> emptyList = Collections.emptyList(); | ||
|
||
Outputter out = Outputter.getDefault(); | ||
PropertiesWithFiles pb; | ||
|
||
ProjectClient clientMock = mock(ProjectClient.class); | ||
NewAction<ProjectProperties, ProjectClient> action; | ||
|
||
@Test | ||
public void test_standard() { | ||
when(clientMock.listApplications()) | ||
.thenReturn(standardList); | ||
|
||
action = new AppListAction(false); | ||
action.act(out, pb, clientMock); | ||
|
||
verify(clientMock).listApplications(); | ||
verifyNoMoreInteractions(clientMock); | ||
} | ||
|
||
@Test | ||
public void test_plainView() { | ||
when(clientMock.listApplications()) | ||
.thenReturn(standardList); | ||
|
||
action = new AppListAction(true); | ||
action.act(out, pb, clientMock); | ||
|
||
verify(clientMock).listApplications(); | ||
verifyNoMoreInteractions(clientMock); | ||
} | ||
|
||
@Test | ||
public void test_emptyList() { | ||
when(clientMock.listApplications()) | ||
.thenReturn(emptyList); | ||
|
||
action = new AppListAction(false); | ||
action.act(out, pb, clientMock); | ||
|
||
verify(clientMock).listApplications(); | ||
verifyNoMoreInteractions(clientMock); | ||
} | ||
|
||
@Test | ||
public void test_emptyList_plainView() { | ||
when(clientMock.listApplications()) | ||
.thenReturn(emptyList); | ||
|
||
action = new AppListAction(true); | ||
action.act(out, pb, clientMock); | ||
|
||
verify(clientMock).listApplications(); | ||
verifyNoMoreInteractions(clientMock); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/java/com/crowdin/cli/commands/picocli/AppListSubcommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.crowdin.cli.commands.picocli; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.mockito.ArgumentMatchers.anyBoolean; | ||
import static org.mockito.Mockito.verify; | ||
|
||
public class AppListSubcommandTest extends PicocliTestUtils { | ||
|
||
@Test | ||
public void testAppList() { | ||
this.execute(CommandNames.APP, CommandNames.LIST); | ||
verify(actionsMock).listApps(anyBoolean()); | ||
this.check(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters