@Test public void canGroupRequests() { final Connection connection = createConnection(); final ChannelAddress addressA = new ChannelAddress( 1, 0 ); final ChannelAddress addressB = new ChannelAddress( 1, 1, 1 ); final ChannelAddress addressC = new ChannelAddress( 1, 1, 2 ); final ChannelAddress addressD = new ChannelAddress( 1, 1, 3 ); final ChannelAddress addressE = new ChannelAddress( 1, 1, 4 ); final String filterP = null; final String filterQ = "F1"; final String filterR = "F2"; final AreaOfInterestRequest request1 = new AreaOfInterestRequest( addressA, AreaOfInterestRequest.Type.ADD, filterP ); final AreaOfInterestRequest request2 = new AreaOfInterestRequest( addressA, AreaOfInterestRequest.Type.REMOVE, filterP ); final AreaOfInterestRequest request3 = new AreaOfInterestRequest( addressA, AreaOfInterestRequest.Type.UPDATE, filterP ); final AreaOfInterestRequest request4 = new AreaOfInterestRequest( addressA, AreaOfInterestRequest.Type.ADD, filterP ); final AreaOfInterestRequest request10 = new AreaOfInterestRequest( addressB, AreaOfInterestRequest.Type.ADD, filterQ ); final AreaOfInterestRequest request11 = new AreaOfInterestRequest( addressC, AreaOfInterestRequest.Type.ADD, filterQ ); final AreaOfInterestRequest request12 = new AreaOfInterestRequest( addressD, AreaOfInterestRequest.Type.REMOVE, null ); final AreaOfInterestRequest request13 = new AreaOfInterestRequest( addressE, AreaOfInterestRequest.Type.REMOVE, null ); final AreaOfInterestRequest request14 = new AreaOfInterestRequest( addressE, AreaOfInterestRequest.Type.UPDATE, filterQ ); final AreaOfInterestRequest request15 = new AreaOfInterestRequest( addressE, AreaOfInterestRequest.Type.ADD, filterP ); final AreaOfInterestRequest request16 = new AreaOfInterestRequest( addressE, AreaOfInterestRequest.Type.UPDATE, filterP ); final AreaOfInterestRequest request17 = new AreaOfInterestRequest( addressE, AreaOfInterestRequest.Type.REMOVE, null ); final AreaOfInterestRequest request18 = new AreaOfInterestRequest( addressE, AreaOfInterestRequest.Type.UPDATE, filterP ); final AreaOfInterestRequest request19 = new AreaOfInterestRequest( addressE, AreaOfInterestRequest.Type.UPDATE, filterR ); final List<AreaOfInterestRequest> requests = Arrays.asList( request1, request2, request3, request4, request10, request11, request12, request13, request14, request15, request16, request17, request18, request19 ); final HashMap<String, String> groupingPairs = new HashMap<>(); groupingPairs.put( request10.toString(), request11.toString() ); groupingPairs.put( request12.toString(), request13.toString() ); groupingPairs.put( request12.toString(), request17.toString() ); groupingPairs.put( request13.toString(), request17.toString() ); groupingPairs.put( request16.toString(), request18.toString() ); for ( final AreaOfInterestRequest r1 : requests ) { for ( final AreaOfInterestRequest r2 : requests ) { final boolean expected = ( r1 == r2 && null != r1.getAddress().getId() ) || Objects.equals( String.valueOf( groupingPairs.get( r1.toString() ) ), r2.toString() ) || Objects.equals( String.valueOf( groupingPairs.get( r2.toString() ) ), r1.toString() ); assertEquals( connection.canGroupRequests( r1, r2 ), expected, "Comparing " + r1 + " versus " + r2 ); } } }
boolean canGroupRequests( @Nonnull final AreaOfInterestRequest template, @Nonnull final AreaOfInterestRequest match ) { final CacheService cacheService = _connector.getReplicantContext().getCacheService(); return null != template.getAddress().getId() && null != match.getAddress().getId() && ( null == cacheService || null == cacheService.lookup( template.getAddress() ) ) && ( null == cacheService || null == cacheService.lookup( match.getAddress() ) ) && template.getType().equals( match.getType() ) && template.getAddress().getChannelId() == match.getAddress().getChannelId() && ( AreaOfInterestRequest.Type.REMOVE == match.getType() || FilterUtil.filtersEqual( match.getFilter(), template.getFilter() ) ); }
Connection { boolean canGroupRequests( @Nonnull final AreaOfInterestRequest template, @Nonnull final AreaOfInterestRequest match ) { final CacheService cacheService = _connector.getReplicantContext().getCacheService(); return null != template.getAddress().getId() && null != match.getAddress().getId() && ( null == cacheService || null == cacheService.lookup( template.getAddress() ) ) && ( null == cacheService || null == cacheService.lookup( match.getAddress() ) ) && template.getType().equals( match.getType() ) && template.getAddress().getChannelId() == match.getAddress().getChannelId() && ( AreaOfInterestRequest.Type.REMOVE == match.getType() || FilterUtil.filtersEqual( match.getFilter(), template.getFilter() ) ); } }
Connection { boolean canGroupRequests( @Nonnull final AreaOfInterestRequest template, @Nonnull final AreaOfInterestRequest match ) { final CacheService cacheService = _connector.getReplicantContext().getCacheService(); return null != template.getAddress().getId() && null != match.getAddress().getId() && ( null == cacheService || null == cacheService.lookup( template.getAddress() ) ) && ( null == cacheService || null == cacheService.lookup( match.getAddress() ) ) && template.getType().equals( match.getType() ) && template.getAddress().getChannelId() == match.getAddress().getChannelId() && ( AreaOfInterestRequest.Type.REMOVE == match.getType() || FilterUtil.filtersEqual( match.getFilter(), template.getFilter() ) ); } Connection( @Nonnull final Connector connector ); }
Connection { boolean canGroupRequests( @Nonnull final AreaOfInterestRequest template, @Nonnull final AreaOfInterestRequest match ) { final CacheService cacheService = _connector.getReplicantContext().getCacheService(); return null != template.getAddress().getId() && null != match.getAddress().getId() && ( null == cacheService || null == cacheService.lookup( template.getAddress() ) ) && ( null == cacheService || null == cacheService.lookup( match.getAddress() ) ) && template.getType().equals( match.getType() ) && template.getAddress().getChannelId() == match.getAddress().getChannelId() && ( AreaOfInterestRequest.Type.REMOVE == match.getType() || FilterUtil.filtersEqual( match.getFilter(), template.getFilter() ) ); } Connection( @Nonnull final Connector connector );  }
Connection { boolean canGroupRequests( @Nonnull final AreaOfInterestRequest template, @Nonnull final AreaOfInterestRequest match ) { final CacheService cacheService = _connector.getReplicantContext().getCacheService(); return null != template.getAddress().getId() && null != match.getAddress().getId() && ( null == cacheService || null == cacheService.lookup( template.getAddress() ) ) && ( null == cacheService || null == cacheService.lookup( match.getAddress() ) ) && template.getType().equals( match.getType() ) && template.getAddress().getChannelId() == match.getAddress().getChannelId() && ( AreaOfInterestRequest.Type.REMOVE == match.getType() || FilterUtil.filtersEqual( match.getFilter(), template.getFilter() ) ); } Connection( @Nonnull final Connector connector );   }