summaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryControllerTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryControllerTest.java')
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryControllerTest.java342
1 files changed, 171 insertions, 171 deletions
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryControllerTest.java
index e76ebdf12..89be75f52 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryControllerTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryControllerTest.java
@@ -57,16 +57,16 @@ import org.springframework.mock.web.MockHttpServletResponse;
* tasks.
*/
public class DictionaryControllerTest {
-
- private static Logger logger = FlexLogger.getLogger(DictionaryControllerTest.class);
- private static CommonClassDao commonClassDao;
- private String jsonString = null;
- private HttpServletRequest request = null;
- private DictionaryController controller = null;
-
- @Before
- public void setUp() throws Exception {
- logger.info("setUp: Entering");
+
+ private static Logger logger = FlexLogger.getLogger(DictionaryControllerTest.class);
+ private static CommonClassDao commonClassDao;
+ private String jsonString = null;
+ private HttpServletRequest request = null;
+ private DictionaryController controller = null;
+
+ @Before
+ public void setUp() throws Exception {
+ logger.info("setUp: Entering");
commonClassDao = Mockito.mock(CommonClassDao.class);
MicroServiceModels testData = new MicroServiceModels();
@@ -86,173 +86,173 @@ public class DictionaryControllerTest {
when(commonClassDao.getData(Attribute.class)).thenReturn(listId);
- request = mock(HttpServletRequest.class);
+ request = mock(HttpServletRequest.class);
controller = new DictionaryController(commonClassDao);
new DictionaryUtils(commonClassDao);
DictionaryUtils.setDictionaryUtils(new DictionaryUtils());
mock(DictionaryUtils.class);
logger.info("setUp: exit");
- }
-
- @Test
- public void testGetAttributeDictionaryEntityDatabyAttributeName() {
- logger.info("testGetAttributeDictionaryEntityDatabyAttributeName: Entering");
-
- MockHttpServletResponse response = new MockHttpServletResponse();
-
- controller.getAttributeDictionaryEntityDatabyAttributeName(response);
-
- try {
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("attributeDictionaryDatas"));
- logger.info("response.getContentAsString(): " + response.getContentAsString());
- } catch (UnsupportedEncodingException e) {
- fail("Exception: " + e);
- }
-
- logger.info("testGetAttributeDictionaryEntityDatabyAttributeName: exit");
- }
-
- @Test
- public void testGetAttributeDictionaryEntityData() {
- logger.info("testGetAttributeDictionaryEntityData: Entering");
-
- MockHttpServletResponse response = new MockHttpServletResponse();
-
- controller.getAttributeDictionaryEntityData(response);
-
- try {
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("attributeDictionaryDatas"));
- logger.info("response.getContentAsString(): " + response.getContentAsString());
- } catch (UnsupportedEncodingException e) {
- fail("Exception: " + e);
- }
-
- logger.info("testGetAttributeDictionaryEntityData: exit");
- }
-
- @Test
- public void testSaveAttributeDictionary() {
- logger.info("testSaveAttributeDictionary: Entering");
-
- MockHttpServletResponse response = new MockHttpServletResponse();
- request = mock(HttpServletRequest.class);
+ }
+
+ @Test
+ public void testGetAttributeDictionaryEntityDatabyAttributeName() {
+ logger.info("testGetAttributeDictionaryEntityDatabyAttributeName: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+
+ controller.getAttributeDictionaryEntityDatabyAttributeName(response);
+
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("attributeDictionaryDatas"));
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ } catch (UnsupportedEncodingException e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testGetAttributeDictionaryEntityDatabyAttributeName: exit");
+ }
+
+ @Test
+ public void testGetAttributeDictionaryEntityData() {
+ logger.info("testGetAttributeDictionaryEntityData: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+
+ controller.getAttributeDictionaryEntityData(response);
+
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("attributeDictionaryDatas"));
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ } catch (UnsupportedEncodingException e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testGetAttributeDictionaryEntityData: exit");
+ }
+
+ @Test
+ public void testSaveAttributeDictionary() {
+ logger.info("testSaveAttributeDictionary: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ request = mock(HttpServletRequest.class);
- try {
- jsonString = "{\"attributeDictionaryData\":{\"datatypeBean\":{\"shortName\":\"string\"},\"description\":\"Qwerty\",\"priority\":\"High\",\"userDataTypeValues\":[{\"$$hashKey\":\"object:641\",\"attributeValues\":\"test\",\"id\":\"choice1\"},{\"$$hashKey\":\"object:646\",\"attributeValues\":\"test\",\"id\":\"choice2\"}],\"xacmlId\":\"Qwerty\"},\"userid\":\"demo\"}";
- BufferedReader br = new BufferedReader(new StringReader(jsonString));
- when(request.getReader()).thenReturn(br);
- controller.saveAttributeDictionary(request, response);
- logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("attributeDictionaryDatas"));
-
- } catch (Exception e) {
- fail("Exception: " + e);
- }
-
- logger.info("testSaveAttributeDictionary: exit");
- }
-
- @Test
- public void testRemoveAttributeDictionary() {
- logger.info("testRemoveAttributeDictionary: Entering");
-
- MockHttpServletResponse response = new MockHttpServletResponse();
- request = mock(HttpServletRequest.class);
-
- try {
- jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"xacmlId\":\"Test\"}}";
- BufferedReader br = new BufferedReader(new StringReader(jsonString));
- when(request.getReader()).thenReturn(br);
- controller.removeAttributeDictionary(request, response);
- logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("attributeDictionaryDatas"));
-
- } catch (Exception e) {
- fail("Exception: " + e);
- }
-
- logger.info("testRemoveAttributeDictionary: exit");
- }
-
- @Test
- public void testGetOnapNameDictionaryByNameEntityData() {
- logger.info("testGetOnapNameDictionaryByNameEntityData: Entering");
-
- MockHttpServletResponse response = new MockHttpServletResponse();
-
- controller.getOnapNameDictionaryByNameEntityData(response);
-
- try {
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("onapNameDictionaryDatas"));
- logger.info("response.getContentAsString(): " + response.getContentAsString());
- } catch (UnsupportedEncodingException e) {
- fail("Exception: " + e);
- }
-
- logger.info("testGetOnapNameDictionaryByNameEntityData: exit");
- }
-
- @Test
- public void testGetOnapNameDictionaryEntityData() {
- logger.info("testGetOnapNameDictionaryEntityData: Entering");
-
- MockHttpServletResponse response = new MockHttpServletResponse();
-
- controller.getOnapNameDictionaryEntityData(response);
-
- try {
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("onapNameDictionaryDatas"));
- logger.info("response.getContentAsString(): " + response.getContentAsString());
- } catch (UnsupportedEncodingException e) {
- fail("Exception: " + e);
- }
-
- logger.info("testGetOnapNameDictionaryEntityData: exit");
- }
-
- @Test
- public void testSaveOnapDictionary() {
-
- logger.info("testSaveOnapDictionary: Entering");
-
- MockHttpServletResponse response = new MockHttpServletResponse();
- request = mock(HttpServletRequest.class);
+ try {
+ jsonString = "{\"attributeDictionaryData\":{\"datatypeBean\":{\"shortName\":\"string\"},\"description\":\"Qwerty\",\"priority\":\"High\",\"userDataTypeValues\":[{\"$$hashKey\":\"object:641\",\"attributeValues\":\"test\",\"id\":\"choice1\"},{\"$$hashKey\":\"object:646\",\"attributeValues\":\"test\",\"id\":\"choice2\"}],\"xacmlId\":\"Qwerty\"},\"userid\":\"demo\"}";
+ BufferedReader br = new BufferedReader(new StringReader(jsonString));
+ when(request.getReader()).thenReturn(br);
+ controller.saveAttributeDictionary(request, response);
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("attributeDictionaryDatas"));
+
+ } catch (Exception e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testSaveAttributeDictionary: exit");
+ }
+
+ @Test
+ public void testRemoveAttributeDictionary() {
+ logger.info("testRemoveAttributeDictionary: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ request = mock(HttpServletRequest.class);
+
+ try {
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"xacmlId\":\"Test\"}}";
+ BufferedReader br = new BufferedReader(new StringReader(jsonString));
+ when(request.getReader()).thenReturn(br);
+ controller.removeAttributeDictionary(request, response);
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("attributeDictionaryDatas"));
+
+ } catch (Exception e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testRemoveAttributeDictionary: exit");
+ }
+
+ @Test
+ public void testGetOnapNameDictionaryByNameEntityData() {
+ logger.info("testGetOnapNameDictionaryByNameEntityData: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+
+ controller.getOnapNameDictionaryByNameEntityData(response);
+
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("onapNameDictionaryDatas"));
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ } catch (UnsupportedEncodingException e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testGetOnapNameDictionaryByNameEntityData: exit");
+ }
+
+ @Test
+ public void testGetOnapNameDictionaryEntityData() {
+ logger.info("testGetOnapNameDictionaryEntityData: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+
+ controller.getOnapNameDictionaryEntityData(response);
+
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("onapNameDictionaryDatas"));
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ } catch (UnsupportedEncodingException e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testGetOnapNameDictionaryEntityData: exit");
+ }
+
+ @Test
+ public void testSaveOnapDictionary() {
+
+ logger.info("testSaveOnapDictionary: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ request = mock(HttpServletRequest.class);
- try {
- jsonString = "{\"userid\":\"demo\",\"onapNameDictionaryData\":{\"description\":\"test\",\"onapName\":\"Test\"}}";
- BufferedReader br = new BufferedReader(new StringReader(jsonString));
- when(request.getReader()).thenReturn(br);
- controller.saveOnapDictionary(request, response);
- logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("onapNameDictionaryDatas"));
-
- } catch (Exception e) {
- fail("Exception: " + e);
- }
-
- logger.info("testSaveOnapDictionary: exit");
- }
-
- @Test
- public void testRemoveOnapDictionary() {
- logger.info("testRemoveOnapDictionary: Entering");
-
- MockHttpServletResponse response = new MockHttpServletResponse();
- request = mock(HttpServletRequest.class);
-
- try {
- jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"onapName\":\"Test\"}}";
- BufferedReader br = new BufferedReader(new StringReader(jsonString));
- when(request.getReader()).thenReturn(br);
- controller.removeOnapDictionary(request, response);
- logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("onapNameDictionaryDatas"));
-
- } catch (Exception e) {
- fail("Exception: " + e);
- }
-
- logger.info("testRemoveOnapDictionary: exit");
- }
+ try {
+ jsonString = "{\"userid\":\"demo\",\"onapNameDictionaryData\":{\"description\":\"test\",\"onapName\":\"Test\"}}";
+ BufferedReader br = new BufferedReader(new StringReader(jsonString));
+ when(request.getReader()).thenReturn(br);
+ controller.saveOnapDictionary(request, response);
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("onapNameDictionaryDatas"));
+
+ } catch (Exception e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testSaveOnapDictionary: exit");
+ }
+
+ @Test
+ public void testRemoveOnapDictionary() {
+ logger.info("testRemoveOnapDictionary: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ request = mock(HttpServletRequest.class);
+
+ try {
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"onapName\":\"Test\"}}";
+ BufferedReader br = new BufferedReader(new StringReader(jsonString));
+ when(request.getReader()).thenReturn(br);
+ controller.removeOnapDictionary(request, response);
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("onapNameDictionaryDatas"));
+
+ } catch (Exception e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testRemoveOnapDictionary: exit");
+ }
}