diff --git a/.java-version b/.java-version new file mode 100644 index 0000000..f222bf6 --- /dev/null +++ b/.java-version @@ -0,0 +1 @@ +21.0.4 diff --git a/changelog.md b/changelog.md index 6705db5..87375da 100644 --- a/changelog.md +++ b/changelog.md @@ -2,14 +2,12 @@ ## Release 4.2 [unreleased] Brief summary of what's in this release: +Removed the calls to Notification Service and the configuration to talk to it since we are no longer sending success emails ### Breaking changes Breaking changes include any database updates needed, if we need to edit any files on system (like .env or certs, etc). Things that are outside of the code itself that need changed for the system to work. -### Non-breaking changes - -Just a place to keep track of things that have changed in the code that we may want to pay special attention to when smoke testing, etc. --- diff --git a/src/main/java/org/kpmp/stateManager/NotificationHandler.java b/src/main/java/org/kpmp/stateManager/NotificationHandler.java deleted file mode 100644 index 848354f..0000000 --- a/src/main/java/org/kpmp/stateManager/NotificationHandler.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.kpmp.stateManager; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; -import org.springframework.web.client.RestTemplate; - -@Component -class NotificationHandler { - - @Value("${notification.service.host}") - private String notificationServiceHost; - @Value("${notification.endpoint}") - private String notificationEndpoint; - private final RestTemplate restTemplate; - - public NotificationHandler(RestTemplate restTemplate) { - this.restTemplate = restTemplate; - } - - public void sendNotification(String packageId, String state, String origin, String codicil) { - - restTemplate.postForObject(notificationServiceHost + notificationEndpoint, - new StateChangeEvent(origin, packageId, state, codicil), Boolean.class); - - } - -} diff --git a/src/main/java/org/kpmp/stateManager/StateService.java b/src/main/java/org/kpmp/stateManager/StateService.java index 11b1693..2f689d8 100644 --- a/src/main/java/org/kpmp/stateManager/StateService.java +++ b/src/main/java/org/kpmp/stateManager/StateService.java @@ -18,21 +18,17 @@ public class StateService { private String uploadFailedState; @Value("${package.state.upload.succeeded}") private String uploadSucceededState; - private NotificationHandler notificationHandler; private StateDisplayRepository stateDisplayRepo; @Autowired - public StateService(CustomStateRepository stateRepository, NotificationHandler notificationHandler, - StateDisplayRepository stateDisplayRepo) { + public StateService(CustomStateRepository stateRepository, StateDisplayRepository stateDisplayRepo) { this.stateRepository = stateRepository; - this.notificationHandler = notificationHandler; this.stateDisplayRepo = stateDisplayRepo; } @CacheEvict(value = "states", allEntries = true) public String setState(State state, String origin) { State savedState = stateRepository.save(state); - notificationHandler.sendNotification(state.getPackageId(), state.getState(), origin, state.getCodicil()); return savedState.getId(); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c8ef140..2ba3b2d 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -6,9 +6,6 @@ spring.main.banner-mode=off state.service.host=http://localhost:3060 state.service.endpoint=/v1/state/host -notification.service.host=http://eridanus-spring:3040 -notification.endpoint=/v2/notifications/package - data-manager.service.host=http://data-manager-service:5000 data-manager.service.endpoint=/v1/dlu diff --git a/src/test/java/org/kpmp/stateManager/NotificationHandlerTest.java b/src/test/java/org/kpmp/stateManager/NotificationHandlerTest.java deleted file mode 100644 index 85fe550..0000000 --- a/src/test/java/org/kpmp/stateManager/NotificationHandlerTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.kpmp.stateManager; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.springframework.test.util.ReflectionTestUtils; -import org.springframework.web.client.RestTemplate; - -public class NotificationHandlerTest { - - @Mock - private RestTemplate restTemplate; - private NotificationHandler handler; - - @BeforeEach - public void setUp() throws Exception { - MockitoAnnotations.openMocks(this); - handler = new NotificationHandler(restTemplate); - ReflectionTestUtils.setField(handler, "notificationServiceHost", "host"); - ReflectionTestUtils.setField(handler, "notificationEndpoint", "/endpoint"); - } - - @AfterEach - public void tearDown() throws Exception { - MockitoAnnotations.openMocks(this).close(); - handler = null; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Test - public void testSendNotification() { - when(restTemplate.postForObject(any(String.class), any(StateChangeEvent.class), any(Class.class))) - .thenReturn(true); - - handler.sendNotification("packageId", "state", "origin", "codicil"); - - ArgumentCaptor urlCaptor = ArgumentCaptor.forClass(String.class); - ArgumentCaptor stateChangeCaptor = ArgumentCaptor.forClass(StateChangeEvent.class); - ArgumentCaptor returnCaptor = ArgumentCaptor.forClass(Class.class); - verify(restTemplate).postForObject(urlCaptor.capture(), stateChangeCaptor.capture(), returnCaptor.capture()); - assertEquals("host/endpoint", urlCaptor.getValue()); - StateChangeEvent stateChangeEvent = stateChangeCaptor.getValue(); - assertEquals("packageId", stateChangeEvent.getPackageId()); - assertEquals("state", stateChangeEvent.getState()); - assertEquals("origin", stateChangeEvent.getOrigin()); - assertEquals("codicil", stateChangeEvent.getCodicil()); - assertEquals(Boolean.class, returnCaptor.getValue()); - } - -} diff --git a/src/test/java/org/kpmp/stateManager/StateServiceTest.java b/src/test/java/org/kpmp/stateManager/StateServiceTest.java index ce3b906..4018222 100644 --- a/src/test/java/org/kpmp/stateManager/StateServiceTest.java +++ b/src/test/java/org/kpmp/stateManager/StateServiceTest.java @@ -24,14 +24,12 @@ public class StateServiceTest { private CustomStateRepository stateRepository; private StateService service; @Mock - private NotificationHandler notificationHandler; - @Mock private StateDisplayRepository stateDisplayRepo; @BeforeEach public void setUp() throws Exception { MockitoAnnotations.openMocks(this); - service = new StateService(stateRepository, notificationHandler, stateDisplayRepo); + service = new StateService(stateRepository, stateDisplayRepo); ReflectionTestUtils.setField(service, "uploadFailedState", "UPLOAD_FAILED"); ReflectionTestUtils.setField(service, "uploadSucceededState", "UPLOAD_SUCCEEDED"); } @@ -56,7 +54,6 @@ public void testSetState() { assertEquals("id", stateId); verify(stateRepository).save(state); - verify(notificationHandler).sendNotification("packageId", "state", "origin", "codicil"); } @Test