Commit cb33214c authored by Jalaluddin Shaikh's avatar Jalaluddin Shaikh

Added JUnit Test Cases.

parent 6a8de120
...@@ -14,29 +14,34 @@ import static org.junit.Assert.assertNotNull; ...@@ -14,29 +14,34 @@ import static org.junit.Assert.assertNotNull;
public class AzureAppConfigServiceTest { public class AzureAppConfigServiceTest {
private static final Logger LOGGER = LoggerFactory.getLogger(AzureAppConfigServiceTest.class); private static final Logger LOGGER = LoggerFactory.getLogger(AzureAppConfigServiceTest.class);
AzureAppConfigService azureAppConfigService; private static final String APP_CONFIGURATION_CONNECTION_STRING = "APP_CONFIGURATION_CONNECTION_STRING";
private static final String EXISTING_KEY = "config.message";
private static final String EXISTING_VALUE = "This is Azure App Config";
private static final String NEW_KEY = "config.dataSource";
private static final String NEW_VALUE = "Data Source URL";
private AzureAppConfigService azureAppConfigService;
@Before @Before
public void setUp() { public void setUp() {
String app_configuration_connection_string = System.getenv("APP_CONFIGURATION_CONNECTION_STRING"); String app_configuration_connection_string = System.getenv(APP_CONFIGURATION_CONNECTION_STRING);
ConfigurationClient configurationClient = new ConfigurationClientBuilder().connectionString(app_configuration_connection_string).buildClient(); ConfigurationClient configurationClient = new ConfigurationClientBuilder().connectionString(app_configuration_connection_string).buildClient();
azureAppConfigService = new AzureAppConfigService(configurationClient, new SettingSelector()); azureAppConfigService = new AzureAppConfigService(configurationClient, new SettingSelector());
} }
@Test @Test
public void getValueByKey() { public void getValueByKey() {
String valueByKey = azureAppConfigService.getValueByKey("config.message"); String valueByKey = azureAppConfigService.getValueByKey(EXISTING_KEY);
LOGGER.info(valueByKey); LOGGER.info(valueByKey);
assertNotNull(valueByKey); assertNotNull(valueByKey);
assertEquals("This is Azure App Config", valueByKey); assertEquals(EXISTING_VALUE, valueByKey);
} }
@Test @Test
public void writeValueByKey() { public void writeValueByKey() {
String writeValueByKey = azureAppConfigService.writeValueByKey("config.dataSource", "Data Source URL"); String writeValueByKey = azureAppConfigService.writeValueByKey(NEW_KEY, NEW_VALUE);
LOGGER.info(writeValueByKey); LOGGER.info(writeValueByKey);
assertNotNull(writeValueByKey); assertNotNull(writeValueByKey);
assertEquals("Data Source URL", writeValueByKey); assertEquals(NEW_VALUE, writeValueByKey);
} }
@Test @Test
...@@ -47,13 +52,9 @@ public class AzureAppConfigServiceTest { ...@@ -47,13 +52,9 @@ public class AzureAppConfigServiceTest {
@Test @Test
public void deleteValueByKey() { public void deleteValueByKey() {
String valueByKey = azureAppConfigService.deleteValueByKey("config.dataSource"); String valueByKey = azureAppConfigService.deleteValueByKey(NEW_KEY);
LOGGER.info(valueByKey); LOGGER.info(valueByKey);
assertNotNull(valueByKey); assertNotNull(valueByKey);
assertEquals("Data Source URL", valueByKey); assertEquals(NEW_VALUE, valueByKey);
}
@Test
public void azureAppConfiguration() {
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment