@Test
  public void flippingProxyModeUpdatesWL() throws Exception {
    // at this point, NexusStartedEvent was fired, and hence, WL's should be inited
    final Manager wm = lookup(Manager.class);
    final MavenProxyRepository proxy1 =
        getRepositoryRegistry().getRepositoryWithFacet(PROXY1_REPO_ID, MavenProxyRepository.class);

    assertThat(proxy1.getProxyMode(), equalTo(ProxyMode.BLOCKED_MANUAL));
    waitForRoutingBackgroundUpdates();

    // let's check states
    {
      // proxy1
      final RoutingStatus proxy1status = wm.getStatusFor(proxy1);
      // this repo is Blocked
      assertThat(proxy1status.getPublishingStatus().getStatus(), equalTo(PStatus.NOT_PUBLISHED));
      assertThat(
          proxy1status.getDiscoveryStatus().getStatus(), equalTo(DStatus.ENABLED_NOT_POSSIBLE));
      assertThat(proxy1status.getDiscoveryStatus().getLastDiscoveryStrategy(), is("none"));
      // Remark: the combination of those three above simply means "discovery never tried against
      // it"
      // yet.
    }
    {
      // group
      final RoutingStatus groupStatus =
          wm.getStatusFor(
              getRepositoryRegistry()
                  .getRepositoryWithFacet(GROUP_REPO_ID, MavenGroupRepository.class));
      // not all members have WL, unpublished
      assertThat(groupStatus.getPublishingStatus().getStatus(), equalTo(PStatus.NOT_PUBLISHED));
      // message should refer to proxy1 as reason of not publishing group WL
      assertThat(
          groupStatus.getPublishingStatus().getLastPublishedMessage(),
          containsString(proxy1.getName()));
      assertThat(groupStatus.getDiscoveryStatus().getStatus(), equalTo(DStatus.NOT_A_PROXY));
    }

    {
      // let's flip proxy1 now
      proxy1.setProxyMode(ProxyMode.ALLOW);
      getApplicationConfiguration().saveConfiguration();
      Thread.yield();
      wairForAsyncEventsToCalmDown();
      waitForRoutingBackgroundUpdates();
    }

    // let's check states again, now with enabled proxy1

    {
      // proxy1
      final RoutingStatus proxy1status =
          wm.getStatusFor(
              getRepositoryRegistry()
                  .getRepositoryWithFacet(PROXY1_REPO_ID, MavenProxyRepository.class));
      // this repo is Out of Service
      assertThat(proxy1status.getPublishingStatus().getStatus(), equalTo(PStatus.PUBLISHED));
      assertThat(proxy1status.getDiscoveryStatus().getStatus(), equalTo(DStatus.SUCCESSFUL));
      assertThat(
          proxy1status.getDiscoveryStatus().getLastDiscoveryStrategy(),
          is(RemotePrefixFileStrategy.ID));
    }
    {
      // group
      final RoutingStatus groupStatus =
          wm.getStatusFor(
              getRepositoryRegistry()
                  .getRepositoryWithFacet(GROUP_REPO_ID, MavenGroupRepository.class));
      assertThat(groupStatus.getPublishingStatus().getStatus(), equalTo(PStatus.PUBLISHED));
      assertThat(groupStatus.getDiscoveryStatus().getStatus(), equalTo(DStatus.NOT_A_PROXY));
    }

    {
      // let's flip proxy1 now back
      proxy1.setProxyMode(ProxyMode.BLOCKED_MANUAL);
      getApplicationConfiguration().saveConfiguration();
      Thread.yield();
      wairForAsyncEventsToCalmDown();
      waitForRoutingBackgroundUpdates();
    }

    // let's check states again, now with enabled proxy1

    {
      // proxy1
      final RoutingStatus proxy1status =
          wm.getStatusFor(
              getRepositoryRegistry()
                  .getRepositoryWithFacet(PROXY1_REPO_ID, MavenProxyRepository.class));
      // this repo is blocked
      assertThat(proxy1status.getPublishingStatus().getStatus(), equalTo(PStatus.PUBLISHED));
      assertThat(
          proxy1status.getDiscoveryStatus().getStatus(), equalTo(DStatus.ENABLED_NOT_POSSIBLE));
      assertThat(proxy1status.getDiscoveryStatus().getLastDiscoveryStrategy(), is("none"));
    }
    {
      // group
      final RoutingStatus groupStatus =
          wm.getStatusFor(
              getRepositoryRegistry()
                  .getRepositoryWithFacet(GROUP_REPO_ID, MavenGroupRepository.class));
      assertThat(groupStatus.getPublishingStatus().getStatus(), equalTo(PStatus.PUBLISHED));
      assertThat(groupStatus.getDiscoveryStatus().getStatus(), equalTo(DStatus.NOT_A_PROXY));
    }
  }
  @Test
  public void manuallyBlockedRepositoryDoesNotAffectWLInitialization() throws Exception {
    // at this point, NexusStartedEvent was fired, and hence, WL's should be inited
    final Manager wm = lookup(Manager.class);
    final MavenProxyRepository proxy1 =
        getRepositoryRegistry().getRepositoryWithFacet(PROXY1_REPO_ID, MavenProxyRepository.class);

    assertThat(proxy1.getProxyMode(), equalTo(ProxyMode.BLOCKED_MANUAL));
    waitForRoutingBackgroundUpdates();

    // let's check states

    {
      // proxy1
      final RoutingStatus proxy1status = wm.getStatusFor(proxy1);
      // this repo is Out of Service
      assertThat(proxy1status.getPublishingStatus().getStatus(), equalTo(PStatus.NOT_PUBLISHED));
      assertThat(
          proxy1status.getDiscoveryStatus().getStatus(), equalTo(DStatus.ENABLED_NOT_POSSIBLE));
      assertThat(proxy1status.getDiscoveryStatus().getLastDiscoveryStrategy(), is("none"));
      // Remark: the combination of those three above simply means "discovery never tried against
      // it"
      // yet.
    }

    {
      // proxy2
      final RoutingStatus proxy2status =
          wm.getStatusFor(
              getRepositoryRegistry()
                  .getRepositoryWithFacet(PROXY2_REPO_ID, MavenProxyRepository.class));
      // this repo should be good
      assertThat(proxy2status.getPublishingStatus().getStatus(), equalTo(PStatus.PUBLISHED));
      assertThat(proxy2status.getDiscoveryStatus().getStatus(), equalTo(DStatus.SUCCESSFUL));
    }

    {
      // hosted
      final RoutingStatus hostedStatus =
          wm.getStatusFor(
              getRepositoryRegistry()
                  .getRepositoryWithFacet(HOSTED_REPO_ID, MavenHostedRepository.class));
      // this repo should be good
      assertThat(hostedStatus.getPublishingStatus().getStatus(), equalTo(PStatus.PUBLISHED));
      assertThat(hostedStatus.getDiscoveryStatus().getStatus(), equalTo(DStatus.NOT_A_PROXY));
    }

    {
      // group
      final RoutingStatus groupStatus =
          wm.getStatusFor(
              getRepositoryRegistry()
                  .getRepositoryWithFacet(GROUP_REPO_ID, MavenGroupRepository.class));
      // not all members have WL, unpublished
      assertThat(groupStatus.getPublishingStatus().getStatus(), equalTo(PStatus.NOT_PUBLISHED));
      // message should refer to proxy1 as reason of not publishing group WL
      assertThat(
          groupStatus.getPublishingStatus().getLastPublishedMessage(),
          containsString(proxy1.getName()));
      assertThat(groupStatus.getDiscoveryStatus().getStatus(), equalTo(DStatus.NOT_A_PROXY));
    }
  }