idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
36,400
public T findElement ( By by , int index ) { T element = null ; List < T > elements = findElements ( by ) ; if ( elements . size ( ) > index ) { element = elements . get ( index ) ; } return element ; }
Finds the nth element matching the By supplied .
55
11
36,401
public < T > T waitUntil ( int maxSecondsToWait , ExpectedCondition < T > condition ) { ExpectedCondition < T > cHandlingStale = getConditionIgnoringStaleElement ( condition ) ; FluentWait < WebDriver > wait = waitDriver ( ) . withTimeout ( Duration . ofSeconds ( maxSecondsToWait ) ) ; return wait . until ( cHandlingSt...
Executes condition until it returns a value other than null or false . It does not forward StaleElementReferenceExceptions but keeps waiting .
91
28
36,402
public boolean isStaleElementException ( WebDriverException e ) { boolean result = false ; if ( e instanceof StaleElementReferenceException ) { result = true ; } else { String msg = e . getMessage ( ) ; if ( msg != null ) { result = msg . contains ( "Element does not exist in cache" ) // Safari stale element || msg . c...
Check whether exception indicates a stale element not all drivers throw the exception one would expect ...
160
17
36,403
public byte [ ] findScreenshot ( Throwable t ) { byte [ ] result = null ; if ( t != null ) { if ( t instanceof ScreenshotException ) { String encodedScreenshot = ( ( ScreenshotException ) t ) . getBase64EncodedScreenshot ( ) ; result = Base64 . getDecoder ( ) . decode ( encodedScreenshot ) ; } else { result = findScree...
Finds screenshot embedded in throwable if any .
97
10
36,404
public void switchToFrame ( T iframe ) { getTargetLocator ( ) . frame ( iframe ) ; setCurrentContext ( null ) ; currentIFramePath . add ( iframe ) ; }
Activates specified child frame of current iframe .
43
10
36,405
public void copySeleniumCookies ( Set < Cookie > browserCookies , CookieStore cookieStore ) { for ( Cookie browserCookie : browserCookies ) { ClientCookie cookie = convertCookie ( browserCookie ) ; cookieStore . addCookie ( cookie ) ; } }
Converts Selenium cookies to Apache http client ones .
60
11
36,406
protected ClientCookie convertCookie ( Cookie browserCookie ) { BasicClientCookie cookie = new BasicClientCookie ( browserCookie . getName ( ) , browserCookie . getValue ( ) ) ; String domain = browserCookie . getDomain ( ) ; if ( domain != null && domain . startsWith ( "." ) ) { // http client does not like domains st...
Converts Selenium cookie to Apache http client .
193
10
36,407
public T waitForRequest ( long maxWait ) { long start = System . currentTimeMillis ( ) ; try { while ( requestsReceived . get ( ) < 1 && ( System . currentTimeMillis ( ) - start ) < maxWait ) { try { Thread . sleep ( 50 ) ; } catch ( InterruptedException ex ) { throw new RuntimeException ( ex ) ; } } } finally { stopSe...
Waits until at least one request is received and then stops the server .
98
15
36,408
public static com . sun . net . httpserver . HttpServer bind ( InetAddress address , int startPort , int maxPort ) { com . sun . net . httpserver . HttpServer aServer = createServer ( ) ; int port = - 1 ; for ( int possiblePort = startPort ; port == - 1 && possiblePort <= maxPort ; possiblePort ++ ) { try { InetSocketA...
Finds free port number and binds a server to it .
179
12
36,409
public static JavascriptExecutor getJavascriptExecutor ( SearchContext searchContext ) { JavascriptExecutor executor = null ; if ( searchContext instanceof JavascriptExecutor ) { executor = ( JavascriptExecutor ) searchContext ; } else { if ( searchContext instanceof WrapsDriver ) { WrapsDriver wraps = ( WrapsDriver ) ...
Obtains executor based on Selenium context .
169
10
36,410
public static Object executeScript ( JavascriptExecutor jse , String script , Object ... parameters ) { Object result ; try { result = jse . executeScript ( script , parameters ) ; } catch ( WebDriverException e ) { String msg = e . getMessage ( ) ; if ( msg != null && msg . contains ( "Detected a page unload event; sc...
Executes Javascript in browser . If script contains the magic variable arguments the parameters will also be passed to the statement . In the latter case the parameters must be a number a boolean a String WebElement or a List of any combination of the above .
125
49
36,411
public CheckResponse getRawCheckResponse ( ) { if ( ! checkCalled ) { setupMaxTries ( ) ; setupWaitTime ( ) ; addResultsToValuesForCheck ( getCurrentRowValues ( ) ) ; long startTime = currentTimeMillis ( ) ; try { executeCheckWithRetry ( ) ; } finally { checkTime = currentTimeMillis ( ) - startTime ; } } return checkRe...
Trigger to actually call check .
90
6
36,412
public void setJsonPathTo ( String path , Object value ) { Object cleanValue = cleanupValue ( value ) ; String jsonPath = getPathExpr ( path ) ; String newContent = getPathHelper ( ) . updateJsonPathWithValue ( content , jsonPath , cleanValue ) ; content = newContent ; }
Update a value in a the content by supplied jsonPath
69
11
36,413
public String savePageSource ( String fileName ) { List < WebElement > framesWithFakeSources = new ArrayList <> ( 2 ) ; Map < String , String > sourceReplacements = new HashMap <> ( ) ; List < WebElement > frames = getFrames ( ) ; for ( WebElement frame : frames ) { String newLocation = saveFrameSource ( frame ) ; if (...
Saves current page s source as new file .
273
10
36,414
public String randomLowerMaxLength ( int minLength , int maxLength ) { int range = maxLength - minLength ; int randomLength = 0 ; if ( range > 0 ) { randomLength = random ( range ) ; } return randomLower ( minLength + randomLength ) ; }
Creates a random string consisting of lowercase letters .
59
11
36,415
public String randomString ( String permitted , int length ) { StringBuilder result = new StringBuilder ( length ) ; int maxIndex = permitted . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { int index = random ( maxIndex ) ; char value = permitted . charAt ( index ) ; result . append ( value ) ; } return result ....
Creates a random string consisting only of supplied characters .
85
11
36,416
private Object getSymbolArrayValue ( Object arraySymbol , int index ) { Object result = null ; if ( index > - 1 && index < ( ( Object [ ] ) arraySymbol ) . length ) { result = ( ( Object [ ] ) arraySymbol ) [ index ] ; } return result ; }
Fetch the value from arraySymbol on specified index .
66
12
36,417
protected boolean configureSeleniumIfNeeded ( ) { setSeleniumDefaultTimeOut ( ) ; try { DriverFactory factory = null ; SeleniumDriverFactoryFactory factoryFactory = getSeleniumDriverFactoryFactory ( ) ; if ( factoryFactory != null ) { factory = factoryFactory . getDriverFactory ( ) ; if ( factory != null ) { SeleniumDr...
Determines whether system properties should override Selenium configuration in wiki . If so Selenium will be configured according to property values and locked so that wiki pages no longer control Selenium setup .
134
38
36,418
public void execute ( ProgramResponse response , int timeout ) { ProcessBuilder builder = createProcessBuilder ( response ) ; invokeProgram ( builder , response , timeout ) ; }
Calls a program and returns any output generated .
34
10
36,419
public String format ( String xml ) { try { boolean keepDeclaration = DECL_PATTERN . matcher ( xml ) . find ( ) ; if ( trimElements ) { xml = trimElements ( xml ) ; } Source xmlInput = new StreamSource ( new StringReader ( xml ) ) ; StreamResult xmlOutput = new StreamResult ( new StringWriter ( ) ) ; TransformerFactory...
Creates formatted version of the supplied XML .
230
9
36,420
public static String trim ( String xml ) { String content = removeDeclaration ( xml ) ; return trimElements ( content ) ; }
Removes both XML declaration and trims all elements .
28
11
36,421
public < T > Supplier < T > getConstructor ( Class < ? extends T > clazz ) { return getConstructorAs ( Supplier . class , "get" , clazz ) ; }
Gets no - arg constructor as Supplier .
43
10
36,422
public < T , A > Function < A , T > getConstructor ( Class < ? extends T > clazz , Class < A > arg ) { return getConstructorAs ( Function . class , "apply" , clazz , arg ) ; }
Gets single arg constructor as Function .
53
8
36,423
public < A1 , A2 , T > BiFunction < A1 , A2 , T > getConstructor ( Class < ? extends T > clazz , Class < A1 > arg1 , Class < A2 > arg2 ) { return getConstructorAs ( BiFunction . class , "apply" , clazz , new Class < ? > [ ] { arg1 , arg2 } ) ; }
Gets two arg constructor as BiFunction .
86
9
36,424
public static String loadFile ( String filename ) { ClassLoader classLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; InputStream is = classLoader . getResourceAsStream ( filename ) ; if ( is == null ) { throw new IllegalArgumentException ( "Unable to locate: " + filename ) ; } return streamToString ( ...
Reads content of UTF - 8 file on classpath to String .
81
14
36,425
public static File copyFile ( String source , String target ) throws IOException { FileChannel inputChannel = null ; FileChannel outputChannel = null ; try { inputChannel = new FileInputStream ( source ) . getChannel ( ) ; outputChannel = new FileOutputStream ( target ) . getChannel ( ) ; outputChannel . transferFrom (...
Copies source file to target .
127
7
36,426
public static File writeFile ( String filename , String content ) { PrintWriter pw = null ; try { pw = new PrintWriter ( filename , FILE_ENCODING ) ; pw . write ( content ) ; pw . flush ( ) ; } catch ( FileNotFoundException e ) { throw new IllegalArgumentException ( "Unable to write to: " + filename , e ) ; } catch ( U...
Writes content to file in UTF - 8 encoding .
131
11
36,427
public static File appendToFile ( String filename , String extraContent , boolean onNewLine ) { PrintWriter pw = null ; try { pw = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( filename , true ) , FILE_ENCODING ) ) ) ; if ( onNewLine ) { pw . println ( ) ; } pw . print ( extraCo...
Appends the extra content to the file in UTF - 8 encoding .
167
14
36,428
public String createContainingBase64Value ( String basename , String key ) { String file ; Object value = value ( key ) ; if ( value == null ) { throw new SlimFixtureException ( false , "No value for key: " + key ) ; } else if ( value instanceof String ) { file = createFileFromBase64 ( basename , ( String ) value ) ; }...
Saves content of a key s value as file in the files section .
121
15
36,429
public void addTo ( Object value , List aList ) { Object cleanValue = cleanupValue ( value ) ; aList . add ( cleanValue ) ; }
Adds new element to end of list .
33
8
36,430
public void copyValuesFromTo ( Collection < Object > source , List < Object > target ) { target . addAll ( source ) ; }
Adds values to list .
29
5
36,431
private XmlHttpResponse getReportXml ( String reportXmlFilename ) { String url = LalCallColumnFixture . getLalUrl ( ) + "/xmlrr/archive/Report/" + reportXmlFilename ; return env . doHttpGetXml ( url ) ; }
Gets content of reportXmlFile
60
8
36,432
public void setValueFor ( Object value , String name ) { getMapHelper ( ) . setValueForIn ( value , name , getCurrentValues ( ) ) ; }
Stores value .
36
4
36,433
public boolean clearValue ( String name ) { String cleanName = cleanupValue ( name ) ; boolean result = getCurrentValues ( ) . containsKey ( cleanName ) ; getCurrentValues ( ) . remove ( cleanName ) ; return result ; }
Clears a values previously set .
51
7
36,434
public String getRequiredSymbol ( String key ) { String result = null ; Object symbol = getSymbol ( key ) ; if ( symbol == null ) { throw new FitFailureException ( "No Symbol defined with key: " + key ) ; } else { result = symbol . toString ( ) ; } return result ; }
Gets symbol value or throws exception if no symbol by that key exists .
68
15
36,435
public void doHttpPost ( String url , String templateName , Object model , HttpResponse result , Map < String , Object > headers , String contentType ) { String request = processTemplate ( templateName , model ) ; result . setRequest ( request ) ; doHttpPost ( url , result , headers , contentType ) ; }
Performs POST to supplied url of result of applying template with model .
69
14
36,436
public void doHttpPost ( String url , HttpResponse result , Map < String , Object > headers , String contentType ) { httpClient . post ( url , result , headers , contentType ) ; }
Performs POST to supplied url of result s request .
43
11
36,437
public void doHttpFilePost ( String url , HttpResponse result , Map < String , Object > headers , File file ) { httpClient . post ( url , result , headers , file ) ; }
Performs POST to supplied url of a file as binary data .
42
13
36,438
public void doHttpFilePut ( String url , HttpResponse result , Map < String , Object > headers , File file ) { httpClient . put ( url , result , headers , file ) ; }
Performs PUT to supplied url of a file as binary data .
42
14
36,439
public void doHttpPut ( String url , String templateName , Object model , HttpResponse result ) { doHttpPut ( url , templateName , model , result , null , XmlHttpResponse . CONTENT_TYPE_XML_TEXT_UTF8 ) ; }
Performs PUT to supplied url of result of applying template with model .
57
15
36,440
public void doHttpPut ( String url , HttpResponse result , Map < String , Object > headers , String contentType ) { httpClient . put ( url , result , headers , contentType ) ; }
Performs PUT to supplied url of result s request .
43
12
36,441
public XmlHttpResponse doHttpGetXml ( String url ) { XmlHttpResponse response = new XmlHttpResponse ( ) ; doGet ( url , response ) ; setContext ( response ) ; return response ; }
GETs XML content from URL .
47
7
36,442
public void doHead ( String url , HttpResponse response , Map < String , Object > headers ) { response . setRequest ( url ) ; httpClient . head ( url , response , headers ) ; }
HEADs content from URL .
43
6
36,443
public void doDelete ( String url , HttpResponse response , Map < String , Object > headers ) { response . setRequest ( url ) ; httpClient . delete ( url , response , headers ) ; }
DELETEs content at URL .
43
8
36,444
public void doDelete ( String url , HttpResponse result , Map < String , Object > headers , String contentType ) { httpClient . delete ( url , result , headers , contentType ) ; }
Performs DELETE to supplied url of result s request .
42
13
36,445
public String getHtml ( Formatter formatter , String value ) { String result = null ; if ( value != null ) { if ( "" . equals ( value ) ) { result = "" ; } else { String formattedResponse = formatter . format ( value ) ; result = "<pre>" + StringEscapeUtils . escapeHtml4 ( formattedResponse ) + "</pre>" ; } } return re...
Formats supplied value for display as pre - formatted text in FitNesse page .
88
17
36,446
public static void handleErrorResponse ( String msg , String responseText ) { String responseHtml ; Environment instance = getInstance ( ) ; try { responseHtml = instance . getHtmlForXml ( responseText ) ; } catch ( Exception e ) { responseHtml = instance . getHtml ( value -> value , responseText ) ; } throw new FitFai...
Creates exception that will display nicely in a columnFixture .
87
13
36,447
public ProgramResponse invokeProgram ( int timeout , String directory , String command , String ... arguments ) { ProgramResponse result = new ProgramResponse ( ) ; result . setDirectory ( directory ) ; result . setCommand ( command ) ; result . setArguments ( arguments ) ; invokeProgram ( timeout , result ) ; return r...
Invokes an external program waits for it to complete and returns the result .
67
15
36,448
public String getWikiUrl ( String filePath ) { String wikiUrl = null ; String filesDir = getFitNesseFilesSectionDir ( ) ; if ( filePath . startsWith ( filesDir ) ) { String relativeFile = filePath . substring ( filesDir . length ( ) ) ; relativeFile = relativeFile . replace ( ' ' , ' ' ) ; wikiUrl = "files" + relativeF...
Converts a file path into a relative wiki path if the path is insides the wiki s files section .
93
22
36,449
public String getFilePathFromWikiUrl ( String wikiUrl ) { String url = getHtmlCleaner ( ) . getUrl ( wikiUrl ) ; File file ; if ( url . startsWith ( "files/" ) ) { String relativeFile = url . substring ( "files" . length ( ) ) ; relativeFile = relativeFile . replace ( ' ' , File . separatorChar ) ; String pathname = ge...
Gets absolute path from wiki url if file exists .
141
11
36,450
public void addSeleniumCookies ( HttpResponse response ) { CookieStore cookieStore = ensureResponseHasCookieStore ( response ) ; CookieConverter converter = getCookieConverter ( ) ; Set < Cookie > browserCookies = getSeleniumHelper ( ) . getCookies ( ) ; converter . copySeleniumCookies ( browserCookies , cookieStore ) ...
Adds Selenium cookies to response s cookie store .
82
10
36,451
public long stopTimer ( String name ) { StopWatch sw = getStopWatch ( name ) ; sw . stop ( ) ; STOP_WATCHES . remove ( name ) ; return sw . getTime ( ) ; }
Stops named timer .
45
5
36,452
public Map < String , Long > stopAllTimers ( ) { Map < String , Long > result = allTimerTimes ( ) ; STOP_WATCHES . clear ( ) ; return result ; }
Stops all running timers .
41
6
36,453
public String createContainingValue ( String filename , String key ) { Object data = value ( key ) ; if ( data == null ) { throw new SlimFixtureException ( false , "No value for key: " + key ) ; } return createContaining ( filename , data ) ; }
Creates new file containing value key .
61
8
36,454
public String encode ( String fileUrl ) { String file = getFilePathFromWikiUrl ( fileUrl ) ; try { byte [ ] content = IOUtils . toByteArray ( new FileInputStream ( file ) ) ; return base64Encode ( content ) ; } catch ( IOException e ) { throw new SlimFixtureException ( "Unable to read: " + file , e ) ; } }
Gets the content of specified file base64 encoded .
87
11
36,455
public String createFrom ( String fileName , String base64String ) { String result ; String baseName = FilenameUtils . getBaseName ( fileName ) ; String target = saveBase + baseName ; String ext = FilenameUtils . getExtension ( fileName ) ; byte [ ] content = base64Decode ( base64String ) ; String downloadedFile = File...
Creates a new file with content read from base64 encoded string .
158
14
36,456
public void addValueToIn ( Object value , String name , Map < String , Object > map ) { Object val = getValue ( map , name ) ; if ( val instanceof Collection ) { Object cleanValue = getCleanValue ( value ) ; ( ( Collection ) val ) . add ( cleanValue ) ; } else if ( val == null ) { setValueForIn ( value , name + "[0]" ,...
Adds a value to the end of a list .
128
10
36,457
public void copyValuesFromTo ( Map < String , Object > otherMap , Map < String , Object > map ) { map . putAll ( otherMap ) ; }
Adds all values in the otherMap to map .
35
10
36,458
public String applyTemplate ( String aTemplate ) { String result = getEnvironment ( ) . processTemplate ( aTemplate , getCurrentValues ( ) ) ; result = postProcess ( result ) ; result = formatResult ( aTemplate , result ) ; return result ; }
Applies template to current values .
54
7
36,459
@ Override public boolean loadValuesFrom ( String filename ) { String yamlStr = textIn ( filename ) ; Object y = yaml . load ( yamlStr ) ; if ( y instanceof Map ) { getCurrentValues ( ) . putAll ( ( Map ) y ) ; } else { getCurrentValues ( ) . put ( "elements" , y ) ; } return true ; }
Adds the yaml loaded from the specified file to current values .
84
13
36,460
@ Override public T apply ( T webElement ) { if ( firstFound == null ) { firstFound = webElement ; } return mayPass ( webElement ) ? webElement : null ; }
Filters out non - displayed elements .
41
8
36,461
private HttpEntity buildBodyWithFile ( File file ) { MultipartEntityBuilder builder = MultipartEntityBuilder . create ( ) ; builder . addBinaryBody ( "file" , file , ContentType . APPLICATION_OCTET_STREAM , file . getName ( ) ) ; HttpEntity multipart = builder . build ( ) ; return multipart ; }
Builds request body with a given file
81
8
36,462
protected static org . apache . http . client . HttpClient buildHttpClient ( boolean contentCompression , boolean sslVerification ) { RequestConfig rc = RequestConfig . custom ( ) . setCookieSpec ( CookieSpecs . STANDARD ) . build ( ) ; HttpClientBuilder builder = HttpClients . custom ( ) . useSystemProperties ( ) ; if...
Builds an apache HttpClient instance
211
9
36,463
public static < T , K , U > Collector < T , ? , LinkedHashMap < K , U > > toLinkedMap ( Function < ? super T , ? extends K > keyMapper , Function < ? super T , ? extends U > valueMapper ) { BinaryOperator < U > mergeFunction = throwingMerger ( ) ; return toLinkedMap ( keyMapper , valueMapper , mergeFunction ) ; }
Collects a stream to a LinkedHashMap each stream element is expected to produce map entry .
93
20
36,464
public static < T , K , U > Collector < T , ? , LinkedHashMap < K , U > > toLinkedMap ( Function < ? super T , ? extends K > keyMapper , Function < ? super T , ? extends U > valueMapper , BinaryOperator < U > mergeFunction ) { return Collectors . toMap ( keyMapper , valueMapper , mergeFunction , LinkedHashMap :: new ) ...
Collects a stream to a LinkedHashMap .
95
11
36,465
public static < T > BinaryOperator < T > throwingMerger ( ) { return ( u , v ) -> { throw new IllegalArgumentException ( String . format ( "Duplicate key: value %s was already present now %s is added" , u , v ) ) ; } ; }
Throws is same key is produced .
64
8
36,466
public boolean validateAgainst ( String xmlContent , String xsdContent ) { try { Source xsd = new SAXSource ( new InputSource ( new StringReader ( xsdContent ) ) ) ; Source xml = new SAXSource ( new InputSource ( new StringReader ( xmlContent ) ) ) ; SchemaFactory schemaFactory = SchemaFactory . newInstance ( XMLConsta...
Validate currently loaded xml against an xsd
190
9
36,467
@ Override public boolean loadValuesFrom ( String filename ) { String propContent = textIn ( filename ) ; PropertiesHelper propHelper = getEnvironment ( ) . getPropertiesHelper ( ) ; Properties properties = propHelper . parsePropertiesString ( propContent ) ; Map < String , Object > propAsMap = propHelper . convertProp...
Adds the properties loaded from the specified file to current values .
95
12
36,468
public boolean startDriver ( String driverClassName , final Map < String , Object > profile ) throws Exception { if ( OVERRIDE_ACTIVE ) { return true ; } DriverFactory driverFactory = new LocalDriverFactory ( driverClassName , profile ) ; WebDriver driver = setAndUseDriverFactory ( driverFactory ) ; return driver != nu...
Creates an instance of the specified class an injects it into SeleniumHelper so other fixtures can use it .
73
23
36,469
public boolean connectToDriverForVersionOnAt ( String browser , String version , String platformName , String url ) throws MalformedURLException { Platform platform = Platform . valueOf ( platformName ) ; DesiredCapabilities desiredCapabilities = new DesiredCapabilities ( browser , version , platform ) ; desiredCapabil...
Connects SeleniumHelper to a remote web driver .
89
11
36,470
public static Integer getFileSizeOnFTPServer ( String hostName , Integer port , String userName , String password , String filePath ) { Integer result = null ; // get file size String replyString = executeCommandOnFTPServer ( hostName , port , userName , password , "SIZE" , filePath ) ; if ( replyString == null || ! re...
Get size of the FTP file .
167
7
36,471
public static String executeCommandOnFTPServer ( String hostName , Integer port , String userName , String password , String command , String commandArgs ) { String result = null ; if ( StringUtils . isNotBlank ( command ) ) { FTPClient ftpClient = new FTPClient ( ) ; String errorMessage = "Unable to connect and execut...
Execute command with supplied arguments on the FTP server .
243
11
36,472
public static String uploadFileToFTPServer ( String hostName , Integer port , String userName , String password , String localFileFullName , String remotePath ) { String result = null ; FTPClient ftpClient = new FTPClient ( ) ; String errorMessage = "Unable to upload file '%s' for FTP server '%s'." ; InputStream inputS...
Upload a given file to FTP server .
364
8
36,473
public static String loadFileFromFTPServer ( String hostName , Integer port , String userName , String password , String filePath , int numberOfLines ) { String result = null ; FTPClient ftpClient = new FTPClient ( ) ; InputStream inputStream = null ; String errorMessage = "Unable to connect and download file '%s' from...
Reads content of file on from FTP server to String .
245
12
36,474
public static void connectAndLoginOnFTPServer ( FTPClient ftpClient , String hostName , Integer port , String userName , String password ) { try { if ( port != null && port . intValue ( ) > 0 ) { ftpClient . connect ( hostName , port ) ; } else { ftpClient . connect ( hostName ) ; } if ( ! FTPReply . isPositiveCompleti...
Connect and login on given FTP server with provided credentials .
221
11
36,475
public static void disconnectAndLogoutFromFTPServer ( FTPClient ftpClient , String hostName ) { try { // logout and disconnect if ( ftpClient != null && ftpClient . isConnected ( ) ) { ftpClient . logout ( ) ; ftpClient . disconnect ( ) ; } } catch ( IOException e ) { // what the hell?! throw new RuntimeException ( "Un...
Disconnect and logout given FTP client .
105
9
36,476
public void addDerivedDates ( Map < String , Object > values ) { Map < String , Object > valuesToAdd = new HashMap < String , Object > ( ) ; for ( Map . Entry < String , Object > entry : values . entrySet ( ) ) { String key = entry . getKey ( ) ; Object object = entry . getValue ( ) ; if ( object != null ) { String str...
Adds derived values for dates in map .
195
8
36,477
public void setIntValueForIn ( int value , String name , Map < String , Object > map ) { setValueForIn ( Integer . valueOf ( value ) , name , map ) ; }
Stores integer value in map .
42
7
36,478
public void setDoubleValueForIn ( double value , String name , Map < String , Object > map ) { setValueForIn ( Double . valueOf ( value ) , name , map ) ; }
Stores double value in map .
42
7
36,479
public void setBooleanValueForIn ( boolean value , String name , Map < String , Object > map ) { setValueForIn ( Boolean . valueOf ( value ) , name , map ) ; }
Stores boolean value in map .
43
7
36,480
public void addValueToIn ( Object value , String name , Map < String , Object > map ) { getMapHelper ( ) . addValueToIn ( value , name , map ) ; }
Adds value to a list map .
41
7
36,481
public void copyValuesFromTo ( Map < String , Object > otherMap , Map < String , Object > map ) { getMapHelper ( ) . copyValuesFromTo ( otherMap , map ) ; }
Adds all values in the supplied map to the current values .
43
12
36,482
public String getXPath ( NamespaceContext context , String xml , String xPathExpr ) { return ( String ) evaluateXpath ( context , xml , xPathExpr , null ) ; }
Evaluates xPathExpr against xml returning single match .
42
13
36,483
public List < String > getAllXPath ( NamespaceContext context , String xml , String xPathExpr ) { List < String > result = null ; NodeList nodes = ( NodeList ) evaluateXpath ( context , xml , xPathExpr , XPathConstants . NODESET ) ; if ( nodes != null ) { result = new ArrayList < String > ( nodes . getLength ( ) ) ; fo...
Evaluates xPathExpr against xml returning all matches .
133
13
36,484
@ SafeVarargs public static < T > T firstNonNull ( Supplier < T > ... suppliers ) { return firstNonNull ( Supplier :: get , suppliers ) ; }
Gets first supplier s result which is not null . Suppliers are called sequentially . Once a non - null result is obtained the remaining suppliers are not called .
37
34
36,485
public static < T , R > R firstNonNull ( T input , Function < T , R > function , Function < T , R > ... functions ) { return firstNonNull ( f -> f . apply ( input ) , Stream . concat ( Stream . of ( function ) , Stream . of ( functions ) ) ) ; }
Gets first result of set of function which is not null .
69
13
36,486
public static < T , R > R firstNonNull ( Function < T , R > function , Stream < T > values ) { return values . map ( function ) . filter ( Objects :: nonNull ) . findFirst ( ) . orElse ( null ) ; }
Gets first element which is not null .
55
9
36,487
public static XPathCheckResult parse ( String value ) { XPathCheckResult parsed = new XPathCheckResult ( ) ; parsed . result = value ; return parsed ; }
Parse method to allow Fitnesse to determine expected values .
36
13
36,488
public void addMisMatch ( String name , String expected , String actual ) { result = "NOK" ; Mismatch mismatch = new Mismatch ( ) ; mismatch . name = name ; mismatch . expected = expected ; mismatch . actual = actual ; mismatches . add ( mismatch ) ; }
Adds a mismatch to this result .
62
7
36,489
public Properties parsePropertiesString ( String propertiesAsString ) { final Properties p = new Properties ( ) ; try ( StringReader reader = new StringReader ( propertiesAsString ) ) { p . load ( reader ) ; } catch ( IOException e ) { throw new IllegalArgumentException ( "Unable to parse .properties: " + propertiesAsS...
Converts String to Properties .
82
6
36,490
public Map < String , Object > convertPropertiesToMap ( Properties properties ) { return properties . entrySet ( ) . stream ( ) . collect ( toLinkedMap ( e -> e . getKey ( ) . toString ( ) , e -> e . getValue ( ) ) ) ; }
Converts Properties to Map
62
5
36,491
protected String createFile ( String dir , String fileName , byte [ ] content ) { String baseName = FilenameUtils . getBaseName ( fileName ) ; String ext = FilenameUtils . getExtension ( fileName ) ; String downloadedFile = FileUtil . saveToFile ( dir + baseName , ext , content ) ; return linkToFile ( downloadedFile ) ...
Creates a file using the supplied content .
83
9
36,492
protected String linkToFile ( File f ) { String url = getWikiUrl ( f . getAbsolutePath ( ) ) ; if ( url == null ) { url = f . toURI ( ) . toString ( ) ; } return String . format ( "<a href=\"%s\" target=\"_blank\">%s</a>" , url , f . getName ( ) ) ; }
Creates a wiki link to a file .
83
9
36,493
public void add ( String prefix , String uri ) { if ( uri == null ) { namespaces . remove ( prefix ) ; } else { if ( namespaces . containsKey ( prefix ) ) { String currentUri = namespaces . get ( prefix ) ; if ( ! currentUri . equals ( uri ) ) { throw new FitFailureException ( String . format ( "The prefix %s is alread...
Adds registration for prefix .
119
5
36,494
public String html ( String htmlSource ) { String cleanSource = htmlCleaner . cleanupPreFormatted ( htmlSource ) ; return "<div>" + StringEscapeUtils . unescapeHtml4 ( cleanSource ) + "</div>" ; }
Unescapes supplied HTML content so it can be rendered inside a wiki page .
53
17
36,495
protected String generateResultXml ( String testName , Throwable exception , double executionTime ) { int errors = 0 ; int failures = 0 ; String failureXml = "" ; if ( exception != null ) { failureXml = "<failure type=\"" + exception . getClass ( ) . getName ( ) + "\" message=\"" + getMessage ( exception ) + "\"></fail...
Creates XML string describing test outcome .
211
8
36,496
protected void writeResult ( String testName , String resultXml ) throws IOException { String finalPath = getXmlFileName ( testName ) ; Writer fw = null ; try { fw = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( finalPath ) , "UTF-8" ) ) ; fw . write ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\...
Writes XML result to disk .
128
7
36,497
public static String getData ( String dataUrl ) { int indexOfComma = dataUrl . indexOf ( ' ' ) ; return dataUrl . substring ( indexOfComma + 1 ) ; }
Gets data embedded in data url .
43
8
36,498
public Object getJsonPath ( String json , String jsonPath ) { if ( ! JsonPath . isPathDefinite ( jsonPath ) ) { throw new RuntimeException ( jsonPath + " returns a list of results, not a single." ) ; } return parseJson ( json ) . read ( jsonPath ) ; }
Evaluates a JsonPath expression returning a single element .
69
13
36,499
public List < Object > getAllJsonPath ( String json , String jsonPath ) { List < Object > result ; if ( JsonPath . isPathDefinite ( jsonPath ) ) { Object val = getJsonPath ( json , jsonPath ) ; if ( val == null ) { result = Collections . emptyList ( ) ; } else { result = Collections . singletonList ( val ) ; } } else {...
Evaluates a JsonPath expression returning a multiple elements .
109
13