### Question:
HandshakeClient implements ClientMessageHandler { public CompletableFuture<ProtocolStack> initiate( Channel channel, ApplicationProtocolRepository applicationProtocolRepository, ModifierProtocolRepository modifierProtocolRepository ) { this.channel = channel; this.applicationProtocolRepository = applicationProtocolRepository; this.supportedApplicationProtocol = applicationProtocolRepository.supportedProtocol(); this.modifierProtocolRepository = modifierProtocolRepository; this.supportedModifierProtocols = modifierProtocolRepository.supportedProtocols(); negotiatedModifierProtocols = new ArrayList<>( supportedModifierProtocols.size() ); channel.write( InitialMagicMessage.instance() ); sendProtocolRequests( channel, supportedApplicationProtocol, supportedModifierProtocols ); return future; }  CompletableFuture<ProtocolStack> initiate( Channel channel, ApplicationProtocolRepository applicationProtocolRepository,
            ModifierProtocolRepository modifierProtocolRepository ); @Override void handle( InitialMagicMessage magicMessage ); @Override void handle( ApplicationProtocolResponse applicationProtocolResponse ); @Override void handle( ModifierProtocolResponse modifierProtocolResponse ); @Override void handle( SwitchOverResponse response );  }### Answer:
@Test public void shouldSendInitialMagicOnInitiation() { client.initiate( channel, applicationProtocolRepository, modifierProtocolRepository ); verify( channel ).write( InitialMagicMessage.instance() ); }
@Test public void shouldSendApplicationProtocolRequestOnInitiation() { client.initiate( channel, applicationProtocolRepository, modifierProtocolRepository ); ApplicationProtocolRequest expectedMessage = new ApplicationProtocolRequest( applicationProtocolIdentifier.canonicalName(), applicationProtocolRepository.getAll( applicationProtocolIdentifier, emptyList() ).versions() ); verify( channel ).writeAndFlush( expectedMessage ); }
@Test public void shouldSendModifierProtocolRequestsOnInitiation() { client.initiate( channel, applicationProtocolRepository, modifierProtocolRepository ); Stream.of( Protocol.ModifierProtocolCategory.values() ).forEach( modifierProtocolIdentifier -> { Set<String> versions = modifierProtocolRepository.getAll( modifierProtocolIdentifier, emptyList() ).versions(); verify( channel ).write( new ModifierProtocolRequest( modifierProtocolIdentifier.canonicalName(), versions ) ); } ); }