ControlledPwmServlet extends AbstractPwmServlet implements PwmServlet { public abstract Class<? extends ProcessAction> getProcessActionsClass( );  String servletUriRemainder( final PwmRequest pwmRequest, final String command ); abstract Class<? extends ProcessAction> getProcessActionsClass( ); abstract ProcessStatus preProcessCheck( PwmRequest pwmRequest );  }
@Test public void testProcess() throws IllegalAccessException, InstantiationException { final Map<Class<? extends ControlledPwmServlet>, Map<String, Method>> dataMap = getClassAndMethods(); for ( final Class<? extends ControlledPwmServlet> controlledPwmServlet : dataMap.keySet() ) { final Class<? extends AbstractPwmServlet.ProcessAction> processActionsClass = controlledPwmServlet.newInstance().getProcessActionsClass(); if ( !processActionsClass.isEnum() ) { Assert.fail( controlledPwmServlet.getName() + " process action class must be an enum" ); } } }
@Test public void testActionHandlersExistence() throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { final Map<Class<? extends ControlledPwmServlet>, Map<String, Method>> dataMap = getClassAndMethods(); for ( final Class<? extends ControlledPwmServlet> controlledPwmServlet : dataMap.keySet() ) { final String servletName = controlledPwmServlet.getName(); final Class<? extends AbstractPwmServlet.ProcessAction> processActionsClass = controlledPwmServlet.newInstance().getProcessActionsClass(); final List<String> names = new ArrayList<>(); for ( final Object enumObject : processActionsClass.getEnumConstants() ) { names.add( ( ( Enum ) enumObject ).name() ); } { final Collection<String> missingActionHandlers = new HashSet<>( names ); missingActionHandlers.removeAll( dataMap.get( controlledPwmServlet ).keySet() ); if ( !missingActionHandlers.isEmpty() ) { Assert.fail( servletName + " does not have an action handler for action " + missingActionHandlers.iterator().next() ); } } { final Collection<String> superflousActionHandlers = new HashSet<>( dataMap.get( controlledPwmServlet ).keySet() ); superflousActionHandlers.removeAll( names ); if ( !superflousActionHandlers.isEmpty() ) { Assert.fail( servletName + " has an action handler for action " + superflousActionHandlers.iterator().next() + " but no such ProcessAction exists" ); } } } }