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

The following examples show how to use com.tngtech.java.junit.dataprovider.DataProvider. These examples are extracted from open source projects. 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 Project: ArchUnit   Source File: FormattersTest.java    License: 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 Project: ArchUnit   Source File: PlantUmlParserTest.java    License: 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 3
Source Project: ArchUnit   Source File: JavaTypeTest.java    License: 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 4
Source Project: vividus   Source File: WebDriverTypeTests.java    License: 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 5
Source Project: ArchUnit   Source File: GivenClassShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] noClass_should_beProtected_rules() {
    return $$(
            $(noClass(ProtectedClass.class).should().notBeProtected(),
                    noClass(ProtectedClass.class).should().beProtected()),
            $(noClass(ProtectedClass.class).should(ArchConditions.notBeProtected()),
                    noClass(ProtectedClass.class).should(ArchConditions.beProtected())),
            $(noClass(ProtectedClass.class.getName()).should().notBeProtected(),
                    noClass(ProtectedClass.class.getName()).should().beProtected()),
            $(noClass(ProtectedClass.class.getName()).should(ArchConditions.notBeProtected()),
                    noClass(ProtectedClass.class.getName()).should(ArchConditions.beProtected()))
    );
}
 
Example 6
Source Project: vividus   Source File: WebDriverTypeTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@DataProvider({
        "FIREFOX,       true",
        "IEXPLORE,      true",
        "CHROME,        false",
        "SAFARI,        false",
        "EDGE,          false",
        "EDGE_CHROMIUM, false",
        "OPERA,         false"
})
public void testIsUseW3C(WebDriverType type, boolean useW3C)
{
    assertEquals(useW3C, type.isUseW3C());
}
 
Example 7
Source Project: ArchUnit   Source File: GivenClassShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] theClass_should_resideInAPackage_rules() {
    String thePackage = SomeClass.class.getPackage().getName();
    return $$(
            $(theClass(SomeClass.class).should().resideInAPackage(thePackage),
                    theClass(SomeClass.class).should().resideOutsideOfPackage(thePackage)),
            $(theClass(SomeClass.class).should(ArchConditions.resideInAPackage(thePackage)),
                    theClass(SomeClass.class).should(ArchConditions.resideOutsideOfPackage(thePackage))),
            $(theClass(SomeClass.class.getName()).should().resideInAPackage(thePackage),
                    theClass(SomeClass.class.getName()).should().resideOutsideOfPackage(thePackage)),
            $(theClass(SomeClass.class.getName()).should(ArchConditions.resideInAPackage(thePackage)),
                    theClass(SomeClass.class.getName()).should(ArchConditions.resideOutsideOfPackage(thePackage)))
    );
}
 
Example 8
Source Project: ArchUnit   Source File: GivenClassShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] theClass_should_haveOnlyFinalFields_rules() {
    return $$(
            $(theClass(ClassWithFinalFields.class).should().haveOnlyFinalFields(),
                    theClass(ClassWithNonFinalFields.class).should().haveOnlyFinalFields()),
            $(theClass(ClassWithFinalFields.class).should(ArchConditions.haveOnlyFinalFields()),
                    theClass(ClassWithNonFinalFields.class).should(ArchConditions.haveOnlyFinalFields())),
            $(theClass(ClassWithFinalFields.class.getName()).should().haveOnlyFinalFields(),
                    theClass(ClassWithNonFinalFields.class.getName()).should().haveOnlyFinalFields()),
            $(theClass(ClassWithFinalFields.class.getName()).should(ArchConditions.haveOnlyFinalFields()),
                    theClass(ClassWithNonFinalFields.class.getName()).should(ArchConditions.haveOnlyFinalFields()))
    );
}
 
Example 9
Source Project: ArchUnit   Source File: GivenClassShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] theClass_should_bePublic_rules() {
    return $$(
            $(theClass(SomeClass.class).should().bePublic(),
                    theClass(SomeClass.class).should().notBePublic()),
            $(theClass(SomeClass.class).should(ArchConditions.bePublic()),
                    theClass(SomeClass.class).should(ArchConditions.notBePublic())),
            $(theClass(SomeClass.class.getName()).should().bePublic(),
                    theClass(SomeClass.class.getName()).should().notBePublic()),
            $(theClass(SomeClass.class.getName()).should(ArchConditions.bePublic()),
                    theClass(SomeClass.class.getName()).should(ArchConditions.notBePublic()))
    );
}
 
Example 10
Source Project: vividus   Source File: ExcelSheetsExtractorTests.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] exceptionDataProvider()
{
    // @formatter:off
    return new Object[][] {
        { EncryptedDocumentException.class },
        { IOException.class }};
    // @formatter:on
}
 
