Skip to content

Commit

Permalink
Bugfix - TimeSeries Profile Instance: Updated to match required param…
Browse files Browse the repository at this point in the history
…eters of controller (#242)

* Updated to match required parameters of controller

* Autogenerated JaCoCo coverage badge

---------

Co-authored-by: builduser <builduser@rmanet.com>
  • Loading branch information
zack-rma and builduser authored Dec 2, 2024
1 parent b6358ad commit 4099203
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/coveragereport/badge_linecoverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion .github/coveragereport/badge_methodcoverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public static GetAll getAll() {
return new GetAll();
}

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

public static Post post(String profileData, TimeSeriesProfile profile, String version) {
Expand Down Expand Up @@ -101,19 +101,20 @@ public static final class GetOne extends EndpointInput {
private boolean previous = false;
private boolean next = false;
private boolean maxVersion = false;
private Instant start = Instant.now();
private Instant end = Instant.now();
private final Instant start;
private final Instant end;
private final String locationId;
private String page;
private int pageSize = 500;

private GetOne(String officeId, String locationId, String parameterId, String version, List<String> unit) {
private GetOne(String officeId, String locationId, String parameterId, String version, List<String> unit, Instant start, Instant end) {
this.officeId = Objects.requireNonNull(officeId, "Office is required");
this.locationId = Objects.requireNonNull(locationId, "Location ID is required");
this.parameterId = Objects.requireNonNull(parameterId, "Parameter ID is required");
this.version = Objects.requireNonNull(version, "Version is required");
this.unit = Objects.requireNonNull(unit,"Unit is required");

this.start = Objects.requireNonNull(start, "Start is required");
this.end = Objects.requireNonNull(end, "End is required");
}

public GetOne versionDate(Instant versionDate) {
Expand Down Expand Up @@ -151,16 +152,6 @@ public GetOne maxVersion(boolean maxVersion) {
return this;
}

public GetOne start(Instant start) {
this.start = start;
return this;
}

public GetOne end(Instant end) {
this.end = end;
return this;
}

public GetOne page(String page) {
this.page = page;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ void testGetOne() throws IOException {
mockHttpServer.enqueue(collect);
mockHttpServer.start();
List<String> parameterList = List.of("F", "m");
Instant firstDate = Instant.ofEpochMilli(1594296000000L);
Instant lastDate = Instant.ofEpochMilli(1752062400000L);
TimeSeriesProfileInstanceEndpointInput.GetOne input = TimeSeriesProfileInstanceEndpointInput
.getOne("SWT", "Test_TSP_Location", "Depth", "DSS-Obs",
parameterList).page("CWMSTESTPAGE").pageSize(50);
parameterList, firstDate, lastDate)
.page("CWMSTESTPAGE").pageSize(50);
TimeSeriesProfileInstance value = new TimeSeriesProfileInstanceController()
.retrieveTimeSeriesProfileInstance(buildConnectionInfo(), input);
assertNotNull(value);
Expand All @@ -31,6 +34,8 @@ void testGetOne() throws IOException {
assertEquals("Depth", value.getTimeSeriesProfile().getKeyParameter());
assertEquals("Description", value.getTimeSeriesProfile().getDescription());
assertEquals("SWT", value.getTimeSeriesProfile().getLocationId().getOfficeId());
assertEquals(firstDate, value.getFirstDate().toInstant());
assertEquals(lastDate, value.getLastDate().toInstant());
assertEquals(parameterList.get(0), value.getParameterColumns().get(0).getUnit());
assertEquals(parameterList.get(1), value.getParameterColumns().get(1).getUnit());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ void testGetAllQueryRequest() {
String locationMask = "*LOC*";
String officeMask = "SPK";
String parameterMask = "*PAR*";
GetAll input = TimeSeriesProfileInstanceEndpointInput.getAll()
String versionMask = "1";
GetAll input = TimeSeriesProfileInstanceEndpointInput.getAll().versionMask(versionMask)
.locationMask(locationMask).officeMask(officeMask).parameterMask(parameterMask);
input.addInputParameters(mockHttpRequestBuilder);
assertEquals(versionMask, mockHttpRequestBuilder.getQueryParameter(GetAll.VERSION_QUERY_PARAMETER));
assertEquals(ACCEPT_HEADER_V1, mockHttpRequestBuilder.getQueryHeader(ACCEPT_QUERY_HEADER));
assertEquals(locationMask, mockHttpRequestBuilder.getQueryParameter(GetAll.LOCATION_MASK_QUERY_PARAMETER));
assertEquals(officeMask, mockHttpRequestBuilder.getQueryParameter(GetAll.OFFICE_MASK_QUERY_PARAMETER));
Expand All @@ -53,8 +55,8 @@ void testGetOneQueryRequest() {
String timezone = "PST";
boolean maxVersion = true;
Instant versionDate = Instant.now();
GetOne input = TimeSeriesProfileInstanceEndpointInput.getOne(office, timeSeriesId, parameter, version, unit)
.startInclusive(startInclusive).endInclusive(endInclusive).start(start).end(end).next(next)
GetOne input = TimeSeriesProfileInstanceEndpointInput.getOne(office, timeSeriesId, parameter, version, unit, start, end)
.startInclusive(startInclusive).endInclusive(endInclusive).next(next)
.previous(previous).maxVersion(maxVersion).timezone(timezone).versionDate(versionDate)
.page(page).pageSize(pageSize);
input.addInputParameters(mockHttpRequestBuilder);
Expand Down Expand Up @@ -98,7 +100,7 @@ void testPostQueryRequest() throws Exception {
.method(method).versionDate(versionDate).overrideProtection(overrideProtection);
input.addInputParameters(mockHttpRequestBuilder);
assertEquals(ACCEPT_HEADER_V1, mockHttpRequestBuilder.getQueryHeader(ACCEPT_QUERY_HEADER));
assertEquals(profileData, mockHttpRequestBuilder.getQueryParameter(Post.PROFILE_DATA_QUERY_PARAMETER));
assertEquals(profileData, input.profileData());
assertEquals(RadarObjectMapper.mapObjectToJson(profile), RadarObjectMapper.mapObjectToJson(input.profile()));
assertEquals(version, mockHttpRequestBuilder.getQueryParameter(Post.VERSION_QUERY_PARAMETER));
assertEquals(method, mockHttpRequestBuilder.getQueryParameter(Post.METHOD_QUERY_PARAMETER));
Expand Down

0 comments on commit 4099203

Please sign in to comment.