diff --git a/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/config/SecurityConfiguration.java b/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/config/SecurityConfiguration.java index 30667cab..252cb56b 100644 --- a/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/config/SecurityConfiguration.java +++ b/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/config/SecurityConfiguration.java @@ -126,6 +126,16 @@ public WebClient webClient(OAuth2AuthorizedClientManager authorizedClientManager .build(); } + /** + * {@link RestClient.Builder} for components scanned from openespi-common (e.g. + * {@code NotificationServiceImpl}) that inject it. Spring Boot's RestClient autoconfiguration + * doesn't supply one in this context, so provide it explicitly. + */ + @Bean + public org.springframework.web.client.RestClient.Builder restClientBuilder() { + return org.springframework.web.client.RestClient.builder(); + } + /** * Legacy RestTemplate bean for backward compatibility. * TODO: Replace all RestTemplate usage with OAuth2-enabled WebClient. diff --git a/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/service/ResourceRESTService.java b/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/service/ResourceRESTService.java deleted file mode 100644 index d7d409fd..00000000 --- a/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/service/ResourceRESTService.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * Copyright (c) 2025 Green Button Alliance, Inc. - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.greenbuttonalliance.espi.thirdparty.service; - -import org.greenbuttonalliance.espi.common.domain.usage.AuthorizationEntity; -import org.greenbuttonalliance.espi.common.domain.common.IdentifiedObject; -import org.greenbuttonalliance.espi.common.domain.usage.UsagePointEntity; - -public interface ResourceRESTService { - IdentifiedObject get(AuthorizationEntity authorization, String uri); - - void update(UsagePointEntity resource); -} diff --git a/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/service/UpdateRESTService.java b/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/service/UpdateRESTService.java deleted file mode 100644 index 80d9300a..00000000 --- a/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/service/UpdateRESTService.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * Copyright (c) 2025 Green Button Alliance, Inc. - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.greenbuttonalliance.espi.thirdparty.service; - -import org.springframework.stereotype.Service; - -import jakarta.xml.bind.JAXBException; - -@Service -public interface UpdateRESTService { - void update(String url) throws JAXBException; -} diff --git a/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/service/impl/ResourceRESTServiceImpl.java b/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/service/impl/ResourceRESTServiceImpl.java deleted file mode 100644 index 04483872..00000000 --- a/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/service/impl/ResourceRESTServiceImpl.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Copyright (c) 2025 Green Button Alliance, Inc. - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.greenbuttonalliance.espi.thirdparty.service.impl; - -import org.greenbuttonalliance.espi.common.domain.usage.AuthorizationEntity; -import org.greenbuttonalliance.espi.common.domain.common.IdentifiedObject; -import org.greenbuttonalliance.espi.common.domain.usage.UsagePointEntity; -import org.greenbuttonalliance.espi.common.repositories.usage.ResourceRepository; -import org.greenbuttonalliance.espi.thirdparty.repository.ResourceRESTRepository; -import org.greenbuttonalliance.espi.thirdparty.service.ResourceRESTService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class ResourceRESTServiceImpl implements ResourceRESTService { - @Autowired - private ResourceRESTRepository resourceRESTRepository; - - @Autowired - private ResourceRepository resourceRepository; - - public IdentifiedObject get(AuthorizationEntity authorization, String uri) { - return resourceRESTRepository.get(authorization, uri); - } - - @Override - public void update(UsagePointEntity resource) { - resourceRepository.update(resource); - } - - public void setResourceRESTRepository( - ResourceRESTRepository resourceRESTRepository) { - this.resourceRESTRepository = resourceRESTRepository; - } - - public void setResourceRepository(ResourceRepository resourceRepository) { - this.resourceRepository = resourceRepository; - } - - public ResourceRESTRepository getResourceRESTRepository() { - return this.resourceRESTRepository; - } - - public ResourceRepository getResourceRepository() { - return this.resourceRepository; - } -} diff --git a/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/service/impl/UpdateRESTServiceImpl.java b/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/service/impl/UpdateRESTServiceImpl.java deleted file mode 100644 index df0bca68..00000000 --- a/openespi-thirdparty/src/main/java/org/greenbuttonalliance/espi/thirdparty/service/impl/UpdateRESTServiceImpl.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * Copyright (c) 2025 Green Button Alliance, Inc. - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.greenbuttonalliance.espi.thirdparty.service.impl; - -import org.greenbuttonalliance.espi.common.domain.usage.AuthorizationEntity; -import org.greenbuttonalliance.espi.common.domain.usage.UsagePointEntity; -import org.greenbuttonalliance.espi.common.service.AuthorizationService; -import org.greenbuttonalliance.espi.thirdparty.service.ResourceRESTService; -import org.greenbuttonalliance.espi.thirdparty.service.UpdateRESTService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import jakarta.xml.bind.JAXBException; - -@Service -public class UpdateRESTServiceImpl implements UpdateRESTService { - @Autowired - private AuthorizationService authorizationService; - - @Autowired - private ResourceRESTService resourceRESTService; - - public void update(String uri) throws JAXBException { - AuthorizationEntity authorization = authorizationService.findByURI(uri); - UsagePointEntity resource = (UsagePointEntity) resourceRESTService.get( - authorization, uri); - resourceRESTService.update(resource); - } - - public void setResourceRESTService(ResourceRESTService resourceRESTService) { - this.resourceRESTService = resourceRESTService; - } - - public void setAuthorizationService( - AuthorizationService authorizationService) { - this.authorizationService = authorizationService; - } - - public ResourceRESTService getResourceRESTService() { - return this.resourceRESTService; - } - - public AuthorizationService getAuthorizationService() { - return this.authorizationService; - } -} diff --git a/openespi-thirdparty/src/main/resources/application-dev-mysql.yml b/openespi-thirdparty/src/main/resources/application-dev-mysql.yml index 6e72cd2e..6e877a9f 100644 --- a/openespi-thirdparty/src/main/resources/application-dev-mysql.yml +++ b/openespi-thirdparty/src/main/resources/application-dev-mysql.yml @@ -15,6 +15,11 @@ spring: jpa: show-sql: true + # Dev sandbox: the Third Party module ships no Flyway migrations yet, so let Hibernate create + # the schema (e.g. batch_lists) for local DC→TP notification testing. (Full TP schema/Flyway + # bring-up is tracked under #146.) + hibernate: + ddl-auto: update properties: hibernate: dialect: org.hibernate.dialect.MySQLDialect diff --git a/openespi-thirdparty/src/main/resources/application.yml b/openespi-thirdparty/src/main/resources/application.yml index c053f922..0f30cb20 100644 --- a/openespi-thirdparty/src/main/resources/application.yml +++ b/openespi-thirdparty/src/main/resources/application.yml @@ -37,7 +37,8 @@ spring: # Jackson JSON Configuration jackson: serialization: - write-dates-as-timestamps: false + # write-dates-as-timestamps removed: not a SerializationFeature in Jackson 3 (Spring Boot 4); + # date/time-as-timestamp handling moved to the Jackson 3 DateTime features. indent-output: true deserialization: fail-on-unknown-properties: false diff --git a/openespi-thirdparty/src/test/java/org/greenbuttonalliance/espi/thirdparty/service/impl/ResourceServiceImplTests.java b/openespi-thirdparty/src/test/java/org/greenbuttonalliance/espi/thirdparty/service/impl/ResourceServiceImplTests.java deleted file mode 100644 index 563feeaf..00000000 --- a/openespi-thirdparty/src/test/java/org/greenbuttonalliance/espi/thirdparty/service/impl/ResourceServiceImplTests.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * Copyright (c) 2025 Green Button Alliance, Inc. - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.greenbuttonalliance.espi.thirdparty.service.impl; - -import jakarta.xml.bind.JAXBException; -import org.greenbuttonalliance.espi.common.repositories.usage.ResourceRepository; -import org.greenbuttonalliance.espi.thirdparty.repository.ResourceRESTRepository; -import org.junit.jupiter.api.Test; - -import static org.mockito.Mockito.mock; - -//todo - JT, missing classes -public class ResourceServiceImplTests { - - @Test - public void get_fetchesResource() throws JAXBException { - ResourceRESTRepository repository = mock(ResourceRESTRepository.class); - - ResourceRESTServiceImpl service = new ResourceRESTServiceImpl(); - service.setResourceRESTRepository(repository); - -// Authorization authorization = new Authorization(); -// String url = Routes.DATA_CUSTODIAN_REST_USAGE_POINT_GET; -// -// service.get(authorization, url); -// -// verify(repository).get(authorization, url); - } - - @Test - public void update_updatesResource() throws JAXBException { - ResourceRepository repository = mock(ResourceRepository.class); - - ResourceRESTServiceImpl service = new ResourceRESTServiceImpl(); - service.setResourceRepository(repository); - -// UsagePoint resource = new UsagePoint(); -// -// service.update(resource); -// -// verify(repository).update(resource); - } -} diff --git a/openespi-thirdparty/src/test/java/org/greenbuttonalliance/espi/thirdparty/service/impl/UpdateServiceImplTests.java b/openespi-thirdparty/src/test/java/org/greenbuttonalliance/espi/thirdparty/service/impl/UpdateServiceImplTests.java deleted file mode 100644 index 4a86e48c..00000000 --- a/openespi-thirdparty/src/test/java/org/greenbuttonalliance/espi/thirdparty/service/impl/UpdateServiceImplTests.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * Copyright (c) 2025 Green Button Alliance, Inc. - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.greenbuttonalliance.espi.thirdparty.service.impl; - -//import org.greenbuttonalliance.espi.common.domain.Authorization; -//import org.greenbuttonalliance.espi.common.domain.Routes; -//import org.greenbuttonalliance.espi.common.domain.UsagePoint; - -import org.greenbuttonalliance.espi.common.service.AuthorizationService; -import org.greenbuttonalliance.espi.thirdparty.service.ResourceRESTService; - - -// todo - missing a bunch of classes, commenting out -public class UpdateServiceImplTests { - - public UpdateRESTServiceImpl updateService; - public AuthorizationService authorizationService; - public ResourceRESTService resourceRESTService; -// public Authorization authorization; -// public UsagePoint updateUsagePoint; - public String uri; -// -// @Before -// public void before() { -// uri = Routes.buildDataCustodianRESTUsagePointGet("1", "1"); -// updateUsagePoint = new UsagePoint(); -// authorization = new Authorization(); -// resourceRESTService = mock(ResourceRESTService.class); -// authorizationService = mock(AuthorizationService.class); -// -// when(authorizationService.findByURI(uri)).thenReturn(authorization); -// when(resourceRESTService.get(authorization, uri)).thenReturn( -// updateUsagePoint); -// -// updateService = new UpdateRESTServiceImpl(); -// updateService.setResourceRESTService(resourceRESTService); -// updateService.setAuthorizationService(authorizationService); -// } -// -// @Test -// public void update_findsAuthorization() throws JAXBException { -// updateService.update(uri); -// -// verify(authorizationService).findByURI(uri); -// } -// -// @Test -// public void update_fetchesResource() throws JAXBException { -// updateService.update(uri); -// -// verify(resourceRESTService).get(authorization, uri); -// } -// -// @Test -// public void update_updatesResource() throws JAXBException { -// updateService.update(uri); -// -// verify(resourceRESTService).update(updateUsagePoint); -// } -}