### Question:
TransSupplier implements Supplier<Trans> { public Trans get() { if ( Utils.isEmpty( transMeta.getVariable( "engine" ) ) ) { log.logBasic( "Using legacy execution engine" ); return fallbackSupplier.get(); } Variables variables = new Variables(); variables.initializeVariablesFrom( null ); String protocol = transMeta.getVariable( "engine.protocol" ); String host = transMeta.getVariable( "engine.host" ); String port = transMeta.getVariable( "engine.port" ); boolean ssl = "https".equalsIgnoreCase( protocol ) || "wss".equalsIgnoreCase( protocol ); return new TransWebSocketEngineAdapter( transMeta, host, port, ssl ); } TransSupplier( TransMeta transMeta, LogChannelInterface log, Supplier<Trans> fallbackSupplier ); Trans get();  }### Answer:
@Test public void testFallback() throws KettleException { when( fallbackSupplier.get() ).thenReturn( trans ); transSupplier = new TransSupplier( meta, log, fallbackSupplier ); Trans transRet = transSupplier.get(); verify( fallbackSupplier ).get(); assertEquals( transRet, trans ); }
@Test public void testWebsocketVersion() throws KettleException { props.setProperty( "KETTLE_AEL_PDI_DAEMON_VERSION", "2.0" ); when( meta.getVariable( "engine" ) ).thenReturn( "spark" ); when( meta.getVariable( "engine.host" ) ).thenReturn( "hostname" ); when( meta.getVariable( "engine.port" ) ).thenReturn( "8080" ); when( meta.nrTransHops() ).thenReturn( 0 ); when( meta.getTransHop( 0 ) ).thenReturn( transHopMeta ); when( meta.realClone( false ) ).thenReturn( meta ); when( transHopMeta.isEnabled() ).thenReturn( false ); transSupplier = new TransSupplier( meta, log, fallbackSupplier ); Trans transRet = transSupplier.get(); assertTrue( transRet instanceof TransWebSocketEngineAdapter ); }
@Test( expected = RuntimeException.class ) public void testInvalidEngine() throws KettleException { props.setProperty( "KETTLE_AEL_PDI_DAEMON_VERSION", "1.0" ); when( meta.getVariable( "engine" ) ).thenReturn( "invalidEngine" ); transSupplier = new TransSupplier( meta, log, fallbackSupplier ); transSupplier.get(); }