Skip to content

Commit b677de3

Browse files
authored
CWMS-2028: Added new LRTS interval identifier support (#270)
* Added new LRTS interval identifier support
1 parent 2065b0f commit b677de3

3 files changed

Lines changed: 34 additions & 1 deletion

File tree

.github/coveragereport/badge_branchcoverage.svg

Lines changed: 1 addition & 1 deletion
Loading

cwms-http-client/src/main/java/mil/army/usace/hec/cwms/http/client/HttpRequestBuilderImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ public HttpRequestBuilderImpl(ApiConnectionInfo apiConnectionInfo, String endpoi
7575
if (url == null) {
7676
throw new ServerNotFoundException("Invalid HTTP URL: " + apiRoot, apiRoot);
7777
}
78+
if (System.getProperty("cwms.interval.localregular.new.enabled", "false").equalsIgnoreCase("true")) {
79+
this.queryHeaders.put("X-CWMS-LRTS-Formatting", "true");
80+
}
7881
this.httpUrl = url;
7982
this.endpoint = Objects.requireNonNull(endpoint, "Cannot process request against the API root endpoint");
8083
this.apiConnectionInfo = apiConnectionInfo;

cwms-http-client/src/test/java/mil/army/usace/hec/cwms/http/client/TestHttpRequestBuilderImpl.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,36 @@ void testHttpRequestBuilderCreateGetRequest() throws IOException {
6969
assertEquals(root + endpoint, request.url().toString());
7070
}
7171

72+
@Test
73+
void testHttpRequestBuilderCreateGetRequestLRTSInterval() throws IOException {
74+
String root = "http://localhost:11524/cwms-data/";
75+
String endpoint = "timeseries";
76+
System.setProperty("cwms.interval.localregular.new.enabled", "true");
77+
ApiConnectionInfo apiConnectionInfo = new ApiConnectionInfoBuilder(root).build();
78+
79+
HttpRequestBuilderImpl httpRequestBuilder = ((HttpRequestExecutorImpl) new HttpRequestBuilderImpl(apiConnectionInfo, endpoint)
80+
.get()
81+
.withMediaType(ACCEPT_HEADER_V1))
82+
.getInstance();
83+
Request request = httpRequestBuilder.createRequest();
84+
assertEquals("true", request.header("X-CWMS-LRTS-Formatting"));
85+
}
86+
87+
@Test
88+
void testHttpRequestBuilderCreateGetRequestLegacyLRTSInterval() throws IOException {
89+
String root = "http://localhost:11524/cwms-data/";
90+
String endpoint = "timeseries";
91+
System.setProperty("cwms.interval.localregular.new.enabled", "false");
92+
ApiConnectionInfo apiConnectionInfo = new ApiConnectionInfoBuilder(root).build();
93+
94+
HttpRequestBuilderImpl httpRequestBuilder = ((HttpRequestExecutorImpl) new HttpRequestBuilderImpl(apiConnectionInfo, endpoint)
95+
.get()
96+
.withMediaType(ACCEPT_HEADER_V1))
97+
.getInstance();
98+
Request request = httpRequestBuilder.createRequest();
99+
assertNull(request.header("X-CWMS-LRTS-Formatting"));
100+
}
101+
72102
@Test
73103
void testHttpRequestBuilderCreatePatchRequest() throws IOException {
74104
String root = "http://localhost:11524/cwms-data/";

0 commit comments

Comments
 (0)