com.tngtech.java.junit.dataprovider.DataProvider Java Examples

The following examples show how to use com.tngtech.java.junit.dataprovider.DataProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FormattersTest.java    From ArchUnit with Apache License 2.0 6 votes vote down vote up
@DataProvider
public static Object[][] simple_name_test_cases() {
    return $$(
            $("", ""),
            $("Dummy", "Dummy"),
            $("org.example.Dummy", "Dummy"),
            $("org.example.Dummy$123", ""),
            $("org.example.Dummy$NestedClass", "NestedClass"),
            $("org.example.Dummy$NestedClass123", "NestedClass123"),
            $("org.example.Dummy$NestedClass$123", ""),
            $("org.example.Dummy$NestedClass$MoreNestedClass", "MoreNestedClass"),
            $("org.example.Dummy$123LocalClass", "LocalClass"),
            $("org.example.Dummy$Inner$123LocalClass", "LocalClass"),
            $("org.example.Dummy$Inner$123LocalClass123", "LocalClass123"),
            $("Dummy[]", "Dummy[]"),
            $("org.example.Dummy[]", "Dummy[]"),
            $("org.example.Dummy$Inner[][]", "Inner[][]"));
}
 
Example #2
Source File: JavaTypeTest.java    From ArchUnit with Apache License 2.0 6 votes vote down vote up
@DataProvider
public static List<List<Object>> arrays() {
    return ImmutableList.<List<Object>>builder()
            .addAll(namesToArray(boolean[].class))
            .addAll(namesToArray(byte[].class))
            .addAll(namesToArray(char[].class))
            .addAll(namesToArray(short[].class))
            .addAll(namesToArray(int[].class))
            .addAll(namesToArray(long[].class))
            .addAll(namesToArray(float[].class))
            .addAll(namesToArray(double[].class))
            .addAll(namesToArray(Object[].class))
            .addAll(namesToArray(boolean[][].class))
            .addAll(namesToArray(byte[][].class))
            .addAll(namesToArray(char[][].class))
            .addAll(namesToArray(short[][].class))
            .addAll(namesToArray(int[][].class))
            .addAll(namesToArray(long[][].class))
            .addAll(namesToArray(float[][].class))
            .addAll(namesToArray(double[][].class))
            .addAll(namesToArray(Object[][].class))
            .build();
}
 
Example #3
Source File: PlantUmlParserTest.java    From ArchUnit with Apache License 2.0 6 votes vote down vote up
@DataProvider
public static Object[][] dependency_arrow_testcases() {
    List<String> arrowCenters = new ArrayList<>();
    for (int i = 1; i <= 10; i++) {
        arrowCenters.add(Strings.repeat("-", i));
    }
    for (int i = 2; i <= 10; i++) {
        for (String infix : ImmutableList.of("left", "right", "up", "down", "[#green]")) {
            arrowCenters.add(Strings.repeat("-", i - 1) + infix + "-");
        }
    }
    List<String> testCase = new ArrayList<>();
    for (String arrowCenter : arrowCenters) {
        testCase.add("[SomeOrigin] " + arrowCenter + "> [SomeTarget]");
        testCase.add("[SomeTarget] <" + arrowCenter + " [SomeOrigin]");
    }
    return testForEach(testCase);
}
 
Example #4
Source File: GivenClassShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] noClass_should_beAssignableTo_rules() {
    return $$(
            $(noClass(List.class).should().notBeAssignableTo(Collection.class),
                    noClass(List.class).should().beAssignableTo(Collection.class)),
            $(noClass(List.class).should(ArchConditions.notBeAssignableTo(Collection.class)),
                    noClass(List.class).should(ArchConditions.beAssignableTo(Collection.class))),
            $(noClass(List.class.getName()).should().notBeAssignableTo(Collection.class),
                    noClass(List.class.getName()).should().beAssignableTo(Collection.class)),
            $(noClass(List.class.getName()).should(ArchConditions.notBeAssignableTo(Collection.class)),
                    noClass(List.class.getName()).should(ArchConditions.beAssignableTo(Collection.class)))
    );
}
 
Example #5
Source File: ClassesShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] onlyCallMethodsThat_rules() {
    return $$(
            $(classes().should().onlyCallMethodsThat(are(declaredIn(ClassWithMethod.class)))),
            $(classes().should(ArchConditions.onlyCallMethodsThat(are(declaredIn(ClassWithMethod.class)))))
    );
}
 
Example #6
Source File: ClassesShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] callConstructorWhere_rules() {
    return $$(
            $(classes().should().callConstructorWhere(callTargetIs(ClassWithConstructor.class))),
            $(classes().should(ArchConditions.callConstructorWhere(callTargetIs(ClassWithConstructor.class))))
    );
}
 
