Skip to content

Commit efb9507

Browse files
committed
RM-3063: move cli tests to the package
1 parent c6c8e2d commit efb9507

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

cdoc2-cli/src/main/java/ee/cyber/cdoc2/cli/commands/CDocInfoCmd.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import static ee.cyber.cdoc2.crypto.KeyLabelTools.keyLabelParamsForDisplaying;
2222

2323

24-
2524
//S106 Standard outputs should not be used directly to log anything
2625
//CLI needs to interact with standard outputs
2726
@SuppressWarnings("java:S106")
@@ -44,18 +43,15 @@ private void setProperty(Map<String, String> props) {
4443

4544
@Override
4645
public Void call() throws Exception {
47-
48-
4946
List<Recipient> recipients = Envelope.parseHeader(Files.newInputStream(cdocFile.toPath()));
5047
for (Recipient recipient: recipients) {
51-
5248
String type = getHumanReadableType(recipient);
5349

5450
Map<String, String> keyLabelParams
5551
= extractKeyLabelParams(recipient.getRecipientKeyLabel());
5652

57-
String server = (recipient instanceof ServerRecipient)
58-
? "(server: " + ((ServerRecipient) recipient).getKeyServerId() + ")"
53+
String server = (recipient instanceof ServerRecipient serverRecipient)
54+
? "(server: " + serverRecipient.getKeyServerId() + ")"
5955
: "";
6056

6157
System.out.println(
@@ -69,8 +65,8 @@ public Void call() throws Exception {
6965
String getHumanReadableType(Recipient recipient) {
7066
Objects.requireNonNull(recipient); //can't have null recipient, fail with exception
7167

72-
if (recipient instanceof PublicKeyRecipient) {
73-
return ((PublicKeyRecipient) recipient).getRecipientPubKey().getAlgorithm() + " PublicKey";
68+
if (recipient instanceof PublicKeyRecipient publicKeyRecipient) {
69+
return publicKeyRecipient.getRecipientPubKey().getAlgorithm() + " PublicKey";
7470
} else if (recipient instanceof SymmetricKeyRecipient) {
7571
return "SymmetricKey";
7672
} else if (recipient instanceof PBKDF2Recipient) {
@@ -81,4 +77,5 @@ String getHumanReadableType(Recipient recipient) {
8177
return recipient.getClass().toString();
8278
}
8379
}
80+
8481
}

cdoc2-cli/src/test/java/CDocCliTest.java renamed to cdoc2-cli/src/test/java/cli/CDocCliTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ee.cyber.cdoc2.cli.CDocCli;
1+
package cli;
22

33
import java.io.ByteArrayOutputStream;
44
import java.io.IOException;
@@ -21,6 +21,9 @@
2121
import org.slf4j.Logger;
2222
import org.slf4j.LoggerFactory;
2323
import picocli.CommandLine;
24+
25+
import ee.cyber.cdoc2.cli.CDocCli;
26+
2427
import static org.junit.jupiter.api.Assertions.assertEquals;
2528
import static org.junit.jupiter.api.Assertions.assertThrows;
2629
import static org.junit.jupiter.api.Assertions.assertTrue;

cdoc2-cli/src/test/java/CryptoTest.java renamed to cdoc2-cli/src/test/java/cli/CryptoTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package cli;
2+
13
import org.junit.jupiter.api.Test;
24

35
import ee.cyber.cdoc2.crypto.Crypto;

0 commit comments

Comments
 (0)