@Test public void canGroup() { final Converger c = Replicant.context().getConverger(); safeAction( () -> { final ChannelAddress address = new ChannelAddress( 1, 0 ); final AreaOfInterest areaOfInterest = Replicant.context().createOrUpdateAreaOfInterest( address, null ); assertTrue( c.canGroup( areaOfInterest, AreaOfInterestRequest.Type.ADD, areaOfInterest, AreaOfInterestRequest.Type.ADD ) ); assertFalse( c.canGroup( areaOfInterest, AreaOfInterestRequest.Type.ADD, areaOfInterest, AreaOfInterestRequest.Type.UPDATE ) ); assertFalse( c.canGroup( areaOfInterest, AreaOfInterestRequest.Type.ADD, areaOfInterest, AreaOfInterestRequest.Type.REMOVE ) ); assertFalse( c.canGroup( areaOfInterest, AreaOfInterestRequest.Type.UPDATE, areaOfInterest, AreaOfInterestRequest.Type.ADD ) ); assertTrue( c.canGroup( areaOfInterest, AreaOfInterestRequest.Type.UPDATE, areaOfInterest, AreaOfInterestRequest.Type.UPDATE ) ); assertFalse( c.canGroup( areaOfInterest, AreaOfInterestRequest.Type.UPDATE, areaOfInterest, AreaOfInterestRequest.Type.REMOVE ) ); assertFalse( c.canGroup( areaOfInterest, AreaOfInterestRequest.Type.REMOVE, areaOfInterest, AreaOfInterestRequest.Type.ADD ) ); assertFalse( c.canGroup( areaOfInterest, AreaOfInterestRequest.Type.REMOVE, areaOfInterest, AreaOfInterestRequest.Type.UPDATE ) ); assertTrue( c.canGroup( areaOfInterest, AreaOfInterestRequest.Type.REMOVE, areaOfInterest, AreaOfInterestRequest.Type.REMOVE ) ); final ChannelAddress channel2 = new ChannelAddress( 1, 0, 2 ); final AreaOfInterest areaOfInterest2 = Replicant.context().createOrUpdateAreaOfInterest( channel2, null ); assertTrue( c.canGroup( areaOfInterest, AreaOfInterestRequest.Type.ADD, areaOfInterest2, AreaOfInterestRequest.Type.ADD ) ); final ChannelAddress address3 = new ChannelAddress( 1, 1, 1 ); final AreaOfInterest areaOfInterest3 = Replicant.context().createOrUpdateAreaOfInterest( address3, null ); assertFalse( c.canGroup( areaOfInterest, AreaOfInterestRequest.Type.ADD, areaOfInterest3, AreaOfInterestRequest.Type.ADD ) ); assertFalse( c.canGroup( areaOfInterest, AreaOfInterestRequest.Type.ADD, areaOfInterest3, AreaOfInterestRequest.Type.UPDATE ) ); assertFalse( c.canGroup( areaOfInterest, AreaOfInterestRequest.Type.ADD, areaOfInterest3, AreaOfInterestRequest.Type.REMOVE ) ); final ChannelAddress address4 = new ChannelAddress( 1, 0, 1 ); final AreaOfInterest areaOfInterest4 = Replicant.context().createOrUpdateAreaOfInterest( address4, "Filter" ); assertFalse( c.canGroup( areaOfInterest, AreaOfInterestRequest.Type.ADD, areaOfInterest4, AreaOfInterestRequest.Type.ADD ) ); areaOfInterest.setFilter( "Filter" ); assertTrue( c.canGroup( areaOfInterest, AreaOfInterestRequest.Type.ADD, areaOfInterest4, AreaOfInterestRequest.Type.ADD ) ); } ); }
boolean canGroup( @Nonnull final AreaOfInterest groupTemplate, @Nullable final AreaOfInterestRequest.Type groupAction, @Nonnull final AreaOfInterest areaOfInterest, @Nullable final AreaOfInterestRequest.Type action ) { if ( null != groupAction && null != action && !groupAction.equals( action ) ) { return false; } else { final boolean sameChannel = groupTemplate.getAddress().getSystemId() == areaOfInterest.getAddress().getSystemId() && groupTemplate.getAddress().getChannelId() == areaOfInterest.getAddress().getChannelId(); return sameChannel && ( AreaOfInterestRequest.Type.REMOVE == action || FilterUtil.filtersEqual( groupTemplate.getFilter(), areaOfInterest.getFilter() ) ); } }
Converger extends ReplicantService { boolean canGroup( @Nonnull final AreaOfInterest groupTemplate, @Nullable final AreaOfInterestRequest.Type groupAction, @Nonnull final AreaOfInterest areaOfInterest, @Nullable final AreaOfInterestRequest.Type action ) { if ( null != groupAction && null != action && !groupAction.equals( action ) ) { return false; } else { final boolean sameChannel = groupTemplate.getAddress().getSystemId() == areaOfInterest.getAddress().getSystemId() && groupTemplate.getAddress().getChannelId() == areaOfInterest.getAddress().getChannelId(); return sameChannel && ( AreaOfInterestRequest.Type.REMOVE == action || FilterUtil.filtersEqual( groupTemplate.getFilter(), areaOfInterest.getFilter() ) ); } } }
Converger extends ReplicantService { boolean canGroup( @Nonnull final AreaOfInterest groupTemplate, @Nullable final AreaOfInterestRequest.Type groupAction, @Nonnull final AreaOfInterest areaOfInterest, @Nullable final AreaOfInterestRequest.Type action ) { if ( null != groupAction && null != action && !groupAction.equals( action ) ) { return false; } else { final boolean sameChannel = groupTemplate.getAddress().getSystemId() == areaOfInterest.getAddress().getSystemId() && groupTemplate.getAddress().getChannelId() == areaOfInterest.getAddress().getChannelId(); return sameChannel && ( AreaOfInterestRequest.Type.REMOVE == action || FilterUtil.filtersEqual( groupTemplate.getFilter(), areaOfInterest.getFilter() ) ); } } Converger( @Nullable final ReplicantContext context ); }
Converger extends ReplicantService { boolean canGroup( @Nonnull final AreaOfInterest groupTemplate, @Nullable final AreaOfInterestRequest.Type groupAction, @Nonnull final AreaOfInterest areaOfInterest, @Nullable final AreaOfInterestRequest.Type action ) { if ( null != groupAction && null != action && !groupAction.equals( action ) ) { return false; } else { final boolean sameChannel = groupTemplate.getAddress().getSystemId() == areaOfInterest.getAddress().getSystemId() && groupTemplate.getAddress().getChannelId() == areaOfInterest.getAddress().getChannelId(); return sameChannel && ( AreaOfInterestRequest.Type.REMOVE == action || FilterUtil.filtersEqual( groupTemplate.getFilter(), areaOfInterest.getFilter() ) ); } } Converger( @Nullable final ReplicantContext context );  }
Converger extends ReplicantService { boolean canGroup( @Nonnull final AreaOfInterest groupTemplate, @Nullable final AreaOfInterestRequest.Type groupAction, @Nonnull final AreaOfInterest areaOfInterest, @Nullable final AreaOfInterestRequest.Type action ) { if ( null != groupAction && null != action && !groupAction.equals( action ) ) { return false; } else { final boolean sameChannel = groupTemplate.getAddress().getSystemId() == areaOfInterest.getAddress().getSystemId() && groupTemplate.getAddress().getChannelId() == areaOfInterest.getAddress().getChannelId(); return sameChannel && ( AreaOfInterestRequest.Type.REMOVE == action || FilterUtil.filtersEqual( groupTemplate.getFilter(), areaOfInterest.getFilter() ) ); } } Converger( @Nullable final ReplicantContext context );   }