Example #7
Source File: GivenClassShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] noClass_should_haveOnlyFinalFields_rules() {
    return $$(
            $(noClass(ClassWithNonFinalFields.class).should().haveOnlyFinalFields(),
                    noClass(ClassWithFinalFields.class).should().haveOnlyFinalFields()),
            $(noClass(ClassWithNonFinalFields.class).should(ArchConditions.haveOnlyFinalFields()),
                    noClass(ClassWithFinalFields.class).should(ArchConditions.haveOnlyFinalFields())),
            $(noClass(ClassWithNonFinalFields.class.getName()).should().haveOnlyFinalFields(),
                    noClass(ClassWithFinalFields.class.getName()).should().haveOnlyFinalFields()),
            $(noClass(ClassWithNonFinalFields.class.getName()).should(ArchConditions.haveOnlyFinalFields()),
                    noClass(ClassWithFinalFields.class.getName()).should(ArchConditions.haveOnlyFinalFields()))
    );
}
 
Example #8
Source File: ClassesShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] callCodeUnitWhere_rules() {
    return $$(
            $(classes().should().callCodeUnitWhere(accessTargetIs(ClassWithFieldMethodAndConstructor.class))),
            $(classes().should(ArchConditions.callCodeUnitWhere(accessTargetIs(ClassWithFieldMethodAndConstructor.class))))
    );
}
 
Example #9
Source File: ClassesShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] visibility_rules() {
    return $$(
            $(classes().should().bePublic(), PUBLIC, PublicClass.class, PrivateClass.class),
            $(classes().should(bePublic()), PUBLIC, PublicClass.class, PrivateClass.class),
            $(classes().should().beProtected(), PROTECTED, ProtectedClass.class, PrivateClass.class),
            $(classes().should(beProtected()), PROTECTED, ProtectedClass.class, PrivateClass.class),
            $(classes().should().bePrivate(), PRIVATE, PrivateClass.class, PublicClass.class),
            $(classes().should(bePrivate()), PRIVATE, PrivateClass.class, PublicClass.class));
}
 
Example #10
Source File: ClassesShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] onlyCallCodeUnitsThat_rules() {
    return $$(
            $(classes().should().onlyCallCodeUnitsThat(are(declaredIn(ClassWithFieldMethodAndConstructor.class)))),
            $(classes().should(ArchConditions.onlyCallCodeUnitsThat(are(declaredIn(ClassWithFieldMethodAndConstructor.class)))))
    );
}
 
Example #11
Source File: ClassesShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] onlyAccessMembersThat_rules() {
    return $$(
            $(classes().should().onlyAccessMembersThat(are(declaredIn(ClassWithFieldMethodAndConstructor.class)))),
            $(classes().should(ArchConditions.onlyAccessMembersThat(are(declaredIn(ClassWithFieldMethodAndConstructor.class)))))
    );
}
 
Example #12
Source File: GivenClassShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] theClass_should_getField_rules() {
    return $$(
            $(theClass(ClassAccessingField.class).should().getField(ClassWithField.class, "field"),
                    theClass(ClassAccessingWrongField.class).should().getField(ClassWithField.class, "field")),
            $(theClass(ClassAccessingField.class).should(ArchConditions.getField(ClassWithField.class, "field")),
                    theClass(ClassAccessingWrongField.class).should(ArchConditions.getField(ClassWithField.class, "field"))),
            $(theClass(ClassAccessingField.class.getName()).should().getField(ClassWithField.class, "field"),
                    theClass(ClassAccessingWrongField.class.getName()).should().getField(ClassWithField.class, "field")),
            $(theClass(ClassAccessingField.class.getName()).should(ArchConditions.getField(ClassWithField.class, "field")),
                    theClass(ClassAccessingWrongField.class.getName()).should(ArchConditions.getField(ClassWithField.class, "field")))
    );
}
 
Example #13
Source File: GivenClassShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] theClass_should_haveSimpleNameStartingWith_rules() {
    String simpleName = SomeClass.class.getSimpleName();
    String prefix = simpleName.substring(0, simpleName.length() - 1);
    return $$(
            $(theClass(SomeClass.class).should().haveSimpleNameStartingWith(prefix),
                    theClass(SomeClass.class).should().haveSimpleNameNotStartingWith(prefix)),
            $(theClass(SomeClass.class).should(ArchConditions.haveSimpleNameStartingWith(prefix)),
                    theClass(SomeClass.class).should(ArchConditions.haveSimpleNameNotStartingWith(prefix))),
            $(theClass(SomeClass.class.getName()).should().haveSimpleNameStartingWith(prefix),
                    theClass(SomeClass.class.getName()).should().haveSimpleNameNotStartingWith(prefix)),
            $(theClass(SomeClass.class.getName()).should(ArchConditions.haveSimpleNameStartingWith(prefix)),
                    theClass(SomeClass.class.getName()).should(ArchConditions.haveSimpleNameNotStartingWith(prefix)))
    );
}
 
