private void configureRunner(Runner runner) throws InvalidOrderingException { Description description = runner.getDescription(); OrderWith orderWith = description.getAnnotation(OrderWith.class); if (orderWith != null) { Ordering ordering = Ordering.definedBy(orderWith.value(), description); ordering.apply(runner); } }
/** * Orders the descriptions. * * @return descriptions in order */ public List<Description> order(Collection<Description> descriptions) throws InvalidOrderingException { List<Description> inOrder = ordering.orderItems( Collections.unmodifiableCollection(descriptions)); if (!ordering.validateOrderingIsCorrect()) { return inOrder; } Set<Description> uniqueDescriptions = new HashSet<Description>(descriptions); if (!uniqueDescriptions.containsAll(inOrder)) { throw new InvalidOrderingException("Ordering added items"); } Set<Description> resultAsSet = new HashSet<Description>(inOrder); if (resultAsSet.size() != inOrder.size()) { throw new InvalidOrderingException("Ordering duplicated items"); } else if (!resultAsSet.containsAll(uniqueDescriptions)) { throw new InvalidOrderingException("Ordering removed items"); } return inOrder; }
throw new InvalidOrderingException(String.format( CONSTRUCTOR_ERROR_FORMAT, getClassName(factoryClass), factoryClass.getSimpleName())); } catch (Exception e) { "Could not create ordering for " + annotatedTestClass, e); return definedBy(factory, annotatedTestClass);
@Override protected Runner createRunner() { Runner runner = request.getRunner(); try { ordering.apply(runner); } catch (InvalidOrderingException e) { return new ErrorReportingRunner(ordering.getClass(), e); } return runner; } }