Skip to content

Commit 4099203

Browse files
zack-rmabuilduser
andauthored
Bugfix - TimeSeries Profile Instance: Updated to match required parameters of controller (#242)
* Updated to match required parameters of controller * Autogenerated JaCoCo coverage badge --------- Co-authored-by: builduser <[email protected]>
1 parent b6358ad commit 4099203

File tree

5 files changed

+21
-23
lines changed

5 files changed

+21
-23
lines changed

.github/coveragereport/badge_linecoverage.svg

Lines changed: 1 addition & 1 deletion
Loading

.github/coveragereport/badge_methodcoverage.svg

Lines changed: 1 addition & 1 deletion
Loading

cwms-radar-client/src/main/java/mil/army/usace/hec/cwms/radar/client/controllers/TimeSeriesProfileInstanceEndpointInput.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public static GetAll getAll() {
2020
return new GetAll();
2121
}
2222

23-
public static GetOne getOne(String officeId, String locationId, String parameterId, String version, List<String> unit) {
24-
return new GetOne(officeId, locationId, parameterId, version, unit);
23+
public static GetOne getOne(String officeId, String locationId, String parameterId, String version, List<String> unit, Instant start, Instant end) {
24+
return new GetOne(officeId, locationId, parameterId, version, unit, start, end);
2525
}
2626

2727
public static Post post(String profileData, TimeSeriesProfile profile, String version) {
@@ -101,19 +101,20 @@ public static final class GetOne extends EndpointInput {
101101
private boolean previous = false;
102102
private boolean next = false;
103103
private boolean maxVersion = false;
104-
private Instant start = Instant.now();
105-
private Instant end = Instant.now();
104+
private final Instant start;
105+
private final Instant end;
106106
private final String locationId;
107107
private String page;
108108
private int pageSize = 500;
109109

110-
private GetOne(String officeId, String locationId, String parameterId, String version, List<String> unit) {
110+
private GetOne(String officeId, String locationId, String parameterId, String version, List<String> unit, Instant start, Instant end) {
111111
this.officeId = Objects.requireNonNull(officeId, "Office is required");
112112
this.locationId = Objects.requireNonNull(locationId, "Location ID is required");
113113
this.parameterId = Objects.requireNonNull(parameterId, "Parameter ID is required");
114114
this.version = Objects.requireNonNull(version, "Version is required");
115115
this.unit = Objects.requireNonNull(unit,"Unit is required");
116-
116+
this.start = Objects.requireNonNull(start, "Start is required");
117+
this.end = Objects.requireNonNull(end, "End is required");
117118
}
118119

119120
public GetOne versionDate(Instant versionDate) {
@@ -151,16 +152,6 @@ public GetOne maxVersion(boolean maxVersion) {
151152
return this;
152153
}
153154

154-
public GetOne start(Instant start) {
155-
this.start = start;
156-
return this;
157-
}
158-
159-
public GetOne end(Instant end) {
160-
this.end = end;
161-
return this;
162-
}
163-
164155
public GetOne page(String page) {
165156
this.page = page;
166157
return this;

cwms-radar-client/src/test/java/mil/army/usace/hec/cwms/radar/client/controllers/TestTimeSeriesProfileInstanceController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ void testGetOne() throws IOException {
1919
mockHttpServer.enqueue(collect);
2020
mockHttpServer.start();
2121
List<String> parameterList = List.of("F", "m");
22+
Instant firstDate = Instant.ofEpochMilli(1594296000000L);
23+
Instant lastDate = Instant.ofEpochMilli(1752062400000L);
2224
TimeSeriesProfileInstanceEndpointInput.GetOne input = TimeSeriesProfileInstanceEndpointInput
2325
.getOne("SWT", "Test_TSP_Location", "Depth", "DSS-Obs",
24-
parameterList).page("CWMSTESTPAGE").pageSize(50);
26+
parameterList, firstDate, lastDate)
27+
.page("CWMSTESTPAGE").pageSize(50);
2528
TimeSeriesProfileInstance value = new TimeSeriesProfileInstanceController()
2629
.retrieveTimeSeriesProfileInstance(buildConnectionInfo(), input);
2730
assertNotNull(value);
@@ -31,6 +34,8 @@ void testGetOne() throws IOException {
3134
assertEquals("Depth", value.getTimeSeriesProfile().getKeyParameter());
3235
assertEquals("Description", value.getTimeSeriesProfile().getDescription());
3336
assertEquals("SWT", value.getTimeSeriesProfile().getLocationId().getOfficeId());
37+
assertEquals(firstDate, value.getFirstDate().toInstant());
38+
assertEquals(lastDate, value.getLastDate().toInstant());
3439
assertEquals(parameterList.get(0), value.getParameterColumns().get(0).getUnit());
3540
assertEquals(parameterList.get(1), value.getParameterColumns().get(1).getUnit());
3641
}

cwms-radar-client/src/test/java/mil/army/usace/hec/cwms/radar/client/controllers/TestTimeSeriesProfileInstanceEndpointInput.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ void testGetAllQueryRequest() {
2525
String locationMask = "*LOC*";
2626
String officeMask = "SPK";
2727
String parameterMask = "*PAR*";
28-
GetAll input = TimeSeriesProfileInstanceEndpointInput.getAll()
28+
String versionMask = "1";
29+
GetAll input = TimeSeriesProfileInstanceEndpointInput.getAll().versionMask(versionMask)
2930
.locationMask(locationMask).officeMask(officeMask).parameterMask(parameterMask);
3031
input.addInputParameters(mockHttpRequestBuilder);
32+
assertEquals(versionMask, mockHttpRequestBuilder.getQueryParameter(GetAll.VERSION_QUERY_PARAMETER));
3133
assertEquals(ACCEPT_HEADER_V1, mockHttpRequestBuilder.getQueryHeader(ACCEPT_QUERY_HEADER));
3234
assertEquals(locationMask, mockHttpRequestBuilder.getQueryParameter(GetAll.LOCATION_MASK_QUERY_PARAMETER));
3335
assertEquals(officeMask, mockHttpRequestBuilder.getQueryParameter(GetAll.OFFICE_MASK_QUERY_PARAMETER));
@@ -53,8 +55,8 @@ void testGetOneQueryRequest() {
5355
String timezone = "PST";
5456
boolean maxVersion = true;
5557
Instant versionDate = Instant.now();
56-
GetOne input = TimeSeriesProfileInstanceEndpointInput.getOne(office, timeSeriesId, parameter, version, unit)
57-
.startInclusive(startInclusive).endInclusive(endInclusive).start(start).end(end).next(next)
58+
GetOne input = TimeSeriesProfileInstanceEndpointInput.getOne(office, timeSeriesId, parameter, version, unit, start, end)
59+
.startInclusive(startInclusive).endInclusive(endInclusive).next(next)
5860
.previous(previous).maxVersion(maxVersion).timezone(timezone).versionDate(versionDate)
5961
.page(page).pageSize(pageSize);
6062
input.addInputParameters(mockHttpRequestBuilder);
@@ -98,7 +100,7 @@ void testPostQueryRequest() throws Exception {
98100
.method(method).versionDate(versionDate).overrideProtection(overrideProtection);
99101
input.addInputParameters(mockHttpRequestBuilder);
100102
assertEquals(ACCEPT_HEADER_V1, mockHttpRequestBuilder.getQueryHeader(ACCEPT_QUERY_HEADER));
101-
assertEquals(profileData, mockHttpRequestBuilder.getQueryParameter(Post.PROFILE_DATA_QUERY_PARAMETER));
103+
assertEquals(profileData, input.profileData());
102104
assertEquals(RadarObjectMapper.mapObjectToJson(profile), RadarObjectMapper.mapObjectToJson(input.profile()));
103105
assertEquals(version, mockHttpRequestBuilder.getQueryParameter(Post.VERSION_QUERY_PARAMETER));
104106
assertEquals(method, mockHttpRequestBuilder.getQueryParameter(Post.METHOD_QUERY_PARAMETER));

0 commit comments

Comments
 (0)