Example #14
Source File: GivenClassShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] noClass_should_resideInAPackage_rules() {
    String thePackage = SomeClass.class.getPackage().getName();
    return $$(
            $(noClass(SomeClass.class).should().resideOutsideOfPackage(thePackage),
                    noClass(SomeClass.class).should().resideInAPackage(thePackage)),
            $(noClass(SomeClass.class).should(ArchConditions.resideOutsideOfPackage(thePackage)),
                    noClass(SomeClass.class).should(ArchConditions.resideInAPackage(thePackage))),
            $(noClass(SomeClass.class.getName()).should().resideOutsideOfPackage(thePackage),
                    noClass(SomeClass.class.getName()).should().resideInAPackage(thePackage)),
            $(noClass(SomeClass.class.getName()).should(ArchConditions.resideOutsideOfPackage(thePackage)),
                    noClass(SomeClass.class.getName()).should(ArchConditions.resideInAPackage(thePackage)))
    );
}
 
Example #15
Source File: HasTypeTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] type_predicates() {
    return testForEach(
            HasType.Predicates.rawType(String.class),
            HasType.Predicates.rawType(String.class.getName()),
            HasType.Predicates.rawType(equivalentTo(String.class)));
}
 
Example #16
Source File: ClassesShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] beClass_rules() {
    return $$(
            $(classes().should().be(String.class), String.class, Collection.class),
            $(classes().should().be(String.class.getName()), String.class, Collection.class),
            $(classes().should(ArchConditions.be(String.class)), String.class, Collection.class),
            $(classes().should(ArchConditions.be(String.class.getName())), String.class, Collection.class));
}
 
Example #17
Source File: ClassesShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static List<List<?>> implement_not_satisfied_rules() {
    return ImmutableList.<List<?>>builder()
            .addAll(implementNotSatisfiedCases(Collection.class, List.class))
            .addAll(implementNotSatisfiedCases(Set.class, ArrayList.class))
            .build();
}
 
Example #18
Source File: ClassesShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] beTopLevelClasses_rules() {
    Class<?> topLevelClass = List.class;
    Class<?> staticNestedClass = NestedClassWithSomeMoreClasses.StaticNestedClass.class;

    return $$(
            $(classes().should().beTopLevelClasses(), topLevelClass, staticNestedClass),
            $(classes().should(ArchConditions.beTopLevelClasses()), topLevelClass, staticNestedClass)
    );
}
 
Example #19
Source File: ClassesShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] containNumberOfElements_rules() {
    return $$(
            $(equalTo(999)),
            $(lessThan(0)),
            $(lessThan(1)),
            $(lessThan(2)),
            $(greaterThan(2)),
            $(greaterThan(3)),
            $(greaterThan(999)),
            $(lessThanOrEqualTo(0)),
            $(lessThanOrEqualTo(1)),
            $(greaterThanOrEqualTo(3)),
            $(greaterThanOrEqualTo(999)));
}
 
Example #20
Source File: ClassesShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] resideOutsideOfPackage_rules() {
    String thePackage = ArchRule.class.getPackage().getName();
    return $$(
            $(classes().should().resideOutsideOfPackage(thePackage), thePackage),
            $(classes().should(ArchConditions.resideOutsideOfPackage(thePackage)), thePackage)
    );
}
 
Example #21
Source File: ClassesShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] resideInAnyPackage_rules() {
    String firstPackage = ArchRule.class.getPackage().getName();
    String secondPackage = ArchConfiguration.class.getPackage().getName();
    return $$(
            $(classes().should().resideInAnyPackage(firstPackage, secondPackage),
                    new String[]{firstPackage, secondPackage}),
            $(classes().should(ArchConditions.resideInAnyPackage(firstPackage, secondPackage)),
                    new String[]{firstPackage, secondPackage})
    );
}
 
