@Test public void updateAreaOfInterest_missingErrorWhenExpected() { pauseScheduler(); final AreaOfInterest aoi = createAreaOfInterest( new ChannelAddress( 1, 0 ) ); final IllegalStateException exception = expectThrows( IllegalStateException.class, () -> aoi.updateAreaOfInterest( AreaOfInterest.Status.LOAD_FAILED, null ) ); assertEquals( exception.getMessage(), "Replicant-0016: Invoked updateAreaOfInterest for channel at address 1.0 with status LOAD_FAILED but failed to supply the expected error." ); }
@Action void updateAreaOfInterest( @Nonnull final Status status, @Nullable final Throwable error ) { if ( Replicant.shouldCheckApiInvariants() ) { final boolean expectError = Status.LOAD_FAILED == status || Status.UPDATE_FAILED == status; final ChannelAddress address = getAddress(); apiInvariant( () -> !expectError || null != error, () -> "Replicant-0016: Invoked updateAreaOfInterest for channel at address " + address + " with status " + status + " but failed to supply " + "the expected error." ); apiInvariant( () -> expectError || null == error, () -> "Replicant-0017: Invoked updateAreaOfInterest for channel at address " + address + " with status " + status + " and supplied an unexpected error." ); apiInvariant( () -> !shouldExpectNoSubscription( status ) || null == getReplicantContext().findSubscription( getAddress() ), () -> "Replicant-0019: Invoked updateAreaOfInterest for channel at address " + address + " with status " + status + " and found unexpected subscription in the context." ); } setStatus( status ); setError( error ); if ( Replicant.areSpiesEnabled() && getReplicantContext().getSpy().willPropagateSpyEvents() ) { getReplicantContext().getSpy().reportSpyEvent( new AreaOfInterestStatusUpdatedEvent( this ) ); } }
AreaOfInterest extends ReplicantService { @Action void updateAreaOfInterest( @Nonnull final Status status, @Nullable final Throwable error ) { if ( Replicant.shouldCheckApiInvariants() ) { final boolean expectError = Status.LOAD_FAILED == status || Status.UPDATE_FAILED == status; final ChannelAddress address = getAddress(); apiInvariant( () -> !expectError || null != error, () -> "Replicant-0016: Invoked updateAreaOfInterest for channel at address " + address + " with status " + status + " but failed to supply " + "the expected error." ); apiInvariant( () -> expectError || null == error, () -> "Replicant-0017: Invoked updateAreaOfInterest for channel at address " + address + " with status " + status + " and supplied an unexpected error." ); apiInvariant( () -> !shouldExpectNoSubscription( status ) || null == getReplicantContext().findSubscription( getAddress() ), () -> "Replicant-0019: Invoked updateAreaOfInterest for channel at address " + address + " with status " + status + " and found unexpected subscription in the context." ); } setStatus( status ); setError( error ); if ( Replicant.areSpiesEnabled() && getReplicantContext().getSpy().willPropagateSpyEvents() ) { getReplicantContext().getSpy().reportSpyEvent( new AreaOfInterestStatusUpdatedEvent( this ) ); } } }
AreaOfInterest extends ReplicantService { @Action void updateAreaOfInterest( @Nonnull final Status status, @Nullable final Throwable error ) { if ( Replicant.shouldCheckApiInvariants() ) { final boolean expectError = Status.LOAD_FAILED == status || Status.UPDATE_FAILED == status; final ChannelAddress address = getAddress(); apiInvariant( () -> !expectError || null != error, () -> "Replicant-0016: Invoked updateAreaOfInterest for channel at address " + address + " with status " + status + " but failed to supply " + "the expected error." ); apiInvariant( () -> expectError || null == error, () -> "Replicant-0017: Invoked updateAreaOfInterest for channel at address " + address + " with status " + status + " and supplied an unexpected error." ); apiInvariant( () -> !shouldExpectNoSubscription( status ) || null == getReplicantContext().findSubscription( getAddress() ), () -> "Replicant-0019: Invoked updateAreaOfInterest for channel at address " + address + " with status " + status + " and found unexpected subscription in the context." ); } setStatus( status ); setError( error ); if ( Replicant.areSpiesEnabled() && getReplicantContext().getSpy().willPropagateSpyEvents() ) { getReplicantContext().getSpy().reportSpyEvent( new AreaOfInterestStatusUpdatedEvent( this ) ); } } AreaOfInterest( @Nullable final ReplicantContext context,
                  @Nonnull final ChannelAddress address,
                  @Nullable final Object filter ); }
