idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
37,300
protected int findMember ( String name ) { int memberCount = name == null ? 0 : members_ . size ( ) ; int i ; for ( i = 0 ; i < memberCount && ! name . equals ( members_ . get ( i ) . getName ( ) ) ; i ++ ) ; return i < memberCount ? i : - 1 ; }
Returns the index of the member variable with the given name .
37,301
public static < T > Stream < T > toStream ( Iterator < T > iterator ) { Iterable < T > iterable = ( ) -> iterator ; return toStream ( iterable ) ; }
Returns a stream that produces the sequence defined by the given Iterator .
37,302
public static < T > List < T > iterableOf ( Optional < T > value ) { return value . map ( Arrays :: asList ) . orElse ( Collections . emptyList ( ) ) ; }
If the given value is present returns it as a singleton list . Otherwise returns an empty list .
37,303
public static < T > Stream < T > streamOf ( Optional < T > value ) { return value . map ( Stream :: of ) . orElse ( Stream . empty ( ) ) ; }
If the given value is present returns it as a single - element stream . Otherwise returns an empty stream .
37,304
public static < T , C extends Collection < T > > Stream < T > membersOf ( C collection ) { return collection == null ? Stream . empty ( ) : collection . stream ( ) ; }
Returns a stream containing the members of the given collection .
37,305
public static < K , V , M extends Map < K , V > > Stream < Map . Entry < K , V > > entriesOf ( M map ) { return map == null ? Stream . empty ( ) : map . entrySet ( ) . stream ( ) ; }
Returns a stream containing the entries of the given map .
37,306
protected InputStream open ( ) { try { if ( getType ( ) == null ) { throw new IllegalStateException ( String . format ( "Unknown type for %s" , this ) ) ; } URL location = getLocation ( ) ; return location == null ? System . in : ( stream_ = location . openStream ( ) ) ; } catch ( Exception e ) { throw new IllegalState...
Opens a stream to read the contents of this resource .
37,307
public static < T extends Resource > T withDefaultType ( T resource , Type defaultType ) { if ( resource . getType ( ) == null ) { resource . setType ( defaultType ) ; } return resource ; }
Returns the given resource assigning the default type if no type yet defined .
37,308
public static File withDefaultType ( File file , Type defaultType ) { return file != null && FilenameUtils . getExtension ( file . getName ( ) ) . isEmpty ( ) ? new File ( String . format ( "%s.%s" , file . getPath ( ) , String . valueOf ( defaultType ) . toLowerCase ( ) ) ) : file ; }
Returns the given file name assigning the default type if no type defined .
37,309
public VarValueDef addProperties ( Collection < String > properties ) { if ( properties != null ) { assertPropertyIdentifiers ( properties ) ; properties_ . addAll ( properties ) ; } return this ; }
Adds to the set of test case properties contributed by this value .
37,310
public void write ( Project project ) { JsonWriterFactory writerFactory = Json . createWriterFactory ( MapBuilder . of ( PRETTY_PRINTING , true ) . build ( ) ) ; JsonWriter jsonWriter = writerFactory . createWriter ( getWriter ( ) ) ; jsonWriter . write ( ProjectJson . toJson ( project ) ) ; }
Writes the given project definition the form of a JSON document .
37,311
public static Tuple of ( Collection < VarBindingDef > tupleBindings ) { Tuple tuple = new Tuple ( ) ; boolean bindingsCompatible ; Iterator < VarBindingDef > bindings ; VarBindingDef nextBinding ; for ( bindings = tupleBindings . iterator ( ) , bindingsCompatible = true ; bindings . hasNext ( ) && ( bindingsCompatible ...
Returns null if all of the given bindings cannot be included in compatible Tuple . Otherwise returns a new compatible Tuple containing all of the given bindings .
37,312
private static boolean isBindingCompatible ( Tuple tuple , VarBindingDef binding ) { VarValueDef currentValue = tuple . getBinding ( binding . getVarDef ( ) ) ; return ( currentValue == null || currentValue . equals ( binding . getValueDef ( ) ) ) ; }
Returns true if the given binding can be added to the give tuple .
37,313
public void setBindings ( Collection < VarBindingDef > bindings ) { bindings_ = new HashMap < VarDef , VarBindingDef > ( ) ; properties_ = new PropertySet ( ) ; if ( bindings != null ) { for ( VarBindingDef binding : bindings ) { add ( binding ) ; } } }
Changes the variable bindings for this tuple .
37,314
public VarValueDef getBinding ( VarDef var ) { VarBindingDef binding = bindings_ . get ( var ) ; return binding == null ? null : binding . getValueDef ( ) ; }
Returns the value bound by this tuple for the given variable .
37,315
public Tuple add ( VarBindingDef binding ) { if ( binding != null ) { VarDef var = binding . getVarDef ( ) ; if ( var == null ) { throw new IllegalArgumentException ( "Invalid binding=" + binding + ": variable undefined" ) ; } VarValueDef value = binding . getValueDef ( ) ; if ( value == null ) { throw new IllegalArgum...
Adds a binding to this tuple .
37,316
public Tuple addAll ( Tuple tuple ) { if ( tuple != null ) { for ( Iterator < VarBindingDef > bindings = tuple . getBindings ( ) ; bindings . hasNext ( ) ; ) { add ( bindings . next ( ) ) ; } } return this ; }
Adds all bindings from the given tuple .
37,317
public Tuple remove ( VarDef var ) { VarBindingDef binding = bindings_ . remove ( var ) ; if ( binding != null ) { properties_ . removeAll ( binding . getValueDef ( ) . getProperties ( ) . iterator ( ) ) ; } return this ; }
Removes a binding from this tuple .
37,318
public boolean isCompatible ( ) { boolean compatible ; Iterator < VarBindingDef > bindings ; VarBindingDef binding = null ; for ( compatible = true , bindings = getBindings ( ) ; compatible && bindings . hasNext ( ) ; compatible = ( binding = bindings . next ( ) ) . getEffectiveCondition ( ) . compatible ( properties_ ...
Returns true if this tuple contains compatible variable bindings .
37,319
private boolean makeSatisfied ( TestCaseDef testCase , VarTupleSet tuples ) { boolean satisfied = testCase . isSatisfied ( ) ; if ( ! satisfied ) { int prevBindings = testCase . getBindingCount ( ) ; for ( Iterator < Tuple > satisfyingTuples = getSatisfyingTuples ( testCase , tuples ) ; satisfyingTuples . hasNext ( ) &...
Using selections from the given set of tuples completes bindings to satisfy all current test case conditions . Returns true if and only if all conditions satisfied .
37,320
private boolean makeSatisfied ( TestCaseDef testCase , VarTupleSet tuples , Tuple satisfyingTuple ) { return testCase . addCompatible ( satisfyingTuple ) != null && ! testCase . isInfeasible ( ) && makeSatisfied ( testCase , tuples ) ; }
Starting with the given tuple completes bindings to satisfy all current test case conditions using additional selections from the given set of tuples if necessary . Returns true if and only if all conditions satisfied .
37,321
private Iterator < Tuple > getBindingsFor ( VarTupleSet tuples , VarDef var ) { return IteratorUtils . chainedIterator ( tuples . getUnused ( var ) , IteratorUtils . chainedIterator ( tuples . getUsed ( var ) , tuples . getUsedOnce ( var ) ) ) ; }
Returns a set of 1 - tuples containing the bindings for the given variable that are applicable to the given test case .
37,322
private Iterator < Tuple > getSatisfyingTuples ( final TestCaseDef testCase , VarTupleSet varTupleSet ) { final Comparator < VarBindingDef > byUsage = byUsage ( varTupleSet ) ; return IteratorUtils . transformedIterator ( new CartesianProduct < VarBindingDef > ( new ArrayList < Set < VarBindingDef > > ( CollectionUtils...
Returns the set of tuples that could satisfy conditions required by the given test case .
37,323
private List < VarDef > getVarsRemaining ( FunctionInputDef inputDef , TestCaseDef testCase ) { return getVarsRemaining ( new VarDefIterator ( inputDef ) , testCase ) ; }
Returns the set of input variables not yet bound by the given test case .
37,324
private VarTupleSet getValidTupleSet ( RandSeq randSeq , FunctionInputDef inputDef ) { List < Tuple > validTuples = new ArrayList < Tuple > ( ) ; getCombiners ( ) . stream ( ) . sorted ( byTupleSize_ ) . forEach ( combiner -> validTuples . addAll ( RandSeq . order ( randSeq , combiner . getTuples ( inputDef ) ) ) ) ; L...
Returns the all valid input tuples required for generated test cases .
37,325
private Collection < Tuple > getUncombinedTuples ( List < VarDef > uncombinedVars , int defaultTupleSize ) { Collection < Tuple > tuples = TupleCombiner . getTuples ( uncombinedVars , defaultTupleSize ) ; if ( defaultTupleSize == 1 ) { for ( Tuple tuple : tuples ) { VarValueDef value = tuple . getBindings ( ) . next ( ...
Returns default tuples for all uncombined variables .
37,326
private VarTupleSet getFailureTupleSet ( RandSeq randSeq , FunctionInputDef inputDef ) { List < Tuple > failureTuples = new ArrayList < Tuple > ( ) ; for ( VarDefIterator vars = new VarDefIterator ( inputDef ) ; vars . hasNext ( ) ; ) { VarDef var = vars . next ( ) ; for ( Iterator < VarValueDef > failures = var . getF...
Returns the all failure input tuples required for generated test cases .
37,327
private MultiValuedMap < String , VarBindingDef > createPropertyProviders ( FunctionInputDef inputDef ) { propertyProviders_ = MultiMapUtils . newListValuedHashMap ( ) ; for ( VarDefIterator varDefs = new VarDefIterator ( inputDef . getVarDefs ( ) ) ; varDefs . hasNext ( ) ; ) { VarDef varDef = varDefs . next ( ) ; for...
Return a map that associates each value property with the set of bindings that provide it .
37,328
private Set < VarBindingDef > getPropertyProviders ( Set < String > properties ) { Set < VarBindingDef > bindings = new HashSet < VarBindingDef > ( ) ; for ( String property : properties ) { bindings . addAll ( propertyProviders_ . get ( property ) ) ; } return bindings ; }
Returns the set of bindings that provide at least one of the given properties
37,329
private Comparator < VarBindingDef > byUsage ( final VarTupleSet varTupleSet ) { return new Comparator < VarBindingDef > ( ) { public int compare ( VarBindingDef binding1 , VarBindingDef binding2 ) { int resultScore = getScore ( binding2 ) . compareTo ( getScore ( binding1 ) ) ; return resultScore == 0 ? varBindingDefS...
Returns a comparator that orders bindings by decreasing preference preferring bindings that are less used .
37,330
public GeneratorSetBuilder generator ( String functionName , ITestCaseGenerator generator ) { generatorSet_ . addGenerator ( functionName , generator ) ; return this ; }
Adds a generator to this set for the given function .
37,331
public VarBindingBuilder start ( VarBinding binding ) { varBinding_ = binding == null ? new VarBinding ( "V" , IVarDef . ARG , "?" ) : binding ; return this ; }
Starts building a new binding .
37,332
public VarBindingBuilder has ( String name , Object value ) { varBinding_ . setAnnotation ( name , Objects . toString ( value , null ) ) ; return this ; }
Adds a binding annotation .
37,333
public VarBindingBuilder hasIf ( String name , Object value ) { return value != null ? has ( name , value ) : this ; }
Adds a binding annotation if the given value is non - null
37,334
public VarValueDefBuilder has ( String name , Object value ) { varValueDef_ . setAnnotation ( name , Objects . toString ( value , null ) ) ; return this ; }
Adds a value annotation .
37,335
public VarValueDefBuilder hasIf ( String name , Object value ) { return value != null ? has ( name , value ) : this ; }
Adds a value annotation if the given value is non - null
37,336
public VarValueDefBuilder hasIf ( String name , Optional < Object > value ) { return hasIf ( name , value . orElse ( null ) ) ; }
Adds a value annotation if the given value is defined
37,337
public VarValueDefBuilder properties ( Optional < String > property ) { property . ifPresent ( p -> varValueDef_ . addProperties ( p ) ) ; return this ; }
Adds a value property if present .
37,338
public VarSetBuilder has ( String name , Object value ) { varSet_ . setAnnotation ( name , Objects . toString ( value , null ) ) ; return this ; }
Adds a variable set annotation .
37,339
public VarSetBuilder hasIf ( String name , Object value ) { return value != null ? has ( name , value ) : this ; }
Adds a variable set annotation if the given value is non - null
37,340
public static JsonObject toJson ( SystemInputDef systemInput ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; builder . add ( SYSTEM_KEY , systemInput . getName ( ) ) ; addAnnotations ( builder , systemInput ) ; toStream ( systemInput . getFunctionInputDefs ( ) ) . forEach ( function -> builder . add ( ...
Returns the JSON object that represents the given system input definition .
37,341
private static JsonStructure toJson ( FunctionInputDef functionInput ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; addAnnotations ( builder , functionInput ) ; Arrays . stream ( functionInput . getVarTypes ( ) ) . forEach ( varType -> builder . add ( varType , toJson ( functionInput , varType ) ) ) ;...
Returns the JSON object that represents the given function input definition .
37,342
private static JsonStructure toJson ( FunctionInputDef functionInput , String varType ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; toStream ( functionInput . getVarDefs ( ) ) . filter ( varDef -> varDef . getType ( ) . equals ( varType ) ) . sorted ( ) . forEach ( varDef -> builder . add ( varDef . ...
Returns the JSON object that represents the function variables of the given type .
37,343
private static JsonStructure toJson ( IVarDef varDef ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; addAnnotations ( builder , varDef ) ; ConditionJson . toJson ( varDef ) . ifPresent ( json -> builder . add ( WHEN_KEY , json ) ) ; if ( varDef . getValues ( ) != null ) { JsonObjectBuilder valuesBuilde...
Returns the JSON object that represents the given variable definition .
37,344
private static JsonStructure toJson ( VarValueDef value ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; if ( value . getType ( ) . equals ( FAILURE ) ) { builder . add ( FAILURE_KEY , true ) ; } else if ( value . getType ( ) . equals ( ONCE ) ) { builder . add ( ONCE_KEY , true ) ; } addAnnotations ( b...
Returns the JSON object that represents the given value definition .
37,345
private static JsonObjectBuilder addAnnotations ( JsonObjectBuilder builder , IAnnotated annotated ) { JsonObjectBuilder annotations = Json . createObjectBuilder ( ) ; toStream ( annotated . getAnnotations ( ) ) . forEach ( name -> annotations . add ( name , annotated . getAnnotation ( name ) ) ) ; JsonObject json = an...
Add any annotatations from the given Annotated object to the given JsonObjectBuilder .
37,346
private static JsonObjectBuilder addProperties ( JsonObjectBuilder builder , VarValueDef value ) { JsonArrayBuilder properties = Json . createArrayBuilder ( ) ; value . getProperties ( ) . forEach ( property -> properties . add ( property ) ) ; JsonArray json = properties . build ( ) ; if ( ! json . isEmpty ( ) ) { bui...
Add any properties from the given value to the given JsonObjectBuilder .
37,347
public static SystemInputDef asSystemInputDef ( JsonObject json ) { String systemName = json . getString ( SYSTEM_KEY ) ; try { SystemInputDef systemInputDef = new SystemInputDef ( validIdentifier ( systemName ) ) ; Optional . ofNullable ( json . getJsonObject ( HAS_KEY ) ) . ifPresent ( has -> has . keySet ( ) . strea...
Returns the SystemInputDef represented by the given JSON object .
37,348
private static FunctionInputDef asFunctionInputDef ( String functionName , JsonObject json ) { FunctionInputDef functionInputDef ; try { functionInputDef = new FunctionInputDef ( validIdentifier ( functionName ) ) ; Optional . ofNullable ( json . getJsonObject ( HAS_KEY ) ) . ifPresent ( has -> has . keySet ( ) . strea...
Returns the FunctionInputDef represented by the given JSON object .
37,349
private static Stream < IVarDef > getVarDefs ( String varType , JsonObject json ) { try { Annotated groupAnnotations = new Annotated ( ) { } ; Optional . ofNullable ( json . getJsonObject ( HAS_KEY ) ) . ifPresent ( has -> has . keySet ( ) . stream ( ) . forEach ( key -> groupAnnotations . setAnnotation ( key , has . g...
Returns the variable definitions represented by the given JSON object .
37,350
private static IVarDef asVarDef ( String varName , String varType , Annotated groupAnnotations , JsonObject json ) { try { validIdentifier ( varName ) ; AbstractVarDef varDef = json . containsKey ( MEMBERS_KEY ) ? new VarSet ( varName ) : new VarDef ( varName ) ; varDef . setType ( varType ) ; Optional . ofNullable ( j...
Returns the variable definition represented by the given JSON object .
37,351
private static Stream < VarValueDef > getValueDefs ( JsonObject json ) { return json . keySet ( ) . stream ( ) . map ( valueName -> asValueDef ( valueName , json . getJsonObject ( valueName ) ) ) ; }
Returns the value definitions represented by the given JSON object .
37,352
private static VarValueDef asValueDef ( String valueName , JsonObject json ) { try { VarValueDef valueDef = new VarValueDef ( ObjectUtils . toObject ( valueName ) ) ; boolean failure = json . getBoolean ( FAILURE_KEY , false ) ; boolean once = json . getBoolean ( ONCE_KEY , false ) ; valueDef . setType ( failure ? VarV...
Returns the value definition represented by the given JSON object .
37,353
private static Optional < ICondition > asContainsAll ( JsonObject json ) { return json . containsKey ( HAS_ALL_KEY ) ? Optional . of ( new ContainsAll ( toIdentifiers ( json . getJsonArray ( HAS_ALL_KEY ) ) ) ) : Optional . empty ( ) ; }
Returns the ContainsAll condition represented by the given JSON object or an empty value if no such condition is found .
37,354
private static Optional < ICondition > asContainsAny ( JsonObject json ) { return json . containsKey ( HAS_ANY_KEY ) ? Optional . of ( new ContainsAny ( toIdentifiers ( json . getJsonArray ( HAS_ANY_KEY ) ) ) ) : Optional . empty ( ) ; }
Returns the ContainsAny condition represented by the given JSON object or an empty value if no such condition is found .
37,355
private static Optional < ICondition > asNot ( JsonObject json ) { return json . containsKey ( NOT_KEY ) ? Optional . of ( new Not ( asCondition ( json . getJsonObject ( NOT_KEY ) ) ) ) : Optional . empty ( ) ; }
Returns the Not condition represented by the given JSON object or an empty value if no such condition is found .
37,356
private static Optional < ICondition > asAllOf ( JsonObject json ) { return json . containsKey ( ALL_OF_KEY ) ? Optional . of ( new AllOf ( toConditions ( json . getJsonArray ( ALL_OF_KEY ) ) ) ) : Optional . empty ( ) ; }
Returns the AllOf condition represented by the given JSON object or an empty value if no such condition is found .
37,357
private static Optional < ICondition > asAnyOf ( JsonObject json ) { return json . containsKey ( ANY_OF_KEY ) ? Optional . of ( new AnyOf ( toConditions ( json . getJsonArray ( ANY_OF_KEY ) ) ) ) : Optional . empty ( ) ; }
Returns the AnyOf condition represented by the given JSON object or an empty value if no such condition is found .
37,358
private static Optional < ICondition > asLessThan ( JsonObject json ) { return Optional . of ( json ) . filter ( j -> j . containsKey ( LESS_THAN_KEY ) ) . map ( j -> j . getJsonObject ( LESS_THAN_KEY ) ) . map ( a -> new AssertLess ( a . getString ( PROPERTY_KEY ) , a . getInt ( MAX_KEY ) ) ) ; }
Returns the AssertLess condition represented by the given JSON object or an empty value if no such condition is found .
37,359
private static Optional < ICondition > asMoreThan ( JsonObject json ) { return Optional . of ( json ) . filter ( j -> j . containsKey ( MORE_THAN_KEY ) ) . map ( j -> j . getJsonObject ( MORE_THAN_KEY ) ) . map ( a -> new AssertMore ( a . getString ( PROPERTY_KEY ) , a . getInt ( MIN_KEY ) ) ) ; }
Returns the AssertMore condition represented by the given JSON object or an empty value if no such condition is found .
37,360
private static Optional < ICondition > asNotLessThan ( JsonObject json ) { return Optional . of ( json ) . filter ( j -> j . containsKey ( NOT_LESS_THAN_KEY ) ) . map ( j -> j . getJsonObject ( NOT_LESS_THAN_KEY ) ) . map ( a -> new AssertNotLess ( a . getString ( PROPERTY_KEY ) , a . getInt ( MIN_KEY ) ) ) ; }
Returns the AssertNotLess condition represented by the given JSON object or an empty value if no such condition is found .
37,361
private static Optional < ICondition > asNotMoreThan ( JsonObject json ) { return Optional . of ( json ) . filter ( j -> j . containsKey ( NOT_MORE_THAN_KEY ) ) . map ( j -> j . getJsonObject ( NOT_MORE_THAN_KEY ) ) . map ( a -> new AssertNotMore ( a . getString ( PROPERTY_KEY ) , a . getInt ( MAX_KEY ) ) ) ; }
Returns the AssertNotMore condition represented by the given JSON object or an empty value if no such condition is found .
37,362
private static Optional < ICondition > asBetween ( JsonObject json ) { return Optional . of ( json ) . filter ( j -> j . containsKey ( BETWEEN_KEY ) ) . map ( j -> j . getJsonObject ( BETWEEN_KEY ) ) . map ( b -> new Between ( b . containsKey ( EXCLUSIVE_MIN_KEY ) ? new AssertMore ( b . getString ( PROPERTY_KEY ) , b ....
Returns the between condition represented by the given JSON object or an empty value if no such condition is found .
37,363
private static Optional < ICondition > asEquals ( JsonObject json ) { return Optional . of ( json ) . filter ( j -> j . containsKey ( EQUALS_KEY ) ) . map ( j -> j . getJsonObject ( EQUALS_KEY ) ) . map ( e -> new Equals ( e . getString ( PROPERTY_KEY ) , e . getInt ( COUNT_KEY ) ) ) ; }
Returns the equals condition represented by the given JSON object or an empty value if no such condition is found .
37,364
private static List < String > toIdentifiers ( JsonArray array ) { return IntStream . range ( 0 , array . size ( ) ) . mapToObj ( i -> validIdentifier ( array . getString ( i ) ) ) . collect ( toList ( ) ) ; }
Returns the contents of the given JSON array as a list of identifiers .
37,365
private static ICondition [ ] toConditions ( JsonArray array ) { return IntStream . range ( 0 , array . size ( ) ) . mapToObj ( i -> asCondition ( array . getJsonObject ( i ) ) ) . collect ( toList ( ) ) . toArray ( new ICondition [ 0 ] ) ; }
Returns the contents of the given JSON array as an array of conditions .
37,366
public ICondition getEffectiveCondition ( ICondition contextCondition ) { ICondition condition = getCondition ( ) ; ICondition effCondition ; if ( condition == null && contextCondition == null ) { effCondition = ICondition . ALWAYS ; } else if ( condition == null && contextCondition != null ) { effCondition = contextCo...
Returns the effective condition that defines when this element is applicable given the specified context condition .
37,367
public SystemInputDef addFunctionInputDef ( FunctionInputDef functionInputDef ) { assert functionInputDef != null ; assert functionInputDef . getName ( ) != null ; if ( findFunctionInputDef ( functionInputDef . getName ( ) ) >= 0 ) { throw new IllegalStateException ( "Function=" + functionInputDef . getName ( ) + " alr...
Adds a new function definition .
37,368
public SystemInputDef removeFunctionInputDef ( String name ) { int i = findFunctionInputDef ( name ) ; if ( i >= 0 ) { functionInputDefs_ . remove ( i ) ; } return this ; }
Removes a function definition .
37,369
public FunctionInputDef getFunctionInputDef ( String name ) { int i = findFunctionInputDef ( name ) ; return i >= 0 ? functionInputDefs_ . get ( i ) : null ; }
Returns the function definition with the given name .
37,370
protected int findFunctionInputDef ( String name ) { int functionCount = name == null ? 0 : functionInputDefs_ . size ( ) ; int i ; for ( i = 0 ; i < functionCount && ! name . equals ( functionInputDefs_ . get ( i ) . getName ( ) ) ; i ++ ) ; return i < functionCount ? i : - 1 ; }
Returns the index of the function definition with the given name .
37,371
private Tuple getNextTuple ( ) { if ( nextTuple_ == null ) { int tupleSize = getTupleSize ( ) ; if ( ! ( values_ != null && values_ . hasNext ( ) ) ) { values_ = null ; subTuple_ = null ; if ( ! ( subTuples_ != null && subTuples_ . hasNext ( ) ) ) { subTuples_ = null ; varStart_ ++ ; if ( tupleSize > 1 ) { for ( ; varS...
Returns the next N - tuple of compatible values .
37,372
private String getProjectFile ( String projectName , String filePattern ) { String projectFile = null ; if ( ! StringUtils . isBlank ( filePattern ) ) { Matcher matcher = projectFilePattern_ . matcher ( filePattern ) ; if ( matcher . matches ( ) ) { projectFile = StringUtils . isBlank ( matcher . group ( 2 ) ) ? filePa...
Returns the file name defined by applying the given pattern to the project name . Returns null if the file pattern is invalid .
37,373
private File getBaseDir ( File path ) { return path == null ? baseDir_ : path . isAbsolute ( ) ? path : new File ( baseDir_ , path . getPath ( ) ) ; }
If the given path is not absolute returns it as an absolute path relative to the project base directory . Otherwise returns the given absolute path .
37,374
private File getTargetDir ( File path ) { return path == null ? targetDir_ : path . isAbsolute ( ) ? path : new File ( targetDir_ , path . getPath ( ) ) ; }
If the given path is not absolute returns it as an absolute path relative to the project target directory . Otherwise returns the given absolute path .
37,375
public void setAnnotation ( String name , String value ) { String annotation = StringUtils . trimToNull ( name ) ; if ( annotation == null ) { throw new IllegalArgumentException ( "Annotation name must be non-blank" ) ; } if ( value == null ) { annotations_ . remove ( annotation ) ; } else { annotations_ . put ( annota...
Changes the value of the given annotation .
37,376
public void addAnnotations ( Annotated other ) { for ( Iterator < String > otherAnnotations = other . getAnnotations ( ) ; otherAnnotations . hasNext ( ) ; ) { String name = otherAnnotations . next ( ) ; if ( getAnnotation ( name ) == null ) { setAnnotation ( name , other . getAnnotation ( name ) ) ; } } }
Adds annotations from another annotated element . This leaves all existing annotation unchanged adding only annotations not already defined .
37,377
public TupleRef addVarBinding ( VarBinding varBinding ) { assert varBinding != null ; assert varBinding . getVar ( ) != null ; String varName = varBinding . getVar ( ) ; if ( varBindings_ . containsKey ( varName ) ) { throw new IllegalStateException ( "Value for " + varName + " already defined" ) ; } varBindings_ . put...
Adds a new variable binding .
37,378
public static void writeGenerators ( IGeneratorSet generators , OutputStream outputStream ) { try ( GeneratorSetJsonWriter writer = new GeneratorSetJsonWriter ( outputStream ) ) { writer . write ( generators ) ; } catch ( Exception e ) { throw new RuntimeException ( "Can't write generator definitions" , e ) ; } }
Writes a JSON document describing the given generator definitions to the given output stream .
37,379
private boolean isYaml ( ) { String extension = getLocation ( ) == null ? null : FilenameUtils . getExtension ( getLocation ( ) . getPath ( ) ) . toLowerCase ( ) ; return "yml" . equals ( extension ) || "yaml" . equals ( extension ) ; }
Returns true if this is a YAML document .
37,380
private static URL toUrl ( File file ) { try { return file == null ? null : file . toURI ( ) . toURL ( ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Can't get URL for file=" + file ) ; } }
Returns a URL for the given file .
37,381
private static InputStream inputFor ( File file ) { try { return file == null ? null : new FileInputStream ( file ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Can't open file=" + file ) ; } }
Returns an InputStream for the given file .
37,382
public SystemInputDefBuilder has ( String name , Object value ) { systemInputDef_ . setAnnotation ( name , Objects . toString ( value , null ) ) ; return this ; }
Adds a system annotation .
37,383
public SystemInputDefBuilder hasIf ( String name , Object value ) { return value != null ? has ( name , value ) : this ; }
Adds a system annotation if the given value is non - null
37,384
public BoundedAssertion getMin ( ) { ICondition min = null ; Iterator < ICondition > conditions = getConditions ( ) ; for ( int i = 0 ; i < 1 ; i ++ ) min = conditions . next ( ) ; return ( BoundedAssertion ) min ; }
Returns the minimum condition .
37,385
public BoundedAssertion getMax ( ) { ICondition max = null ; Iterator < ICondition > conditions = getConditions ( ) ; for ( int i = 0 ; i < 2 ; i ++ ) max = conditions . next ( ) ; return ( BoundedAssertion ) max ; }
Returns the maximum condition .
37,386
public FunctionInputDefBuilder vars ( String type , AbstractVarDef ... vars ) { for ( AbstractVarDef var : vars ) { var . setType ( type ) ; functionInputDef_ . addVarDef ( var ) ; } return this ; }
Adds function input variables of the given type .
37,387
public FunctionInputDefBuilder has ( String name , Object value ) { functionInputDef_ . setAnnotation ( name , Objects . toString ( value , null ) ) ; return this ; }
Adds a function annotation .
37,388
public FunctionInputDefBuilder hasIf ( String name , Object value ) { return value != null ? has ( name , value ) : this ; }
Adds a function annotation if the given value is non - null
37,389
public static < T > ListBuilder < T > to ( List < T > list ) { return new ListBuilder < T > ( list ) ; }
Creates a new ListBuilder object .
37,390
public ListBuilder < T > addAll ( Iterable < T > elements ) { for ( T element : elements ) { list_ . add ( element ) ; } return this ; }
Appends all elements of the given colletion to the list for this builder .
37,391
public Iterator < Tuple > getUsed ( ) { if ( usedChanged_ ) { Collections . sort ( used_ , tupleSizeDescending_ ) ; usedChanged_ = false ; } return used_ . iterator ( ) ; }
Returns input tuples already used in a test case .
37,392
private Iterator < Tuple > getBinds ( Iterator < Tuple > tuples , final VarDef var ) { return IteratorUtils . filteredIterator ( tuples , tuple -> tuple . getBinding ( var ) != null ) ; }
Returns input tuples that bind the given variable .
37,393
public void used ( final TestCaseDef testCase ) { List < Tuple > usedTuples = IteratorUtils . toList ( IteratorUtils . filteredIterator ( IteratorUtils . chainedIterator ( unused_ . iterator ( ) , used_ . iterator ( ) ) , tuple -> testCase . usesTuple ( tuple ) ) ) ; for ( Tuple tuple : usedTuples ) { used ( tuple ) ; ...
Asserts use of all tuples contained in the given test case .
37,394
public void used ( Tuple tuple ) { int i = unused_ . indexOf ( tuple ) ; if ( i >= 0 ) { unused_ . remove ( i ) ; addUsed ( tuple ) ; if ( tuple . size ( ) > 1 ) { for ( Iterator < VarBindingDef > bindings = tuple . getBindings ( ) ; bindings . hasNext ( ) ; ) { Tuple tuple1 = new Tuple ( bindings . next ( ) ) ; tuple1...
Asserts that the given tuple has been used in a test case .
37,395
public void remove ( Tuple tuple ) { int i = unused_ . indexOf ( tuple ) ; if ( i >= 0 ) { unused_ . remove ( tuple ) ; } }
Removes the given tuple from use in test cases .
37,396
public Tuple getNextUnused ( ) { Iterator < Tuple > unused = getUnused ( ) ; return unused . hasNext ( ) ? unused . next ( ) : null ; }
Returns the next unused tuple from this set . Returns null if all tuples have been used .
37,397
public VarDefBuilder has ( String name , Object value ) { varDef_ . setAnnotation ( name , Objects . toString ( value , null ) ) ; return this ; }
Adds a variable annotation .
37,398
public VarDefBuilder hasIf ( String name , Object value ) { return value != null ? has ( name , value ) : this ; }
Adds a variable annotation if the given value is non - null
37,399
private static String errorReasonFor ( URL location , List < String > errors ) { return Stream . concat ( Stream . of ( String . format ( "%s conformance problem(s) found in Open API document%s" , errors . size ( ) , locationId ( location ) ) ) , IntStream . range ( 0 , errors . size ( ) ) . mapToObj ( i -> String . fo...
Returns a reason for the errors in the document at the given location .