-public class DashboardControllerTest{
- private static Logger logger = FlexLogger.getLogger(DashboardControllerTest.class);
-
- private static CommonClassDao commonClassDao;
- private static SystemLogDbDao systemDAO;
- private static PolicyController ctrl = null;
- private HttpServletRequest request = null;
- private DashboardController controller = null;
- private MockHttpServletResponse response = null;
- private Path repo;
- StdEngine engine = null;
-
- @Before
- public void setUp() throws Exception {
- logger.info("setUp: Entering");
- controller = new DashboardController();
- commonClassDao = Mockito.mock(CommonClassDao.class);
- systemDAO = Mockito.mock(SystemLogDbDao.class);
- controller.setSystemLogDbDao(systemDAO);
- controller.setCommonClassDao(commonClassDao);
- request = mock(HttpServletRequest.class);
- response = new MockHttpServletResponse();
- repo = Paths.get("src/test/resources/pdps");
- engine = new StdEngine(repo);
- ctrl = new PolicyController();
- PolicyController.setPapEngine(engine);
- controller.setPolicyController(ctrl);
- logger.info("setUp: exit");
- }
-
- @Test
- public void testGetData() {
- try {
- controller.getData(request, response);
- assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("availableLoggingDatas"));
- } catch (UnsupportedEncodingException e) {
- logger.error("Exception Occured"+e);
- fail();
- }
- }