AreaOfInterest extends ReplicantService { @Action void updateAreaOfInterest( @Nonnull final Status status, @Nullable final Throwable error ) { if ( Replicant.shouldCheckApiInvariants() ) { final boolean expectError = Status.LOAD_FAILED == status || Status.UPDATE_FAILED == status; final ChannelAddress address = getAddress(); apiInvariant( () -> !expectError || null != error, () -> "Replicant-0016: Invoked updateAreaOfInterest for channel at address " + address + " with status " + status + " but failed to supply " + "the expected error." ); apiInvariant( () -> expectError || null == error, () -> "Replicant-0017: Invoked updateAreaOfInterest for channel at address " + address + " with status " + status + " and supplied an unexpected error." ); apiInvariant( () -> !shouldExpectNoSubscription( status ) || null == getReplicantContext().findSubscription( getAddress() ), () -> "Replicant-0019: Invoked updateAreaOfInterest for channel at address " + address + " with status " + status + " and found unexpected subscription in the context." ); } setStatus( status ); setError( error ); if ( Replicant.areSpiesEnabled() && getReplicantContext().getSpy().willPropagateSpyEvents() ) { getReplicantContext().getSpy().reportSpyEvent( new AreaOfInterestStatusUpdatedEvent( this ) ); } } AreaOfInterest( @Nullable final ReplicantContext context,
                  @Nonnull final ChannelAddress address,
                  @Nullable final Object filter ); void incRefCount(); int getRefCount(); void decRefCount(); @Nonnull ChannelAddress getAddress(); @Observable @Nullable Object getFilter(); @Observable( readOutsideTransaction = Feature.ENABLE ) @Nonnull Status getStatus(); @Observable @Nullable abstract Throwable getError(); @Memoize @Nullable Subscription getSubscription(); @Override String toString(); }
AreaOfInterest extends ReplicantService { @Action void updateAreaOfInterest( @Nonnull final Status status, @Nullable final Throwable error ) { if ( Replicant.shouldCheckApiInvariants() ) { final boolean expectError = Status.LOAD_FAILED == status || Status.UPDATE_FAILED == status; final ChannelAddress address = getAddress(); apiInvariant( () -> !expectError || null != error, () -> "Replicant-0016: Invoked updateAreaOfInterest for channel at address " + address + " with status " + status + " but failed to supply " + "the expected error." ); apiInvariant( () -> expectError || null == error, () -> "Replicant-0017: Invoked updateAreaOfInterest for channel at address " + address + " with status " + status + " and supplied an unexpected error." ); apiInvariant( () -> !shouldExpectNoSubscription( status ) || null == getReplicantContext().findSubscription( getAddress() ), () -> "Replicant-0019: Invoked updateAreaOfInterest for channel at address " + address + " with status " + status + " and found unexpected subscription in the context." ); } setStatus( status ); setError( error ); if ( Replicant.areSpiesEnabled() && getReplicantContext().getSpy().willPropagateSpyEvents() ) { getReplicantContext().getSpy().reportSpyEvent( new AreaOfInterestStatusUpdatedEvent( this ) ); } } AreaOfInterest( @Nullable final ReplicantContext context,
                  @Nonnull final ChannelAddress address,
                  @Nullable final Object filter ); void incRefCount(); int getRefCount(); void decRefCount(); @Nonnull ChannelAddress getAddress(); @Observable @Nullable Object getFilter(); @Observable( readOutsideTransaction = Feature.ENABLE ) @Nonnull Status getStatus(); @Observable @Nullable abstract Throwable getError(); @Memoize @Nullable Subscription getSubscription(); @Override String toString();  }