Example 11
@DataProvider
public static Object[][] dataProviderGetAggregatedJudgment() {
  return new Object[][] {
    // final score, marginal, pass, expected didPass result
    {95D, null, null, true},
    {60D, 75D, 95D, false},
    {85D, 75D, null, true},
    {85D, 75D, 95D, false},
    {97D, 75D, 95D, true},
  };
}
 
Example 12
Source Project: ArchUnit   Source File: GivenClassShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] noClass_should_bePublic_rules() {
    return $$(
            $(noClass(SomeClass.class).should().notBePublic(),
                    noClass(SomeClass.class).should().bePublic()),
            $(noClass(SomeClass.class).should(ArchConditions.notBePublic()),
                    noClass(SomeClass.class).should(ArchConditions.bePublic())),
            $(noClass(SomeClass.class.getName()).should().notBePublic(),
                    noClass(SomeClass.class.getName()).should().bePublic()),
            $(noClass(SomeClass.class.getName()).should(ArchConditions.notBePublic()),
                    noClass(SomeClass.class.getName()).should(ArchConditions.bePublic()))
    );
}
 
Example 13
Source Project: ArchUnit   Source File: ClassesShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] notBeTopLevelClasses_rules() {
    Class<?> topLevelClass = List.class;
    Class<?> staticNestedClass = NestedClassWithSomeMoreClasses.StaticNestedClass.class;

    return $$(
            $(classes().should().notBeTopLevelClasses(), staticNestedClass, topLevelClass),
            $(classes().should(ArchConditions.notBeTopLevelClasses()), staticNestedClass, topLevelClass)
    );
}
 
Example 14
Source Project: ArchUnit   Source File: ConditionEventsTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] eventsWithEmpty() {
    return $$(
            $(events(SimpleConditionEvent.satisfied("irrelevant", "irrelevant")), false),
            $(events(SimpleConditionEvent.violated("irrelevant", "irrelevant")), false),
            $(new ConditionEvents(), true));
}
 
Example 15
Source Project: ArchUnit   Source File: GivenClassShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] theClass_should_getFieldWhere_rules() {
    return $$(
            $(theClass(ClassAccessingField.class).should().getFieldWhere(accessTargetIs(ClassWithField.class)),
                    theClass(ClassAccessingWrongField.class).should().getFieldWhere(accessTargetIs(ClassWithField.class))),
            $(theClass(ClassAccessingField.class).should(ArchConditions.getFieldWhere(accessTargetIs(ClassWithField.class))),
                    theClass(ClassAccessingWrongField.class).should(ArchConditions.getFieldWhere(accessTargetIs(ClassWithField.class)))),
            $(theClass(ClassAccessingField.class.getName()).should().getFieldWhere(accessTargetIs(ClassWithField.class)),
                    theClass(ClassAccessingWrongField.class.getName()).should().getFieldWhere(accessTargetIs(ClassWithField.class))),
            $(theClass(ClassAccessingField.class.getName()).should(ArchConditions.getFieldWhere(accessTargetIs(ClassWithField.class))),
                    theClass(ClassAccessingWrongField.class.getName()).should(ArchConditions.getFieldWhere(accessTargetIs(ClassWithField.class))))
    );
}
 
Example 16
Source Project: ArchUnit   Source File: GivenClassShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] theClass_should_beProtected_rules() {
    return $$(
            $(theClass(ProtectedClass.class).should().beProtected(),
                    theClass(ProtectedClass.class).should().notBeProtected()),
            $(theClass(ProtectedClass.class).should(ArchConditions.beProtected()),
                    theClass(ProtectedClass.class).should(ArchConditions.notBeProtected())),
            $(theClass(ProtectedClass.class.getName()).should().beProtected(),
                    theClass(ProtectedClass.class.getName()).should().notBeProtected()),
            $(theClass(ProtectedClass.class.getName()).should(ArchConditions.beProtected()),
                    theClass(ProtectedClass.class.getName()).should(ArchConditions.notBeProtected()))
    );
}
 
Example 17
Source Project: ArchUnit   Source File: TransformersTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] members_testcases() {
    return $$(
            $(Transformers.members(),
                    Sets.union(
                            createMemberStrings(ClassWithMembers.class,
                                    "field1", "field2", "<init>()", "<init>(java.lang.String)", "method1()", "method2()"),
                            createMemberStrings(AnotherClassWithMembers.class, "field3", "<init>()", "method3()"))),
            $(Transformers.fields(),
                    Sets.union(
                            createMemberStrings(ClassWithMembers.class, "field1", "field2"),
                            createMemberStrings(AnotherClassWithMembers.class, "field3"))),
            $(Transformers.codeUnits(),
                    Sets.union(
                            createMemberStrings(ClassWithMembers.class,
                                    "<init>()", "<init>(java.lang.String)", "method1()", "method2()"),
                            createMemberStrings(AnotherClassWithMembers.class, "<init>()", "method3()"))),
            $(Transformers.methods(),
                    Sets.union(
                            createMemberStrings(ClassWithMembers.class, "method1()", "method2()"),
                            createMemberStrings(AnotherClassWithMembers.class, "method3()"))),
            $(Transformers.constructors(),
                    Sets.union(
                            createMemberStrings(ClassWithMembers.class, "<init>()", "<init>(java.lang.String)"),
                            createMemberStrings(AnotherClassWithMembers.class, "<init>()")))
    );
}
 
