introduce UraClientConfiguration class to encapsulate client config

Legacy constructors use new pattern internally.
This commit is contained in:
2020-05-09 18:31:57 +02:00
parent 7be56ad740
commit 9b80a4e889
4 changed files with 181 additions and 17 deletions

View File

@ -0,0 +1,34 @@
package de.stklcode.pubtrans.ura;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Unit test for {@link UraClientConfiguration}.
*
* @author Stefan Kalscheuer
*/
public class UraClientConfigurationTest {
@Test
public void configBuilderTest() {
final String baseURL = "https://ura.example.com";
final String instantPath = "/path/to/instant";
final String streamPath = "/path/to/stream";
// With Base-URL only.
UraClientConfiguration config = UraClientConfiguration.forBaseURL(baseURL).build();
assertEquals(baseURL, config.getBaseURL(), "Unexpected base URL");
assertEquals("/interfaces/ura/instant_V1", config.getInstantPath(), "Unexpected default instant path");
assertEquals("/interfaces/ura/stream_V1", config.getStreeamPath(), "Unexpected default stream path");
// With custom paths.
config = UraClientConfiguration.forBaseURL(baseURL)
.withInstantPath(instantPath)
.withStreamPath(streamPath)
.build();
assertEquals(baseURL, config.getBaseURL(), "Unexpected base URL");
assertEquals(instantPath, config.getInstantPath(), "Unexpected custom instant path");
assertEquals(streamPath, config.getStreeamPath(), "Unexpected custom stream path");
}
}