aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java5
-rw-r--r--src/main/java/org/onap/clamp/clds/exception/BadRequestException.java6
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsDictionaryServiceItCase.java47
-rw-r--r--src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java2
4 files changed, 28 insertions, 32 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java b/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java
index afef5919c..f15d33df2 100644
--- a/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java
+++ b/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java
@@ -35,7 +35,6 @@ import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.model.properties.PolicyChain;
import org.onap.clamp.clds.model.properties.PolicyItem;
import org.onap.policy.api.AttributeType;
-import org.onap.policy.api.RuleProvider;
public class GuardPolicyAttributesConstructor {
public static final String ACTOR = "actor";
@@ -79,10 +78,10 @@ public class GuardPolicyAttributesConstructor {
matchingAttributes.put(RECIPE, policyItem.getRecipe());
matchingAttributes.put(TARGETS, policyItem.getGuardTargets());
matchingAttributes.put(CLNAME, modelProp.getControlNameAndPolicyUniqueId());
- if (RuleProvider.GUARD_MIN_MAX.equals(RuleProvider.valueOf(policyItem.getGuardPolicyType()))) {
+ if ("GUARD_MIN_MAX".equals(policyItem.getGuardPolicyType())) {
matchingAttributes.put(MIN, policyItem.getMinGuard());
matchingAttributes.put(MAX, policyItem.getMaxGuard());
- } else if (RuleProvider.GUARD_YAML.equals(RuleProvider.valueOf(policyItem.getGuardPolicyType()))) {
+ } else if ("GUARD_YAML".equals(policyItem.getGuardPolicyType())) {
matchingAttributes.put(LIMIT, policyItem.getLimitGuard());
matchingAttributes.put(TIME_WINDOW, policyItem.getTimeWindowGuard());
matchingAttributes.put(TIME_UNITS, policyItem.getTimeUnitsGuard());
diff --git a/src/main/java/org/onap/clamp/clds/exception/BadRequestException.java b/src/main/java/org/onap/clamp/clds/exception/BadRequestException.java
index 14d14a44d..c6b0d5556 100644
--- a/src/main/java/org/onap/clamp/clds/exception/BadRequestException.java
+++ b/src/main/java/org/onap/clamp/clds/exception/BadRequestException.java
@@ -47,9 +47,9 @@ public class BadRequestException extends RuntimeException {
}
/**
- * This constructor can be used to create a new CldsConfigException. Use
- * this constructor only if you are creating a new exception stack, not if
- * an exception was already raised by another code.
+ * This constructor can be used to create a new CldsConfigException. Use this
+ * constructor only if you are creating a new exception stack, not if an
+ * exception was already raised by another code.
*
* @param message
* A string message detailing the problem
diff --git a/src/test/java/org/onap/clamp/clds/it/CldsDictionaryServiceItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsDictionaryServiceItCase.java
index d31d5a01e..00b6f84c2 100644
--- a/src/test/java/org/onap/clamp/clds/it/CldsDictionaryServiceItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/CldsDictionaryServiceItCase.java
@@ -62,21 +62,21 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class CldsDictionaryServiceItCase {
-
+
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDictionaryServiceItCase.class);
@Autowired
private CldsDictionaryService cldsDictionaryService;
private Authentication authentication;
private CldsDictionary cldsDictionary;
private CldsDictionaryItem cldsDictionaryItem;
- private List<GrantedAuthority> authList = new LinkedList<GrantedAuthority>();
+ private List<GrantedAuthority> authList = new LinkedList<GrantedAuthority>();
private LoggingUtils util;
-
+
/**
* Setup the variable before the tests execution.
- *
+ *
* @throws IOException
- * In case of issues when opening the files
+ * In case of issues when opening the files
*/
@Before
public void setupBefore() throws IOException {
@@ -87,7 +87,7 @@ public class CldsDictionaryServiceItCase {
authList.add(new SimpleGrantedAuthority("permission-type-filter-vf|dev|*"));
authList.add(new SimpleGrantedAuthority("permission-type-tosca|dev|read"));
authList.add(new SimpleGrantedAuthority("permission-type-tosca|dev|update"));
- authentication = new UsernamePasswordAuthenticationToken(new User("admin", "", authList), "", authList);
+ authentication = new UsernamePasswordAuthenticationToken(new User("admin", "", authList), "", authList);
SecurityContext securityContext = Mockito.mock(SecurityContext.class);
Mockito.when(securityContext.getAuthentication()).thenReturn(authentication);
@@ -97,13 +97,13 @@ public class CldsDictionaryServiceItCase {
cldsDictionaryService.setLoggingUtil(util);
cldsDictionaryService.setSecurityContext(securityContext);
-
+
cldsDictionary = new CldsDictionary();
-
+
cldsDictionary.setDictionaryName("TestDictionary");
ResponseEntity entity = cldsDictionaryService.createOrUpdateDictionary("TestDictionary", cldsDictionary);
cldsDictionary = (CldsDictionary) entity.getBody();
-
+
cldsDictionaryItem = new CldsDictionaryItem();
cldsDictionaryItem.setDictElementShortName("TestDictionaryItemShortName");
cldsDictionaryItem.setDictElementName("TestDictionaryItemName");
@@ -111,20 +111,19 @@ public class CldsDictionaryServiceItCase {
cldsDictionaryItem.setDictionaryId(cldsDictionary.getDictionaryId());
cldsDictionaryItem.setDictElementDesc("TestDictionaryItemDesc");
cldsDictionaryService.createOrUpdateDictionaryElements("TestDictionary", cldsDictionaryItem);
-
+
logger.info("Initial Clds Dictionary uploaded in DB:" + cldsDictionaryItem);
}
-
+
@Test
public void testCreateOrUpdateDictionary() throws Exception {
- ResponseEntity<CldsDictionary> responseEntity = cldsDictionaryService.createOrUpdateDictionary("TestDictionary",
- cldsDictionary);
- CldsDictionary dictionary = responseEntity.getBody();
+ ResponseEntity<CldsDictionary> responseEntity = cldsDictionaryService.createOrUpdateDictionary("TestDictionary", cldsDictionary);
+ CldsDictionary dictionary = responseEntity.getBody();
assertNotNull(dictionary);
logger.info("CLDS Dictionary is:" + dictionary);
assertEquals("TestDictionary", dictionary.getDictionaryName());
}
-
+
@Test
public void testCreateOrUpdateDictionaryElements() throws Exception {
cldsDictionaryItem = new CldsDictionaryItem();
@@ -133,28 +132,26 @@ public class CldsDictionaryServiceItCase {
cldsDictionaryItem.setDictElementType("string");
cldsDictionaryItem.setDictionaryId(cldsDictionary.getDictionaryId());
cldsDictionaryItem.setDictElementDesc("TestDictionaryItemDesc1");
-
- ResponseEntity<CldsDictionaryItem> responseEntity = cldsDictionaryService
- .createOrUpdateDictionaryElements("TestDictionary", cldsDictionaryItem);
- CldsDictionaryItem dictionaryItem = responseEntity.getBody();
+
+ ResponseEntity<CldsDictionaryItem> responseEntity = cldsDictionaryService.createOrUpdateDictionaryElements("TestDictionary", cldsDictionaryItem);
+ CldsDictionaryItem dictionaryItem = responseEntity.getBody();
assertNotNull(dictionaryItem);
logger.info("CLDS Dictionary Item is:" + dictionaryItem);
assertEquals("TestDictionaryItemName1", dictionaryItem.getDictElementName());
}
-
+
@Test
public void testGetAllDictionaryNames() throws Exception {
ResponseEntity<List<CldsDictionary>> responseEntity = cldsDictionaryService.getAllDictionaryNames();
- List<CldsDictionary> dictionaries = responseEntity.getBody();
+ List<CldsDictionary> dictionaries = responseEntity.getBody();
assertNotNull(dictionaries);
logger.info("CLDS Dictionary List is:" + dictionaries);
}
-
+
@Test
public void testGetDictionaryElementsByName() throws Exception {
- ResponseEntity<List<CldsDictionaryItem>> responseEntity = cldsDictionaryService
- .getDictionaryElementsByName("TestDictionary");
- List<CldsDictionaryItem> dictionaryItems = responseEntity.getBody();
+ ResponseEntity<List<CldsDictionaryItem>> responseEntity = cldsDictionaryService.getDictionaryElementsByName("TestDictionary");
+ List<CldsDictionaryItem> dictionaryItems = responseEntity.getBody();
assertNotNull(dictionaryItems);
logger.info("CLDS Dictionary Item LIst is:" + dictionaryItems);
}
diff --git a/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java b/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java
index 37eb6aed3..9d58ba8f0 100644
--- a/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java
@@ -102,7 +102,7 @@ public class CldsReferencePropertiesItCase {
public void testGetStringList() {
List<String> profileList = refProp.getStringList("policy.pdpUrl1", ",");
assertTrue(profileList.size() == 3);
- assertTrue(profileList.get(0).trim().equals("http://localhost:8085/pdp/"));
+ assertTrue(profileList.get(0).trim().startsWith("http://localhost:"));
assertTrue(profileList.get(1).trim().equals("testpdp"));
assertTrue(profileList.get(2).trim().equals("alpha123"));
}