Search in sources :

Example 1 with A

use of com.buschmais.jqassistant.plugin.java.test.set.scanner.resolver.A in project jqa-java-plugin by buschmais.

the class TypeResolverIT method ambiguousDependencies.

/**
     * Verifies scanning a type depending on another type which exists in two
     * independent artifacts.
     *
     * @throws IOException
     *             If the test fails.
     */
@Test
public void ambiguousDependencies() throws IOException {
    store.beginTransaction();
    JavaArtifactFileDescriptor a1 = getArtifactDescriptor("a1");
    JavaArtifactFileDescriptor a2 = getArtifactDescriptor("a2");
    JavaArtifactFileDescriptor a3 = getArtifactDescriptor("a3");
    store.create(a3, DependsOnDescriptor.class, a1);
    store.create(a3, DependsOnDescriptor.class, a2);
    store.commitTransaction();
    scanClasses("a1", A.class);
    scanClasses("a2", A.class);
    scanClasses("a3", B.class);
    store.beginTransaction();
    TestResult testResult = query("match (:Artifact)-[:CONTAINS]->(t:Type) where t.fqn={t} return t", MapBuilder.<String, Object>create("t", A.class.getName()).get());
    assertThat(testResult.getRows().size(), equalTo(2));
    testResult = query("match (artifact3:Artifact)-[:CONTAINS]->(b:Type)-[:DEPENDS_ON]->(a:Type)-[:CONTAINS]-(otherArtifact:Artifact) where b.fqn={b} return otherArtifact", MapBuilder.<String, Object>create("a", A.class.getName()).put("b", B.class.getName()).get());
    assertThat(testResult.getRows().size(), equalTo(1));
    JavaArtifactFileDescriptor otherArtifact = (JavaArtifactFileDescriptor) testResult.getColumn("otherArtifact").get(0);
    assertThat(otherArtifact, anyOf(equalTo(a1), equalTo(a2)));
    store.commitTransaction();
}
Also used : A(com.buschmais.jqassistant.plugin.java.test.set.scanner.resolver.A) JavaArtifactFileDescriptor(com.buschmais.jqassistant.plugin.java.api.model.JavaArtifactFileDescriptor) Test(org.junit.Test)

Aggregations

JavaArtifactFileDescriptor (com.buschmais.jqassistant.plugin.java.api.model.JavaArtifactFileDescriptor)1 A (com.buschmais.jqassistant.plugin.java.test.set.scanner.resolver.A)1 Test (org.junit.Test)1