Commit f0084040 authored by jashaikh's avatar jashaikh

Added Jacoco Code Coverage For Sonar.

parent f42a7cb8
...@@ -47,6 +47,8 @@ public class AzureAppConfigService { ...@@ -47,6 +47,8 @@ public class AzureAppConfigService {
public String writeValueByKey(String key, String value) { public String writeValueByKey(String key, String value) {
try { try {
LOGGER.info("Writing Single Value by key"); LOGGER.info("Writing Single Value by key");
if(key == null || value == null)
throw new Exception("Key and Value cannot be null");
ConfigurationSetting configurationSetting = configurationClient.setConfigurationSetting(key, null, value); ConfigurationSetting configurationSetting = configurationClient.setConfigurationSetting(key, null, value);
return configurationSetting.getValue(); return configurationSetting.getValue();
} catch (Exception e) { } catch (Exception e) {
...@@ -61,12 +63,7 @@ public class AzureAppConfigService { ...@@ -61,12 +63,7 @@ public class AzureAppConfigService {
*/ */
public PagedIterable<ConfigurationSetting> readAllKeyValue() { public PagedIterable<ConfigurationSetting> readAllKeyValue() {
LOGGER.info("Read All Values..."); LOGGER.info("Read All Values...");
try { return configurationClient.listConfigurationSettings(settingSelector);
return configurationClient.listConfigurationSettings(settingSelector);
} catch (Exception e) {
LOGGER.error(e.getMessage());
return null;
}
} }
/** /**
......
...@@ -11,8 +11,7 @@ import org.junit.jupiter.api.TestMethodOrder; ...@@ -11,8 +11,7 @@ import org.junit.jupiter.api.TestMethodOrder;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@TestMethodOrder(OrderAnnotation.class) @TestMethodOrder(OrderAnnotation.class)
class AzureAppConfigServiceTest { class AzureAppConfigServiceTest {
...@@ -40,6 +39,12 @@ class AzureAppConfigServiceTest { ...@@ -40,6 +39,12 @@ class AzureAppConfigServiceTest {
assertEquals(EXISTING_VALUE, valueByKey); assertEquals(EXISTING_VALUE, valueByKey);
} }
@Test
@Order(5)
void getValueByKeyException() {
assertNull(azureAppConfigService.getValueByKey(null));
}
@Test @Test
@Order(2) @Order(2)
void writeValueByKey() { void writeValueByKey() {
...@@ -49,6 +54,12 @@ class AzureAppConfigServiceTest { ...@@ -49,6 +54,12 @@ class AzureAppConfigServiceTest {
assertEquals(NEW_VALUE, writeValueByKey); assertEquals(NEW_VALUE, writeValueByKey);
} }
@Test
@Order(6)
void writeValueByKeyException() {
assertNull(azureAppConfigService.writeValueByKey(null, null));
}
@Test @Test
@Order(4) @Order(4)
void readAllKeyValue() { void readAllKeyValue() {
...@@ -64,4 +75,10 @@ class AzureAppConfigServiceTest { ...@@ -64,4 +75,10 @@ class AzureAppConfigServiceTest {
assertNotNull(valueByKey); assertNotNull(valueByKey);
assertEquals(NEW_VALUE, valueByKey); assertEquals(NEW_VALUE, valueByKey);
} }
@Test
@Order(7)
void deleteValueByKeyException() {
assertNull(azureAppConfigService.deleteValueByKey(null));
}
} }
\ 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