Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

Add Rest endpoint to check if email exists #930

Merged
merged 3 commits into from
Mar 12, 2022

Conversation

kuruvasatya
Copy link
Contributor

@kuruvasatya kuruvasatya commented Feb 15, 2022

Summary of change

Added new rest endpoint in the UserController.java class to check if email exists or not

Related issue

Closes #925

Pull request checklist

Please keep this checklist in & ensure you have done the following:

  • Read, understood and adhered to our contributing document.

    • Ensure that you were first assigned to a relevant issue before creating this pull request
    • Ensure code changes pass all tests
  • Read, understood and adhered to our style guide. A lot of our code reviews are spent on ensuring compliance with our style guide, so it would save a lot of time if this was adhered to from the outset.

  • Set this pull request to 'draft' if you are still working on it

  • Resolved any merge conflicts

  • Filled in the summary, context (if applicable) and related issue section. Replace the square brackets and its placeholder content with your contents. For an example, see any merged in pull request

For any of the optional checkboxes (e.g. the screenshots one), still check it if it does not apply.

Copy link
Member

@knjk04 knjk04 left a comment

Choose a reason for hiding this comment

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

Thanks for adding this endpoint! Could you also please write some tests for this (check that we return 200 OK on success and 404 on failure)?

@kuruvasatya
Copy link
Contributor Author

Hi @knjk04, for some reasons MockMvc is not working, it is blocking me from writing test, could you help regarding the same?

@knjk04
Copy link
Member

knjk04 commented Feb 19, 2022

Hi @kuruvasatya, sure. I can help you with this. How come you closed this pull request?

@kuruvasatya kuruvasatya reopened this Feb 19, 2022
@kuruvasatya
Copy link
Contributor Author

Hey @knjk04, that was by mistake, i am able to test the service, but for testing controller I think we need MockMvc, that seems to be not working, please help me

@kuruvasatya
Copy link
Contributor Author

Hey @knjk04 any Updates, its been days

@@ -88,6 +90,16 @@ public User getUser(@PathVariable Long id) {
);
}

@GetMapping("/email/{email}")
public ResponseEntity<String> checkIfEmailExists(@PathVariable String email) {
Optional<User> user = userService.findUserByEmail(email);
Copy link
Contributor

Choose a reason for hiding this comment

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

userService.findUserByEmail(email)
    .map(user-> ResponseEntity.ok())
    .orElse(ResponseEntity.status(HttpStatus.NOT_FOUND).body(EMAIL_NOT_FOUND));

Copy link
Member

@knjk04 knjk04 Mar 12, 2022

Choose a reason for hiding this comment

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

@mslowiak I don't think that'll work:

image

@knjk04
Copy link
Member

knjk04 commented Mar 12, 2022

Hi @kuruvasatya, so sorry for the delay & thanks for chasing up. I didn't get a chance to implement this, but I'll do it now.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@knjk04 knjk04 left a comment

Choose a reason for hiding this comment

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

Thanks!

@knjk04 knjk04 merged commit 2046226 into Project-Books:main Mar 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create endpoint to check if email exists
3 participants