aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/onap/clamp/clds/exception/NotAuthorizedException.java40
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsDictionaryServiceItCase.java47
2 files changed, 45 insertions, 42 deletions
diff --git a/src/main/java/org/onap/clamp/clds/exception/NotAuthorizedException.java b/src/main/java/org/onap/clamp/clds/exception/NotAuthorizedException.java
index 0cf5c8dde..4ea050392 100644
--- a/src/main/java/org/onap/clamp/clds/exception/NotAuthorizedException.java
+++ b/src/main/java/org/onap/clamp/clds/exception/NotAuthorizedException.java
@@ -5,20 +5,20 @@
* Copyright (C) 2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.exception;
@@ -30,29 +30,29 @@ package org.onap.clamp.clds.exception;
public class NotAuthorizedException extends RuntimeException {
/**
- *
- */
- private static final long serialVersionUID = -5738167530541646123L;
+ *
+ */
+ private static final long serialVersionUID = -5738167530541646123L;
- /**
+ /**
* This constructor can be used to create a new CldsConfigException.
- *
+ *
* @param message
- * A string message detailing the problem
+ * A string message detailing the problem
* @param e
- * The exception sent by the code
+ * The exception sent by the code
*/
public NotAuthorizedException(String message, Throwable e) {
super(message, e);
}
/**
- * 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
+ * A string message detailing the problem
*/
public NotAuthorizedException(String message) {
super(message);
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 00b6f84c2..d31d5a01e 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,19 +111,20 @@ 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();
@@ -132,26 +133,28 @@ 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);
}