Example 18
Source Project: ArchUnit   Source File: GivenClassShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] noClass_should_bePackagePrivate_rules() {
    return $$(
            $(noClass(PackagePrivateClass.class).should().notBePackagePrivate(),
                    noClass(PackagePrivateClass.class).should().bePackagePrivate()),
            $(noClass(PackagePrivateClass.class).should(ArchConditions.notBePackagePrivate()),
                    noClass(PackagePrivateClass.class).should(ArchConditions.bePackagePrivate())),
            $(noClass(PackagePrivateClass.class.getName()).should().notBePackagePrivate(),
                    noClass(PackagePrivateClass.class.getName()).should().bePackagePrivate()),
            $(noClass(PackagePrivateClass.class.getName()).should(ArchConditions.notBePackagePrivate()),
                    noClass(PackagePrivateClass.class.getName()).should(ArchConditions.bePackagePrivate()))
    );
}
 
Example 19
Source Project: ArchUnit   Source File: ShouldOnlyByClassesThatTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] should_only_be_by_rule_starts() {
    return testForEach(
            classes().should().onlyBeAccessed().byClassesThat(),
            classes().should().onlyHaveDependentClassesThat()
    );
}
 
Example 20
Source Project: ArchUnit   Source File: ClassesShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] notBeLocalClasses_rules() {
    Class<?> localClass = NestedClassWithSomeMoreClasses.getLocalClass();
    Class<?> staticNestedClass = NestedClassWithSomeMoreClasses.StaticNestedClass.class;

    return $$(
            $(classes().should().notBeLocalClasses(), staticNestedClass, localClass),
            $(classes().should(ArchConditions.notBeLocalClasses()), staticNestedClass, localClass)
    );
}
 
Example 21
Source Project: ArchUnit   Source File: ShouldClassesThatTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] no_classes_should_predicate_rule_starts() {
    return testForEach(
            noClasses().should().accessClassesThat(are(not(assignableFrom(classWithNameOf(Collection.class))))),
            noClasses().should().dependOnClassesThat(are(not(assignableFrom(classWithNameOf(Collection.class)))))
    );
}
 
Example 22
Source Project: ArchUnit   Source File: ShouldClassesThatTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] classes_should_only_predicate_rule_starts() {
    return testForEach(
            classes().should().onlyAccessClassesThat(are(assignableFrom(classWithNameOf(Collection.class)))),
            classes().should().onlyDependOnClassesThat(are(assignableFrom(classWithNameOf(Collection.class))))
    );
}
 
Example 23
Source Project: ArchUnit   Source File: GivenClassShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] theClass_should_beAssignableTo_rules() {
    return $$(
            $(theClass(List.class).should().beAssignableTo(Collection.class),
                    theClass(List.class).should().notBeAssignableTo(Collection.class)),
            $(theClass(List.class).should(ArchConditions.beAssignableTo(Collection.class)),
                    theClass(List.class).should(ArchConditions.notBeAssignableTo(Collection.class))),
            $(theClass(List.class.getName()).should().beAssignableTo(Collection.class),
                    theClass(List.class.getName()).should().notBeAssignableTo(Collection.class)),
            $(theClass(List.class.getName()).should(ArchConditions.beAssignableTo(Collection.class)),
                    theClass(List.class.getName()).should(ArchConditions.notBeAssignableTo(Collection.class)))
    );
}
 
Example 24
Source Project: ArchUnit   Source File: GivenClassShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] theClass_should_haveFullyQualifiedName_rules() {
    return $$(
            $(theClass(SomeClass.class).should().haveFullyQualifiedName(SomeClass.class.getName()),
                    theClass(SomeClass.class).should().notHaveFullyQualifiedName(SomeClass.class.getName())),
            $(theClass(SomeClass.class).should(ArchConditions.haveFullyQualifiedName(SomeClass.class.getName())),
                    theClass(SomeClass.class).should(ArchConditions.notHaveFullyQualifiedName(SomeClass.class.getName()))),
            $(theClass(SomeClass.class.getName()).should().haveFullyQualifiedName(SomeClass.class.getName()),
                    theClass(SomeClass.class.getName()).should().notHaveFullyQualifiedName(SomeClass.class.getName())),
            $(theClass(SomeClass.class.getName()).should(ArchConditions.haveFullyQualifiedName(SomeClass.class.getName())),
                    theClass(SomeClass.class.getName()).should(ArchConditions.notHaveFullyQualifiedName(SomeClass.class.getName())))
    );
}
 
