/*
 * Copyright 2015-2016 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.junit.gen5.meta;

import static de.schauderhaft.degraph.check.JCheck.classpath;
import static de.schauderhaft.degraph.check.JCheck.violationFree;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

import de.schauderhaft.degraph.configuration.NamedPattern;

import org.junit.gen5.api.Test;
import org.junit.gen5.junit4.runner.JUnit5;
import org.junit.runner.RunWith;

/**
 * Checks against dependency cycles on package and module level.
 *
 * <p>Modules in that sense are defined by the package name element after org.junit.gen5,
 * so "org.junit.gen5.console.ConsoleRunner" belongs to the module "console".
 */
@RunWith(JUnit5.class)
public class DependencyTests {

	@Test
	void noCycles() {
		// we can't use noJar(), because with gradle the dependencies of other modules are
		// included as jar files in the path.
		//@formatter:off
		assertThat(
			classpath()
				.printTo("dependencies.graphml")
				.including("org.junit.gen5.**")
				.withSlicing("module",
					new NamedPattern("org.junit.gen5.engine.junit4.**", "junit4-engine"),
					new NamedPattern("org.junit.gen5.engine.junit5.**", "junit5-engine"),
					new NamedPattern("org.junit.gen5.engine.**", "engine-api"),
					"org.junit.gen5.(*).**"),
			is(violationFree()));
		//@formatter:on
	}
}

@@ -655,99 +655,45 @@
 st;%0A
-import org.junit.gen5.junit4.runner.JUnit5;%0Aimport org.junit.runner.RunWith;%0A%0A/**%0A * C
+%0A/**%0A * %7B@code DependencyTests%7D c
 heck
-s
  aga
@@ -719,18 +719,22 @@
 les 
-on
+at the
  package
  and
@@ -729,16 +729,19 @@
  package
+%0A *
  and mod
@@ -749,16 +749,17 @@
 le level
+s
 .%0A *%0A * 
@@ -765,29 +765,24 @@
  %3Cp%3E
+%3Cem%3E
 Modules
- in that sense
+%3C/em%3E
  are
@@ -822,37 +822,97 @@
 ent 
-after org.junit.gen5,%0A * so %22
+immediately%0A * following the %7B@code org.junit.gen5%7D base package. For example,%0A * %7B@code 
 org.
@@ -943,17 +943,17 @@
 leRunner
-%22
+%7D
  belongs
@@ -964,60 +964,39 @@
 the 
-modul
+%7B@cod
 e 
-%22
 console
-%22.%0A */%0A@RunWith(JUnit5.class)%0Apublic 
+%7D%0A * module.%0A */%0A
 clas
@@ -1607,10 +1607,11 @@
 r:on%0A%09%7D%0A
+%0A
 %7D%0A

Convert DependencyTests to a pure JUnit 5 test class