@Test public void addApplicationEventHandler_alreadyExists() { ReplicantTestUtil.enableEvents(); ReplicantTestUtil.resetState(); final ApplicationEventBroker broker = new ApplicationEventBroker(); final ApplicationEventHandler handler = new TestApplicationEventHandler(); broker.addApplicationEventHandler( handler ); final IllegalStateException exception = expectThrows( IllegalStateException.class, () -> broker.addApplicationEventHandler( handler ) ); assertEquals( exception.getMessage(), "Replicant-0089: Attempting to add handler " + handler + " that is already in the list of application handlers." ); }
public void addApplicationEventHandler( @Nonnull final ApplicationEventHandler handler ) { if ( Replicant.shouldCheckApiInvariants() ) { apiInvariant( () -> !_applicationEventHandlers.contains( handler ), () -> "Replicant-0089: Attempting to add handler " + handler + " that is already " + "in the list of application handlers." ); } _applicationEventHandlers.add( Objects.requireNonNull( handler ) ); }
ApplicationEventBroker { public void addApplicationEventHandler( @Nonnull final ApplicationEventHandler handler ) { if ( Replicant.shouldCheckApiInvariants() ) { apiInvariant( () -> !_applicationEventHandlers.contains( handler ), () -> "Replicant-0089: Attempting to add handler " + handler + " that is already " + "in the list of application handlers." ); } _applicationEventHandlers.add( Objects.requireNonNull( handler ) ); } }
ApplicationEventBroker { public void addApplicationEventHandler( @Nonnull final ApplicationEventHandler handler ) { if ( Replicant.shouldCheckApiInvariants() ) { apiInvariant( () -> !_applicationEventHandlers.contains( handler ), () -> "Replicant-0089: Attempting to add handler " + handler + " that is already " + "in the list of application handlers." ); } _applicationEventHandlers.add( Objects.requireNonNull( handler ) ); }  }
ApplicationEventBroker { public void addApplicationEventHandler( @Nonnull final ApplicationEventHandler handler ) { if ( Replicant.shouldCheckApiInvariants() ) { apiInvariant( () -> !_applicationEventHandlers.contains( handler ), () -> "Replicant-0089: Attempting to add handler " + handler + " that is already " + "in the list of application handlers." ); } _applicationEventHandlers.add( Objects.requireNonNull( handler ) ); }  void addApplicationEventHandler( @Nonnull final ApplicationEventHandler handler ); void removeApplicationEventHandler( @Nonnull final ApplicationEventHandler handler ); void reportApplicationEvent( @Nonnull final Object event ); boolean willPropagateApplicationEvents(); }
ApplicationEventBroker { public void addApplicationEventHandler( @Nonnull final ApplicationEventHandler handler ) { if ( Replicant.shouldCheckApiInvariants() ) { apiInvariant( () -> !_applicationEventHandlers.contains( handler ), () -> "Replicant-0089: Attempting to add handler " + handler + " that is already " + "in the list of application handlers." ); } _applicationEventHandlers.add( Objects.requireNonNull( handler ) ); }  void addApplicationEventHandler( @Nonnull final ApplicationEventHandler handler ); void removeApplicationEventHandler( @Nonnull final ApplicationEventHandler handler ); void reportApplicationEvent( @Nonnull final Object event ); boolean willPropagateApplicationEvents();  }