Workaround the inaccessbility of WebSessionManager.Val
The inability to mock the guava cache and also
the WebSessionManager.Val force the need to "hack" the access
to a "fake" Val by hijacking the constructor with a static
method inside the same package com.google.gerrit.httpd.
The hack allows to resume the normal execution of
the mocked tests since the introduction of the stricter
errorprone rules that denied the Guava cache mocking.
Change-Id: I1efcd1b145cae7f7921019fc21c8f34e72d5288e
diff --git a/src/test/java/com/google/gerrit/httpd/FakeWebSessionVal.java b/src/test/java/com/google/gerrit/httpd/FakeWebSessionVal.java
new file mode 100644
index 0000000..25babf9
--- /dev/null
+++ b/src/test/java/com/google/gerrit/httpd/FakeWebSessionVal.java
@@ -0,0 +1,14 @@
+package com.google.gerrit.httpd;
+
+import com.google.gerrit.entities.Account;
+import com.google.gerrit.httpd.WebSessionManager.Val;
+import com.google.gerrit.server.account.externalids.ExternalId;
+import org.junit.Ignore;
+
+@Ignore
+public class FakeWebSessionVal {
+
+ public static Val getVal(Account.Id accountId, ExternalId.Key externalIdKey) {
+ return new Val(accountId, 0, false, externalIdKey, 0, "", "");
+ }
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/websession/broker/BrokerBasedWebSessionCacheTest.java b/src/test/java/com/googlesource/gerrit/plugins/websession/broker/BrokerBasedWebSessionCacheTest.java
index 2832405..8bfeb56 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/websession/broker/BrokerBasedWebSessionCacheTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/websession/broker/BrokerBasedWebSessionCacheTest.java
@@ -29,6 +29,7 @@
import com.google.common.util.concurrent.MoreExecutors;
import com.google.gerrit.entities.Account;
import com.google.gerrit.extensions.registration.DynamicItem;
+import com.google.gerrit.httpd.FakeWebSessionVal;
import com.google.gerrit.httpd.WebSessionManager.Val;
import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.config.PluginConfig;
@@ -54,8 +55,7 @@
private static final int DEFAULT_ACCOUNT_ID = 1000000;
private static final String KEY = "aSceprtma6B0qZ0hKxXHvQ5iyfUhCcFXxG";
- private static Val VAL =
- new Val(Account.id(1), 0, false, ExternalId.Key.parse("foo:bar"), 0, "", "");
+ private static Val VAL = FakeWebSessionVal.getVal(Account.id(1), ExternalId.Key.parse("foo:bar"));
private static final String PLUGIN_NAME = "websession-broker";
private byte[] emptyPayload = new byte[] {-84, -19, 0, 5, 112};