-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from nhsconnect/PRMT-3413-REFACTOR
PRMT-3413 E2E testing - Unexpected Interaction ID and NHS number
- Loading branch information
Showing
8 changed files
with
196 additions
and
5 deletions.
There are no files selected for viewing
2 changes: 0 additions & 2 deletions
2
src/main/java/uk/nhs/prm/e2etests/model/request/PdsAdaptorRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
package uk.nhs.prm.e2etests.model.request; | ||
|
||
import lombok.EqualsAndHashCode; | ||
|
||
public record PdsAdaptorRequest(String previousGp, | ||
String recordETag) | ||
{ } |
14 changes: 14 additions & 0 deletions
14
src/main/java/uk/nhs/prm/e2etests/property/EhrOutServiceProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package uk.nhs.prm.e2etests.property; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class EhrOutServiceProperties { | ||
@Value("${aws.configuration.serviceUrls.ehrOutService}") | ||
private String ehrOutServiceUrl; | ||
|
||
public String getEhrOutServiceUrl() { | ||
return ehrOutServiceUrl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/main/java/uk/nhs/prm/e2etests/service/HealthCheckService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package uk.nhs.prm.e2etests.service; | ||
|
||
import lombok.extern.log4j.Log4j2; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.client.HttpStatusCodeException; | ||
import org.springframework.web.client.RestTemplate; | ||
import uk.nhs.prm.e2etests.exception.ServiceException; | ||
import uk.nhs.prm.e2etests.property.EhrOutServiceProperties; | ||
import uk.nhs.prm.e2etests.property.EhrRepositoryProperties; | ||
import uk.nhs.prm.e2etests.property.Gp2gpMessengerProperties; | ||
|
||
import java.util.Map; | ||
|
||
@Log4j2 | ||
@Service | ||
public class HealthCheckService { | ||
private final RestTemplate restTemplate = new RestTemplate(); | ||
|
||
private final Map<String, String> listOfServices; | ||
|
||
@Autowired | ||
public HealthCheckService( | ||
Gp2gpMessengerProperties gp2gpMessengerProperties, | ||
EhrRepositoryProperties ehrRepositoryProperties, | ||
EhrOutServiceProperties ehrOutServiceProperties | ||
) { | ||
// Ehr Transfer Service doesn't seem to have a health check endpoint for now, so it is not included here. | ||
this.listOfServices = Map.of( | ||
"Gp2gp Messenger", gp2gpMessengerProperties.getGp2gpMessengerUrl(), | ||
"Ehr Repository", ehrRepositoryProperties.getEhrRepositoryUrl(), | ||
"Ehr Out Service", ehrOutServiceProperties.getEhrOutServiceUrl() | ||
); | ||
} | ||
|
||
public boolean healthCheckAllPassing() { | ||
return this.listOfServices.entrySet().stream().allMatch( | ||
entry -> runHealthCheck(entry.getKey(), entry.getValue()) | ||
); | ||
} | ||
|
||
private boolean runHealthCheck(String nameOfService, String baseUrl) { | ||
log.info("Running health check for service: {}", nameOfService); | ||
String ehrRepoHealthCheckUrl = String.format("%s/health", baseUrl); | ||
try { | ||
ResponseEntity<String> exchange = restTemplate.exchange(ehrRepoHealthCheckUrl, | ||
HttpMethod.GET, new HttpEntity<String>(createHeaders()), String.class); | ||
return exchange.getStatusCode().is2xxSuccessful(); | ||
} catch (HttpStatusCodeException exception) { | ||
throw new ServiceException(getClass().getName(), exception.getMessage()); | ||
} | ||
} | ||
|
||
private HttpHeaders createHeaders() { | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.setContentType(MediaType.APPLICATION_JSON); | ||
return headers; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters