Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: get GMC by id #1040

Merged
merged 2 commits into from
Jan 13, 2025
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 tcs-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.transformuk.hee.tis</groupId>
<artifactId>tcs-client</artifactId>
<version>6.4.0</version>
<version>6.5.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,12 @@ public List<GdcDetailsDTO> findGdcDetailsIn(List<String> gdcIds) {
return responseEntity.getBody();
}

/**
* Retrieve the list of GMC details having GMC numbers in the provided list.
*
* @param gmcIds The GMC numbers to search for.
* @return The list of matching GMC details.
*/
public List<GmcDetailsDTO> findGmcDetailsIn(List<String> gmcIds) {
String url = serviceUrl + API_GMC_DETAILS_IN + getIdsAsUrlEncodedCSVs(gmcIds);
ResponseEntity<List<GmcDetailsDTO>> responseEntity = tcsRestTemplate.
Expand All @@ -698,6 +704,18 @@ public List<GmcDetailsDTO> findGmcDetailsIn(List<String> gmcIds) {
return responseEntity.getBody();
}

/**
* Retrieve the 'id' GMC details.
*
* @param id The ID of the GMC details to retrieve. (This is the ID of the person with these GMC details.)
* @return The GMC details, or null if not found.
*/
public GmcDetailsDTO getGmcDetailsById(Long id) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't include a javadoc because there aren't any in this file. I can amend if needed, but then perhaps we need to write javadocs for all the client functions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the a javadoc please.

log.debug("calling getGmcDetailsById with {}", id);
String url = serviceUrl + API_GMC_DETAILS + id.toString();
return tcsRestTemplate.getForEntity(url, GmcDetailsDTO.class).getBody();
}

public List<PostDTO> findPostsByNationalPostNumbersIn(List<String> npns) {
String url = serviceUrl + API_POSTS_IN + getIdsAsUrlEncodedCSVs(npns);
ResponseEntity<List<PostDTO>> responseEntity = tcsRestTemplate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.transformuk.hee.tis.tcs.api.dto.AbsenceDTO;
import com.transformuk.hee.tis.tcs.api.dto.CurriculumDTO;
import com.transformuk.hee.tis.tcs.api.dto.CurriculumMembershipDTO;
import com.transformuk.hee.tis.tcs.api.dto.GmcDetailsDTO;
import com.transformuk.hee.tis.tcs.api.dto.ProgrammeMembershipDTO;
import com.transformuk.hee.tis.tcs.api.dto.SpecialtyDTO;
import com.transformuk.hee.tis.tcs.api.enumeration.SpecialtyType;
Expand Down Expand Up @@ -378,4 +379,27 @@ public void createCurriculumMembershipShouldReturnSavedDto() {
new ParameterizedTypeReference<CurriculumMembershipDTO>() {
});
}

@Test
public void getGmcDetailsByIdShouldFindGmcDto() {
GmcDetailsDTO gmc = new GmcDetailsDTO();
gmc.setId(20L);

String url = "http://localhost:9999/tcs/api/gmc-details/20";

ResponseEntity responseEntity = new ResponseEntity(gmc, HttpStatus.OK);
doReturn(responseEntity).when(restTemplate).getForEntity(url, GmcDetailsDTO.class);

GmcDetailsDTO result = testObj.getGmcDetailsById(20L);
assertThat("Unexpected result", result, is(gmc));
verify(restTemplate).getForEntity(url, GmcDetailsDTO.class);
}

@Test
public void getGmcDetailsByIdShouldThrowErrorWhenNotFound() {
exceptionRule.expect(HttpClientErrorException.class);
exceptionRule.expectMessage("404 Not Found");
// RestTemplate hasn't been set up to find any GMC, so should throw exception
testObj.getGmcDetailsById(20L);
}
}
Loading