当前位置: 首页>>代码示例>>Java>>正文


Java UseDataProvider类代码示例

本文整理汇总了Java中com.tngtech.java.junit.dataprovider.UseDataProvider的典型用法代码示例。如果您正苦于以下问题:Java UseDataProvider类的具体用法?Java UseDataProvider怎么用?Java UseDataProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UseDataProvider类属于com.tngtech.java.junit.dataprovider包,在下文中一共展示了UseDataProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parsesParagraphs

import com.tngtech.java.junit.dataprovider.UseDataProvider; //导入依赖的package包/类
@Test
@UseDataProvider("paragraphs")
public void parsesParagraphs(final String input, final List<Paragraph> expectedElements) throws Exception {

    //given
    final StructuredText actual = new StructuredText(input);

    // when
    List<Element> actualElement = actual.getElements();

    // then
    int i = 0;
    for(Element element: actualElement) {
        assertThat("Paragraph element matches",
            element.toString(), is(expectedElements.get(i++).toString()));
    }
}
 
开发者ID:NHS-digital-website,项目名称:hippo,代码行数:18,代码来源:StructuredTextTest.java

示例2: parsesParagraphsAndLists

import com.tngtech.java.junit.dataprovider.UseDataProvider; //导入依赖的package包/类
@Test
@UseDataProvider("paragraphsAndLists")
public void parsesParagraphsAndLists(final String input, final List<Element> expectedElements) throws Exception {

    //given
    final StructuredText actual = new StructuredText(input);

    // when
    List<Element> actualElement = actual.getElements();

    // then
    int i = 0;
    for(Element element: actualElement) {
        assertThat("Paragraph element matches",
            element.getClass().getSimpleName(), is(expectedElements.get(i++).getClass().getSimpleName()));
    }
}
 
开发者ID:NHS-digital-website,项目名称:hippo,代码行数:18,代码来源:StructuredTextTest.java

示例3: parsesList

import com.tngtech.java.junit.dataprovider.UseDataProvider; //导入依赖的package包/类
@Test
@UseDataProvider("lists")
public void parsesList(final String input, final List<Paragraph> expectedElements) throws Exception {

    //given
    final BulletList actual = new BulletList(input);

    // when
    List<String> actualItems = actual.getItems();

    // then
    int i = 0;
    for(String item: actualItems) {
        assertThat("List Item matches: " + expectedElements.get(i),
            item, is(expectedElements.get(i++)));
    }
}
 
开发者ID:NHS-digital-website,项目名称:hippo,代码行数:18,代码来源:UnorderedListTest.java

示例4: permitsAllGetters_whenPublicationFlaggedAsPubliclyAvailable

import com.tngtech.java.junit.dataprovider.UseDataProvider; //导入依赖的package包/类
@Test
@UseDataProvider("allPublicGetters")
public void permitsAllGetters_whenPublicationFlaggedAsPubliclyAvailable(final Method permittedGetter) throws Exception {

    // given
    given(publication.isPubliclyAccessible()).willReturn(true);

    // some getters have arguments so we need to construct mocked instances and pass them in as parameters
    Object[] args = Arrays.stream(permittedGetter.getParameterTypes())
        .map(DatasetTest::newInstanceForClass)
        .toArray();

    try {
        // when
        permittedGetter.invoke(dataset, args);

        // then
        // pass
    } catch (final Throwable e) {
        e.printStackTrace(); // helps with debugging
        throw new AssertionError(
            "No exception was expected to be thrown from '" + permittedGetter + "' but one was emitted;" +
                " see stack trace below for details.", e
        );
    }
}
 
开发者ID:NHS-digital-website,项目名称:hippo,代码行数:27,代码来源:DatasetTest.java

示例5: shouldUpdateDatasetFromSubfolder

import com.tngtech.java.junit.dataprovider.UseDataProvider; //导入依赖的package包/类
@Test
@UseDataProvider("documentState")
public void shouldUpdateDatasetFromSubfolder(final String state, ArrayList<String> changed, ArrayList<String> unchanged) throws Exception {

    // process publication and datasets
    datasetProcessor.processNode(getNode(RPS_ROOT_FOLDER + "/publication-with-datasets/dataset"), Arrays.asList(state));

    for (int i = 0; i < changed.size(); i++) {
        assertFalse(
            "common:searchable flag is set to false for " + changed.get(i),
            getNodeBooleanProperty(changed.get(i), "common:searchable")
        );
    }

    for (int i = 0; i < changed.size(); i++) {
        assertFalse(
            "common:searchable flag is set to true for " + changed.get(i),
            getNodeBooleanProperty(changed.get(i), "common:searchable")
        );
    }
}
 
开发者ID:NHS-digital-website,项目名称:hippo,代码行数:22,代码来源:DatasetProcessorTest.java

示例6: shouldUpdateDocumentWithGivenStatusTest

import com.tngtech.java.junit.dataprovider.UseDataProvider; //导入依赖的package包/类
@Test
@UseDataProvider("documentState")
public void shouldUpdateDocumentWithGivenStatusTest(final String state, ArrayList<String> changed, ArrayList<String> unchanged) throws Exception {
    // mock query results
    MockJcr.setQueryResult(session, getQueryResults(Arrays.asList(
        RPS_ROOT_FOLDER + "/publication-with-datasets/dataset/dataset",
        RPS_ROOT_FOLDER + "/publication-with-datasets/dataset/dataset[2]",
        RPS_ROOT_FOLDER + "/publication-with-datasets/dataset/dataset[3]"
    )));
    // process publication and datasets
    publicationProcessor.processNode(getNode(RPS_ROOT_FOLDER + "/publication-with-datasets/content"), Arrays.asList(state));

    for (int i = 0; i < changed.size(); i++) {
        assertFalse(
            "common:searchable flag is set to false for " + changed.get(i),
            getNodeBooleanProperty(changed.get(i), "common:searchable")
        );
    }

    for (int i = 0; i < changed.size(); i++) {
        assertFalse(
            "common:searchable flag is set to true for " + changed.get(i),
            getNodeBooleanProperty(changed.get(i), "common:searchable")
        );
    }
}
 
开发者ID:NHS-digital-website,项目名称:hippo,代码行数:27,代码来源:PublicationProcessorTest.java

示例7: chaining_messages

import com.tngtech.java.junit.dataprovider.UseDataProvider; //导入依赖的package包/类
@Test
@UseDataProvider("rules_with_expected_base_description")
public void chaining_messages(SliceRule rule, String baseDescription) {
    assertThat(rule.getDescription()).isEqualTo(baseDescription);

    rule = rule.because("reason one");
    assertThat(rule.getDescription()).isEqualTo(baseDescription + ", because reason one");

    rule = rule.because("reason two");
    assertThat(rule.getDescription()).isEqualTo(baseDescription + ", because reason one, because reason two");

    rule = rule.as("overridden");
    assertThat(rule.getDescription()).isEqualTo("overridden");

    rule = rule.because("new reason");
    assertThat(rule.getDescription()).isEqualTo("overridden, because new reason");
}
 
开发者ID:TNG,项目名称:ArchUnit,代码行数:18,代码来源:SlicesShouldTest.java

示例8: testCreateNewFailedMsgRetryManager

import com.tngtech.java.junit.dataprovider.UseDataProvider; //导入依赖的package包/类
/**
 * Tests that create new deserializer instance works as expected.
 */
@Test
@UseDataProvider("provideFailedMsgRetryManagerClasses")
public void testCreateNewFailedMsgRetryManager(final Class clazz) {
    // Try with UTF8 String deserializer
    final Map config = Maps.newHashMap();
    config.put(SpoutConfig.RETRY_MANAGER_CLASS, clazz.getName());
    final FactoryManager factoryManager = new FactoryManager(config);

    // Create a few instances
    final List<RetryManager> instances = Lists.newArrayList();
    for (int x = 0; x < 5; x++) {
        final RetryManager retryManager = factoryManager.createNewFailedMsgRetryManagerInstance();

        // Validate it
        assertNotNull(retryManager);
        assertEquals("Is correct instance type", retryManager.getClass(), clazz);

        // Verify its a different instance than our previous ones
        assertFalse("Not a previous instance", instances.contains(retryManager));

        // Add to our list
        instances.add(retryManager);
    }
}
 
开发者ID:salesforce,项目名称:storm-dynamic-spout,代码行数:28,代码来源:FactoryManagerTest.java

示例9: testCreateNewMessageBuffer

import com.tngtech.java.junit.dataprovider.UseDataProvider; //导入依赖的package包/类
/**
 * Tests that create new deserializer instance works as expected.
 */
@Test
@UseDataProvider("provideMessageBufferClasses")
public void testCreateNewMessageBuffer(final Class clazz) {
    // Try with UTF8 String deserializer
    final Map config = Maps.newHashMap();
    config.put(SpoutConfig.TUPLE_BUFFER_CLASS, clazz.getName());
    final FactoryManager factoryManager = new FactoryManager(config);

    // Create a few instances
    final List<MessageBuffer> instances = Lists.newArrayList();
    for (int x = 0; x < 5; x++) {
        final MessageBuffer messageBuffer = factoryManager.createNewMessageBufferInstance();

        // Validate it
        assertNotNull(messageBuffer);
        assertEquals("Is correct instance type", messageBuffer.getClass(), clazz);

        // Verify its a different instance than our previous ones
        assertFalse("Not a previous instance", instances.contains(messageBuffer));

        // Add to our list
        instances.add(messageBuffer);
    }
}
 
开发者ID:salesforce,项目名称:storm-dynamic-spout,代码行数:28,代码来源:FactoryManagerTest.java

示例10: testConstructorWithConfigValue

import com.tngtech.java.junit.dataprovider.UseDataProvider; //导入依赖的package包/类
/**
 * Makes sure that we can properly parse long config values on open().
 */
@Test
@UseDataProvider("provideConfigObjects")
public void testConstructorWithConfigValue(Number inputValue) throws InterruptedException {
    logger.info("Testing with object type {} and value {}", inputValue.getClass().getSimpleName(), inputValue);

    // Create config
    Map<String, Object> config = Maps.newHashMap();
    config.put(SpoutConfig.TUPLE_BUFFER_MAX_SIZE, inputValue);

    // Create buffer
    RoundRobinBuffer messageBuffer = new RoundRobinBuffer();
    messageBuffer.open(config);

    // Validate
    assertEquals("Set correct", inputValue.intValue(), messageBuffer.getMaxBufferSizePerVirtualSpout());
}
 
开发者ID:salesforce,项目名称:storm-dynamic-spout,代码行数:20,代码来源:RoundRobinBufferTest.java

示例11: resideInAPackage

import com.tngtech.java.junit.dataprovider.UseDataProvider; //导入依赖的package包/类
@Test
@UseDataProvider("resideInAPackage_rules")
public void resideInAPackage(ArchRule rule, String packageIdentifier) {
    checkTestStillValid(packageIdentifier,
            ImmutableSet.of(ArchRule.class, ArchCondition.class),
            ImmutableSet.<Class<?>>of(ArchConfiguration.class),
            ImmutableSet.<Class<?>>of(GivenObjects.class));

    EvaluationResult result = rule.evaluate(importClasses(
            ArchRule.class, ArchCondition.class, ArchConfiguration.class, GivenObjects.class));

    assertThat(singleLineFailureReportOf(result))
            .contains(String.format("classes should reside in a package '%s'", packageIdentifier))
            .contains(doesntResideInAPackageMessageFor(ArchConfiguration.class, packageIdentifier))
            .contains(doesntResideInAPackageMessageFor(GivenObjects.class, packageIdentifier))
            .doesNotContain(String.format("%s", ArchRule.class.getSimpleName()))
            .doesNotContain(String.format("%s", ArchCondition.class.getSimpleName()));
}
 
开发者ID:TNG,项目名称:ArchUnit,代码行数:19,代码来源:ClassesShouldTest.java

示例12: resideInAnyPackage

import com.tngtech.java.junit.dataprovider.UseDataProvider; //导入依赖的package包/类
@Test
@UseDataProvider("resideInAnyPackage_rules")
public void resideInAnyPackage(ArchRule rule, String... packageIdentifiers) {
    checkTestStillValid(packageIdentifiers,
            ImmutableSet.of(ArchRule.class, ArchConfiguration.class),
            ImmutableSet.<Class<?>>of(GivenObjects.class));

    EvaluationResult result = rule.evaluate(importClasses(
            ArchRule.class, ArchConfiguration.class, GivenObjects.class));

    assertThat(singleLineFailureReportOf(result))
            .contains(String.format("classes should reside in any package ['%s']",
                    Joiner.on("', '").join(packageIdentifiers)))
            .contains(doesntResideInAnyPackageMessageFor(GivenObjects.class, packageIdentifiers))
            .doesNotContain(String.format("%s", ArchRule.class.getSimpleName()))
            .doesNotContain(String.format("%s", ArchConfiguration.class.getSimpleName()));
}
 
开发者ID:TNG,项目名称:ArchUnit,代码行数:18,代码来源:ClassesShouldTest.java

示例13: resideOutsideOfPackage

import com.tngtech.java.junit.dataprovider.UseDataProvider; //导入依赖的package包/类
@Test
@UseDataProvider("resideOutsideOfPackage_rules")
public void resideOutsideOfPackage(ArchRule rule, String packageIdentifier) {
    checkTestStillValid(packageIdentifier,
            ImmutableSet.of(ArchRule.class, ArchCondition.class),
            ImmutableSet.<Class<?>>of(ArchConfiguration.class),
            ImmutableSet.<Class<?>>of(GivenObjects.class));

    EvaluationResult result = rule.evaluate(importClasses(
            ArchRule.class, ArchCondition.class, ArchConfiguration.class, GivenObjects.class));

    assertThat(singleLineFailureReportOf(result))
            .contains(String.format("classes should reside outside of package '%s'", packageIdentifier))
            .contains(doesntResideOutsideOfPackageMessageFor(ArchRule.class, packageIdentifier))
            .contains(doesntResideOutsideOfPackageMessageFor(ArchCondition.class, packageIdentifier))
            .doesNotContain(String.format("%s", ArchConfiguration.class.getSimpleName()))
            .doesNotContain(String.format("%s", GivenObjects.class.getSimpleName()));
}
 
开发者ID:TNG,项目名称:ArchUnit,代码行数:19,代码来源:ClassesShouldTest.java

示例14: rule_has_expected_description_and_can_be_evaluated_without_error

import com.tngtech.java.junit.dataprovider.UseDataProvider; //导入依赖的package包/类
@Test
@UseDataProvider("random_rules")
public void rule_has_expected_description_and_can_be_evaluated_without_error(
        DescribedRule describedRule, String expectedDescription) {
    ArchRule archRule = describedRule.archRule;

    assertThat(archRule.getDescription()).as("description of constructed ArchRule").isEqualTo(expectedDescription);

    archRule.evaluate(importClassesWithContext());
    archRule.check(importClassesWithContext());

    ArchRule overriddenText = archRule.as("overridden rule text");
    assertThat(overriddenText.getDescription()).isEqualTo("overridden rule text");
    assertThat(overriddenText.evaluate(
            importClassesWithContext()).getFailureReport().toString()).contains(
            "overridden rule text");
}
 
开发者ID:TNG,项目名称:ArchUnit,代码行数:18,代码来源:RandomSyntaxTestBase.java

示例15: accessField

import com.tngtech.java.junit.dataprovider.UseDataProvider; //导入依赖的package包/类
@Test
@UseDataProvider("accessField_rules")
public void accessField(ArchRule rule, String accessTypePlural, String accessTypeSingular) {
    EvaluationResult result = rule.evaluate(importClasses(
            ClassWithField.class, ClassAccessingField.class, ClassAccessingWrongField.class));

    assertThat(singleLineFailureReportOf(result))
            .contains(String.format("classes should %s field %s.%s",
                    accessTypePlural, ClassWithField.class.getSimpleName(), "field"))
            .containsPattern(accessesFieldRegex(
                    ClassAccessingWrongField.class, accessTypeSingular,
                    ClassAccessingField.class, "classWithField"))
            .doesNotMatch(accessesFieldRegex(
                    ClassAccessingField.class, accessTypeSingular,
                    ClassWithField.class, "field"));
}
 
开发者ID:TNG,项目名称:ArchUnit,代码行数:17,代码来源:ClassesShouldTest.java


注:本文中的com.tngtech.java.junit.dataprovider.UseDataProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。