EnOceanGateway implements RadioInterface, RadioTelegramListener { public void connect() throws ConfigurationException, ConnectionException { internalConnect(); } EnOceanGateway(EnOceanConnectionManager mgr, EspPortConfiguration config); void sendRadio(EspRadioTelegram.RORG rorg, DeviceID deviceID, byte[] payload, byte statusByte); void addRadioListener(DeviceID deviceID, RadioTelegramListener listener); @Override void removeRadioListener(DeviceID deviceID, RadioTelegramListener listener); @Override void radioTelegramReceived(EspRadioTelegram telegram); void connect(); void disconnect();  }
@Test public void testConnect() throws Exception { TestConnectionManager mgr = new TestConnectionManager(); EnOceanGateway gateway = new EnOceanGateway(mgr, new EspPortConfiguration()); gateway.connect(); Assert.assertEquals(1, mgr.getConnectionCallCount); }
@Test (expected = ConfigurationException.class) public void testMissingComPort() throws ConfigurationException { EspPortConfiguration config = new EspPortConfiguration(); config.setSerialProtocol(EspPortConfiguration.SerialProtocol.ESP3); config.setCommLayer(EspPortConfiguration.CommLayer.RXTX); EnOceanGateway gateway1 = new EnOceanGateway(new EnOceanConnectionManager(), config); try { gateway1.connect(); } catch (ConnectionException e) { } }
@Test (expected = ConfigurationException.class) public void testMissingSerialProtocol() throws ConfigurationException { EspPortConfiguration config = new EspPortConfiguration(); config.setComPort("/dev/cu.usbserial-FTUOKF2Q"); config.setCommLayer(EspPortConfiguration.CommLayer.RXTX); EnOceanGateway gateway1 = new EnOceanGateway(new EnOceanConnectionManager(), config); try { gateway1.connect(); } catch (ConnectionException e) { } }
@Test (expected = ConfigurationException.class) public void testMissingCommLayerProtocol() throws ConfigurationException { EspPortConfiguration config = new EspPortConfiguration(); config.setComPort("/dev/cu.usbserial-FTUOKF2Q"); config.setSerialProtocol(EspPortConfiguration.SerialProtocol.ESP3); EnOceanGateway gateway1 = new EnOceanGateway(new EnOceanConnectionManager(), config); try { gateway1.connect(); } catch (ConnectionException e) { } }