Browse Source

Small fix and formatting AdapterTestUtils

JNI-96
heck 5 years ago
parent
commit
adbe59f77e
  1. 19
      test/java/foundation/pEp/jniadapter/test/utils/AdapterTestUtils.java

19
test/java/foundation/pEp/jniadapter/test/utils/AdapterTestUtils.java

@ -1,4 +1,5 @@
package foundation.pEp.jniadapter.test.utils; package foundation.pEp.jniadapter.test.utils;
import foundation.pEp.jniadapter.*; import foundation.pEp.jniadapter.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -9,7 +10,7 @@ import static foundation.pEp.pitytest.utils.TestUtils.clipString;
public class AdapterTestUtils { public class AdapterTestUtils {
public static String identityToString(Identity i, Boolean full) { public static String identityToString(Identity i, Boolean full) {
String ret = ""; String ret = "";
if(full) { if (full) {
ret += "address: " + i.address + "\n"; ret += "address: " + i.address + "\n";
ret += "fpr: " + i.fpr + "\n"; ret += "fpr: " + i.fpr + "\n";
ret += "username: " + i.username + "\n"; ret += "username: " + i.username + "\n";
@ -174,7 +175,7 @@ public class AdapterTestUtils {
} catch (Throwable e) { } catch (Throwable e) {
value = e.toString(); value = e.toString();
} }
kvs.add(new Pair<String,String>(key, value)); kvs.add(new Pair<String, String>(key, value));
if (!full) { if (!full) {
kvs = clipStrings(kvs, 200, "clipped..."); kvs = clipStrings(kvs, 200, "clipped...");
@ -257,14 +258,14 @@ public class AdapterTestUtils {
return ret; return ret;
} }
public static ArrayList<Pair<String,String>> clipStrings(ArrayList<Pair<String,String>> spv, int len, String clipMsg) { public static ArrayList<Pair<String, String>> clipStrings(ArrayList<Pair<String, String>> spv, int len, String clipMsg) {
for (Pair<String,String> p : spv) { for (Pair<String, String> p : spv) {
if(p != null) { if (p != null) {
if(p.first != null) { if (p.first != null) {
p.first = clipString(p.first, len, clipMsg); p.first = clipString(p.first, len, clipMsg);
} }
if(p.second != null) { if (p.second != null) {
p.second = clipString(p.second, len,clipMsg); p.second = clipString(p.second, len, clipMsg);
} }
} }
} }
@ -274,7 +275,9 @@ public class AdapterTestUtils {
public static Message makeNewTestMessage(Identity from, Identity to, Message.Direction dir) { public static Message makeNewTestMessage(Identity from, Identity to, Message.Direction dir) {
Message msg = new Message(); Message msg = new Message();
Vector<Identity> vID = new Vector<Identity>(); Vector<Identity> vID = new Vector<Identity>();
if (to != null) {
vID.add(to); vID.add(to);
}
msg.setFrom(from); msg.setFrom(from);
msg.setTo(vID); msg.setTo(vID);

Loading…
Cancel
Save