- }
-
- @Test
- public void testGetAdminRole(){
- AdminTabController admin = new AdminTabController();
- try {
- admin.getAdminTabEntityData(request, response);
- assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("lockdowndata"));
- } catch (UnsupportedEncodingException e) {
- logger.error("Exception Occured"+e);
- fail();
- }
- }
-
- @Test
- public void testSaveAdminRole() throws Exception{
- AdminTabController admin = new AdminTabController();
- String data = "{\"lockdowndata\":{\"lockdown\":true}}";
- BufferedReader reader = new BufferedReader(new StringReader(data));
- try {
- when(request.getReader()).thenReturn(reader);
- admin.saveAdminTabLockdownValue(request, response);
- assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("descriptiveScopeDictionaryDatas"));
- } catch (UnsupportedEncodingException e) {
- logger.error("Exception Occured"+e);
- fail();
- }
- }
-
+ }
+
+ @Test
+ public void testGetAdminRole() {
+ assertNotNull(AdminTabController.getCommonClassDao());
+ try {
+ admin.getAdminTabEntityData(request, response);
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("lockdowndata"));
+ } catch (UnsupportedEncodingException e) {
+ logger.error("Exception Occured" + e);
+ fail();
+ }
+ }
+
+ @Test
+ public void testSaveAdminRole() throws Exception {
+ String data = "{\"lockdowndata\":{\"lockdown\":true}}";
+ BufferedReader reader = new BufferedReader(new StringReader(data));
+ try {
+ when(request.getReader()).thenReturn(reader);
+ admin.saveAdminTabLockdownValue(request, response);
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("descriptiveScopeDictionaryDatas"));
+ } catch (UnsupportedEncodingException e) {
+ logger.error("Exception Occured" + e);
+ fail();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testGetAdminTabEntityDataException() throws IOException {
+ HttpServletResponse mockResponse = Mockito.mock(HttpServletResponse.class);
+ when(mockResponse.getWriter()).thenThrow(IOException.class);
+ admin.getAdminTabEntityData(request, mockResponse);
+ verify(mockResponse).getWriter();
+ }
+
+ @Test
+ public void testSaveAdminTabLockdownValueException() throws IOException {
+ assertNull(admin.saveAdminTabLockdownValue(request, response));
+ }