Example #22
Source File: GivenClassShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] noClass_should_haveNameMatching_rules() {
    String regex = containsPartOfRegex(SomeClass.class.getSimpleName());
    return $$(
            $(noClass(SomeClass.class).should().haveNameNotMatching(regex),
                    noClass(SomeClass.class).should().haveNameMatching(regex)),
            $(noClass(SomeClass.class).should(ArchConditions.haveNameNotMatching(regex)),
                    noClass(SomeClass.class).should(ArchConditions.haveNameMatching(regex))),
            $(noClass(SomeClass.class.getName()).should().haveNameNotMatching(regex),
                    noClass(SomeClass.class.getName()).should().haveNameMatching(regex)),
            $(noClass(SomeClass.class.getName()).should(ArchConditions.haveNameNotMatching(regex)),
                    noClass(SomeClass.class.getName()).should(ArchConditions.haveNameMatching(regex)))
    );
}
 
Example #23
Source File: GivenClassShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] theClass_should_haveModifier_public_rules() {
    return $$(
            $(theClass(PublicClass.class).should().haveModifier(PUBLIC),
                    theClass(PublicClass.class).should().notHaveModifier(PUBLIC)),
            $(theClass(PublicClass.class).should(ArchConditions.haveModifier(PUBLIC)),
                    theClass(PublicClass.class).should(ArchConditions.notHaveModifier(PUBLIC))),
            $(theClass(PublicClass.class.getName()).should().haveModifier(PUBLIC),
                    theClass(PublicClass.class.getName()).should().notHaveModifier(PUBLIC)),
            $(theClass(PublicClass.class.getName()).should(ArchConditions.haveModifier(PUBLIC)),
                    theClass(PublicClass.class.getName()).should(ArchConditions.notHaveModifier(PUBLIC)))
    );
}
 
Example #24
Source File: CompositeArchRuleTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] rules_to_AND() {
    return $$(
            $(archRuleThatSucceeds(), archRuleThatSucceeds(), SATISFIED),
            $(archRuleThatSucceeds(), archRuleThatFails(), UNSATISFIED),
            $(archRuleThatFails(), archRuleThatSucceeds(), UNSATISFIED),
            $(archRuleThatFails(), archRuleThatFails(), UNSATISFIED)
    );
}
 
Example #25
Source File: ClassesShouldConjunctionTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] ANDed_conditions() {
    return $$(
            $(classes()
                    .should(haveFullyQualifiedName(RightOne.class.getName()))
                    .andShould(haveFullyQualifiedName(RightTwo.class.getName()))),
            $(classes()
                    .should().haveFullyQualifiedName(RightOne.class.getName())
                    .andShould().haveFullyQualifiedName(RightTwo.class.getName())));
}
 
Example #26
Source File: ClassesShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] haveSimpleNameNotStartingWith_rules() {
    String simpleName = WrongNamedClass.class.getSimpleName();
    String prefix = simpleName.substring(0, simpleName.length() - 1);
    return $$(
            $(classes().should().haveSimpleNameNotStartingWith(prefix), prefix),
            $(classes().should(ArchConditions.haveSimpleNameNotStartingWith(prefix)), prefix)
    );
}
 
Example #27
Source File: ClassesShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] haveSimpleNameStartingWith_rules() {
    String simpleName = SomeClass.class.getSimpleName();
    String prefix = simpleName.substring(0, simpleName.length() - 1);
    return $$(
            $(classes().should().haveSimpleNameStartingWith(prefix), prefix),
            $(classes().should(ArchConditions.haveSimpleNameStartingWith(prefix)), prefix)
    );
}
 
Example #28
Source File: ClassesShouldTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] haveNameNotMatching_rules() {
    String regex = containsPartOfRegex(WrongNamedClass.class.getSimpleName());
    return $$(
            $(classes().should().haveNameNotMatching(regex), regex),
            $(classes().should(ArchConditions.haveNameNotMatching(regex)), regex)
    );
}
 
Example #29
Source File: WebDriverTypeTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Test
@DataProvider({
    "FIREFOX,       true",
    "IEXPLORE,      false",
    "CHROME,        true",
    "SAFARI,        false",
    "EDGE,          false",
    "EDGE_CHROMIUM, false",
    "OPERA,         true"
    })
public void testIsBinaryPathSupported(WebDriverType type, boolean binaryPathSupported)
{
    assertEquals(binaryPathSupported, type.isBinaryPathSupported());
}
 
Example #30
Source File: DependencyTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] annotated_members() {
    JavaClass javaClass = importClassesWithContext(ClassWithAnnotatedMembers.class, SomeAnnotation.class, SomeMemberType.class)
            .get(ClassWithAnnotatedMembers.class);

    return testForEach(
            javaClass.getField("annotatedField"),
            javaClass.getConstructor(Object.class),
            javaClass.getMethod("annotatedMethod"));
}