diff --git a/signup-service/src/test/java/io/mosip/signup/controllers/RegistrationControllerTest.java b/signup-service/src/test/java/io/mosip/signup/controllers/RegistrationControllerTest.java index ed7641c9..761b7f17 100644 --- a/signup-service/src/test/java/io/mosip/signup/controllers/RegistrationControllerTest.java +++ b/signup-service/src/test/java/io/mosip/signup/controllers/RegistrationControllerTest.java @@ -519,6 +519,23 @@ public void doGenerateChallenge_withRegistrationPurpose_thenPass() throws Except .andExpect(jsonPath("$.errors").isEmpty()); } + @Test + public void doGenerateChallenge_withNullPurpose_returnErrorResponse() throws Exception { + String status = "SUCCESSFUL"; + GenerateChallengeResponse generateChallengeResponse = new GenerateChallengeResponse(status); + generateChallengeRequest.setPurpose(null); + when(registrationService.generateChallenge(generateChallengeRequest, "")) + .thenReturn(generateChallengeResponse); + + mockMvc.perform(post("/registration/generate-challenge") + .content(objectMapper.writeValueAsString(wrapper)) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.response").isEmpty()) + .andExpect(jsonPath("$.errors").isNotEmpty()) + .andExpect(jsonPath("$.errors[0].errorCode").value(ErrorConstants.INVALID_PURPOSE)); + } + @Test public void doGenerateChallenge_withResetPasswordPurpose_thenPass() throws Exception { String status = "SUCCESSFUL";