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

Test otp generation #15

Merged
merged 6 commits into from
Jan 8, 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.adorsys.webank.dto.OtpRequest;
import com.adorsys.webank.dto.OtpValidationRequest;
import com.adorsys.webank.service.OtpServiceApi;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

@RestController
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package com.adorsys.webank.service;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Service
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.adorsys.webank.serviceimpl;
import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.Test;

public class OtpServiceTest {


OtpServiceImpl otpServiceImpl = new OtpServiceImpl();

@Test
void generateFourDigitOtp() {
String otp = otpServiceImpl.generateOtp();

assertNotNull(otp, "Otp should not be null");
assert otp.length() == 4 : "Otp should be four digits";
assert otp.matches("\\d+") : "Otp should only contain digits";
assert Integer.parseInt(otp) >= 1000 && Integer.parseInt(otp) <= 9999 : "Otp should be between 1000 and 9999";
}

}
Loading