Skip to content

Commit

Permalink
Merge pull request #116 from ADORSYS-GIS/114-make-end-points-on-obs-r…
Browse files Browse the repository at this point in the history
…eference-logic-in-prs

feat(): Made the endpoints in the OBS to reference the logic in the P…
  • Loading branch information
Arielpetit authored Jan 9, 2025
2 parents 21c23b7 + b143993 commit 9bf299e
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@Tag(name = "OTP", description = "Operations related to OTP processing")
@RequestMapping("/api/otp")
public interface OtpRestApi {
public interface ObsOtpRestApi {

@Operation(summary = "Send OTP", description = "Sends an OTP to the user's phone number")
@ApiResponses(value = {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

import com.adorsys.webank.obs.dto.OtpRequest;
import com.adorsys.webank.obs.dto.OtpValidationRequest;
import com.adorsys.webank.obs.service.OtpServiceApi;
import com.adorsys.webank.obs.service.ObsOtpServiceApi;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OtpRestServer implements OtpRestApi {
private final OtpServiceApi otpService;
public class ObsOtpRestServer implements ObsOtpRestApi {
private final ObsOtpServiceApi otpService;

public OtpRestServer(OtpServiceApi otpService) {
public ObsOtpRestServer(ObsOtpServiceApi otpService) {

this.otpService = otpService;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//package com.adorsys.webank.obs.resource;
//
//import com.adorsys.webank.obs.dto.OtpRequest;
//import com.adorsys.webank.obs.service.OtpServiceApi;
//import com.adorsys.webank.obs.service.ObsOtpServiceApi;
//import org.junit.jupiter.api.BeforeEach;
//import org.junit.jupiter.api.Test;
//import org.mockito.InjectMocks;
Expand All @@ -15,13 +15,13 @@
//import static org.junit.jupiter.api.Assertions.assertEquals;
//import static org.mockito.Mockito.when;
//
//public class OtpRestServerTest {
//public class ObsOtpRestServerTest {
//
// @InjectMocks
// private OtpRestServer otpRestServer; // Class under test
// private ObsOtpRestServer ObsOtpRestServer; // Class under test
//
// @Mock
// private OtpServiceApi otpServiceApi; // Mocked dependency
// private ObsOtpServiceApi ObsOtpServiceApi; // Mocked dependency
//
// @BeforeEach
// void setUp() {
Expand All @@ -35,10 +35,10 @@
// otpRequest.setOtp("123456");
//
// String expectedResponse = "OTP is valid";
// when(otpServiceApi.receiveOtp(otpRequest.getOtp())).thenReturn(expectedResponse);
// when(ObsOtpServiceApi.receiveOtp(otpRequest.getOtp())).thenReturn(expectedResponse);
//
// // Act
// ResponseEntity<?> responseEntity = otpRestServer.receiveOtp(otpRequest);
// ResponseEntity<?> responseEntity = ObsOtpRestServer.receiveOtp(otpRequest);
//
// // Assert
// assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
Expand All @@ -53,10 +53,10 @@
// otpRequest.setOtp("invalid");
//
// String expectedErrorMessage = "Invalid OTP";
// when(otpServiceApi.receiveOtp(otpRequest.getOtp())).thenThrow(new IllegalArgumentException(expectedErrorMessage));
// when(ObsOtpServiceApi.receiveOtp(otpRequest.getOtp())).thenThrow(new IllegalArgumentException(expectedErrorMessage));
//
// // Act
// ResponseEntity<?> responseEntity = otpRestServer.receiveOtp(otpRequest);
// ResponseEntity<?> responseEntity = ObsOtpRestServer.receiveOtp(otpRequest);
//
// // Assert
// assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import org.springframework.stereotype.Service;

@Service
public interface OtpServiceApi {
public interface ObsOtpServiceApi {
String sendOtp(String phoneNumber, String publicKey);

boolean validateOtp(String phoneNumber, String publicKey, String otpInput , String otpHash);
Expand Down
12 changes: 5 additions & 7 deletions obs/obs-service-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
<artifactId>obs-service-api</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.adorsys.webank</groupId>
<artifactId>prs-service-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>



Expand All @@ -45,12 +49,6 @@
<!-- test depedencies -->


<dependency>
<groupId>de.adorsys.webank</groupId>
<artifactId>webank-bank-account-service-impl</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@Target(value = {java.lang.annotation.ElementType.TYPE})
@Documented
@Import({
ServiceimplConfiguration.class
ObsServiceimplConfiguration.class
})
public @interface EnableObsServiceimpl {
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@

@Configuration
@ComponentScan(basePackageClasses= {ServiceimplBasePackage.class})
public class ServiceimplConfiguration {
public class ObsServiceimplConfiguration {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.adorsys.webank.obs.serviceimpl;

import com.adorsys.webank.obs.service.ObsOtpServiceApi;
import com.adorsys.webank.service.OtpServiceApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ObsOtpServiceImpl implements ObsOtpServiceApi {

@Autowired
private OtpServiceApi otpServiceApi;

@Override
public String sendOtp(String phoneNumber, String publicKey) {

return otpServiceApi.sendOtp(phoneNumber, publicKey);
}
@Override
public boolean validateOtp(String phoneNumber, String publicKey, String otpInput , String otpHash){

return otpServiceApi.validateOtp(phoneNumber, publicKey, otpInput, otpHash);

}
}


Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.UUID;

@Service
public class OBSServiceImpl implements RegistrationServiceApi {
public class ObsServiceImpl implements RegistrationServiceApi {

@Autowired
private BankAccountService bankAccountService;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;

class OBSServiceImplTest {
class ObsServiceImplTest {

@Mock
private BankAccountService bankAccountService;

@InjectMocks
private OBSServiceImpl obsService;
private ObsServiceImpl obsService;

@BeforeEach
void setUp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
//
//import static org.junit.jupiter.api.Assertions.*;
//
//class OtpServiceImplTest {
//class ObsOtpServiceImplTest {
//
// @InjectMocks
// private OtpServiceImpl otpService;
// private ObsOtpServiceImpl otpService;
//
// @BeforeEach
// void setUp() {
Expand Down
11 changes: 11 additions & 0 deletions online-banking-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@
<artifactId>ledgers-postings-service-impl</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.adorsys.webank</groupId>
<artifactId>prs-service-impl</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.adorsys.webank</groupId>
<artifactId>prs-rest-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>

</dependencies>
<dependencyManagement>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ApplicationListener;


@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
@EnableBankAccountService
@EnablePostingService
Expand Down

0 comments on commit 9bf299e

Please sign in to comment.