### Question:
SupportedProtocols { public Set<U> mutuallySupportedVersionsFor( Set<U> requestedVersions ) { if ( versions().isEmpty() ) { return requestedVersions; } else { return requestedVersions.stream().filter( versions()::contains ).collect( Collectors.toSet() ); } } SupportedProtocols( Protocol.Category<T> category, List<U> versions ); Set<U> mutuallySupportedVersionsFor( Set<U> requestedVersions ); Protocol.Category<T> identifier(); List<U> versions();  }### Answer:
@Test public void shouldMutuallySupportIntersectionOfParameterVersionsSuperset() { ApplicationSupportedProtocols supportedProtocols = new ApplicationSupportedProtocols( RAFT, Arrays.asList( 1, 2 ) ); Set<Integer> mutuallySupported = supportedProtocols.mutuallySupportedVersionsFor( Iterators.asSet( 1, 2, 3 ) ); assertThat( mutuallySupported, containsInAnyOrder( 1, 2 ) ); }
@Test public void shouldMutuallySupportIntersectionOfParameterVersionsSubset() { ApplicationSupportedProtocols supportedProtocols = new ApplicationSupportedProtocols( RAFT, Arrays.asList( 4, 5, 6 ) ); Set<Integer> mutuallySupported = supportedProtocols.mutuallySupportedVersionsFor( Iterators.asSet( 4, 5 ) ); assertThat( mutuallySupported, containsInAnyOrder( 4, 5 ) ); }
@Test public void shouldMutuallySupportParameterIfEmptyVersions() { ApplicationSupportedProtocols supportedProtocols = new ApplicationSupportedProtocols( RAFT, emptyList() ); Set<Integer> mutuallySupported = supportedProtocols.mutuallySupportedVersionsFor( Iterators.asSet( 7, 8 ) ); assertThat( mutuallySupported, containsInAnyOrder( 7, 8 ) ); }
@Test public void shouldMutuallySupportNothingIfParametersEmpty() { ApplicationSupportedProtocols supportedProtocols = new ApplicationSupportedProtocols( RAFT, Arrays.asList( 1, 2 ) ); Set<Integer> mutuallySupported = supportedProtocols.mutuallySupportedVersionsFor( emptySet() ); assertThat( mutuallySupported, empty() ); }