### Question:
RemoteValidatorSubscriptions implements BeaconChainEventsListener { SubscriptionStatus subscribe(String id, Consumer<BeaconChainEvent> sendEvent) { synchronized (this) { if (subscriptions.size() >= maxSubscribers) { return SubscriptionStatus.maxSubscribers(); } else { subscriptions.put(id, sendEvent); updateSubscribedValidatorsMetric(); return SubscriptionStatus.success(); } } } RemoteValidatorSubscriptions(
      final GlobalConfiguration configuration, final RemoteValidatorMetrics metrics); @Override void onEvent(final BeaconChainEvent event);  }### Answer:
@Test public void whenSuccessfullySubscribingValidator_shouldReturnSuccess() { final SubscriptionStatus subscriptionStatus = subscriptions.subscribe("1", subscriberCallback); assertThat(subscriptionStatus.hasSubscribed()).isTrue(); assertThat(subscriptionStatus.getInfo()).isEqualTo("ok"); }
@Test public void whenMaxValidatorsHaveSubscribed_shouldReturnMaxValidatorsFailures() { subscriptions.subscribe("1", subscriberCallback); subscriptions.subscribe("2", subscriberCallback); assertThat(internalSubscriptionsMap()).hasSize(MAX_SUBSCRIBERS); final SubscriptionStatus subscriptionStatus = this.subscriptions.subscribe("3", subscriberCallback); assertThat(subscriptionStatus.hasSubscribed()).isFalse(); assertThat(subscriptionStatus.getInfo()).isEqualTo("Reached max subscribers"); }
@Test public void subscribeShouldUpdateMetrics() { subscriptions.subscribe("1", subscriberCallback); verify(metrics).updateConnectedValidators(1); subscriptions.subscribe("2", subscriberCallback); verify(metrics).updateConnectedValidators(2); }