Example 25
Source Project: ArchUnit   Source File: MembersShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] haveNameNotStartingWith_rules() {
    return $$(
            $(members().should().haveNameNotStartingWith("violated"), "violated"),
            $(members().should(ArchConditions.haveNameNotStartingWith("violated")), "violated"),
            $(fields().should().haveNameNotStartingWith("violated"), "violated"),
            $(fields().should(ArchConditions.haveNameNotStartingWith("violated")), "violated"),
            $(codeUnits().should().haveNameNotStartingWith("violated"), "violated"),
            $(codeUnits().should(ArchConditions.haveNameNotStartingWith("violated")), "violated"),
            $(methods().should().haveNameNotStartingWith("violated"), "violated"),
            $(methods().should(ArchConditions.haveNameNotStartingWith("violated")), "violated"),
            $(constructors().should().haveNameNotStartingWith("<init>"), "<init>"),
            $(constructors().should(ArchConditions.haveNameNotStartingWith("<init>")), "<init>")
    );
}
 
Example 26
Source Project: ArchUnit   Source File: ClassesShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] beNestedClasses_rules() {
    Class<?> topLevelClass = List.class;
    Class<?> staticNestedClass = NestedClassWithSomeMoreClasses.StaticNestedClass.class;

    return $$(
            $(classes().should().beNestedClasses(), staticNestedClass, topLevelClass),
            $(classes().should(ArchConditions.beNestedClasses()), staticNestedClass, topLevelClass)
    );
}
 
Example 27
Source Project: ArchUnit   Source File: MembersShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] haveNameNotContaining_rules() {
    return $$(
            $(members().should().haveNameNotContaining("violated"), "violated"),
            $(members().should(ArchConditions.haveNameNotContaining("violated")), "violated"),
            $(fields().should().haveNameNotContaining("violated"), "violated"),
            $(fields().should(ArchConditions.haveNameNotContaining("violated")), "violated"),
            $(codeUnits().should().haveNameNotContaining("violated"), "violated"),
            $(codeUnits().should(ArchConditions.haveNameNotContaining("violated")), "violated"),
            $(methods().should().haveNameNotContaining("violated"), "violated"),
            $(methods().should(ArchConditions.haveNameNotContaining("violated")), "violated"),
            $(constructors().should().haveNameNotContaining("<init>"), "<init>"),
            $(constructors().should(ArchConditions.haveNameNotContaining("<init>")), "<init>")
    );
}
 
Example 28
Source Project: ArchUnit   Source File: GivenClassShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] noClass_should_haveModifier_public_rules() {
    return $$(
            $(noClass(PublicClass.class).should().notHaveModifier(PUBLIC),
                    noClass(PublicClass.class).should().haveModifier(PUBLIC)),
            $(noClass(PublicClass.class).should(ArchConditions.notHaveModifier(PUBLIC)),
                    noClass(PublicClass.class).should(ArchConditions.haveModifier(PUBLIC))),
            $(noClass(PublicClass.class.getName()).should().notHaveModifier(PUBLIC),
                    noClass(PublicClass.class.getName()).should().haveModifier(PUBLIC)),
            $(noClass(PublicClass.class.getName()).should(ArchConditions.notHaveModifier(PUBLIC)),
                    noClass(PublicClass.class.getName()).should(ArchConditions.haveModifier(PUBLIC)))
    );
}
 
Example 29
Source Project: ArchUnit   Source File: GivenClassShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] noClass_should_beAssignableFrom_rules() {
    return $$(
            $(noClass(Collection.class).should().notBeAssignableFrom(List.class),
                    noClass(Collection.class).should().beAssignableFrom(List.class)),
            $(noClass(Collection.class).should(ArchConditions.notBeAssignableFrom(List.class)),
                    noClass(Collection.class).should(ArchConditions.beAssignableFrom(List.class))),
            $(noClass(Collection.class.getName()).should().notBeAssignableFrom(List.class),
                    noClass(Collection.class.getName()).should().beAssignableFrom(List.class)),
            $(noClass(Collection.class.getName()).should(ArchConditions.notBeAssignableFrom(List.class)),
                    noClass(Collection.class.getName()).should(ArchConditions.beAssignableFrom(List.class)))
    );
}
 
Example 30
Source Project: ArchUnit   Source File: ClassesShouldTest.java    License: Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] notHaveFullyQualifiedName_rules() {
    return $$(
            $(classes().should().notHaveFullyQualifiedName(WrongNamedClass.class.getName())),
            $(classes().should(ArchConditions.notHaveFullyQualifiedName(WrongNamedClass.class.getName())))
    );
}