24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/postman/postman-environment.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "798deb34-93fd-4cd4-b026-43c898424c51",
3 | "name": "Royal Reserve Bank",
4 | "values": [
5 | {
6 | "key": "oidc_provider",
7 | "value": "https://dev-w4tsg2n64xw88mjb.us.auth0.com/oauth/token",
8 | "type": "default",
9 | "enabled": true
10 | },
11 | {
12 | "key": "url",
13 | "value": "http://localhost:8080",
14 | "type": "default",
15 | "enabled": true
16 | },
17 | {
18 | "key": "secret",
19 | "value": "e5qQhoxUuG9_f_2FMlSiNkdix7R4BALqecMNb-SAKTGd123j8IrzpspKTr1dcWkS",
20 | "type": "default",
21 | "enabled": true
22 | },
23 | {
24 | "key": "client_id",
25 | "value": "o9BivpkKvTVVzCTp5cbBy7CqJ2fpDoEA",
26 | "type": "default",
27 | "enabled": true
28 | },
29 | {
30 | "key": "audience",
31 | "value": "23425532",
32 | "type": "default",
33 | "enabled": true
34 | }
35 | ],
36 | "_postman_variable_scope": "environment",
37 | "_postman_exported_at": "2023-05-11T20:21:42.881Z",
38 | "_postman_exported_using": "Postman/10.13.5"
39 | }
--------------------------------------------------------------------------------
/account-api/src/test/java/com/royal/reserve/bank/account/api/integration/config/TestConfig.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.account.api.integration.config;
2 |
3 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
4 | import org.springframework.boot.test.context.TestConfiguration;
5 | import org.springframework.context.annotation.Bean;
6 | import org.springframework.test.web.servlet.MockMvc;
7 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
8 | import org.springframework.web.context.WebApplicationContext;
9 |
10 | /**
11 | * Test configuration for the integration tests.
12 | */
13 | @TestConfiguration
14 | @AutoConfigureMockMvc
15 | public class TestConfig {
16 | /**
17 | * Creates a {@link MockMvc} instance.
18 | *
19 | * @param webApplicationContext the web application context
20 | * @return the {@link MockMvc} instance
21 | */
22 | @Bean
23 | public MockMvc mockMvc(WebApplicationContext webApplicationContext) {
24 | return MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/asset-management-api/src/test/java/com/royal/reserve/bank/asset/management/api/integration/config/TestConfig.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.asset.management.api.integration.config;
2 |
3 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
4 | import org.springframework.boot.test.context.TestConfiguration;
5 | import org.springframework.context.annotation.Bean;
6 | import org.springframework.test.web.servlet.MockMvc;
7 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
8 | import org.springframework.web.context.WebApplicationContext;
9 |
10 | /**
11 | * Test configuration for the integration tests.
12 | */
13 | @TestConfiguration
14 | @AutoConfigureMockMvc
15 | public class TestConfig {
16 | /**
17 | * Creates a {@link MockMvc} instance.
18 | *
19 | * @param webApplicationContext the web application context
20 | * @return the {@link MockMvc} instance
21 | */
22 | @Bean
23 | public MockMvc mockMvc(WebApplicationContext webApplicationContext) {
24 | return MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/transaction-api/src/test/java/com/royal/reserve/bank/transaction/api/unit/dto/AssetManagementResponseTest.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.transaction.api.unit.dto;
2 |
3 | import com.royal.reserve.bank.transaction.api.dto.AssetManagementResponse;
4 | import org.junit.jupiter.api.Assertions;
5 | import org.junit.jupiter.api.Test;
6 |
7 | /**
8 | * Unit tests for the {@link AssetManagementResponse} class.
9 | */
10 | class AssetManagementResponseTest {
11 |
12 | /**
13 | * Test the constructors.
14 | */
15 | @Test
16 | void testAssetManagementResponse() {
17 | // Given
18 | String expectedAssetCode = "F";
19 | boolean expectedIsAssetAvailable = true;
20 |
21 | // When
22 | AssetManagementResponse response = AssetManagementResponse.builder()
23 | .assetCode(expectedAssetCode)
24 | .isAssetAvailable(expectedIsAssetAvailable)
25 | .build();
26 |
27 | // Then
28 | Assertions.assertEquals(expectedAssetCode, response.getAssetCode());
29 | Assertions.assertTrue(response.isAssetAvailable());
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 zoltanvin
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/asset-management-api/src/test/java/com/royal/reserve/bank/asset/management/api/unit/dto/AssetManagementResponseTest.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.asset.management.api.unit.dto;
2 |
3 | import com.royal.reserve.bank.asset.management.api.dto.AssetManagementResponse;
4 | import org.junit.jupiter.api.Assertions;
5 | import org.junit.jupiter.api.Test;
6 |
7 | /**
8 | * Unit tests for the {@link AssetManagementResponse} class.
9 | */
10 | class AssetManagementResponseTest {
11 |
12 | /**
13 | * Test the constructors.
14 | */
15 | @Test
16 | void testAssetManagementResponse() {
17 | // Given
18 | String expectedAssetCode = "USDT";
19 | boolean expectedIsAssetAvailable = true;
20 |
21 | // When
22 | AssetManagementResponse response = AssetManagementResponse.builder()
23 | .assetCode(expectedAssetCode)
24 | .isAssetAvailable(expectedIsAssetAvailable)
25 | .build();
26 |
27 | // Then
28 | Assertions.assertEquals(expectedAssetCode, response.getAssetCode());
29 | Assertions.assertTrue(response.isAssetAvailable());
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | title: ''
4 |
5 | ---
6 |
7 | **Description**
8 | Provide a clear and concise description of the feature you are requesting.
9 |
10 | **Use Case**
11 | Explain the use case or scenario where this feature would be beneficial or necessary.
12 |
13 | **Possible Solution**
14 | If you have any suggestions or ideas for a possible solution, include them here.
15 |
16 | **Additional Information**
17 | Include any additional information, references, or examples that might be helpful for understanding and implementing the feature.
18 |
19 | **Impact**
20 | Discuss the potential impact of the feature on existing functionality, performance, or user experience.
21 |
22 | **Dependencies**
23 | List any dependencies or prerequisites that are required for implementing this feature.
24 |
25 | **Related Issues**
26 | If applicable, mention any related issues that are associated with this feature request.
27 |
28 | **Screenshots or Mockups**
29 | If applicable, include any screenshots, design mockups, or visual representations of the feature.
30 |
31 | **Additional Context**
32 | Add any other context about the problem here.
33 |
--------------------------------------------------------------------------------
/transaction-api/src/main/java/com/royal/reserve/bank/transaction/api/client/AssetManagementClient.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.transaction.api.client;
2 |
3 | import com.royal.reserve.bank.transaction.api.dto.AssetManagementResponse;
4 | import io.github.resilience4j.retry.annotation.Retry;
5 | import org.springframework.cloud.openfeign.FeignClient;
6 | import org.springframework.web.bind.annotation.GetMapping;
7 | import org.springframework.web.bind.annotation.RequestParam;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * A Feign client interface for interacting with the Asset Management API.
13 | */
14 | @FeignClient(name = "asset-management-api")
15 | @Retry(name = "asset-management")
16 | public interface AssetManagementClient {
17 |
18 | /**
19 | *
20 | *Retrieves asset availability information from the Asset Management API.
21 | *@param assetCode The list of asset codes to check availability for.
22 | *@return A list of AssetManagementResponse objects containing asset availability information.
23 | */
24 | @GetMapping("/api/asset-management")
25 | List checkAssetAvailability(@RequestParam List assetCode);
26 | }
--------------------------------------------------------------------------------
/transaction-api/src/test/java/com/royal/reserve/bank/transaction/api/unit/dto/TransactionRequestTest.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.transaction.api.unit.dto;
2 |
3 | import com.royal.reserve.bank.transaction.api.dto.TransactionItemsDto;
4 | import com.royal.reserve.bank.transaction.api.dto.TransactionRequest;
5 | import org.junit.jupiter.api.Assertions;
6 | import org.junit.jupiter.api.Test;
7 |
8 | import java.util.Arrays;
9 | import java.util.List;
10 |
11 | /**
12 | * Unit tests for the {@link TransactionRequest} class.
13 | */
14 | class TransactionRequestTest {
15 |
16 | /**
17 | * Test the constructors.
18 | */
19 | @Test
20 | void testTransactionRequest() {
21 | // Given
22 | TransactionItemsDto item1 = new TransactionItemsDto(1L, "EDE", "Eden Innovations Ltd.", 100);
23 | TransactionItemsDto item2 = new TransactionItemsDto(2L, "T", "AT&T Inc.", 200);
24 | List expectedItemList = Arrays.asList(item1, item2);
25 |
26 | // When
27 | TransactionRequest request = new TransactionRequest(expectedItemList);
28 |
29 | // Then
30 | Assertions.assertEquals(expectedItemList, request.getTransactionItemsDtoList());
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/notification-api/src/main/java/com/royal/reserve/bank/notification/api/NotificationApiApplication.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.notification.api;
2 |
3 | import com.royal.reserve.bank.notification.api.event.TransactionEvent;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import lombok.extern.slf4j.Slf4j;
7 | import org.springframework.kafka.annotation.KafkaListener;
8 |
9 | /**
10 | * Main class for the Notification Api.
11 | */
12 | @SpringBootApplication
13 | @Slf4j
14 | public class NotificationApiApplication {
15 |
16 | public static void main(String[] args) {
17 | SpringApplication.run(NotificationApiApplication.class, args);
18 | }
19 |
20 | /**
21 | *This method is a Kafka message listener for the "notificationTopic" topic.
22 | *It handles incoming messages and processes the TransactionEvent object.
23 | *@param transactionEvent The TransactionEvent object received from the Kafka message.
24 | */
25 | @KafkaListener(topics = "notificationTopic")
26 | public void handleNotification(TransactionEvent transactionEvent) {
27 | log.info("Received notification for transaction: {}", transactionEvent.getTransactionId());
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/transaction-api/src/test/java/com/royal/reserve/bank/transaction/api/unit/dto/TransactionItemsDtoTest.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.transaction.api.unit.dto;
2 |
3 | import com.royal.reserve.bank.transaction.api.dto.TransactionItemsDto;
4 | import org.junit.jupiter.api.Assertions;
5 | import org.junit.jupiter.api.Test;
6 |
7 | /**
8 | * Unit tests for the {@link TransactionItemsDto} class.
9 | */
10 | class TransactionItemsDtoTest {
11 |
12 | /**
13 | * Test the constructors.
14 | */
15 | @Test
16 | void testTransactionItemsDto() {
17 | // Given
18 | Long expectedId = 1L;
19 | String expectedAssetCode = "IBM";
20 | String expectedAssetName = "International Business Machines Corporation";
21 | int expectedValue = 942200;
22 |
23 | // When
24 | TransactionItemsDto dto = new TransactionItemsDto(expectedId, expectedAssetCode, expectedAssetName, expectedValue);
25 |
26 | // Then
27 | Assertions.assertEquals(expectedId, dto.getId());
28 | Assertions.assertEquals(expectedAssetCode, dto.getAssetCode());
29 | Assertions.assertEquals(expectedAssetName, dto.getAssetName());
30 | Assertions.assertEquals(expectedValue, dto.getValue());
31 | }
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/discovery-server/src/main/java/com/royal/reserve/bank/discovery/server/config/SecurityConfig.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.discovery.server.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.security.config.annotation.web.builders.HttpSecurity;
6 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
7 | import org.springframework.security.web.SecurityFilterChain;
8 |
9 | /**
10 | * Configuration class for web security.
11 | */
12 | @EnableWebSecurity
13 | @Configuration
14 | public class SecurityConfig {
15 |
16 | /**
17 | *Configures the security filter chain for the application. Ignore the /eureka/** path from CSRF protection.
18 | *@param httpSecurity the HttpSecurity object used for configuring the security filter chain
19 | *@return the configured SecurityFilterChain object
20 | *@throws Exception if an error occurs during configuration
21 | */
22 | @Bean
23 | public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception {
24 | httpSecurity.csrf().ignoringRequestMatchers("/eureka/**");
25 | return httpSecurity.build();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/asset-management-api/src/test/java/com/royal/reserve/bank/asset/management/api/unit/model/AssetTest.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.asset.management.api.unit.model;
2 |
3 | import com.royal.reserve.bank.asset.management.api.model.Asset;
4 | import org.junit.jupiter.api.Test;
5 |
6 | import static org.junit.jupiter.api.Assertions.assertEquals;
7 | import static org.junit.jupiter.api.Assertions.assertNotEquals;
8 |
9 | /**
10 | * Unit tests for the {@link Asset} class.
11 | */
12 | class AssetTest {
13 |
14 | /**
15 | * Test for the {@link Asset#equals(Object)} and {@link Asset#hashCode()} methods.
16 | */
17 | @Test
18 | void testEqualsAndHashCode() {
19 | // Given
20 | Asset asset1 = new Asset();
21 | asset1.setAssetCode("RUT");
22 | asset1.setAssetName("Russel 2000");
23 | asset1.setValue(1000);
24 |
25 | Asset asset2 = new Asset();
26 | asset2.setAssetCode("RUT");
27 | asset2.setAssetName("Russel 2000");
28 | asset2.setValue(1000);
29 |
30 | // When and Then
31 | assertEquals(asset1, asset2);
32 | assertEquals(asset1.hashCode(), asset2.hashCode());
33 |
34 | asset2.setValue(2000);
35 | assertNotEquals(asset1, asset2);
36 | assertNotEquals(asset1.hashCode(), asset2.hashCode());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/discovery-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | royal-reserve-bank
7 | org.royal-reserve-bank
8 | 1.0
9 |
10 | 4.0.0
11 |
12 | discovery-server
13 |
14 |
15 |
16 | org.springframework.cloud
17 | spring-cloud-starter-netflix-eureka-server
18 |
19 |
20 | org.springframework.boot
21 | spring-boot-starter-security
22 |
23 |
24 | org.springframework.security
25 | spring-security-web
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-config-client
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/notification-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | royal-reserve-bank
9 | org.royal-reserve-bank
10 | 1.0
11 |
12 |
13 | notification-api
14 |
15 |
16 |
17 | org.springframework.boot
18 | spring-boot-starter-web
19 |
20 |
21 | org.springframework.kafka
22 | spring-kafka
23 |
24 |
25 | org.springframework.cloud
26 | spring-cloud-starter-netflix-eureka-client
27 |
28 |
29 | org.springframework.kafka
30 | spring-kafka-test
31 | test
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-config
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/account-api/src/test/java/com/royal/reserve/bank/account/api/unit/dto/AccountRequestTest.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.account.api.unit.dto;
2 |
3 |
4 | import com.royal.reserve.bank.account.api.dto.AccountRequest;
5 | import org.junit.jupiter.api.Assertions;
6 | import org.junit.jupiter.api.Test;
7 |
8 | import java.math.BigDecimal;
9 | import java.util.Currency;
10 |
11 | /**
12 | * Unit tests for the {@link AccountRequest} class.
13 | */
14 | class AccountRequestTest {
15 |
16 | /**
17 | * Test the constructors.
18 | */
19 | @Test
20 | void testAccountRequest() {
21 | // Given
22 | String expectedAccountHolderName = "Steve Jobs";
23 | BigDecimal expectedBalance = new BigDecimal("13000.00");
24 | Currency expectedCurrency = Currency.getInstance("RUB");
25 |
26 | // When
27 | AccountRequest request = AccountRequest.builder()
28 | .accountHolderName(expectedAccountHolderName)
29 | .balance(expectedBalance)
30 | .currency(expectedCurrency)
31 | .build();
32 |
33 | // Then
34 | Assertions.assertEquals(expectedAccountHolderName, request.getAccountHolderName());
35 | Assertions.assertEquals(expectedBalance, request.getBalance());
36 | Assertions.assertEquals(expectedCurrency, request.getCurrency());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/prometheus-configuration.yml:
--------------------------------------------------------------------------------
1 | global:
2 | scrape_interval: 10s
3 | evaluation_interval: 10s
4 |
5 | scrape_configs:
6 | - job_name: 'account-api'
7 | metrics_path: '/actuator/prometheus'
8 | static_configs:
9 | - targets: ['account-api:8080']
10 | labels:
11 | application: 'Account-API'
12 | - job_name: 'transaction-api'
13 | metrics_path: '/actuator/prometheus'
14 | static_configs:
15 | - targets: ['transaction-api:8080']
16 | labels:
17 | application: 'Transaction-API'
18 | - job_name: 'asset-management-api'
19 | metrics_path: '/actuator/prometheus'
20 | static_configs:
21 | - targets: ['asset-management-api:8080']
22 | labels:
23 | application: 'Asset-management-API'
24 | - job_name: 'notification-api'
25 | metrics_path: '/actuator/prometheus'
26 | static_configs:
27 | - targets: ['notification-api:8080']
28 | labels:
29 | application: 'Notification-API'
30 | - job_name: 'discovery-server'
31 | metrics_path: '/actuator/prometheus'
32 | static_configs:
33 | - targets: ['discovery-server:8761']
34 | labels:
35 | application: 'Discovery-Server'
36 | - job_name: 'config-server'
37 | metrics_path: '/actuator/prometheus'
38 | static_configs:
39 | - targets: ['config-server:8888']
40 | labels:
41 | application: 'Config-Server'
42 |
--------------------------------------------------------------------------------
/transaction-api/src/test/java/com/royal/reserve/bank/transaction/api/integration/config/TestConfig.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.transaction.api.integration.config;
2 |
3 | import com.fasterxml.jackson.databind.ObjectMapper;
4 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
5 | import org.springframework.boot.test.context.TestConfiguration;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
8 | import org.springframework.test.web.servlet.MockMvc;
9 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
10 | import org.springframework.web.context.WebApplicationContext;
11 |
12 | /**
13 | * Test configuration for the integration tests.
14 | */
15 | @TestConfiguration
16 | @AutoConfigureMockMvc
17 | public class TestConfig {
18 | /**
19 | * Creates a {@link MockMvc} instance.
20 | *
21 | * @param webApplicationContext the web application context
22 | * @return the {@link MockMvc} instance
23 | */
24 | @Bean
25 | public MockMvc mockMvc(WebApplicationContext webApplicationContext) {
26 | return MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
27 | }
28 |
29 | /**
30 | * Creates an {@link ObjectMapper} bean.
31 | *
32 | * @return the {@link ObjectMapper} bean
33 | */
34 | @Bean
35 | public ObjectMapper objectMapper() {
36 | return Jackson2ObjectMapperBuilder.json().build();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/asset-management-api/src/main/java/com/royal/reserve/bank/asset/management/api/controller/AssetManagementController.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.asset.management.api.controller;
2 |
3 | import com.royal.reserve.bank.asset.management.api.dto.AssetManagementResponse;
4 | import com.royal.reserve.bank.asset.management.api.service.AssetManagementService;
5 | import lombok.RequiredArgsConstructor;
6 | import lombok.extern.slf4j.Slf4j;
7 | import org.springframework.http.HttpStatus;
8 | import org.springframework.web.bind.annotation.*;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * Controller class that handles HTTP requests related to asset management.
14 | */
15 | @RestController
16 | @RequestMapping("/api/asset-management")
17 | @RequiredArgsConstructor
18 | @Slf4j
19 | public class AssetManagementController {
20 |
21 | private final AssetManagementService assetManagementService;
22 |
23 | /**
24 | *
25 | *Retrieves the availability status of assets based on their codes.
26 | *@param assetCode The list of asset codes to check availability for.
27 | *@return The list of asset management responses containing the availability status for each asset code.
28 | */
29 | @GetMapping
30 | @ResponseStatus(HttpStatus.OK)
31 | public List isAssetAvailable(@RequestParam List assetCode) {
32 | log.info("Received asset availability check request for asset code: {}", assetCode);
33 | return assetManagementService.isAssetAvailable(assetCode);
34 | }
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/docs/javadoc/element-list:
--------------------------------------------------------------------------------
1 | com.royal.reserve.bank.account.api
2 | com.royal.reserve.bank.account.api.config
3 | com.royal.reserve.bank.account.api.controller
4 | com.royal.reserve.bank.account.api.dto
5 | com.royal.reserve.bank.account.api.model
6 | com.royal.reserve.bank.account.api.repository
7 | com.royal.reserve.bank.account.api.serializer
8 | com.royal.reserve.bank.account.api.service
9 | com.royal.reserve.bank.account.api.util
10 | com.royal.reserve.bank.api.gateway
11 | com.royal.reserve.bank.api.gateway.config
12 | com.royal.reserve.bank.asset.management.api
13 | com.royal.reserve.bank.asset.management.api.controller
14 | com.royal.reserve.bank.asset.management.api.dto
15 | com.royal.reserve.bank.asset.management.api.model
16 | com.royal.reserve.bank.asset.management.api.repository
17 | com.royal.reserve.bank.asset.management.api.service
18 | com.royal.reserve.bank.asset.management.api.util
19 | com.royal.reserve.bank.config.server
20 | com.royal.reserve.bank.discovery.server
21 | com.royal.reserve.bank.discovery.server.config
22 | com.royal.reserve.bank.notification.api
23 | com.royal.reserve.bank.notification.api.event
24 | com.royal.reserve.bank.transaction.api
25 | com.royal.reserve.bank.transaction.api.client
26 | com.royal.reserve.bank.transaction.api.config
27 | com.royal.reserve.bank.transaction.api.controller
28 | com.royal.reserve.bank.transaction.api.dto
29 | com.royal.reserve.bank.transaction.api.event
30 | com.royal.reserve.bank.transaction.api.model
31 | com.royal.reserve.bank.transaction.api.repository
32 | com.royal.reserve.bank.transaction.api.service
33 |
--------------------------------------------------------------------------------
/asset-management-api/src/test/java/com/royal/reserve/bank/asset/management/api/unit/repository/AssetManagementRepositoryTest.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.asset.management.api.unit.repository;
2 | import com.royal.reserve.bank.asset.management.api.model.Asset;
3 | import com.royal.reserve.bank.asset.management.api.repository.AssetManagementRepository;
4 | import org.junit.jupiter.api.Test;
5 | import org.junit.jupiter.api.extension.ExtendWith;
6 | import org.mockito.Mock;
7 | import org.mockito.junit.jupiter.MockitoExtension;
8 |
9 | import java.util.Arrays;
10 | import java.util.List;
11 |
12 | import static org.junit.jupiter.api.Assertions.assertEquals;
13 | import static org.mockito.Mockito.when;
14 |
15 | /**
16 | * Unit tests for the {@link AssetManagementRepository} class.
17 | */
18 | @ExtendWith(MockitoExtension.class)
19 | class AssetManagementRepositoryTest {
20 |
21 | @Mock
22 | private AssetManagementRepository assetManagementRepository;
23 |
24 | /**
25 | * Test for the {@link AssetManagementRepository#findByAssetCodeIn(List)} method.
26 | */
27 | @Test
28 | void testFindByAssetCodeIn() {
29 | // Given
30 | List assetCodes = Arrays.asList("78231", "24722");
31 | List expectedAssets = Arrays.asList(
32 | new Asset(1L, "78231", "a", 25400),
33 | new Asset(2L, "24722", "b", 52000)
34 | );
35 |
36 | // When
37 | when(assetManagementRepository.findByAssetCodeIn(assetCodes)).thenReturn(expectedAssets);
38 | List actualAssets = assetManagementRepository.findByAssetCodeIn(assetCodes);
39 |
40 | // Then
41 | assertEquals(expectedAssets, actualAssets);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/account-api/src/test/java/com/royal/reserve/bank/account/api/unit/dto/AccountResponseTest.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.account.api.unit.dto;
2 |
3 | import com.royal.reserve.bank.account.api.dto.AccountResponse;
4 | import org.junit.jupiter.api.Assertions;
5 | import org.junit.jupiter.api.Test;
6 |
7 | import java.math.BigDecimal;
8 | import java.util.Currency;
9 |
10 | /**
11 | * Unit tests for the {@link AccountResponse} class.
12 | */
13 | class AccountResponseTest {
14 |
15 | /**
16 | * Test the constructors.
17 | */
18 | @Test
19 | void testAccountResponse() {
20 | // Given
21 | String expectedId = "52342";
22 | String expectedAccountNumber = "BN12-4123-1235-7653-8576";
23 | String expectedAccountHolderName = "Nelson Mandela";
24 | BigDecimal expectedBalance = new BigDecimal("610345.00");
25 | Currency expectedCurrency = Currency.getInstance("EUR");
26 |
27 | // When
28 | AccountResponse response = AccountResponse.builder()
29 | .id(expectedId)
30 | .accountNumber(expectedAccountNumber)
31 | .accountHolderName(expectedAccountHolderName)
32 | .balance(expectedBalance)
33 | .currency(expectedCurrency)
34 | .build();
35 |
36 | // Then
37 | Assertions.assertEquals(expectedId, response.getId());
38 | Assertions.assertEquals(expectedAccountNumber, response.getAccountNumber());
39 | Assertions.assertEquals(expectedAccountHolderName, response.getAccountHolderName());
40 | Assertions.assertEquals(expectedBalance, response.getBalance());
41 | Assertions.assertEquals(expectedCurrency, response.getCurrency());
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/asset-management-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | royal-reserve-bank
9 | org.royal-reserve-bank
10 | 1.0
11 |
12 |
13 | asset-management-api
14 |
15 |
16 |
17 | org.springframework.boot
18 | spring-boot-starter-data-jpa
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-web
23 |
24 |
25 | org.springframework.cloud
26 | spring-cloud-starter-netflix-eureka-client
27 |
28 |
29 | com.mysql
30 | mysql-connector-j
31 | runtime
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-config-client
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-data-redis
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/docs/javadoc/package-search-index.js:
--------------------------------------------------------------------------------
1 | packageSearchIndex = [{"l":"All Packages","u":"allpackages-index.html"},{"l":"com.royal.reserve.bank.account.api"},{"l":"com.royal.reserve.bank.account.api.config"},{"l":"com.royal.reserve.bank.account.api.controller"},{"l":"com.royal.reserve.bank.account.api.dto"},{"l":"com.royal.reserve.bank.account.api.model"},{"l":"com.royal.reserve.bank.account.api.repository"},{"l":"com.royal.reserve.bank.account.api.serializer"},{"l":"com.royal.reserve.bank.account.api.service"},{"l":"com.royal.reserve.bank.account.api.util"},{"l":"com.royal.reserve.bank.api.gateway"},{"l":"com.royal.reserve.bank.api.gateway.config"},{"l":"com.royal.reserve.bank.asset.management.api"},{"l":"com.royal.reserve.bank.asset.management.api.controller"},{"l":"com.royal.reserve.bank.asset.management.api.dto"},{"l":"com.royal.reserve.bank.asset.management.api.model"},{"l":"com.royal.reserve.bank.asset.management.api.repository"},{"l":"com.royal.reserve.bank.asset.management.api.service"},{"l":"com.royal.reserve.bank.asset.management.api.util"},{"l":"com.royal.reserve.bank.config.server"},{"l":"com.royal.reserve.bank.discovery.server"},{"l":"com.royal.reserve.bank.discovery.server.config"},{"l":"com.royal.reserve.bank.notification.api"},{"l":"com.royal.reserve.bank.notification.api.event"},{"l":"com.royal.reserve.bank.transaction.api"},{"l":"com.royal.reserve.bank.transaction.api.client"},{"l":"com.royal.reserve.bank.transaction.api.config"},{"l":"com.royal.reserve.bank.transaction.api.controller"},{"l":"com.royal.reserve.bank.transaction.api.dto"},{"l":"com.royal.reserve.bank.transaction.api.event"},{"l":"com.royal.reserve.bank.transaction.api.model"},{"l":"com.royal.reserve.bank.transaction.api.repository"},{"l":"com.royal.reserve.bank.transaction.api.service"}];updateSearchResults();
--------------------------------------------------------------------------------
/docs/javadoc/script-dir/jquery-ui.min.css:
--------------------------------------------------------------------------------
1 | /*! jQuery UI - v1.13.1 - 2022-05-12
2 | * http://jqueryui.com
3 | * Includes: core.css, autocomplete.css, menu.css
4 | * Copyright jQuery Foundation and other contributors; Licensed MIT */
5 |
6 | .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;-ms-filter:"alpha(opacity=0)"}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important;pointer-events:none}.ui-icon{display:inline-block;vertical-align:middle;margin-top:-.25em;position:relative;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-icon-block{left:50%;margin-left:-8px;display:block}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}.ui-menu{list-style:none;padding:0;margin:0;display:block;outline:0}.ui-menu .ui-menu{position:absolute}.ui-menu .ui-menu-item{margin:0;cursor:pointer;list-style-image:url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")}.ui-menu .ui-menu-item-wrapper{position:relative;padding:3px 1em 3px .4em}.ui-menu .ui-menu-divider{margin:5px 0;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-state-focus,.ui-menu .ui-state-active{margin:-1px}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item-wrapper{padding-left:2em}.ui-menu .ui-icon{position:absolute;top:0;bottom:0;left:.2em;margin:auto 0}.ui-menu .ui-menu-icon{left:auto;right:0}
--------------------------------------------------------------------------------
/asset-management-api/src/main/java/com/royal/reserve/bank/asset/management/api/service/AssetManagementService.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.asset.management.api.service;
2 |
3 | import com.royal.reserve.bank.asset.management.api.dto.AssetManagementResponse;
4 | import com.royal.reserve.bank.asset.management.api.repository.AssetManagementRepository;
5 | import lombok.RequiredArgsConstructor;
6 | import lombok.SneakyThrows;
7 | import lombok.extern.slf4j.Slf4j;
8 | import org.springframework.cache.annotation.Cacheable;
9 | import org.springframework.stereotype.Service;
10 | import org.springframework.transaction.annotation.Transactional;
11 |
12 | import java.util.List;
13 |
14 | /**
15 | * Service class that provides operations for managing assets.
16 | */
17 | @Service
18 | @RequiredArgsConstructor
19 | @Slf4j
20 | public class AssetManagementService {
21 |
22 | private final AssetManagementRepository assetManagementRepository;
23 |
24 | /**
25 | *
26 | *Checks the availability of assets based on their codes.
27 | *@param assetCode The list of asset codes to check.
28 | *@return A list of AssetManagementResponse objects indicating the availability of each asset.
29 | */
30 | @Transactional(readOnly = true)
31 | @SneakyThrows
32 | @Cacheable("assetAvailability")
33 | public List isAssetAvailable(List assetCode) {
34 | log.info("Checking asset availability");
35 | return assetManagementRepository.findByAssetCodeIn(assetCode).stream()
36 | .map(asset ->
37 | AssetManagementResponse.builder()
38 | .assetCode(asset.getAssetCode())
39 | .isAssetAvailable(asset.getValue() > 0)
40 | .build()
41 | ).toList();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/account-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | royal-reserve-bank
9 | org.royal-reserve-bank
10 | 1.0
11 |
12 |
13 | account-api
14 |
15 |
16 |
17 | org.springframework.boot
18 | spring-boot-starter-data-mongodb
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-web
23 |
24 |
25 | org.springframework.cloud
26 | spring-cloud-starter-netflix-eureka-client
27 |
28 |
29 | org.testcontainers
30 | mongodb
31 | test
32 |
33 |
34 | org.testcontainers
35 | junit-jupiter
36 | test
37 |
38 |
39 | org.springframework.cloud
40 | spring-cloud-config-client
41 |
42 |
43 | org.springframework.boot
44 | spring-boot-starter-data-redis
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/account-api/src/test/java/com/royal/reserve/bank/account/api/unit/model/AccountTest.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.account.api.unit.model;
2 |
3 | import com.royal.reserve.bank.account.api.model.Account;
4 | import org.junit.jupiter.api.Assertions;
5 | import org.junit.jupiter.api.Test;
6 | import org.junit.jupiter.api.extension.ExtendWith;
7 | import org.mockito.Mock;
8 | import org.mockito.junit.jupiter.MockitoExtension;
9 |
10 | import java.math.BigDecimal;
11 | import java.util.Currency;
12 |
13 | import static org.mockito.Mockito.when;
14 |
15 | /**
16 | * Unit tests for the {@link Account} class.
17 | */
18 | @ExtendWith(MockitoExtension.class)
19 | class AccountTest {
20 |
21 | @Mock
22 | private Account account;
23 |
24 | /**
25 | * Test the constructors.
26 | */
27 | @Test
28 | void testAccount() {
29 | // Given
30 | String expectedId = "2742431";
31 | String expectedAccountNumber = "GR46-4391-5577-4195-4725";
32 | String expectedAccountHolderName = "Matt Damon";
33 | BigDecimal expectedBalance = new BigDecimal("211000.00");
34 | Currency expectedCurrency = Currency.getInstance("USD");
35 |
36 | // When
37 | when(account.getId()).thenReturn(expectedId);
38 | when(account.getAccountNumber()).thenReturn(expectedAccountNumber);
39 | when(account.getAccountHolderName()).thenReturn(expectedAccountHolderName);
40 | when(account.getBalance()).thenReturn(expectedBalance);
41 | when(account.getCurrency()).thenReturn(expectedCurrency);
42 |
43 | // Then
44 | Assertions.assertEquals(expectedId, account.getId());
45 | Assertions.assertEquals(expectedAccountNumber, account.getAccountNumber());
46 | Assertions.assertEquals(expectedAccountHolderName, account.getAccountHolderName());
47 | Assertions.assertEquals(expectedBalance, account.getBalance());
48 | Assertions.assertEquals(expectedCurrency, account.getCurrency());
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/asset-management-api/src/main/java/com/royal/reserve/bank/asset/management/api/model/Asset.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.asset.management.api.model;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | import jakarta.persistence.*;
9 |
10 | import java.util.Objects;
11 |
12 | /**
13 | * Represents an asset.
14 | */
15 | @Entity
16 | @Table(name = "t_asset")
17 | @Getter
18 | @Setter
19 | @AllArgsConstructor
20 | @NoArgsConstructor
21 | public class Asset {
22 |
23 | @Id
24 | @GeneratedValue(strategy = GenerationType.IDENTITY)
25 | private Long id;
26 | private String assetCode;
27 | private String assetName;
28 | private int value;
29 |
30 | /**
31 | * Overrides the equals method to provide custom comparison logic for testing purposes.
32 | *
33 | * This override ensures that the expected and actual Asset objects are considered equal
34 | * when they have the same assetCode, assetName, and value properties.
35 | *
36 | * This is necessary to resolve the error where the expected and actual Asset
37 | * objects were not considered equal due to reference inequality.
38 | *
39 | * @param obj the object to compare for equality
40 | * @return {@code true} if the objects are considered equal based on their properties, {@code false} otherwise
41 | */
42 | @Override
43 | public boolean equals(Object obj) {
44 | if (this == obj) {
45 | return true;
46 | }
47 | if (obj == null || getClass() != obj.getClass()) {
48 | return false;
49 | }
50 | Asset other = (Asset) obj;
51 | return Objects.equals(assetCode, other.assetCode) &&
52 | Objects.equals(assetName, other.assetName) &&
53 | value == other.value;
54 | }
55 |
56 | @Override
57 | public int hashCode() {
58 | return Objects.hash(assetCode, assetName, value);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/docs/javadoc/legal/jqueryUI.md:
--------------------------------------------------------------------------------
1 | ## jQuery UI v1.12.1
2 |
3 | ### jQuery UI License
4 | ```
5 | Copyright jQuery Foundation and other contributors, https://jquery.org/
6 |
7 | This software consists of voluntary contributions made by many
8 | individuals. For exact contribution history, see the revision history
9 | available at https://github.com/jquery/jquery-ui
10 |
11 | The following license applies to all parts of this software except as
12 | documented below:
13 |
14 | ====
15 |
16 | Permission is hereby granted, free of charge, to any person obtaining
17 | a copy of this software and associated documentation files (the
18 | "Software"), to deal in the Software without restriction, including
19 | without limitation the rights to use, copy, modify, merge, publish,
20 | distribute, sublicense, and/or sell copies of the Software, and to
21 | permit persons to whom the Software is furnished to do so, subject to
22 | the following conditions:
23 |
24 | The above copyright notice and this permission notice shall be
25 | included in all copies or substantial portions of the Software.
26 |
27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 |
35 | ====
36 |
37 | Copyright and related rights for sample code are waived via CC0. Sample
38 | code is defined as all source code contained within the demos directory.
39 |
40 | CC0: http://creativecommons.org/publicdomain/zero/1.0/
41 |
42 | ====
43 |
44 | All files located in the node_modules and external directories are
45 | externally maintained libraries used by this software which have their
46 | own licenses; we recommend you read them, as their terms may differ from
47 | the terms above.
48 |
49 | ```
50 |
--------------------------------------------------------------------------------
/account-api/src/main/java/com/royal/reserve/bank/account/api/serializer/CustomBigDecimalRedisSerializer.java:
--------------------------------------------------------------------------------
1 | package com.royal.reserve.bank.account.api.serializer;
2 |
3 | import org.springframework.data.redis.serializer.RedisSerializer;
4 | import org.springframework.data.redis.serializer.SerializationException;
5 |
6 | import java.math.BigDecimal;
7 | import java.nio.charset.StandardCharsets;
8 |
9 | /**
10 | * Custom serializer for BigDecimal values.
11 | */
12 | public class CustomBigDecimalRedisSerializer implements RedisSerializer