-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from inomera/1-add-runtime-configs-interceptors
1 add runtime configs interceptors
- Loading branch information
Showing
42 changed files
with
1,702 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.0 | ||
1.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 112 additions & 8 deletions
120
.../com/inomera/adapter/config/bridge/DynamicAdapterConfigDataBridgeSupplierHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,132 @@ | ||
package com.inomera.adapter.config.bridge; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.mockito.Mockito.eq; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import com.inomera.adapter.config.bridge.exception.AdapterConfigException; | ||
import com.inomera.integration.config.model.AdapterConfig; | ||
import com.inomera.integration.config.model.AdapterProperties; | ||
import com.inomera.telco.commons.config.ConfigurationHolder; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
|
||
class DynamicAdapterConfigDataBridgeSupplierHandlerTest { | ||
|
||
@InjectMocks | ||
private DynamicAdapterConfigDataBridgeSupplierHandler handler; | ||
|
||
@Mock | ||
private ConfigurationHolder configurationHolder; | ||
|
||
private AutoCloseable autoCloseable; | ||
@BeforeEach | ||
void setUp() { | ||
autoCloseable = MockitoAnnotations.openMocks(this); | ||
} | ||
|
||
@AfterEach | ||
void destroy() throws Exception { | ||
autoCloseable.close(); | ||
} | ||
|
||
|
||
@Test | ||
void testGetConfigV1_Success() { | ||
String key = "testKey"; | ||
AdapterProperties mockAdapterProperties = new AdapterProperties(); | ||
mockAdapterProperties.setAuth(null); | ||
|
||
Map<String, Object> mockAdapterPropertiesMap = Map.of("auth", Map.of("type", "NONE")); | ||
|
||
when(configurationHolder.getJsonObjectProperty(eq(key), eq(Map.class))).thenReturn(mockAdapterPropertiesMap); | ||
when(configurationHolder.getJsonObjectProperty(eq(key), eq(AdapterProperties.class))).thenReturn(mockAdapterProperties); | ||
|
||
AdapterConfig result = handler.getConfigV1(key); | ||
|
||
assertNotNull(result); | ||
assertEquals(key, result.getKey()); | ||
assertNotNull(result.getAdapterProperties()); | ||
verify(configurationHolder, times(1)).getJsonObjectProperty(eq(key), eq(Map.class)); | ||
} | ||
|
||
@Test | ||
void getConfigV1() { | ||
void testGetConfigV1_KeyNotFound_ThrowsException() { | ||
String key = "testKey"; | ||
|
||
when(configurationHolder.getJsonObjectProperty(eq(key), eq(Map.class))).thenReturn(null); | ||
|
||
AdapterConfigException exception = assertThrows(AdapterConfigException.class, () -> handler.getConfigV1(key)); | ||
assertEquals("Adapter config for key 'testKey' is not found", exception.getCause().getMessage()); | ||
|
||
verify(configurationHolder, times(1)).getJsonObjectProperty(eq(key), eq(Map.class)); | ||
} | ||
|
||
@Test | ||
void getConfig() { | ||
void testGetConfig_StringProperty_Success() { | ||
String key = "stringKey"; | ||
String expectedValue = "testValue"; | ||
|
||
when(configurationHolder.getStringProperty(eq(key))).thenReturn(expectedValue); | ||
|
||
String result = handler.getConfig(key, String.class); | ||
|
||
assertNotNull(result); | ||
assertEquals(expectedValue, result); | ||
verify(configurationHolder, times(1)).getStringProperty(eq(key)); | ||
} | ||
|
||
@Test | ||
void testGetConfig() { | ||
void testGetConfig_JsonObject_Success() { | ||
String key = "jsonKey"; | ||
AdapterProperties expectedObject = new AdapterProperties(); | ||
|
||
when(configurationHolder.getJsonObjectProperty(eq(key), eq(AdapterProperties.class))).thenReturn(expectedObject); | ||
|
||
AdapterProperties result = handler.getConfig(key, AdapterProperties.class); | ||
|
||
assertNotNull(result); | ||
assertEquals(expectedObject, result); | ||
verify(configurationHolder, times(1)).getJsonObjectProperty(eq(key), eq(AdapterProperties.class)); | ||
} | ||
|
||
@Test | ||
void getConfigs() { | ||
void testGetConfigs_Success() { | ||
String key = "listKey"; | ||
AdapterProperties mockObject1 = new AdapterProperties(); | ||
AdapterProperties mockObject2 = new AdapterProperties(); | ||
|
||
when(configurationHolder.getJsonListProperty(eq(key), eq(AdapterProperties.class))) | ||
.thenReturn(List.of(mockObject1, mockObject2)); | ||
|
||
List<AdapterProperties> result = handler.getConfigs(key, AdapterProperties.class); | ||
|
||
assertNotNull(result); | ||
assertEquals(2, result.size()); | ||
verify(configurationHolder, times(1)).getJsonListProperty(eq(key), eq(AdapterProperties.class)); | ||
} | ||
|
||
@Test | ||
void testGetConfigs() { | ||
void testGetConfigV1_AuthExtraction_ThrowsException() { | ||
String key = "testKey"; | ||
Map<String, Object> mockAdapterPropertiesMap = Map.of(); | ||
|
||
when(configurationHolder.getJsonObjectProperty(eq(key), eq(Map.class))).thenReturn(mockAdapterPropertiesMap); | ||
|
||
AdapterConfigException exception = assertThrows(AdapterConfigException.class, () -> handler.getConfigV1(key)); | ||
assertEquals("'auth' section is missing in adapter properties", exception.getCause().getMessage()); | ||
|
||
verify(configurationHolder, times(1)).getJsonObjectProperty(eq(key), eq(Map.class)); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
.../ms-example/src/main/java/com/inomera/adapter/example/msexample/MsExampleApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
config.adapter.common.v1={"logging":{"strategy":"REQ_RES","sensitiveFields":[],"nonLoggingFields":[]},"headers":{},"http":{"requestTimeout":30000,"connectTimeout":10000,"idleConnectionsTimeout":180000,"maxConnections":10,"maxConnPerRoute":10,"poolConcurrencyPolicy":"LAX","timeToLive":60000,"skipSsl":true,"redirectsEnable":true},"auth":{"type":"NONE"}} | ||
config.adapter.mirket.v1={"auth":{"type":"NONE"},"headers":{"X-GW-TOKEN":""},"http":{"requestTimeout":30000,"connectTimeout":10000,"idleConnectionsTimeout":60000,"maxConnections":50,"maxConnPerRoute":50,"poolConcurrencyPolicy":"LAX","timeToLive":60000,"skipSsl":true,"redirectsEnable":true},"logging":{"strategy":"REQ_RES","sensitiveFields":["Authorization"],"nonLoggingFields":["file","content"]},"url":"https://api.mirket.inomera.com/"} | ||
config.adapter.country.v1={"logging":{"strategy":"ALL","sensitiveFields":[],"nonLoggingFields":[]},"headers":{},"http":{"requestTimeout":30000,"connectTimeout":10000,"idleConnectionsTimeout":180000,"maxConnections":10,"maxConnPerRoute":10,"poolConcurrencyPolicy":"LAX","timeToLive":60000,"skipSsl":true,"redirectsEnable":true},"auth":{"type":"NONE"},"url": "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso"} | ||
config.adapter.mirket.v1={"runtime": true,"auth":{"type":"NONE"},"headers":{"X-GW-TOKEN":""},"http":{"requestTimeout":30000,"connectTimeout":10000,"idleConnectionsTimeout":60000,"maxConnections":50,"maxConnPerRoute":50,"poolConcurrencyPolicy":"LAX","timeToLive":60000,"skipSsl":true,"redirectsEnable":true},"logging":{"strategy":"REQ_RES","sensitiveFields":["Authorization"],"nonLoggingFields":["file","content"]},"url":"https://api.mirket.inomera.com/"} | ||
config.adapter.country.v1={"runtime": true,"logging":{"strategy":"ALL","sensitiveFields":[],"nonLoggingFields":[]},"headers":{},"http":{"requestTimeout":30000,"connectTimeout":10000,"idleConnectionsTimeout":180000,"maxConnections":10,"maxConnPerRoute":10,"poolConcurrencyPolicy":"LAX","timeToLive":60000,"skipSsl":true,"redirectsEnable":true},"auth":{"type":"NONE"},"url": "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso"} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.