SimulatedDriver implements PlcDriver { @Override public PlcConnection getConnection(String url) throws PlcConnectionException { String deviceName = url.substring(getProtocolCode().length() + 1); if (deviceName.isEmpty()) { throw new PlcConnectionException("Invalid URL: no device name given."); } SimulatedDevice device = new SimulatedDevice(deviceName); return new SimulatedConnection(device); }  @Override String getProtocolCode(); @Override String getProtocolName(); @Override PlcConnection getConnection(String url); @Override PlcConnection getConnection(String url, PlcAuthentication authentication); @Override SimulatedField prepareField(String query);  }
@Test void connect() throws Exception { assertThat(SUT.getConnection("simulated:foobar")).isInstanceOf(SimulatedConnection.class); }
@Test void connect_secure() { assertThatThrownBy(() -> SUT.getConnection(null, null)).isInstanceOf(PlcConnectionException.class); }
@Test void wrongUrl() { assertThatThrownBy(() -> SUT.getConnection("simulated:")) .isInstanceOf(PlcConnectionException.class) .hasMessage("Invalid URL: no device name given."); }