@Test public void testFilterOnNullInputs() { PeerSequenceFilterEntries psfNullEntries = new PeerSequenceFilterEntriesBuilder().build(); SxpDatabaseBinding nullBinding = new SxpDatabaseBindingBuilder().build(); PeerSequenceFilterEntries psfEmptyEntries = new PeerSequenceFilterEntriesBuilder() .setPeerSequenceEntry(new ArrayList<>()).build(); SxpDatabaseBinding emptyBinding = new SxpDatabaseBindingBuilder() .setPeerSequence(new PeerSequenceBuilder().build()).build(); assertTrue(filter.filter(psfNullEntries, nullBinding)); assertTrue(filter.filter(psfEmptyEntries, emptyBinding)); assertTrue(filter.filter(psfEmptyEntries, nullBinding)); assertTrue(filter.filter(psfNullEntries, emptyBinding)); }
@Override protected boolean filter(PeerSequenceFilterEntries filterEntries, SxpBindingFields binding) { if (filterEntries.getPeerSequenceEntry() == null || filterEntries.getPeerSequenceEntry().isEmpty() || binding.getPeerSequence() == null || binding.getPeerSequence().getPeer() == null) { return true; } int peerSeqLength = MasterDBBindingComparator.getPeerSequenceLength(binding); for (PeerSequenceEntry psEntry : filterEntries.getPeerSequenceEntry()) { boolean entryMatch = false; switch (psEntry.getPeerSequenceRange()) { case Ge: entryMatch = peerSeqLength >= psEntry.getPeerSequenceLength(); break; case Le: entryMatch = peerSeqLength <= psEntry.getPeerSequenceLength(); break; case Eq: entryMatch = peerSeqLength == psEntry.getPeerSequenceLength(); break; } if (entryMatch) { return FilterEntryType.Deny.equals(psEntry.getEntryType()); } } return true; }
PeerSequenceFilter extends SxpBindingFilter<PeerSequenceFilterEntries, T> { @Override protected boolean filter(PeerSequenceFilterEntries filterEntries, SxpBindingFields binding) { if (filterEntries.getPeerSequenceEntry() == null || filterEntries.getPeerSequenceEntry().isEmpty() || binding.getPeerSequence() == null || binding.getPeerSequence().getPeer() == null) { return true; } int peerSeqLength = MasterDBBindingComparator.getPeerSequenceLength(binding); for (PeerSequenceEntry psEntry : filterEntries.getPeerSequenceEntry()) { boolean entryMatch = false; switch (psEntry.getPeerSequenceRange()) { case Ge: entryMatch = peerSeqLength >= psEntry.getPeerSequenceLength(); break; case Le: entryMatch = peerSeqLength <= psEntry.getPeerSequenceLength(); break; case Eq: entryMatch = peerSeqLength == psEntry.getPeerSequenceLength(); break; } if (entryMatch) { return FilterEntryType.Deny.equals(psEntry.getEntryType()); } } return true; } }
PeerSequenceFilter extends SxpBindingFilter<PeerSequenceFilterEntries, T> { @Override protected boolean filter(PeerSequenceFilterEntries filterEntries, SxpBindingFields binding) { if (filterEntries.getPeerSequenceEntry() == null || filterEntries.getPeerSequenceEntry().isEmpty() || binding.getPeerSequence() == null || binding.getPeerSequence().getPeer() == null) { return true; } int peerSeqLength = MasterDBBindingComparator.getPeerSequenceLength(binding); for (PeerSequenceEntry psEntry : filterEntries.getPeerSequenceEntry()) { boolean entryMatch = false; switch (psEntry.getPeerSequenceRange()) { case Ge: entryMatch = peerSeqLength >= psEntry.getPeerSequenceLength(); break; case Le: entryMatch = peerSeqLength <= psEntry.getPeerSequenceLength(); break; case Eq: entryMatch = peerSeqLength == psEntry.getPeerSequenceLength(); break; } if (entryMatch) { return FilterEntryType.Deny.equals(psEntry.getEntryType()); } } return true; } protected  PeerSequenceFilter(T filter, String peerGroupName); }
PeerSequenceFilter extends SxpBindingFilter<PeerSequenceFilterEntries, T> { @Override protected boolean filter(PeerSequenceFilterEntries filterEntries, SxpBindingFields binding) { if (filterEntries.getPeerSequenceEntry() == null || filterEntries.getPeerSequenceEntry().isEmpty() || binding.getPeerSequence() == null || binding.getPeerSequence().getPeer() == null) { return true; } int peerSeqLength = MasterDBBindingComparator.getPeerSequenceLength(binding); for (PeerSequenceEntry psEntry : filterEntries.getPeerSequenceEntry()) { boolean entryMatch = false; switch (psEntry.getPeerSequenceRange()) { case Ge: entryMatch = peerSeqLength >= psEntry.getPeerSequenceLength(); break; case Le: entryMatch = peerSeqLength <= psEntry.getPeerSequenceLength(); break; case Eq: entryMatch = peerSeqLength == psEntry.getPeerSequenceLength(); break; } if (entryMatch) { return FilterEntryType.Deny.equals(psEntry.getEntryType()); } } return true; } protected  PeerSequenceFilter(T filter, String peerGroupName);  }
PeerSequenceFilter extends SxpBindingFilter<PeerSequenceFilterEntries, T> { @Override protected boolean filter(PeerSequenceFilterEntries filterEntries, SxpBindingFields binding) { if (filterEntries.getPeerSequenceEntry() == null || filterEntries.getPeerSequenceEntry().isEmpty() || binding.getPeerSequence() == null || binding.getPeerSequence().getPeer() == null) { return true; } int peerSeqLength = MasterDBBindingComparator.getPeerSequenceLength(binding); for (PeerSequenceEntry psEntry : filterEntries.getPeerSequenceEntry()) { boolean entryMatch = false; switch (psEntry.getPeerSequenceRange()) { case Ge: entryMatch = peerSeqLength >= psEntry.getPeerSequenceLength(); break; case Le: entryMatch = peerSeqLength <= psEntry.getPeerSequenceLength(); break; case Eq: entryMatch = peerSeqLength == psEntry.getPeerSequenceLength(); break; } if (entryMatch) { return FilterEntryType.Deny.equals(psEntry.getEntryType()); } } return true; } protected  PeerSequenceFilter(T filter, String peerGroupName);   }