AsciiDocRuleSetReaderTest.java 文件源码

java
阅读 20 收藏 0 点赞 0 评论 0

项目:jqa-core-framework 作者:
@Test
public void cypherRules() throws Exception {
    RuleSet ruleSet = RuleSetTestHelper.readRuleSet("/junit-without-assert.adoc");
    ConceptBucket concepts = ruleSet.getConceptBucket();
    assertThat(concepts.size(), equalTo(2));

    Concept concept1 = concepts.getById("junit4:TestClassOrMethod");
    assertThat(concept1.getId(), equalTo("junit4:TestClassOrMethod"));
    assertThat(concept1.getDescription(), CoreMatchers.containsString("labels them and their containing classes with `:Test` and `:Junit4`."));

    Executable executable1 = concept1.getExecutable();
    assertThat(executable1, instanceOf(CypherExecutable.class));
    assertThat(((CypherExecutable) executable1).getStatement(), containsString("c:Test:Junit4, m:Test:Junit4"));
    assertThat(concept1.getRequiresConcepts().keySet(), IsEmptyCollection.<String> empty());

    Concept concept2 = concepts.getById("junit4:AssertMethod");
    assertThat(concept2.getId(), containsString("junit4:AssertMethod"));
    assertThat(concept2.getDescription(), containsString("Labels all assertion methods declared by `org.junit.Assert` with `:Assert`."));

    Executable executable2 = concept2.getExecutable();
    assertThat(executable2, instanceOf(CypherExecutable.class));
    assertThat(((CypherExecutable) executable2).getStatement(), containsString("and assertMethod.signature =~ 'void assert.*'"));
    assertThat(concept2.getRequiresConcepts().keySet(), IsEmptyCollection.<String> empty());

    ConstraintBucket constraints = ruleSet.getConstraintBucket();
    assertThat(constraints.size(), equalTo(1));

    Constraint constraint = constraints.getById("junit4:TestMethodWithoutAssertion");
    assertThat(constraint.getId(), containsString("junit4:TestMethodWithoutAssertion"));
    assertThat(constraint.getDescription(), containsString("All test methods must perform assertions."));
    assertEquals("junit4:TestMethodWithoutAssertion", constraint.getId());
    assertEquals("All test methods must perform assertions.", constraint.getDescription());

    Executable constraintExecutable = constraint.getExecutable();
    assertThat(constraintExecutable, instanceOf(CypherExecutable.class));
    assertThat(((CypherExecutable) constraintExecutable).getStatement(), containsString("not (testMethod)-[:INVOKES*]->(:Method:Assert)"));

    assertThat(ruleSet.getConceptBucket().getIds(), containsInAnyOrder(constraint.getRequiresConcepts().keySet().toArray()));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号