Connector { public ConnectorSettings getSettings() { return connectorSettings; } Connector(ConnectorSettings settings); ConnectorSettings getSettings(); void setSettings(ConnectorSettings settings);  }
@Test public void getSettingsTest() { try { ConnectorSettings connectorSettings = ConnectorSettings .builder() .baseUrl("http: .userName("myUserName") .password("myPassword") .readTimeout(1000) .connectTimeout(4000) .retryCount(4) .build(); Connector connector = new Connector(connectorSettings); ConnectorSettings retSettings = connector.getSettings(); assertThat(retSettings, notNullValue()); assertThat(retSettings.getUri(), equalTo(new URI("http: assertThat(retSettings.getBaseUrl(), equalTo(connectorSettings.getBaseUrl())); assertThat(retSettings.getUserName(), equalTo(connectorSettings.getUserName())); assertThat(retSettings.getPassword(), equalTo(connectorSettings.getPassword())); assertThat(retSettings.getReadTimeout(), equalTo(connectorSettings.getReadTimeout())); assertThat(retSettings.getConnectTimeout(), equalTo(connectorSettings.getConnectTimeout())); assertThat(retSettings.getRetryCount(), equalTo(connectorSettings.getRetryCount())); } catch (SettingsIsNullException | URISyntaxException e) { e.printStackTrace(); fail(e.getMessage()); } }
@Test public void getSettingsEmptyTest() { try { String defaultUrl = "http: String stringEmpty = ""; int defaultTimeout = 7000; int defaultRetryCount = 3; Connector connector = new Connector(ConnectorSettings.builder().build()); ConnectorSettings retSettings = connector.getSettings(); assertThat(retSettings, notNullValue()); assertThat(retSettings.getUri(), equalTo(new URI(defaultUrl))); assertThat(retSettings.getBaseUrl(), equalTo(defaultUrl)); assertThat(retSettings.getUserName(), equalTo(stringEmpty)); assertThat(retSettings.getPassword(), equalTo(stringEmpty)); assertThat(retSettings.getReadTimeout(), equalTo(defaultTimeout)); assertThat(retSettings.getConnectTimeout(), equalTo(defaultTimeout)); assertThat(retSettings.getRetryCount(), equalTo(defaultRetryCount)); } catch (SettingsIsNullException | URISyntaxException e) { e.printStackTrace(); fail(e.getMessage()); } }