Fix unit tests by proper usage of PluginConfig

Adapt test code to the new PluginConfig class which is now split into
mutable and immutable parts and it is implemented as an AutoValue
(breaking change: I47bd35d50dae07aa2afd4862b998a4ae94454150).

Bug: Issue 13229
Change-Id: Ib64cc38161adc08028f6b1b9c9cf48e462d8187f
diff --git a/src/test/java/com/googlesource/gerrit/plugins/metricsreportercloudwatch/GerritCloudwatchReporterConfigTest.java b/src/test/java/com/googlesource/gerrit/plugins/metricsreportercloudwatch/GerritCloudwatchReporterConfigTest.java
index 30c769e..d1895d6 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/metricsreportercloudwatch/GerritCloudwatchReporterConfigTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/metricsreportercloudwatch/GerritCloudwatchReporterConfigTest.java
@@ -32,7 +32,8 @@
 @RunWith(MockitoJUnitRunner.class)
 public class GerritCloudwatchReporterConfigTest {
   private static final String PLUGIN_NAME = "foo";
-  private final PluginConfig emptyGlobalPluginConfig = new PluginConfig(PLUGIN_NAME, new Config());
+  private final PluginConfig.Update emptyGlobalPluginConfig =
+      PluginConfig.Update.forTest(PLUGIN_NAME, new Config());
 
   GerritCloudwatchReporterConfig reporterConfig;
 
@@ -40,7 +41,8 @@
 
   @Test
   public void shouldGetAllDefaultsWhenConfigurationIsEmpty() {
-    when(configFactory.getFromGerritConfig(PLUGIN_NAME)).thenReturn(emptyGlobalPluginConfig);
+    when(configFactory.getFromGerritConfig(PLUGIN_NAME))
+        .thenReturn(emptyGlobalPluginConfig.asPluginConfig());
     reporterConfig = new GerritCloudwatchReporterConfig(configFactory, PLUGIN_NAME);
 
     assertThat(reporterConfig.getInitialDelay())
@@ -57,14 +59,15 @@
 
   @Test
   public void shouldReadMetricValuesFromConfiguration() {
-    PluginConfig globalPluginConfig = emptyGlobalPluginConfig;
+    PluginConfig.Update globalPluginConfig = emptyGlobalPluginConfig;
     globalPluginConfig.setString(GerritCloudwatchReporterConfig.KEY_NAMESPACE, "foobar");
     globalPluginConfig.setString(GerritCloudwatchReporterConfig.KEY_RATE, "3m");
     globalPluginConfig.setString(GerritCloudwatchReporterConfig.KEY_INITIAL_DELAY, "20s");
     globalPluginConfig.setBoolean(GerritCloudwatchReporterConfig.KEY_DRYRUN, true);
     globalPluginConfig.setBoolean(GerritCloudwatchReporterConfig.KEY_JVM_METRICS, true);
 
-    when(configFactory.getFromGerritConfig(PLUGIN_NAME)).thenReturn(globalPluginConfig);
+    when(configFactory.getFromGerritConfig(PLUGIN_NAME))
+        .thenReturn(globalPluginConfig.asPluginConfig());
     reporterConfig = new GerritCloudwatchReporterConfig(configFactory, PLUGIN_NAME);
 
     assertThat(reporterConfig.getInitialDelay()).isEqualTo(20);
@@ -76,11 +79,12 @@
 
   @Test
   public void shouldReadCorrectExclusionFilter() {
-    PluginConfig globalPluginConfig = emptyGlobalPluginConfig;
+    PluginConfig.Update globalPluginConfig = emptyGlobalPluginConfig;
     globalPluginConfig.setStringList(
         GerritCloudwatchReporterConfig.KEY_EXCLUDE_METRICS, Arrays.asList("foo.*", ".*bar"));
 
-    when(configFactory.getFromGerritConfig(PLUGIN_NAME)).thenReturn(globalPluginConfig);
+    when(configFactory.getFromGerritConfig(PLUGIN_NAME))
+        .thenReturn(globalPluginConfig.asPluginConfig());
     reporterConfig = new GerritCloudwatchReporterConfig(configFactory, PLUGIN_NAME);
 
     MetricFilter exclusionFilter = reporterConfig.getExclusionFilter();
@@ -92,11 +96,12 @@
   @Test
   public void shouldThrowAnExceptionWhenExcludeMetricsRegexIsNotValid() {
     final String INVALID_REGEXP = "[[?";
-    PluginConfig globalPluginConfig = emptyGlobalPluginConfig;
+    PluginConfig.Update globalPluginConfig = emptyGlobalPluginConfig;
     globalPluginConfig.setString(
         GerritCloudwatchReporterConfig.KEY_EXCLUDE_METRICS, INVALID_REGEXP);
 
-    when(configFactory.getFromGerritConfig(PLUGIN_NAME)).thenReturn(globalPluginConfig);
+    when(configFactory.getFromGerritConfig(PLUGIN_NAME))
+        .thenReturn(globalPluginConfig.asPluginConfig());
 
     assertThrows(
         PatternSyntaxException.class,