Forwarder tests: Replace null event json with valid one

By means of using a properly typed Event sub-class. Before this change,
using an anonymous inner sub-class (defaulting to an outer class based
name) led to an unconvertible object type (to json). Converting it to
json was lending "null", rather than the expected event json structure.

The involved tests were passing before this change, however this fix
allows for event json test data that is more realistic, thus reliable.

Make the added trivial TestEvent class self-testing still, allowing it
to be in the same package as its users, while cleanly asserting itself.

Change-Id: Ie6ff172094996db2c8978e0f64beb60bf9fedc73
diff --git a/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedAwareEventBrokerTest.java b/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedAwareEventBrokerTest.java
index bc19732..9933838 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedAwareEventBrokerTest.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedAwareEventBrokerTest.java
@@ -28,7 +28,7 @@
 
   private EventListener listenerMock;
   private ForwardedAwareEventBroker broker;
-  private Event event = new Event(null) {};
+  private Event event = new TestEvent();
 
   @Before
   public void setUp() {
diff --git a/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/TestEvent.java b/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/TestEvent.java
new file mode 100644
index 0000000..f2f22cd
--- /dev/null
+++ b/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/TestEvent.java
@@ -0,0 +1,33 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.ericsson.gerrit.plugins.highavailability.forwarder;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.google.gerrit.server.events.Event;
+import org.junit.Test;
+
+public class TestEvent extends Event {
+  private static final String TYPE = "test-event";
+
+  public TestEvent() {
+    super(TYPE);
+  }
+
+  @Test
+  public void typeSet() {
+    assertThat(getType()).isEqualTo(TYPE);
+  }
+}
diff --git a/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarderServletModuleIT.java b/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarderServletModuleIT.java
index c726ae4..0092902 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarderServletModuleIT.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarderServletModuleIT.java
@@ -14,6 +14,7 @@
 
 package com.ericsson.gerrit.plugins.highavailability.forwarder.rest;
 
+import com.ericsson.gerrit.plugins.highavailability.forwarder.TestEvent;
 import com.google.common.base.Joiner;
 import com.google.gerrit.acceptance.LightweightPluginDaemonTest;
 import com.google.gerrit.acceptance.NoHttpd;
@@ -30,7 +31,7 @@
     httpModule = "com.ericsson.gerrit.plugins.highavailability.HttpModule")
 public class RestForwarderServletModuleIT extends LightweightPluginDaemonTest {
 
-  private final Event event = new Event("un-deserializable") {};
+  private final Event event = new TestEvent();
   private final String endpointPrefix = "/plugins/high-availability";
   private final String eventEndpointSuffix = "event";
 
diff --git a/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarderTest.java b/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarderTest.java
index bb40763..fb12578 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarderTest.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarderTest.java
@@ -22,6 +22,7 @@
 
 import com.ericsson.gerrit.plugins.highavailability.Configuration;
 import com.ericsson.gerrit.plugins.highavailability.cache.Constants;
+import com.ericsson.gerrit.plugins.highavailability.forwarder.TestEvent;
 import com.ericsson.gerrit.plugins.highavailability.forwarder.rest.HttpResponseHandler.HttpResult;
 import com.ericsson.gerrit.plugins.highavailability.peers.PeerInfo;
 import com.google.common.base.Joiner;
@@ -63,7 +64,7 @@
       Joiner.on("/").join(URL, PLUGINS, PLUGIN_NAME, "index/group", UUID);
 
   // Event
-  private static Event event = new Event("test-event") {};
+  private static Event event = new TestEvent();
   private static final String EVENT_ENDPOINT =
       Joiner.on("/").join(URL, PLUGINS, PLUGIN_NAME, "event", event.type);
   private static String eventJson = new GsonBuilder().create().toJson(event);