Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Commit 24df6fc

Browse files
committed
Warning Cleanup and UsagePoint/show local time zone fix
1 parent 6fa1511 commit 24df6fc

File tree

15 files changed

+36
-34
lines changed

15 files changed

+36
-34
lines changed

src/main/java/org/energyos/espi/thirdparty/repository/impl/ResourceRESTRepositoryImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public class ResourceRESTRepositoryImpl implements ResourceRESTRepository {
4343
public IdentifiedObject get(Authorization authorization, String url) {
4444
HttpHeaders requestHeaders = new HttpHeaders();
4545
requestHeaders.set("Authorization", "Bearer " + authorization.getAccessToken());
46-
HttpEntity<?> requestEntity = new HttpEntity(requestHeaders);
46+
@SuppressWarnings({ "rawtypes", "unchecked" })
47+
HttpEntity<?> requestEntity = new HttpEntity(requestHeaders);
4748

4849
HttpEntity<String> response = template.exchange(url, HttpMethod.GET, requestEntity, String.class);
4950

src/main/java/org/energyos/espi/thirdparty/repository/impl/UsagePointRESTRepositoryImpl.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.energyos.espi.common.domain.Authorization;
2525
import org.energyos.espi.common.domain.RetailCustomer;
2626
import org.energyos.espi.common.domain.UsagePoint;
27-
import org.energyos.espi.common.models.atom.FeedType;
2827
import org.energyos.espi.common.repositories.UsagePointRepository;
2928
import org.energyos.espi.common.service.AuthorizationService;
3029
import org.energyos.espi.common.service.ImportService;
@@ -134,16 +133,11 @@ public UsagePoint findByHashedId(Long retailCustomerId, String usagePointHashedI
134133
return null;
135134
}
136135

137-
private FeedType unmarshalFeedType(HttpEntity<String> response) throws JAXBException {
138-
ByteArrayInputStream bs = new ByteArrayInputStream(response.getBody().toString().getBytes());
139-
//TODO: hook in the import service
140-
return atomMarshaller.unmarshal(bs);
141-
}
142-
143136
private HttpEntity<String> getUsagePoints(Authorization authorization) {
144137
HttpHeaders requestHeaders = new HttpHeaders();
145138
requestHeaders.set("Authorization", "Bearer " + authorization.getAccessToken());
146-
HttpEntity<?> requestEntity = new HttpEntity(requestHeaders);
139+
@SuppressWarnings({ "rawtypes", "unchecked" })
140+
HttpEntity<?> requestEntity = new HttpEntity(requestHeaders);
147141

148142
return template.exchange(authorization.getResourceURI(), HttpMethod.GET, requestEntity, String.class);
149143
}

src/main/java/org/energyos/espi/thirdparty/web/ClientRestTemplate.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ public ClientRestTemplate(String username, String password) {
5555

5656
static class PreemptiveAuthInterceptor implements HttpRequestInterceptor {
5757

58-
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
58+
@SuppressWarnings("deprecation")
59+
// TODO there are two deprecated calls here ...
60+
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
5961
AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
6062

6163
if (authState.getAuthScheme() == null) {

src/main/java/org/energyos/espi/thirdparty/web/UsagePointController.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.energyos.espi.common.domain.ElectricPowerUsageSummary;
2828
import org.energyos.espi.common.domain.MeterReading;
2929
import org.energyos.espi.common.domain.Routes;
30+
import org.energyos.espi.common.domain.TimeConfiguration;
3031
import org.energyos.espi.common.domain.UsagePoint;
3132
import org.energyos.espi.common.service.ApplicationInformationService;
3233
import org.energyos.espi.common.service.ResourceService;
@@ -74,7 +75,7 @@ public String index(ModelMap model, Principal principal) {
7475
public String show(@PathVariable Long retailCustomerId, @PathVariable Long usagePointId, ModelMap model) {
7576
try {
7677

77-
UsagePoint usagePoint = resourceService.testById(usagePointId, UsagePoint.class);
78+
resourceService.testById(usagePointId, UsagePoint.class);
7879
// because of the lazy loading from DB it's easier to build a bag and hand it off
7980
// in a separate transaction, fill up a display bag lazily - do it in a private method
8081
// so the transaction is scoped appropriately.
@@ -87,7 +88,7 @@ public String show(@PathVariable Long retailCustomerId, @PathVariable Long usage
8788
} catch (Exception e) {
8889

8990
// got to do a dummy DB access to satify the transaction rollback needs ...
90-
ApplicationInformation ai = resourceService.findById(1L, ApplicationInformation.class);
91+
resourceService.findById(1L, ApplicationInformation.class);
9192
System.out.printf("UX Error: %s\n", e.toString());
9293
model.put("errorString", e.toString());
9394
try {
@@ -137,6 +138,7 @@ private HashMap<String, Object> buildDisplayBag(Long retailCustomerId, Long usag
137138
displayBag.put("Uri", usagePoint.getSelfHref());
138139
displayBag.put("usagePointId", usagePoint.getId());
139140
// put the meterReadings
141+
@SuppressWarnings("rawtypes")
140142
List<HashMap> meterReadings = new ArrayList<HashMap> ();
141143
Iterator <MeterReading> it = usagePoint.getMeterReadings().iterator();
142144
while (it.hasNext()) {
@@ -155,6 +157,9 @@ private HashMap<String, Object> buildDisplayBag(Long retailCustomerId, Long usag
155157
List <ElectricPowerUsageSummary> usageSummaryList = usagePoint.getElectricPowerUsageSummaries();
156158
displayBag.put("QualitySummaryList", qualitySummaryList);
157159
displayBag.put("UsageSummaryList", usageSummaryList);
160+
161+
TimeConfiguration timeConfiguration = usagePoint.getLocalTimeParameters();
162+
displayBag.put("localTimeParameters", timeConfiguration);
158163

159164
return displayBag;
160165
}

src/main/java/org/energyos/espi/thirdparty/web/custodian/RetailCustomerController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public String show(@PathVariable Long retailCustomerId, ModelMap model) {
8585

8686
public static class RetailCustomerValidator implements Validator {
8787

88-
public boolean supports(Class clazz) {
88+
public boolean supports(@SuppressWarnings("rawtypes") Class clazz) {
8989
return RetailCustomer.class.isAssignableFrom(clazz);
9090
}
9191

src/main/webapp/WEB-INF/jsp/customer/usagepoints/show.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
<tbody>
184184
<tr>
185185
<td>
186-
<c:out value="${usagePoint.localTimeParameters.tzOffset}"/>
186+
<c:out value="${displayBag.get('localTimeParameters').tzOffset}"/>
187187
</td>
188188
</tr>
189189
</tbody>

src/test/java/org/energyos/espi/thirdparty/integration/web/filters/CORSFilterTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
1616
import org.springframework.test.context.web.WebAppConfiguration;
1717
import org.springframework.test.web.servlet.MockMvc;
18-
import org.springframework.test.web.servlet.MvcResult;
1918
import org.springframework.test.web.servlet.RequestBuilder;
2019
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
2120
import org.springframework.web.context.WebApplicationContext;
@@ -45,7 +44,7 @@ public void optionsResponse_hasCorrectFilters() throws Exception {
4544
RequestBuilder requestBuilder = MockMvcRequestBuilders.options("/ThirdParty")
4645
.header("Origin", "JUnit_Test");
4746

48-
MvcResult result = mockMvc.perform(requestBuilder)
47+
mockMvc.perform(requestBuilder)
4948
.andExpect(header().string("Access-Control-Allow-Origin", is("*")))
5049
.andExpect(header().string("Access-Control-Allow-Methods", is("GET, POST, PUT, DELETE, OPTIONS")))
5150
.andExpect(header().string("Access-Control-Allow-Headers", is("Origin, Authorization, Accept, Content-Type")))

src/test/java/org/energyos/espi/thirdparty/mocks/MockClientRestTemplate.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
public class MockClientRestTemplate extends ClientRestTemplate {
88

9-
public <T> T getForObject(String url, Class<T> responseType, Object... urlVariables) throws RestClientException {
9+
@SuppressWarnings("unchecked")
10+
public <T> T getForObject(String url, Class<T> responseType, Object... urlVariables) throws RestClientException {
1011
AccessToken accessToken = new AccessToken();
1112

1213
accessToken.setAccessToken("6b945882-8349-471a-915f-25e791971248");

src/test/java/org/energyos/espi/thirdparty/mocks/MockRestTemplate.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
public class MockRestTemplate extends RestTemplate {
1515

16-
public <T> T getForObject(String url, Class<T> responseType, Object... urlVariables) throws RestClientException {
16+
@SuppressWarnings("unchecked")
17+
public <T> T getForObject(String url, Class<T> responseType, Object... urlVariables) throws RestClientException {
1718
ClassPathResource sourceFile = new ClassPathResource("/fixtures/test_usage_data.xml");
1819
String inputStreamString;
1920
try {
@@ -26,7 +27,8 @@ public <T> T getForObject(String url, Class<T> responseType, Object... urlVariab
2627

2728
}
2829

29-
@Override
30+
@SuppressWarnings("unchecked")
31+
@Override
3032
public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables) throws RestClientException {
3133
ClassPathResource sourceFile = new ClassPathResource("/fixtures/test_usage_data.xml");
3234
String inputStreamString;

src/test/java/org/energyos/espi/thirdparty/repository/impl/ResourceRESTRepositoryImplTests.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public class ResourceRESTRepositoryImplTests {
4747
public Authorization authorization;
4848
public String uri;
4949

50-
@Before
50+
@SuppressWarnings("unchecked")
51+
@Before
5152
public void before() {
5253
repository = new ResourceRESTRepositoryImpl();
5354
marshaller = mock(Jaxb2Marshaller.class);
@@ -64,18 +65,21 @@ public void before() {
6465
uri = Routes.DATA_CUSTODIAN_REST_USAGE_POINT_GET;
6566
}
6667

67-
@Test
68+
@SuppressWarnings("unchecked")
69+
@Test
6870
public void get_fetchesResource() throws JAXBException {
6971
repository.get(authorization, uri);
7072

7173
verify(template).exchange(anyString(), eq(HttpMethod.GET), any(HttpEntity.class), any(Class.class));
7274
}
7375

74-
@Test
76+
@SuppressWarnings("unchecked")
77+
@Test
7578
public void get_usesAccessToken() throws JAXBException {
7679
repository.get(authorization, uri);
7780

78-
ArgumentCaptor<HttpEntity> argumentCaptor = ArgumentCaptor.forClass(HttpEntity.class);
81+
@SuppressWarnings("rawtypes")
82+
ArgumentCaptor<HttpEntity> argumentCaptor = ArgumentCaptor.forClass(HttpEntity.class);
7983
verify(template).exchange(anyString(), eq(HttpMethod.GET), argumentCaptor.capture(), any(Class.class));
8084
assertEquals("Bearer token", argumentCaptor.getValue().getHeaders().get("Authorization").get(0));
8185
}

0 commit comments

Comments
 (0)