Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -0,0 +1,52 @@
/*
* MIT License
*
* Copyright (c) 2026 Hydrologic Engineering Center
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package mil.army.usace.hec.cwms.data.api.client.controllers;

import static mil.army.usace.hec.cwms.data.api.client.controllers.CdaEndpointConstants.ACCEPT_HEADER_V1;
import static mil.army.usace.hec.cwms.data.api.client.controllers.CdaEndpointConstants.ACCEPT_QUERY_HEADER;

import java.io.IOException;
import mil.army.usace.hec.cwms.data.api.client.model.LocationToPublishedDataList;
import mil.army.usace.hec.cwms.data.api.client.model.RadarObjectMapper;
import mil.army.usace.hec.cwms.http.client.ApiConnectionInfo;
import mil.army.usace.hec.cwms.http.client.HttpRequestBuilderImpl;
import mil.army.usace.hec.cwms.http.client.HttpRequestResponse;
import mil.army.usace.hec.cwms.http.client.request.HttpRequestExecutor;

public final class PublishedController {

private static final String PUBLISHED_ENDPOINT = "published";

public LocationToPublishedDataList retrievePublishedData(ApiConnectionInfo apiConnectionInfo, PublishedEndpointInput.GetAll input)
throws IOException {
HttpRequestExecutor executor = new HttpRequestBuilderImpl(apiConnectionInfo, PUBLISHED_ENDPOINT)
.addQueryHeader(ACCEPT_QUERY_HEADER, ACCEPT_HEADER_V1)
.addEndpointInput(input)
.get();
try (HttpRequestResponse response = executor.execute()) {
return RadarObjectMapper.mapJsonToObject(response.getBody(), LocationToPublishedDataList.class);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* MIT License
*
* Copyright (c) 2026 Hydrologic Engineering Center
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package mil.army.usace.hec.cwms.data.api.client.controllers;

import static mil.army.usace.hec.cwms.data.api.client.controllers.CdaEndpointConstants.ACCEPT_HEADER_V1;
import static mil.army.usace.hec.cwms.data.api.client.controllers.CdaEndpointConstants.ACCEPT_QUERY_HEADER;

import java.util.Objects;
import mil.army.usace.hec.cwms.http.client.EndpointInput;
import mil.army.usace.hec.cwms.http.client.HttpRequestBuilder;

public final class PublishedEndpointInput {

private PublishedEndpointInput() {
throw new AssertionError("Factory class");
}

public static GetAll getAll() {
return new GetAll();
}

public static final class GetAll extends EndpointInput {

static final String OFFICE_MASK_QUERY_PARAMETER = "office-mask";
static final String LOCATION_MASK_QUERY_PARAMETER = "location-mask";
static final String PAGE_QUERY_PARAMETER = "page";
static final String PAGE_SIZE_QUERY_PARAMETER = "page-size";

private String officeIdMask;
private String locationIdMask;
private String page;
private Integer pageSize;

private GetAll() {
}

public GetAll withOfficeIdMask(String officeIdMask) {
this.officeIdMask = officeIdMask;
return this;
}

public GetAll withLocationIdMask(String locationIdMask) {
this.locationIdMask = locationIdMask;
return this;
}

public GetAll withPage(String page) {
this.page = page;
return this;
}

public GetAll withPageSize(int pageSize) {
this.pageSize = pageSize;
return this;
}

@Override
protected HttpRequestBuilder addInputParameters(HttpRequestBuilder httpRequestBuilder) {
return httpRequestBuilder.addQueryParameter(OFFICE_MASK_QUERY_PARAMETER, officeIdMask)
.addQueryParameter(LOCATION_MASK_QUERY_PARAMETER, locationIdMask)
.addQueryParameter(PAGE_QUERY_PARAMETER, page)
.addQueryParameter(PAGE_SIZE_QUERY_PARAMETER, getNullableFieldString(pageSize))
.addQueryHeader(ACCEPT_QUERY_HEADER, ACCEPT_HEADER_V1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* MIT License
*
* Copyright (c) 2026 Hydrologic Engineering Center
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package mil.army.usace.hec.cwms.data.api.client.controllers;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.io.IOException;
import mil.army.usace.hec.cwms.data.api.client.model.LocationToPublishedData;
import mil.army.usace.hec.cwms.data.api.client.model.LocationToPublishedDataList;
import org.junit.jupiter.api.Test;

class TestPublishedController extends TestController {

@Test
void testRetrievePublishedTimeSeries() throws IOException {
String json = readJsonFile("radar/v1/json/published_time_series.json");
mockHttpServer.enqueue(json);
mockHttpServer.start();
PublishedEndpointInput.GetAll input = PublishedEndpointInput.getAll().withOfficeIdMask("SWT");
LocationToPublishedDataList result = new PublishedController().retrievePublishedData(buildConnectionInfo(), input);
assertNotNull(result);
assertFalse(result.getLocationToPublishedData().isEmpty());
LocationToPublishedData entry = result.getLocationToPublishedData().get(0);
assertEquals("AARK", entry.getLocationId().getName());
assertEquals("SPK", entry.getLocationId().getOfficeId());
assertEquals("AARK.Stage.Inst.15Minutes.0.Ccp-Rev", entry.getPublishedTimesSeries().get("STAGE").getTimeSeriesId().getName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* MIT License
*
* Copyright (c) 2026 Hydrologic Engineering Center
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package mil.army.usace.hec.cwms.data.api.client.controllers;

import static mil.army.usace.hec.cwms.data.api.client.controllers.CdaEndpointConstants.ACCEPT_HEADER_V1;
import static mil.army.usace.hec.cwms.data.api.client.controllers.CdaEndpointConstants.ACCEPT_QUERY_HEADER;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

class TestPublishedEndpointInput {

@Test
void testGetAllQueryRequest() {
MockHttpRequestBuilder mockHttpRequestBuilder = new MockHttpRequestBuilder();
PublishedEndpointInput.GetAll input = PublishedEndpointInput.getAll()
.withOfficeIdMask("SPK")
.withLocationIdMask("BURL")
.withPage("cursor")
.withPageSize(50);
input.addInputParameters(mockHttpRequestBuilder);
assertEquals("SPK", mockHttpRequestBuilder.getQueryParameter(PublishedEndpointInput.GetAll.OFFICE_MASK_QUERY_PARAMETER));
assertEquals("BURL", mockHttpRequestBuilder.getQueryParameter(PublishedEndpointInput.GetAll.LOCATION_MASK_QUERY_PARAMETER));
assertEquals("cursor", mockHttpRequestBuilder.getQueryParameter(PublishedEndpointInput.GetAll.PAGE_QUERY_PARAMETER));
assertEquals("50", mockHttpRequestBuilder.getQueryParameter(PublishedEndpointInput.GetAll.PAGE_SIZE_QUERY_PARAMETER));
assertEquals(ACCEPT_HEADER_V1, mockHttpRequestBuilder.getQueryHeader(ACCEPT_QUERY_HEADER));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"cursor": "cursor",
"page-size": 20,
"total": 3,
"next-page": "",
"location-to-published-data": [
{
"location-id": {
"office-id": "SPK",
"name": "AARK"
},
"bounding-office-id": "SPK",
"kind": "SITE",
"published-times-series": {
"STAGE": {
"time-series-id": {
"office-id": "SPK",
"name": "AARK.Stage.Inst.15Minutes.0.Ccp-Rev"
},
"timezone-name": "UTC",
"interval-offset-minutes": 0,
"active": true,
"date-refreshed": "2025-03-03T12:00:00Z",
"notes": "Stage data for AARK"
},
"INFLOW": {
"time-series-id": {
"office-id": "SPK",
"name": "AARK.Flow.Inst.1Hour.0.Ccp-Rev"
},
"timezone-name": "UTC",
"interval-offset-minutes": 0,
"active": true,
"date-refreshed": "2025-03-03T12:00:00Z",
"notes": "Flow data for AARK"
},
"PRECIP": {
"time-series-id": {
"office-id": "SPK",
"name": "AARK.Precip.Inst.1Hour.0.Ccp-Rev"
},
"timezone-name": "UTC",
"interval-offset-minutes": 0,
"active": true,
"date-refreshed": "2025-03-03T12:00:00Z",
"notes": "Precip data for AARK"
}
}
},
{
"location-id": {
"office-id": "SWT",
"name": "ADDI"
},
"bounding-office-id": "SWT",
"kind": "SITE",
"published-times-series": {
"STAGE": {
"time-series-id": {
"office-id": "SWT",
"name": "ADDI.Stage.Inst.15Minutes.0.Ccp-Rev"
},
"timezone-name": "UTC",
"interval-offset-minutes": 0,
"active": true,
"date-refreshed": "2025-03-03T12:00:00Z",
"notes": "Stage data for ADDI"
},
"INFLOW": {
"time-series-id": {
"office-id": "SWT",
"name": "ADDI.Flow.Inst.1Hour.0.Ccp-Rev"
},
"timezone-name": "UTC",
"interval-offset-minutes": 0,
"active": true,
"date-refreshed": "2025-03-03T12:00:00Z",
"notes": "Flow data for ADDI"
},
"PRECIP": {
"time-series-id": {
"office-id": "SWT",
"name": "ADDI.Precip.Inst.1Hour.0.Ccp-Rev"
},
"timezone-name": "UTC",
"interval-offset-minutes": 0,
"active": true,
"date-refreshed": "2025-03-03T12:00:00Z",
"notes": "Precip data for ADDI"
}
}
},
{
"location-id": {
"office-id": "NWD",
"name": "BBNK"
},
"bounding-office-id": "NWD",
"kind": "SITE",
"published-times-series": {
"STAGE": {
"time-series-id": {
"office-id": "NWD",
"name": "BBNK.Stage.Inst.15Minutes.0.Ccp-Rev"
},
"timezone-name": "UTC",
"interval-offset-minutes": 0,
"active": true,
"date-refreshed": "2025-03-03T12:00:00Z",
"notes": "Stage data for BBNK"
},
"INFLOW": {
"time-series-id": {
"office-id": "NWD",
"name": "BBNK.Flow.Inst.1Hour.0.Ccp-Rev"
},
"timezone-name": "UTC",
"interval-offset-minutes": 0,
"active": true,
"date-refreshed": "2025-03-03T12:00:00Z",
"notes": "Flow data for BBNK"
},
"PRECIP": {
"time-series-id": {
"office-id": "NWD",
"name": "BBNK.Precip.Inst.1Hour.0.Ccp-Rev"
},
"timezone-name": "UTC",
"interval-offset-minutes": 0,
"active": true,
"date-refreshed": "2025-03-03T12:00:00Z",
"notes": "Precip data for BBNK"
}
}
}
]
}
Loading