Added Junits for ONAP-PAP-REST
[policy/engine.git] / ONAP-PAP-REST / src / test / java / org / onap / policy / pap / xacml / rest / controller / ClosedLoopDictionaryControllerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-PAP-REST
4  * ================================================================================
5  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.policy.pap.xacml.rest.controller;
21
22 import static org.junit.Assert.assertTrue;
23 import static org.junit.Assert.fail;
24 import static org.mockito.Mockito.doNothing;
25 import static org.mockito.Mockito.when;
26
27 import java.io.BufferedReader;
28 import java.io.StringReader;
29 import java.util.ArrayList;
30 import java.util.Date;
31 import java.util.List;
32
33 import javax.servlet.http.HttpServletRequest;
34
35 import org.junit.Before;
36 import org.junit.Test;
37 import org.mockito.Mockito;
38 import org.onap.policy.common.logging.flexlogger.FlexLogger;
39 import org.onap.policy.common.logging.flexlogger.Logger;
40 import org.onap.policy.rest.dao.CommonClassDao;
41 import org.onap.policy.rest.jpa.ClosedLoopD2Services;
42 import org.onap.policy.rest.jpa.ClosedLoopSite;
43 import org.onap.policy.rest.jpa.PEPOptions;
44 import org.onap.policy.rest.jpa.UserInfo;
45 import org.onap.policy.rest.jpa.VNFType;
46 import org.onap.policy.rest.jpa.VSCLAction;
47 import org.onap.policy.rest.jpa.VarbindDictionary;
48 import org.springframework.mock.web.MockHttpServletResponse;
49
50 public class ClosedLoopDictionaryControllerTest {
51         
52         private static Logger logger = FlexLogger.getLogger(ClosedLoopDictionaryControllerTest.class);
53         private static CommonClassDao commonClassDao;
54         private String jsonString = null;
55         private HttpServletRequest request = null;
56         private ClosedLoopDictionaryController controller = null;
57         private MockHttpServletResponse response = null;
58         private UserInfo userInfo;
59         private List<String>  data;
60
61         @Before
62         public void setUp() throws Exception {
63                 logger.info("setUp: Entering");
64                 commonClassDao = Mockito.mock(CommonClassDao.class);
65                 
66                 data = new ArrayList<>();
67                 data.add("Test");
68                 
69                 userInfo = new UserInfo();
70                 userInfo.setUserLoginId("Test");
71                 userInfo.setUserName("Test");
72         
73                 doNothing().when(commonClassDao).delete(new VSCLAction());
74                 doNothing().when(commonClassDao).save(new VSCLAction());
75                 
76                 controller = new ClosedLoopDictionaryController();
77                 controller.setCommonClassDao(commonClassDao);
78                 
79                 request = Mockito.mock(HttpServletRequest.class);
80                 response =  new MockHttpServletResponse();  
81                 logger.info("setUp: exit");
82         }
83         
84         public List<Object> testVSCLAction(){
85                 List<Object>  objectData = new ArrayList<>();
86                 
87                 VSCLAction data = new VSCLAction();
88                 data.setId(1);
89                 assertTrue(1 == data.getId());
90                 data.setVsclaction("Test");
91                 assertTrue("Test".equals(data.getVsclaction()));
92                 data.setDescription("Test");
93                 assertTrue("Test".equals(data.getDescription()));
94                 data.setCreatedDate(new Date());
95                 assertTrue(data.getCreatedDate()!= null);
96                 data.setModifiedDate(new Date());
97                 assertTrue(data.getModifiedDate()!= null);
98                 data.setUserCreatedBy(userInfo);
99                 assertTrue(data.getUserCreatedBy()!= null);
100                 data.setUserModifiedBy(userInfo);
101                 assertTrue(data.getUserModifiedBy()!= null);
102                 objectData.add(data);
103                 
104                 return objectData;
105         }
106         
107         public List<Object> testVNFType(){
108                 List<Object>  objectData = new ArrayList<>();
109                 
110                 VNFType data = new VNFType();
111                 data.setId(1);
112                 assertTrue(1 == data.getId());
113                 data.setVnftype("Test");
114                 assertTrue("Test".equals(data.getVnftype()));
115                 data.setDescription("Test");
116                 assertTrue("Test".equals(data.getDescription()));
117                 data.setCreatedDate(new Date());
118                 assertTrue(data.getCreatedDate()!= null);
119                 data.setModifiedDate(new Date());
120                 assertTrue(data.getModifiedDate()!= null);
121                 data.setUserCreatedBy(userInfo);
122                 assertTrue(data.getUserCreatedBy()!= null);
123                 data.setUserModifiedBy(userInfo);
124                 assertTrue(data.getUserModifiedBy()!= null);
125                 objectData.add(data);
126                 
127                 return objectData;
128         }
129         
130         public List<Object> testPEPOptions(){
131                 List<Object>  objectData = new ArrayList<>();
132
133                 PEPOptions data = new PEPOptions();
134                 data.setId(1);
135                 assertTrue(1 == data.getId());
136                 data.setPepName("Test");
137                 assertTrue("Test".equals(data.getPepName()));
138                 data.setDescription("Test");
139                 assertTrue("Test".equals(data.getDescription()));
140                 data.setCreatedDate(new Date());
141                 assertTrue(data.getCreatedDate()!= null);
142                 data.setModifiedDate(new Date());
143                 assertTrue(data.getModifiedDate()!= null);
144                 data.setUserCreatedBy(userInfo);
145                 assertTrue(data.getUserCreatedBy()!= null);
146                 data.setUserModifiedBy(userInfo);
147                 assertTrue(data.getUserModifiedBy()!= null);
148                 objectData.add(data);
149
150                 return objectData;
151         }
152         
153         public List<Object> testVarbindDictionary(){
154                 List<Object>  objectData = new ArrayList<>();
155
156                 VarbindDictionary data = new VarbindDictionary();
157                 data.setId(1);
158                 assertTrue(1 == data.getId());
159                 data.setVarbindName("Test");
160                 assertTrue("Test".equals(data.getVarbindName()));
161                 data.setVarbindDescription("Test");
162                 assertTrue("Test".equals(data.getVarbindDescription()));
163                 data.setVarbindOID("Test");
164                 assertTrue("Test".equals(data.getVarbindOID()));
165                 data.setCreatedDate(new Date());
166                 assertTrue(data.getCreatedDate()!= null);
167                 data.setModifiedDate(new Date());
168                 assertTrue(data.getModifiedDate()!= null);
169                 data.setUserCreatedBy(userInfo);
170                 assertTrue(data.getUserCreatedBy()!= null);
171                 data.setUserModifiedBy(userInfo);
172                 assertTrue(data.getUserModifiedBy()!= null);
173                 objectData.add(data);
174
175                 return objectData;
176         }
177         
178         public List<Object> testClosedLoopD2Services(){
179                 List<Object>  objectData = new ArrayList<>();
180
181                 ClosedLoopD2Services data = new ClosedLoopD2Services();
182                 data.setId(1);
183                 assertTrue(1 == data.getId());
184                 data.setServiceName("Test");
185                 assertTrue("Test".equals(data.getServiceName()));
186                 data.setDescription("Test");
187                 assertTrue("Test".equals(data.getDescription()));
188                 data.setCreatedDate(new Date());
189                 assertTrue(data.getCreatedDate()!= null);
190                 data.setModifiedDate(new Date());
191                 assertTrue(data.getModifiedDate()!= null);
192                 data.setUserCreatedBy(userInfo);
193                 assertTrue(data.getUserCreatedBy()!= null);
194                 data.setUserModifiedBy(userInfo);
195                 assertTrue(data.getUserModifiedBy()!= null);
196                 objectData.add(data);
197
198                 return objectData;
199         }
200         
201         
202         public List<Object> testClosedLoopSite(){
203                 List<Object>  objectData = new ArrayList<>();
204
205                 ClosedLoopSite data = new ClosedLoopSite();
206                 data.setId(1);
207                 assertTrue(1 == data.getId());
208                 data.setSiteName("Test");
209                 assertTrue("Test".equals(data.getSiteName()));
210                 data.setDescription("Test");
211                 assertTrue("Test".equals(data.getDescription()));
212                 data.setCreatedDate(new Date());
213                 assertTrue(data.getCreatedDate()!= null);
214                 data.setModifiedDate(new Date());
215                 assertTrue(data.getModifiedDate()!= null);
216                 data.setUserCreatedBy(userInfo);
217                 assertTrue(data.getUserCreatedBy()!= null);
218                 data.setUserModifiedBy(userInfo);
219                 assertTrue(data.getUserModifiedBy()!= null);
220                 objectData.add(data);
221
222                 return objectData;
223         }
224         
225         @Test
226         public void testGetVSCLActionDictionaryByNameEntityData(){
227                 when(commonClassDao.getDataByColumn(VSCLAction.class, "vsclaction")).thenReturn(data);
228                 controller.getVSCLActionDictionaryByNameEntityData(response);
229                 try {
230                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vsclActionDictionaryDatas"));
231                 } catch (Exception e) {
232                         fail();
233                         logger.error(e.getMessage(),e);
234                 }
235         }
236         
237         @Test
238         public void testGetVSCLActionDictionaryEntityData(){
239                 when(commonClassDao.getData(VSCLAction.class)).thenReturn(testVSCLAction());
240                 controller.getVSCLActionDictionaryEntityData(response);
241                 try {
242                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vsclActionDictionaryDatas"));
243                 } catch (Exception e) {
244                         fail();
245                         logger.error(e.getMessage(),e);
246                 }
247         }
248         
249         @Test
250         public void testGetVNFTypeDictionaryByNameEntityData(){
251                 when(commonClassDao.getDataByColumn(VNFType.class, "vnftype")).thenReturn(data);
252                 controller.getVNFTypeDictionaryByNameEntityData(response);
253                 try {
254                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vnfTypeDictionaryDatas"));
255                 } catch (Exception e) {
256                         fail();
257                         logger.error(e.getMessage(),e);
258                 }
259         }
260         
261         @Test
262         public void testGetVNFTypeDictionaryEntityData(){
263                 when(commonClassDao.getData(VNFType.class)).thenReturn(testVNFType());
264                 controller.getVNFTypeDictionaryEntityData(response);
265                 try {
266                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vnfTypeDictionaryDatas"));
267                 } catch (Exception e) {
268                         fail();
269                         logger.error(e.getMessage(),e);
270                 }
271         }
272         
273         @Test
274         public void testGetPEPOptionsDictionaryByNameEntityData(){
275                 when(commonClassDao.getDataByColumn(PEPOptions.class, "pepName")).thenReturn(data);
276                 controller.getPEPOptionsDictionaryByNameEntityData(response);
277                 try {
278                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("pepOptionsDictionaryDatas"));
279                 } catch (Exception e) {
280                         fail();
281                         logger.error(e.getMessage(),e);
282                 }
283         }
284         
285         @Test
286         public void testGetPEPOptionsDictionaryEntityData(){
287                 when(commonClassDao.getData(PEPOptions.class)).thenReturn(testPEPOptions());
288                 controller.getPEPOptionsDictionaryEntityData(response);
289                 try {
290                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("pepOptionsDictionaryDatas"));
291                 } catch (Exception e) {
292                         fail();
293                         logger.error(e.getMessage(),e);
294                 }
295         }
296         
297         @Test
298         public void testGetVarbindDictionaryByNameEntityData(){
299                 when(commonClassDao.getDataByColumn(VarbindDictionary.class, "varbindName")).thenReturn(data);
300                 controller.getVarbindDictionaryByNameEntityData(response);
301                 try {
302                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("varbindDictionaryDatas"));
303                 } catch (Exception e) {
304                         fail();
305                         logger.error(e.getMessage(),e);
306                 }
307         }
308         
309         @Test
310         public void testGetVarbindDictionaryEntityData(){
311                 when(commonClassDao.getData(VarbindDictionary.class)).thenReturn(testVarbindDictionary());
312                 controller.getVarbindDictionaryEntityData(response);
313                 try {
314                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("varbindDictionaryDatas"));
315                 } catch (Exception e) {
316                         fail();
317                         logger.error(e.getMessage(),e);
318                 }
319         }
320         
321         @Test
322         public void testGetClosedLoopServiceDictionaryByNameEntityData(){
323                 when(commonClassDao.getDataByColumn(ClosedLoopD2Services.class, "serviceName")).thenReturn(data);
324                 controller.getClosedLoopServiceDictionaryByNameEntityData(response);
325                 try {
326                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopServiceDictionaryDatas"));
327                 } catch (Exception e) {
328                         fail();
329                         logger.error(e.getMessage(),e);
330                 }
331         }
332         
333         @Test
334         public void testGetClosedLoopServiceDictionaryEntityData(){
335                 when(commonClassDao.getData(ClosedLoopD2Services.class)).thenReturn(testClosedLoopD2Services());
336                 controller.getClosedLoopServiceDictionaryEntityData(response);
337                 try {
338                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopServiceDictionaryDatas"));
339                 } catch (Exception e) {
340                         fail();
341                         logger.error(e.getMessage(),e);
342                 }
343         }
344         
345         @Test
346         public void testGetClosedLoopSiteDictionaryByNameEntityData(){
347                 when(commonClassDao.getDataByColumn(ClosedLoopSite.class, "siteName")).thenReturn(data);
348                 controller.getClosedLoopSiteDictionaryByNameEntityData(response);
349                 try {
350                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopSiteDictionaryDatas"));
351                 } catch (Exception e) {
352                         fail();
353                         logger.error(e.getMessage(),e);
354                 }
355         }
356         
357         @Test
358         public void testGetClosedLoopSiteDictionaryEntityData(){
359                 when(commonClassDao.getData(ClosedLoopSite.class)).thenReturn(testClosedLoopSite());
360                 controller.getClosedLoopSiteDictionaryEntityData(response);
361                 try {
362                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopSiteDictionaryDatas"));
363                 } catch (Exception e) {
364                         fail();
365                         logger.error(e.getMessage(),e);
366                 }
367         }
368         
369         @Test
370         public void testSaveVSCLAction(){
371                 jsonString = "{\"userid\":\"demo\",\"vsclActionDictionaryData\":{\"description\":\"test\",\"vsclaction\":\"Test\"}}";
372                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
373                         when(request.getReader()).thenReturn(br);
374                         controller.saveVSCLAction(request, response);
375                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vsclActionDictionaryDatas"));
376                 }catch(Exception e){
377                         logger.error("Exception"+ e);
378                 } 
379         }
380         
381         @Test
382         public void testUpdateVSCLAction(){
383                 jsonString = "{\"userid\":\"demo\",\"vsclActionDictionaryData\":{\"id\":1,\"description\":\"test\",\"vsclaction\":\"Test\"}}";
384                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
385                         when(request.getReader()).thenReturn(br);
386                         controller.saveVSCLAction(request, response);
387                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vsclActionDictionaryDatas"));
388                 }catch(Exception e){
389                         logger.error("Exception"+ e);
390                 } 
391         }
392         
393         @Test
394         public void testRemoveVSCLAction(){
395                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"vsclaction\":\"Test\"}}";
396                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
397                         when(request.getReader()).thenReturn(br);
398                         controller.removeVSCLAction(request, response);
399                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vsclActionDictionaryDatas"));
400                 }catch(Exception e){
401                         logger.error("Exception"+ e);
402                 } 
403         }
404         
405         @Test
406         public void testSaveVnfType(){
407                 jsonString = "{\"userid\":\"demo\",\"vnfTypeDictionaryData\":{\"description\":\"test\",\"vnftype\":\"Test\"}}";
408                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
409                         when(request.getReader()).thenReturn(br);
410                         controller.saveVnfType(request, response);
411                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vnfTypeDictionaryData"));
412                 }catch(Exception e){
413                         logger.error("Exception"+ e);
414                 } 
415         }
416         
417         @Test
418         public void testUpdateVnfType(){
419                 jsonString = "{\"userid\":\"demo\",\"vnfTypeDictionaryData\":{\"id\":1,\"description\":\"test\",\"vnftype\":\"Test\"}}";
420                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
421                         when(request.getReader()).thenReturn(br);
422                         controller.saveVnfType(request, response);
423                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vnfTypeDictionaryData"));
424                 }catch(Exception e){
425                         logger.error("Exception"+ e);
426                 } 
427         }
428         
429         @Test
430         public void testRemoveVnfType(){
431                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"vnftype\":\"Test\"}}";
432                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
433                         when(request.getReader()).thenReturn(br);
434                         controller.removeVnfType(request, response);
435                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vnfTypeDictionaryData"));
436                 }catch(Exception e){
437                         logger.error("Exception"+ e);
438                 } 
439         }
440         
441         @Test
442         public void testSavePEPOptions(){
443                 jsonString = "{\"pepOptionsDictionaryData\":{\"attributes\":[{\"$$hashKey\":\"object:257\",\"id\":\"choice1\",\"number\":\"12\",\"option\":\"test\"}],\"description\":\"test\",\"pepName\":\"Test\"},\"userid\":\"demo\"}";
444                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
445                         when(request.getReader()).thenReturn(br);
446                         controller.savePEPOptions(request, response);
447                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("pepOptionsDictionaryDatas"));
448                 }catch(Exception e){
449                         logger.error("Exception"+ e);
450                 } 
451         }
452         
453         @Test
454         public void testUpdatePEPOptions(){
455                 jsonString = "{\"pepOptionsDictionaryData\":{\"attributes\":[{\"$$hashKey\":\"object:257\",\"id\":\"choice1\",\"number\":\"12\",\"option\":\"test\"}],\"description\":\"test\",\"pepName\":\"Test\",\"id\":1},\"userid\":\"demo\"}";
456                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
457                         when(request.getReader()).thenReturn(br);
458                         controller.savePEPOptions(request, response);
459                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("pepOptionsDictionaryDatas"));
460                 }catch(Exception e){
461                         logger.error("Exception"+ e);
462                 } 
463         }
464         
465         @Test
466         public void testRemovePEPOptions(){
467                 jsonString = "{\"data\":{\"attributes\":[{\"$$hashKey\":\"object:257\",\"id\":\"choice1\",\"number\":\"12\",\"option\":\"test\"}],\"description\":\"test\",\"pepName\":\"Test\"},\"userid\":\"demo\"}";
468                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
469                         when(request.getReader()).thenReturn(br);
470                         controller.removePEPOptions(request, response);
471                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("pepOptionsDictionaryDatas"));
472                 }catch(Exception e){
473                         logger.error("Exception"+ e);
474                 } 
475         }
476         
477         @Test
478         public void testSaveServiceType(){
479                 jsonString = "{\"userid\":\"demo\",\"closedLoopServiceDictionaryData\":{\"description\":\"test\",\"serviceName\":\"Test\",\"id\":1}}";
480                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
481                         when(request.getReader()).thenReturn(br);
482                         controller.saveServiceType(request, response);
483                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopServiceDictionaryData"));
484                 }catch(Exception e){
485                         logger.error("Exception"+ e);
486                 } 
487         }
488         
489         @Test
490         public void testUpdateServiceType(){
491                 jsonString = "{\"userid\":\"demo\",\"closedLoopServiceDictionaryData\":{\"id\":1,\"description\":\"test\",\"serviceName\":\"Test\"}}";
492                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
493                         when(request.getReader()).thenReturn(br);
494                         controller.saveServiceType(request, response);
495                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopServiceDictionaryData"));
496                 }catch(Exception e){
497                         logger.error("Exception"+ e);
498                 } 
499         }
500         
501         @Test
502         public void testRemoveServiceType(){
503                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"serviceName\":\"Test\"}}";
504                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
505                         when(request.getReader()).thenReturn(br);
506                         controller.removeServiceType(request, response);
507                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopServiceDictionaryData"));
508                 }catch(Exception e){
509                         logger.error("Exception"+ e);
510                 } 
511         }
512         
513         @Test
514         public void testSaveSiteType(){
515                 jsonString = "{\"userid\":\"demo\",\"closedLoopSiteDictionaryData\":{\"description\":\"test\",\"siteName\":\"Test\"}}";
516                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
517                         when(request.getReader()).thenReturn(br);
518                         controller.saveSiteType(request, response);
519                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopSiteDictionaryDatas"));
520                 }catch(Exception e){
521                         logger.error("Exception"+ e);
522                 } 
523         }
524         
525         @Test
526         public void testUpdateSiteType(){
527                 jsonString = "{\"userid\":\"demo\",\"closedLoopSiteDictionaryData\":{\"id\":1,\"description\":\"test\",\"siteName\":\"Test\"}}";
528                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
529                         when(request.getReader()).thenReturn(br);
530                         controller.saveSiteType(request, response);
531                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopSiteDictionaryDatas"));
532                 }catch(Exception e){
533                         logger.error("Exception"+ e);
534                 } 
535         }
536         
537         @Test
538         public void testRemoveSiteType(){
539                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"siteName\":\"Test\"}}";
540                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
541                         when(request.getReader()).thenReturn(br);
542                         controller.removeSiteType(request, response);
543                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopSiteDictionaryDatas"));
544                 }catch(Exception e){
545                         logger.error("Exception"+ e);
546                 } 
547         }
548         
549         @Test
550         public void testSaveVarbind(){
551                 jsonString = "{\"userid\":\"demo\",\"varbindDictionaryData\":{\"description\":\"test\",\"varbindName\":\"Test\"}}";
552                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
553                         when(request.getReader()).thenReturn(br);
554                         controller.saveVarbind(request, response);
555                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("varbindDictionaryDatas"));
556                 }catch(Exception e){
557                         logger.error("Exception"+ e);
558                 } 
559         }
560         
561         @Test
562         public void testUpdateVarbind(){
563                 jsonString = "{\"userid\":\"demo\",\"varbindDictionaryData\":{\"id\":1,\"description\":\"test\",\"varbindName\":\"Test\"}}";
564                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
565                         when(request.getReader()).thenReturn(br);
566                         controller.saveVarbind(request, response);
567                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("varbindDictionaryDatas"));
568                 }catch(Exception e){
569                         logger.error("Exception"+ e);
570                 } 
571         }
572         
573         @Test
574         public void testRemoveVarbind(){
575                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"varbindName\":\"Test\"}}";
576                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
577                         when(request.getReader()).thenReturn(br);
578                         controller.removeVarbind(request, response);
579                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("varbindDictionaryDatas"));
580                 }catch(Exception e){
581                         logger.error("Exception"+ e);
582                 } 
583         }
584 }