@Test @SuppressWarnings({"rawtypes", "unchecked"}) public void testGetActionsByClassIfHasValidSize() { Class clazz = UserController.class; List<ControllerMapping> mappings = classScanner.getActionsByClass(clazz, "user"); assertEquals(7, mappings.size()); }
@Test @SuppressWarnings({"rawtypes", "unchecked"}) public void testGetActionsByClassIfIsNotNull() { Class clazz = UserController.class; List<ControllerMapping> mappings = classScanner.getActionsByClass(clazz, "user"); assertNotNull(mappings); }
@Test @SuppressWarnings({"rawtypes", "unchecked"}) public void testGetActionsByClassIfHasValidMethodForRunBeforeAllActions() { Class clazz = UserController.class; List<ControllerMapping> mappings = classScanner.getActionsByClass(clazz, "user"); for (ControllerMapping mapping : mappings) { assertNotNull(mapping.getRunBeforeActions()); } }
@Test @SuppressWarnings({"rawtypes", "unchecked"}) public void testGetActionsByClassIfHasValidMethodForRunBeforeSomeActions() { Class clazz = PersonController.class; List<ControllerMapping> mappings = classScanner.getActionsByClass(clazz, "user"); for (ControllerMapping mapping : mappings) { String action = mapping.getActionName(); if ("save".equals(action) || "update".equals(action) || "delete".equals(action)) { assertNotNull(mapping.getRunBeforeActions()); } else { assertNull(mapping.getRunBeforeActions()); } } }