Search in sources :

Example 1 with Pojo

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

the class PojoIT method variables.

@Test
public void variables() throws IOException {
    scanClasses(Pojo.class);
    store.beginTransaction();
    List<VariableDescriptor> variables = query("MATCH (:Java:Method{name:'equals'})-[:DECLARES]->(v:Java:Variable) return v").getColumn("v");
    assertThat(variables.size(), equalTo(2));
    Map<String, VariableDescriptor> map = new HashMap<>();
    for (VariableDescriptor variable : variables) {
        map.put(variable.getName(), variable);
    }
    VariableDescriptor o = map.get("o");
    assertThat(o, notNullValue());
    assertThat(o.getSignature(), equalTo(Object.class.getName() + " o"));
    assertThat(o.getType(), typeDescriptor(Object.class));
    VariableDescriptor pojo = map.get("pojo");
    assertThat(pojo, notNullValue());
    assertThat(pojo.getSignature(), equalTo(Pojo.class.getName() + " pojo"));
    assertThat(pojo.getType(), typeDescriptor(Pojo.class));
    store.commitTransaction();
}
Also used : Pojo(com.buschmais.jqassistant.plugin.java.test.set.scanner.pojo.Pojo) HashMap(java.util.HashMap) VariableDescriptor(com.buschmais.jqassistant.plugin.java.api.model.VariableDescriptor) Test(org.junit.Test)

Example 2 with Pojo

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

the class PojoIT method attributes.

@Test
public void attributes() throws IOException {
    scanClasses(Pojo.class);
    store.beginTransaction();
    TestResult testResult = query("MATCH (t:Type:Class) WHERE t.fqn =~ '.*Pojo' RETURN t as types");
    assertThat(testResult.getRows().size(), equalTo(1));
    ClassFileDescriptor typeDescriptor = (ClassFileDescriptor) testResult.getRows().get(0).get("types");
    assertThat(typeDescriptor, is(typeDescriptor(Pojo.class)));
    assertThat(typeDescriptor.getFileName(), equalTo("/" + Pojo.class.getName().replace('.', '/') + ".class"));
    assertThat(typeDescriptor.getSourceFileName(), equalTo(Pojo.class.getSimpleName() + ".java"));
    assertThat(query("MATCH (t:Type:Class) WHERE t.fqn =~ '.*Pojo' RETURN t.name as name").getColumn("name"), hasItem(equalTo("Pojo")));
    testResult = query("MATCH (t:Type:Class)-[:DECLARES]->(f:Field) RETURN f.signature as signature, f.name as name");
    assertThat(testResult.getColumn("signature"), allOf(hasItem(equalTo("java.lang.String stringValue")), hasItem(equalTo("int intValue"))));
    assertThat(testResult.getColumn("name"), allOf(hasItem(equalTo("stringValue")), hasItem(equalTo("intValue"))));
    testResult = query("MATCH (t:Type:Class)-[:DECLARES]->(m:Method) RETURN m.signature as signature, m.name as name");
    assertThat(testResult.getColumn("signature"), allOf(hasItem(equalTo("java.lang.String getStringValue()")), hasItem(equalTo("void setStringValue(java.lang.String)")), hasItem(equalTo("int getIntValue()")), hasItem(equalTo("void setIntValue(int)"))));
    assertThat(testResult.getColumn("name"), allOf(hasItem(equalTo("getStringValue")), hasItem(equalTo("setStringValue")), hasItem(equalTo("getIntValue")), hasItem(equalTo("setIntValue"))));
    store.commitTransaction();
}
Also used : Pojo(com.buschmais.jqassistant.plugin.java.test.set.scanner.pojo.Pojo) ClassFileDescriptor(com.buschmais.jqassistant.plugin.java.api.model.ClassFileDescriptor) Test(org.junit.Test)

Example 3 with Pojo

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

the class ByteCodeVersionIT method javaVersion.

@Test
public void javaVersion() throws Exception {
    scanClasses(Pojo.class);
    assertThat(applyConcept("java:JavaVersion").getStatus(), CoreMatchers.equalTo(SUCCESS));
    store.beginTransaction();
    List<ClassFileDescriptor> types = query("MATCH (t:Type) WHERE t.name='Pojo' and t.javaVersion='Java 8' RETURN t").getColumn("t");
    assertThat(types.size(), equalTo(1));
    ClassFileDescriptor pojo = types.get(0);
    assertThat(pojo, typeDescriptor(Pojo.class));
    store.commitTransaction();
}
Also used : Pojo(com.buschmais.jqassistant.plugin.java.test.set.scanner.pojo.Pojo) ClassFileDescriptor(com.buschmais.jqassistant.plugin.java.api.model.ClassFileDescriptor) Test(org.junit.Test)

Aggregations

Pojo (com.buschmais.jqassistant.plugin.java.test.set.scanner.pojo.Pojo)3 Test (org.junit.Test)3 ClassFileDescriptor (com.buschmais.jqassistant.plugin.java.api.model.ClassFileDescriptor)2 VariableDescriptor (com.buschmais.jqassistant.plugin.java.api.model.VariableDescriptor)1 HashMap (java.util.HashMap)1