private void checkThatCommandIsAccepted(Object cmd) { if( ! AcceptedClientCommands.isAcceptedCommandClass(cmd.getClass()) ) { throw new UnsupportedOperationException(cmd.getClass().getName() + " is not an accepted command." ); } }
@Test public void isAcceptableCommandTest() throws Exception { assertTrue( "The .isAcceptedCommandClass method is not functioning correctly: generated classes", AcceptedClientCommands.isAcceptedCommandClass(org.kie.remote.jaxb.gen.AddTaskCommand.class)); assertFalse( "The .isAcceptedCommandClass method is not functioning correctly: original command classes", AcceptedClientCommands.isAcceptedCommandClass(org.jbpm.services.task.commands.AddTaskCommand.class)); }
@Test public void reflectionMappingTest() throws Exception { Set<Class<?>> classes = reflections.getTypesAnnotatedWith(XmlAccessorType.class); assertFalse(classes.isEmpty()); List<Class<?>> classList = new LinkedList<Class<?>>(classes); Collections.sort(classList, new Comparator<Class<?>>() { @Override public int compare( Class<?> o1, Class<?> o2 ) { return o1.getSimpleName().compareTo(o2.getSimpleName()); } }); classes = new LinkedHashSet<Class<?>>(classList); Map<Class, Class> kieCmdGenCmdClassMap = new LinkedHashMap<Class, Class>(); for( Class<?> cmdClass : classes ) { if( ! cmdClass.getSimpleName().endsWith("Command") ) { continue; } if( ! AcceptedClientCommands.isAcceptedCommandClass(cmdClass) ) { continue; } Class genCmdClass = Class.forName("org.kie.remote.jaxb.gen." + cmdClass.getSimpleName()); assertTrue( genCmdClass.getSimpleName() + " is not an accepted command?", AcceptedClientCommands.isAcceptedCommandClass(genCmdClass) ); kieCmdGenCmdClassMap.put(cmdClass, genCmdClass); } assertFalse("No generated command classes could be found to test.", kieCmdGenCmdClassMap.isEmpty()); for( Entry<Class, Class> classEntry : kieCmdGenCmdClassMap.entrySet() ) { compareKieClassInstanceToGenClassInstance(classEntry.getKey(), classEntry.getValue()); } }