mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-12-22 21:07:57 +01:00
Remove label related CLI tests
This commit is contained in:
parent
802bc0aa73
commit
d24ff9cbde
1 changed files with 12 additions and 41 deletions
|
@ -4,17 +4,6 @@
|
||||||
|
|
||||||
package sop.cli.picocli.commands;
|
package sop.cli.picocli.commands;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.never;
|
|
||||||
import static org.mockito.Mockito.times;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
|
|
||||||
import com.ginsberg.junit.exit.ExpectSystemExitWithStatus;
|
import com.ginsberg.junit.exit.ExpectSystemExitWithStatus;
|
||||||
import com.ginsberg.junit.exit.FailOnSystemExit;
|
import com.ginsberg.junit.exit.FailOnSystemExit;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
@ -22,10 +11,20 @@ import org.junit.jupiter.api.Test;
|
||||||
import sop.Ready;
|
import sop.Ready;
|
||||||
import sop.SOP;
|
import sop.SOP;
|
||||||
import sop.cli.picocli.SopCLI;
|
import sop.cli.picocli.SopCLI;
|
||||||
import sop.enums.ArmorLabel;
|
|
||||||
import sop.exception.SOPGPException;
|
import sop.exception.SOPGPException;
|
||||||
import sop.operation.Armor;
|
import sop.operation.Armor;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class ArmorCmdTest {
|
public class ArmorCmdTest {
|
||||||
|
|
||||||
private Armor armor;
|
private Armor armor;
|
||||||
|
@ -41,40 +40,12 @@ public class ArmorCmdTest {
|
||||||
SopCLI.setSopInstance(sop);
|
SopCLI.setSopInstance(sop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void assertLabelIsNotCalledByDefault() throws SOPGPException.UnsupportedOption {
|
|
||||||
SopCLI.main(new String[] {"armor"});
|
|
||||||
verify(armor, never()).label(any());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void assertLabelIsCalledWhenFlaggedWithArgument() throws SOPGPException.UnsupportedOption {
|
|
||||||
for (ArmorLabel label : ArmorLabel.values()) {
|
|
||||||
SopCLI.main(new String[] {"armor", "--label", label.name()});
|
|
||||||
verify(armor, times(1)).label(label);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void assertDataIsAlwaysCalled() throws SOPGPException.BadData, IOException {
|
public void assertDataIsAlwaysCalled() throws SOPGPException.BadData, IOException {
|
||||||
SopCLI.main(new String[] {"armor"});
|
SopCLI.main(new String[] {"armor"});
|
||||||
verify(armor, times(1)).data((InputStream) any());
|
verify(armor, times(1)).data((InputStream) any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@ExpectSystemExitWithStatus(SOPGPException.UnsupportedOption.EXIT_CODE)
|
|
||||||
public void assertThrowsForInvalidLabel() {
|
|
||||||
SopCLI.main(new String[] {"armor", "--label", "Invalid"});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@ExpectSystemExitWithStatus(SOPGPException.UnsupportedOption.EXIT_CODE)
|
|
||||||
public void ifLabelsUnsupportedExit37() throws SOPGPException.UnsupportedOption {
|
|
||||||
when(armor.label(any())).thenThrow(new SOPGPException.UnsupportedOption("Custom Armor labels are not supported."));
|
|
||||||
|
|
||||||
SopCLI.main(new String[] {"armor", "--label", "Sig"});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ExpectSystemExitWithStatus(SOPGPException.BadData.EXIT_CODE)
|
@ExpectSystemExitWithStatus(SOPGPException.BadData.EXIT_CODE)
|
||||||
public void ifBadDataExit41() throws SOPGPException.BadData, IOException {
|
public void ifBadDataExit41() throws SOPGPException.BadData, IOException {
|
||||||
|
@ -94,7 +65,7 @@ public class ArmorCmdTest {
|
||||||
private static Ready nopReady() {
|
private static Ready nopReady() {
|
||||||
return new Ready() {
|
return new Ready() {
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(OutputStream outputStream) {
|
public void writeTo(@Nonnull OutputStream outputStream) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue