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


Java ParameterSignature类代码示例

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


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

示例1: shouldFindPossibleAssignmentsFromMethod

import org.junit.experimental.theories.ParameterSignature; //导入依赖的package包/类
@Test
public void shouldFindPossibleAssignmentsFromMethod() throws Throwable {
    this.assignments = new PotentialAssignments(new TestClass(AssignmentsFromMethod.class));
    final List<Assignment> assignments = this.assignments.allPossible().collect(Collectors.toList());

    assertThat(assignments).hasSize(2);

    ArrayList<ParameterSignature> parameterSignature =
            ParameterSignature.signatures(AssignmentsFromMethod.class.getMethod("a", String.class));

    assertThat(assignments.get(0).isValidFor(parameterSignature.get(0)));
    assertThat(assignments.get(0).parameterProducer().produceParamValue()).isEqualTo("42");

    assertThat(assignments.get(1).isValidFor(parameterSignature.get(0)));
    assertThat(assignments.get(1).parameterProducer().produceParamValue()).isEqualTo("27");
}
 
开发者ID:SeriyBg,项目名称:junit-easy-tools,代码行数:17,代码来源:PotentialAssignmentsTest.java

示例2: getValueSources

import org.junit.experimental.theories.ParameterSignature; //导入依赖的package包/类
@Override
public List<PotentialAssignment> getValueSources(final ParameterSignature param) {
    final ArrayList<PotentialAssignment> list = new ArrayList<>();
    list.add(PotentialAssignment.forValue("", "foo"));
    list.add(PotentialAssignment.forValue("", "bar"));
    list.add(PotentialAssignment.forValue("", "foo"));
    list.add(PotentialAssignment.forValue("", "bar"));
    list.add(PotentialAssignment.forValue("", "foobar"));
    list.add(PotentialAssignment.forValue("", "foobar"));
    list.add(PotentialAssignment.forValue("", "foobar"));
    list.add(PotentialAssignment.forValue("", "whut?"));
    list.add(PotentialAssignment.forValue("", "OMGWTFBBQ"));
    list.add(PotentialAssignment.forValue("", "muahhahahahahahahaha"));
    list.add(PotentialAssignment.forValue("", "ijrobbeoubgt3t9hboebalnpajtih39"));
    list.add(PotentialAssignment.forValue("", "ijrobbeoubgt3t9hboebalnpajtih39"));
    return list;
}
 
开发者ID:RWTH-i5-IDSG,项目名称:jamocha,代码行数:18,代码来源:TestData.java

示例3: addMultiPointMethods

import org.junit.experimental.theories.ParameterSignature; //导入依赖的package包/类
private void addMultiPointMethods(ParameterSignature sig, List<PotentialAssignment> list) throws Throwable {
    for (FrameworkMethod dataPointsMethod : getDataPointsMethods(sig)) {
        Class<?> returnType = dataPointsMethod.getReturnType();
        
        if ((returnType.isArray() && sig.canPotentiallyAcceptType(returnType.getComponentType())) ||
                Iterable.class.isAssignableFrom(returnType)) {
            try {
                addDataPointsValues(returnType, sig, dataPointsMethod.getName(), list, 
                        dataPointsMethod.invokeExplosively(null));
            } catch (Throwable throwable) {
                DataPoints annotation = dataPointsMethod.getAnnotation(DataPoints.class);
                if (annotation != null && isAssignableToAnyOf(annotation.ignoredExceptions(), throwable)) {
                    return;
                } else {
                    throw throwable;
                }
            }
        }
    }
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:21,代码来源:AllMembersSupplier.java

示例4: getSingleDataPointFields

import org.junit.experimental.theories.ParameterSignature; //导入依赖的package包/类
@Override
protected Collection<Field> getSingleDataPointFields(ParameterSignature sig) {
    Collection<Field> fields = super.getSingleDataPointFields(sig);        
    String requestedName = sig.getAnnotation(FromDataPoints.class).value();

    List<Field> fieldsWithMatchingNames = new ArrayList<Field>();
    
    for (Field field : fields) {
        String[] fieldNames = field.getAnnotation(DataPoint.class).value();
        if (Arrays.asList(fieldNames).contains(requestedName)) {
            fieldsWithMatchingNames.add(field);
        }
    }
    
    return fieldsWithMatchingNames;
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:17,代码来源:SpecificDataPointsSupplier.java

示例5: getDataPointsFields

import org.junit.experimental.theories.ParameterSignature; //导入依赖的package包/类
@Override
protected Collection<Field> getDataPointsFields(ParameterSignature sig) {
    Collection<Field> fields = super.getDataPointsFields(sig);        
    String requestedName = sig.getAnnotation(FromDataPoints.class).value();
    
    List<Field> fieldsWithMatchingNames = new ArrayList<Field>();
    
    for (Field field : fields) {
        String[] fieldNames = field.getAnnotation(DataPoints.class).value();
        if (Arrays.asList(fieldNames).contains(requestedName)) {
            fieldsWithMatchingNames.add(field);
        }
    }
    
    return fieldsWithMatchingNames;
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:17,代码来源:SpecificDataPointsSupplier.java

示例6: getSingleDataPointMethods

import org.junit.experimental.theories.ParameterSignature; //导入依赖的package包/类
@Override
protected Collection<FrameworkMethod> getSingleDataPointMethods(ParameterSignature sig) {
    Collection<FrameworkMethod> methods = super.getSingleDataPointMethods(sig);
    String requestedName = sig.getAnnotation(FromDataPoints.class).value();
    
    List<FrameworkMethod> methodsWithMatchingNames = new ArrayList<FrameworkMethod>();
    
    for (FrameworkMethod method : methods) {
        String[] methodNames = method.getAnnotation(DataPoint.class).value();
        if (Arrays.asList(methodNames).contains(requestedName)) {
            methodsWithMatchingNames.add(method);
        }
    }
    
    return methodsWithMatchingNames;
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:17,代码来源:SpecificDataPointsSupplier.java

示例7: getDataPointsMethods

import org.junit.experimental.theories.ParameterSignature; //导入依赖的package包/类
@Override
protected Collection<FrameworkMethod> getDataPointsMethods(ParameterSignature sig) {
    Collection<FrameworkMethod> methods = super.getDataPointsMethods(sig);
    String requestedName = sig.getAnnotation(FromDataPoints.class).value();
    
    List<FrameworkMethod> methodsWithMatchingNames = new ArrayList<FrameworkMethod>();
    
    for (FrameworkMethod method : methods) {
        String[] methodNames = method.getAnnotation(DataPoints.class).value();
        if (Arrays.asList(methodNames).contains(requestedName)) {
            methodsWithMatchingNames.add(method);
        }
    }
    
    return methodsWithMatchingNames;
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:17,代码来源:SpecificDataPointsSupplier.java

示例8: addFields

import org.junit.experimental.theories.ParameterSignature; //导入依赖的package包/类
private void addFields(ParameterSignature sig,
        List<PotentialAssignment> list) {
    for (final Field field : fClass.getJavaClass().getFields()) {
        if (Modifier.isStatic(field.getModifiers())) {
            Class<?> type = field.getType();
            if (sig.canAcceptArrayType(type)
                    && field.getAnnotation(DataPoints.class) != null) {
                try {
                    addArrayValues(field.getName(), list, getStaticFieldValue(field));
                } catch (Throwable e) {
                    // ignore and move on
                }
            } else if (sig.canAcceptType(type)
                    && field.getAnnotation(DataPoint.class) != null) {
                list.add(PotentialAssignment
                        .forValue(field.getName(), getStaticFieldValue(field)));
            }
        }
    }
}
 
开发者ID:lcm-proj,项目名称:lcm,代码行数:21,代码来源:AllMembersSupplier.java

示例9: addFields

import org.junit.experimental.theories.ParameterSignature; //导入依赖的package包/类
private void addFields(final ParameterSignature sig, final List<PotentialAssignment> list) {
	for (final Field field : fClass.getJavaClass().getFields()) {
		if (Modifier.isStatic(field.getModifiers())) {
			Class<?> type = field.getType();
			if (sig.canAcceptArrayType(type) && field.getAnnotation(DataPoints.class) != null) {
				try {
					addArrayValues(field.getName(), list, getStaticFieldValue(field));
				} catch (Throwable e) {
					// ignore and move on
				}
			} else if (sig.canAcceptType(type) && field.getAnnotation(DataPoint.class) != null) {
				list.add(PotentialAssignment.forValue(field.getName(), getStaticFieldValue(field)));
			}
		}
	}
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:17,代码来源:AllMembersSupplier.java

示例10: isValidFor

import org.junit.experimental.theories.ParameterSignature; //导入依赖的package包/类
@Override
public boolean isValidFor(ParameterSignature parameterSignature) {
    if (!isProducerNameValid(parameterSignature.getAnnotation(ProducedValue.class))) {
        return false;
    }
    Class<?> type = field.getField().getType();
    Class<?> aClass = primitiveSupplierToType.get(type);
    if (aClass != null && aClass.equals(parameterSignature.getType())) {
        return true;
    } else {
        Type genericType = field.getField().getGenericType();
        return isValidGenericType(parameterSignature, genericType);
    }
}
 
开发者ID:SeriyBg,项目名称:junit-easy-tools,代码行数:15,代码来源:FieldAssignment.java

示例11: potentialNextParameterProducers

import org.junit.experimental.theories.ParameterSignature; //导入依赖的package包/类
List<ParameterProducer> potentialNextParameterProducers() throws Throwable {
    ParameterSignature next = nextUnassigned();
    return new PotentialAssignments(testClass).allPossible()
            .filter(assignment -> assignment.isValidFor(next))
            .map(Assignment::parameterProducer)
            .collect(Collectors.toList());
}
 
开发者ID:SeriyBg,项目名称:junit-easy-tools,代码行数:8,代码来源:ProducerAssignments.java

示例12: isValidGenericType

import org.junit.experimental.theories.ParameterSignature; //导入依赖的package包/类
boolean isValidGenericType(ParameterSignature parameterSignature, Type genericType) {
    if (genericType instanceof ParameterizedType) {
        ParameterizedType parametrizedType = (ParameterizedType) genericType;
        Type[] actualTypeArguments = parametrizedType.getActualTypeArguments();
        Type actualTypeArgument = actualTypeArguments[0];
        if (parameterSignature.getType().equals(actualTypeArgument)
                || parameterSignature.getType().equals(primitiveSupplierToType.get(actualTypeArgument))) {
            return true;
        }
    }
    return false;
}
 
开发者ID:SeriyBg,项目名称:junit-easy-tools,代码行数:13,代码来源:BasicAssignment.java

示例13: shouldHaveAssignmentsFromField

import org.junit.experimental.theories.ParameterSignature; //导入依赖的package包/类
@Test
public void shouldHaveAssignmentsFromField() throws Throwable {
    this.assignments = new PotentialAssignments(new TestClass(AssignmentsFromField.class));
    List<Assignment> assignments = this.assignments.allPossible().collect(Collectors.toList());
    assertThat(assignments).hasSize(1);

    ArrayList<ParameterSignature> parameterSignature =
            ParameterSignature.signatures(AssignmentsFromField.class.getMethod("a", String.class));

    Assignment assignment = assignments.get(0);
    assertThat(assignment.isValidFor(parameterSignature.get(0))).isTrue();
}
 
开发者ID:SeriyBg,项目名称:junit-easy-tools,代码行数:13,代码来源:PotentialAssignmentsTest.java

示例14: shouldNotBeValidIfTypeDoesNotMatch

import org.junit.experimental.theories.ParameterSignature; //导入依赖的package包/类
@Test
public void shouldNotBeValidIfTypeDoesNotMatch() throws Throwable {
    this.assignments = new PotentialAssignments(new TestClass(AssignmentsFromField.class));
    List<Assignment> assignments = this.assignments.allPossible().collect(Collectors.toList());;

    ArrayList<ParameterSignature> parameterSignature =
            ParameterSignature.signatures(AssignmentsFromField.class.getMethod("b", Integer.TYPE));
    Assignment assignment = assignments.get(0);
    assertThat(assignment.isValidFor(parameterSignature.get(0))).isFalse();
}
 
开发者ID:SeriyBg,项目名称:junit-easy-tools,代码行数:11,代码来源:PotentialAssignmentsTest.java

示例15: getValueSources

import org.junit.experimental.theories.ParameterSignature; //导入依赖的package包/类
@Override
public List<PotentialAssignment> getValueSources(ParameterSignature sig) throws Throwable {

    final List<PotentialAssignment> list = new ArrayList<PotentialAssignment>();

    list.add(PotentialAssignment.forValue("long", 2L));
    list.add(PotentialAssignment.forValue("float", 5.00f));
    list.add(PotentialAssignment.forValue("double", 89d));

    return list;
}
 
开发者ID:tvajjala,项目名称:interview-preparation,代码行数:12,代码来源:NumberSupplier.java


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