@@ -0,0 +1,2142 @@
+// Copyright (C) 2020 The Android Open Source Project%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A// http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A%0Apackage com.google.gerrit.acceptance.config;%0A%0Aimport static com.google.common.truth.Truth.assertThat;%0A%0Aimport com.google.gerrit.acceptance.LightweightPluginDaemonTest;%0Aimport com.google.gerrit.acceptance.TestPlugin;%0Aimport com.google.gerrit.common.Nullable;%0Aimport com.google.gerrit.server.config.GerritInstanceId;%0Aimport com.google.inject.AbstractModule;%0Aimport com.google.inject.Inject;%0Aimport com.google.inject.Scopes;%0Aimport org.junit.Test;%0A%0A@TestPlugin(%0A    name = %22instance-id-from-plugin%22,%0A    sysModule = %22com.google.gerrit.acceptance.config.InstanceIdFromPluginIT$Module%22)%0Apublic class InstanceIdFromPluginIT extends LightweightPluginDaemonTest %7B%0A%0A  public static class Module extends AbstractModule %7B%0A%0A    @Override%0A    protected void configure() %7B%0A      bind(InstanceIdLoader.class).in(Scopes.SINGLETON);%0A    %7D%0A  %7D%0A%0A  public static class InstanceIdLoader %7B%0A    public final String gerritInstanceId;%0A%0A    @Inject%0A    InstanceIdLoader(@Nullable @GerritInstanceId String gerritInstanceId) %7B%0A      this.gerritInstanceId = gerritInstanceId;%0A    %7D%0A  %7D%0A%0A  @Test%0A  @GerritConfig(name = %22gerrit.instanceId%22, value = %22testInstanceId%22)%0A  public void shouldReturnInstanceIdWhenDefined() %7B%0A    assertThat(getInstanceIdLoader().gerritInstanceId).isEqualTo(%22testInstanceId%22);%0A  %7D%0A%0A  @Test%0A  public void shouldReturnNullWhenNotDefined() %7B%0A    assertThat(getInstanceIdLoader().gerritInstanceId).isNull();%0A  %7D%0A%0A  private InstanceIdLoader getInstanceIdLoader() %7B%0A    return plugin.getSysInjector().getInstance(InstanceIdLoader.class);%0A  %7D%0A%7D%0A

Verify that instanceId is accessible from plugins