idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
39,700 | public void copyTo ( String localPath , String remotePath ) throws Exception { FileInputStream fis = null ; String rfile = remotePath ; String localfile = localPath ; boolean ptimestamp = true ; String command = "scp " + ( ptimestamp ? "-p" : "" ) + " -d -t " + rfile ; Channel channel = session . openChannel ( "exec" )... | Copy localPath to remotePath using the session created |
39,701 | public void runCommand ( String command ) throws Exception { String result = "" ; String extras = "export PYTHONWARNINGS=\"ignore:Unverified HTTPS request\" && " ; Channel channel = session . openChannel ( "exec" ) ; ( ( ChannelExec ) channel ) . setCommand ( extras + command ) ; channel . setInputStream ( null ) ; ( (... | Execute the command in the session created |
39,702 | @ Given ( "^I authenticate to DCOS cluster '(.+?)' using email '(.+?)'( with user '(.+?)'( and password '(.+?)'| and pem file '(.+?)'))?$" ) public void authenticateDCOSpem ( String remoteHost , String email , String foo , String user , String bar , String password , String pemFile ) throws Exception { String DCOSsecre... | Authenticate in a DCOS cluster |
39,703 | @ Given ( "^I( do not)? set sso token using host '(.+?)' with user '(.+?)' and password '(.+?)'( and tenant '(.+?)')?$" ) public void setGoSecSSOCookie ( String set , String ssoHost , String userName , String passWord , String foo , String tenant ) throws Exception { if ( set == null ) { HashMap < String , String > sso... | Generate token to authenticate in gosec SSO |
39,704 | @ Given ( "^I save the IP of an unused node in hosts '(.+?)' in the in environment variable '(.+?)'?$" ) public void getUnusedNode ( String hosts , String envVar ) throws Exception { Set < String > hostList = new HashSet ( Arrays . asList ( hosts . split ( "," ) ) ) ; commonspec . executeCommand ( "dcos task | awk '{pr... | Checks if there are any unused nodes in the cluster and returns the IP of one of them . REQUIRES A PREVIOUSLY - ESTABLISHED SSH CONNECTION TO DCOS - CLI TO WORK |
39,705 | @ Given ( "^I convert jsonSchema '(.+?)' to json and save it in variable '(.+?)'" ) public void convertJSONSchemaToJSON ( String jsonSchema , String envVar ) throws Exception { String json = commonspec . parseJSONSchema ( new JSONObject ( jsonSchema ) ) . toString ( ) ; ThreadProperty . set ( envVar , json ) ; } | Convert jsonSchema to json |
39,706 | @ Given ( "^json (.+?) matches schema (.+?)$" ) public void jsonMatchesSchema ( String json , String schema ) throws Exception { JSONObject jsonschema = new JSONObject ( schema ) ; JSONObject jsondeploy = new JSONObject ( json ) ; commonspec . matchJsonToSchema ( jsonschema , jsondeploy ) ; } | Check if json is validated against a schema |
39,707 | @ Given ( "^I get service '(.+?)' health status in cluster '(.+?)' and save it in variable '(.+?)'" ) public void getServiceHealthStatus ( String service , String cluster , String envVar ) throws Exception { String health = commonspec . retrieveHealthServiceStatus ( service , cluster ) ; ThreadProperty . set ( envVar ,... | Get service health status |
39,708 | @ Given ( "^I destroy service '(.+?)' in cluster '(.+?)'" ) public void destroyService ( String service , String cluster ) throws Exception { String endPoint = "/service/deploy-api/deploy/uninstall?app=" + service ; Future response ; this . commonspec . setRestProtocol ( "https://" ) ; this . commonspec . setRestHost (... | Destroy specified service |
39,709 | @ When ( "^All resources from service '(.+?)' have been freed$" ) public void checkResources ( String service ) throws Exception { Future < Response > response = commonspec . generateRequest ( "GET" , true , null , null , "/mesos/state-summary" , null , null ) ; String json = "[" + response . get ( ) . getResponseBody ... | Check if resources are released after uninstall and framework doesn t appear as inactive on mesos |
39,710 | @ Then ( "^I add a new DCOS label with key '(.+?)' and value '(.+?)' to the service '(.+?)'?$" ) public void sendAppendRequest ( String key , String value , String service ) throws Exception { commonspec . runCommandAndGetResult ( "touch " + service + ".json && dcos marathon app show " + service + " > /dcos/" + service... | A PUT request over the body value . |
39,711 | @ Then ( "^I modify marathon environment variable '(.+?)' with value '(.+?)' for service '(.+?)'?$" ) public void setMarathonProperty ( String key , String value , String service ) throws Exception { commonspec . runCommandAndGetResult ( "touch " + service + "-env.json && dcos marathon app show " + service + " > /dcos/... | Set a environment variable in marathon and deploy again . |
39,712 | @ Then ( "^service '(.+?)' status in cluster '(.+?)' is '(suspended|running|deploying)'( in less than '(\\d+?)' seconds checking every '(\\d+?)' seconds)?" ) public void serviceStatusCheck ( String service , String cluster , String status , String foo , Integer totalWait , Integer interval ) throws Exception { String r... | Check service status has value specified |
39,713 | @ Then ( "^The role '(.+?)' of the service '(.+?)' with instance '(.+?)' complies the constraints '(.+?)'$" ) public void checkComponentConstraints ( String role , String service , String instance , String constraints ) throws Exception { checkComponentConstraint ( role , service , instance , constraints . split ( "," ... | Check if a role of a service complies the established constraints |
39,714 | @ Given ( "^I open a ssh connection to '(.+?)'( in port '(.+?)')? with user '(.+?)'( and password '(.+?)')?( using pem file '(.+?)')?$" ) public void openSSHConnection ( String remoteHost , String tmp , String remotePort , String user , String foo , String password , String bar , String pemFile ) throws Exception { if ... | Opens a ssh connection to remote host |
39,715 | @ Given ( "^I run '(.+?)' locally( with exit status '(.+?)')?( and save the value in environment variable '(.+?)')?$" ) public void executeLocalCommand ( String command , String foo , Integer exitStatus , String bar , String envVar ) throws Exception { if ( exitStatus == null ) { exitStatus = 0 ; } commonspec . runLoca... | Executes the command specified in local system |
39,716 | @ Then ( "^the command output contains '(.+?)'$" ) public void findShellOutput ( String search ) throws Exception { assertThat ( commonspec . getCommandResult ( ) ) . as ( "Contains " + search + "." ) . contains ( search ) ; } | Check the existence of a text at a command output |
39,717 | @ Then ( "^the command output does not contain '(.+?)'$" ) public void notFindShellOutput ( String search ) throws Exception { assertThat ( commonspec . getCommandResult ( ) ) . as ( "NotContains " + search + "." ) . doesNotContain ( search ) ; } | Check the non existence of a text at a command output |
39,718 | @ Then ( "^the command exit status is '(.+?)'$" ) public void checkShellExitStatus ( int expectedExitStatus ) throws Exception { assertThat ( commonspec . getCommandExitStatus ( ) ) . as ( "Is equal to " + expectedExitStatus + "." ) . isEqualTo ( expectedExitStatus ) ; } | Check the exitStatus of previous command execution matches the expected one |
39,719 | @ Given ( "^I create a Cassandra index named '(.+?)' in table '(.+?)' using magic_column '(.+?)' using keyspace '(.+?)'$" ) public void createBasicMapping ( String index_name , String table , String column , String keyspace ) throws Exception { String query = "CREATE INDEX " + index_name + " ON " + table + " (" + colum... | Create a basic Index . |
39,720 | @ Given ( "^I( securely)? connect to '(Cassandra|Mongo|Elasticsearch)' cluster at '(.+)'$" ) public void connect ( String secured , String clusterType , String url ) throws DBException , UnknownHostException { switch ( clusterType ) { case "Cassandra" : commonspec . getCassandraClient ( ) . setHost ( url ) ; commonspec... | Connect to cluster . |
39,721 | @ Given ( "^I connect to Elasticsearch cluster at host '(.+?)'( using native port '(.+?)')?( using cluster name '(.+?)')?$" ) public void connectToElasticSearch ( String host , String foo , String nativePort , String bar , String clusterName ) throws DBException , UnknownHostException , NumberFormatException { LinkedHa... | Connect to ElasticSearch using custom parameters |
39,722 | @ Given ( "^I obtain elasticsearch cluster name in '([^:]+?)(:.+?)?' and save it in variable '(.+?)'?$" ) public void saveElasticCluster ( String host , String port , String envVar ) throws Exception { commonspec . setRestProtocol ( "http://" ) ; commonspec . setRestHost ( host ) ; commonspec . setRestPort ( port ) ; F... | Save clustername of elasticsearch in an environment varible for future use . |
39,723 | @ Given ( "^I insert into a MongoDB database '(.+?)' and table '(.+?)' this values:$" ) public void insertOnMongoTable ( String dataBase , String tabName , DataTable table ) { commonspec . getMongoDBClient ( ) . connectToMongoDBDataBase ( dataBase ) ; commonspec . getMongoDBClient ( ) . insertIntoMongoDBCollection ( ta... | Insert data in a MongoDB table . |
39,724 | @ Given ( "^I drop every document at a MongoDB database '(.+?)' and table '(.+?)'" ) public void truncateTableInMongo ( String database , String table ) { commonspec . getMongoDBClient ( ) . connectToMongoDBDataBase ( database ) ; commonspec . getMongoDBClient ( ) . dropAllDataMongoDBCollection ( table ) ; } | Truncate table in MongoDB . |
39,725 | @ Given ( "^I insert into MongoDB database '(.+?)' and collection '(.+?)' the document from schema '(.+?)'$" ) public void insertOnMongoTable ( String dataBase , String collection , String document ) throws Exception { String retrievedDoc = commonspec . retrieveData ( document , "json" ) ; commonspec . getMongoDBClient... | Insert document in a MongoDB table . |
39,726 | @ When ( "^I execute a query over fields '(.+?)' with schema '(.+?)' of type '(json|string)' with magic_column '(.+?)' from table: '(.+?)' using keyspace: '(.+?)' with:$" ) public void sendQueryOfType ( String fields , String schema , String type , String magic_column , String table , String keyspace , DataTable modifi... | Execute a query with schema over a cluster |
39,727 | @ When ( "^I execute an elasticsearch query over index '(.*?)' and mapping '(.*?)' and column '(.*?)' with value '(.*?)' to '(.*?)'$" ) public void elasticSearchQueryWithFilter ( String indexName , String mappingName , String columnName , String filterType , String value ) { try { commonspec . setResultsType ( "elastic... | Execute query with filter over elasticsearch |
39,728 | @ When ( "^I create a Cassandra index named '(.+?)' with schema '(.+?)' of type '(json|string)' in table '(.+?)' using magic_column '(.+?)' using keyspace '(.+?)' with:$" ) public void createCustomMapping ( String index_name , String schema , String type , String table , String magic_column , String keyspace , DataTabl... | Create a Cassandra index . |
39,729 | @ When ( "^I create an elasticsearch index named '(.+?)'( removing existing index if exist)?$" ) public void createElasticsearchIndex ( String index , String removeIndex ) { if ( removeIndex != null && commonspec . getElasticSearchClient ( ) . indexExists ( index ) ) { commonspec . getElasticSearchClient ( ) . dropSing... | Create an elasticsearch index . |
39,730 | @ When ( "^I index a document in the index named '(.+?)' using the mapping named '(.+?)' with key '(.+?)' and value '(.+?)'$" ) public void indexElasticsearchDocument ( String indexName , String mappingName , String key , String value ) throws Exception { ArrayList < XContentBuilder > mappingsource = new ArrayList < XC... | Index a document within a mapping type . |
39,731 | @ Then ( "^a Cassandra keyspace '(.+?)' exists$" ) public void assertKeyspaceOnCassandraExists ( String keyspace ) { assertThat ( commonspec . getCassandraClient ( ) . getKeyspaces ( ) ) . as ( "The keyspace " + keyspace + " exists on cassandra" ) . contains ( keyspace ) ; } | Checks if a keyspaces exists in Cassandra . |
39,732 | @ Then ( "^a Cassandra keyspace '(.+?)' does not exist$" ) public void assertKeyspaceOnCassandraDoesNotExist ( String keyspace ) { assertThat ( commonspec . getCassandraClient ( ) . getKeyspaces ( ) ) . as ( "The keyspace " + keyspace + " does not exist on cassandra" ) . doesNotContain ( keyspace ) ; } | Checks a keyspace does not exist in Cassandra . |
39,733 | @ Then ( "^a Cassandra keyspace '(.+?)' contains a table '(.+?)'$" ) public void assertTableExistsOnCassandraKeyspace ( String keyspace , String tableName ) { assertThat ( commonspec . getCassandraClient ( ) . getTables ( keyspace ) ) . as ( "The table " + tableName + "exists on cassandra" ) . contains ( tableName ) ; ... | Checks if a cassandra keyspace contains a table . |
39,734 | @ Then ( "^a Cassandra keyspace '(.+?)' does not contain a table '(.+?)'$" ) public void assertTableDoesNotExistOnCassandraKeyspace ( String keyspace , String tableName ) { assertThat ( commonspec . getCassandraClient ( ) . getTables ( keyspace ) ) . as ( "The table " + tableName + "exists on cassandra" ) . doesNotCont... | Checks a cassandra keyspace does not contain a table . |
39,735 | @ Then ( "^a Cassandra keyspace '(.+?)' contains a table '(.+?)' with '(.+?)' rows$" ) public void assertRowNumberOfTableOnCassandraKeyspace ( String keyspace , String tableName , String numberRows ) { Long numberRowsLong = Long . parseLong ( numberRows ) ; commonspec . getCassandraClient ( ) . useKeyspace ( keyspace )... | Checks the number of rows in a cassandra table . |
39,736 | @ Then ( "^a Cassandra keyspace '(.+?)' contains a table '(.+?)' with values:$" ) public void assertValuesOfTable ( String keyspace , String tableName , DataTable data ) throws InterruptedException { commonspec . getCassandraClient ( ) . useKeyspace ( keyspace ) ; Map < String , String > dataTableColumns = extractColum... | Checks if a cassandra table contains the values of a DataTable . |
39,737 | @ Then ( "^a Mongo dataBase '(.+?)' contains a table '(.+?)' with values:" ) public void assertValuesOfTableMongo ( String dataBase , String tableName , DataTable data ) { commonspec . getMongoDBClient ( ) . connectToMongoDBDataBase ( dataBase ) ; ArrayList < DBObject > result = ( ArrayList < DBObject > ) commonspec . ... | Checks the values of a MongoDB table . |
39,738 | @ Then ( "^a Mongo dataBase '(.+?)' doesnt contains a table '(.+?)'$" ) public void aMongoDataBaseContainsaTable ( String database , String tableName ) { commonspec . getMongoDBClient ( ) . connectToMongoDBDataBase ( database ) ; Set < String > collectionsNames = commonspec . getMongoDBClient ( ) . getMongoDBCollection... | Checks if a MongoDB database contains a table . |
39,739 | @ Then ( "^There are results found with:$" ) public void resultsMustBe ( DataTable expectedResults ) throws Exception { String type = commonspec . getResultsType ( ) ; assertThat ( type ) . isNotEqualTo ( "" ) . overridingErrorMessage ( "It's necessary to define the result type" ) ; switch ( type ) { case "cassandra" :... | Checks the different results of a previous query |
39,740 | @ Then ( "^The Elasticsearch index named '(.+?)' and mapping '(.+?)' contains a column named '(.+?)' with the value '(.+?)'$" ) public void elasticSearchIndexContainsDocument ( String indexName , String mappingName , String columnName , String columnValue ) throws Exception { Assertions . assertThat ( ( commonspec . ge... | Check that an elasticsearch index contains a specific document |
39,741 | @ When ( "^I search in LDAP using the filter '(.+?)' and the baseDn '(.+?)'$" ) public void searchLDAP ( String filter , String baseDn ) throws Exception { this . commonspec . setPreviousLdapResults ( commonspec . getLdapUtils ( ) . search ( new SearchRequest ( baseDn , filter ) ) ) ; } | Search for a LDAP object |
39,742 | @ Then ( "^the LDAP entry contains the attribute '(.+?)' with the value '(.+?)'$" ) public void ldapEntryContains ( String attributeName , String expectedValue ) { if ( this . commonspec . getPreviousLdapResults ( ) . isPresent ( ) ) { Assertions . assertThat ( this . commonspec . getPreviousLdapResults ( ) . get ( ) .... | Checks if the previous LDAP search contained a single Entry with a specific attribute and an expected value |
39,743 | @ DataProvider ( parallel = true ) public static Iterator < String [ ] > availableBrowsers ( ITestContext context , Constructor < ? > testConstructor ) throws Exception { Map < String , String > map = new HashMap < String , String > ( ) ; List < String > browsers = gridBrowsers ( map ) ; return buildIterator ( browsers... | Get the browsers available in a selenium grid . |
39,744 | @ DataProvider ( parallel = true ) public static Iterator < String [ ] > availableUniqueBrowsers ( ITestContext context , Constructor < ? > testConstructor ) throws Exception { Map < String , String > map = new HashMap < String , String > ( ) ; List < String > browsers = gridBrowsers ( map ) ; HashSet < String > hs = n... | Get unique browsers available in a selenium grid . |
39,745 | private static Iterator < String [ ] > buildIterator ( List < String > browsers ) { List < String [ ] > lData = Lists . newArrayList ( ) ; for ( String s : browsers ) { lData . add ( new String [ ] { s } ) ; } if ( lData . size ( ) == 0 ) { lData . add ( new String [ ] { "" } ) ; } return lData . iterator ( ) ; } | Build an String Iterator from String List . |
39,746 | @ Around ( value = "availableBrowsersCallPointcut()" ) public Object availableBrowsersCalls ( ProceedingJoinPoint pjp ) throws Throwable { if ( pjp . getArgs ( ) . length > 0 ) { if ( pjp . getArgs ( ) [ 0 ] instanceof ITestContext ) { if ( Arrays . asList ( ( ( ITestContext ) pjp . getArgs ( ) [ 0 ] ) . getIncludedGro... | If a System property with FORCE_BROWSER exists then Methods in BrowsersDataProvider will return its value . |
39,747 | @ Given ( "^I connect to Zookeeper at '(.+)'$" ) public void connectToZk ( String zookeeperHosts ) throws InterruptedException { commonspec . getZookeeperSecClient ( ) . setZookeeperSecConnection ( zookeeperHosts , 3000 ) ; commonspec . getZookeeperSecClient ( ) . connectZk ( ) ; } | Connect to zookeeper . |
39,748 | @ When ( "^I create the zNode '(.+?)'( with content '(.+?)')? which (IS|IS NOT) ephemeral$" ) public void createZNode ( String path , String foo , String content , boolean ephemeral ) throws Exception { if ( content != null ) { commonspec . getZookeeperSecClient ( ) . zCreate ( path , content , ephemeral ) ; } else { c... | Create zPath and domcument |
39,749 | public void connect ( String secured ) { buildCluster ( secured ) ; this . cassandraqueryUtils = new CassandraQueryUtils ( ) ; this . metadata = this . cluster . getMetadata ( ) ; LOGGER . debug ( "Connected to cluster (" + host + "): " + metadata . getClusterName ( ) + "\n" ) ; this . session = this . cluster . connec... | Connect to Cassandra host . |
39,750 | public void executeQueriesList ( List < String > queriesList ) { for ( String query : queriesList ) { this . session . execute ( query ) ; } } | Execute a list of queries over Cassandra . |
39,751 | public void reconnect ( ) { metadata = cluster . getMetadata ( ) ; LOGGER . debug ( "Connected to cluster (" + host + "): " + metadata . getClusterName ( ) + "\n" ) ; this . session = this . cluster . connect ( ) ; } | Reconnect to Cassandra host . |
39,752 | public void disconnect ( ) throws DBException { if ( this . session == null ) { throw new DBException ( "The Cassandra is null" ) ; } if ( this . cluster . isClosed ( ) ) { throw new DBException ( "The cluster has been closed" ) ; } this . session . close ( ) ; this . cluster . close ( ) ; } | Disconnect from Cassandra host . |
39,753 | public Metadata getMetadata ( ) throws DBException { if ( ! this . cluster . isClosed ( ) ) { this . metadata = cluster . getMetadata ( ) ; return this . metadata ; } else { throw new DBException ( "The cluster has been closed" ) ; } } | Get the metadata of the Cassandra Cluster . |
39,754 | public void buildCluster ( String secured ) { if ( secured == null ) { this . cluster = Cluster . builder ( ) . addContactPoint ( this . host ) . build ( ) ; this . cluster . getConfiguration ( ) . getQueryOptions ( ) . setConsistencyLevel ( ConsistencyLevel . ONE ) ; } else { try { this . cluster = Cluster . builder (... | Build a Cassandra cluster . |
39,755 | public void createKeyspace ( String keyspace ) { Map < String , String > replicationSimpleOneExtra = new HashMap < > ( ) ; replicationSimpleOneExtra . put ( "'class'" , "'SimpleStrategy'" ) ; replicationSimpleOneExtra . put ( "'replication_factor'" , "1" ) ; String query = this . cassandraqueryUtils . createKeyspaceQue... | Create a keyspace in Cassandra . |
39,756 | public void createTableWithData ( String table , Map < String , String > colums , ArrayList < String > pk ) { String query = this . cassandraqueryUtils . createTable ( table , colums , pk ) ; LOGGER . debug ( query ) ; executeQuery ( query ) ; } | Create a table in Cassandra . |
39,757 | public void insertData ( String table , Map < String , Object > fields ) { String query = this . cassandraqueryUtils . insertData ( table , fields ) ; LOGGER . debug ( query ) ; executeQuery ( query ) ; } | Insert data in a keyspace . |
39,758 | public boolean existsKeyspace ( String keyspace , boolean showLog ) { this . metadata = cluster . getMetadata ( ) ; if ( ! ( this . metadata . getKeyspaces ( ) . isEmpty ( ) ) ) { for ( KeyspaceMetadata k : metadata . getKeyspaces ( ) ) { if ( k . getName ( ) . equals ( keyspace ) ) { return true ; } } } return false ;... | Checks if a keyspace exists in Cassandra . |
39,759 | public List < String > getKeyspaces ( ) { ArrayList < String > result = new ArrayList < String > ( ) ; this . metadata = this . cluster . getMetadata ( ) ; if ( ! ( metadata . getKeyspaces ( ) . isEmpty ( ) ) ) { for ( KeyspaceMetadata k : this . metadata . getKeyspaces ( ) ) { result . add ( k . getName ( ) ) ; } } re... | Get a list of the existing keyspaces in Cassandra . |
39,760 | public boolean existsTable ( String keyspace , String table , boolean showLog ) { this . metadata = this . cluster . getMetadata ( ) ; if ( ! ( this . metadata . getKeyspace ( keyspace ) . getTables ( ) . isEmpty ( ) ) ) { for ( TableMetadata t : this . metadata . getKeyspace ( keyspace ) . getTables ( ) ) { if ( t . g... | Checks if a keyspace contains an especific table . |
39,761 | public List < String > getTables ( String keyspace ) { ArrayList < String > result = new ArrayList < String > ( ) ; this . metadata = this . cluster . getMetadata ( ) ; if ( ( ! existsKeyspace ( keyspace , false ) ) || ( this . metadata . getKeyspace ( keyspace ) . getTables ( ) . isEmpty ( ) ) ) { return result ; } fo... | Get tables of a keyspace . |
39,762 | public static List < String > loadScript ( String path ) { List < String > result = new ArrayList < String > ( ) ; URL url = CassandraUtils . class . getResource ( path ) ; LOGGER . debug ( url . toString ( ) ) ; LOGGER . info ( "Loading script from: " + url ) ; try ( BufferedReader br = new BufferedReader ( new InputS... | Load the lines of a CQL script containing one statement per line into a list . l |
39,763 | public static Pattern matchesOrContains ( String expectedMessage ) { Pattern pattern ; if ( expectedMessage . startsWith ( "regex:" ) ) { String regex = expectedMessage . substring ( expectedMessage . indexOf ( "regex:" ) + 6 , expectedMessage . length ( ) ) ; pattern = Pattern . compile ( regex ) ; } else { pattern = ... | Checks if a given string matches a regular expression or contains a string |
39,764 | public String retrieveData ( String baseData , String type ) { String result ; InputStream stream = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( baseData ) ; Writer writer = new StringWriter ( ) ; char [ ] buffer = new char [ 1024 ] ; Reader reader ; if ( stream == null ) { this . getLogger ( ) . error ( "... | Returns the information contained in file passed as parameter |
39,765 | public JsonObject removeNulls ( JsonObject object ) { for ( int j = 0 ; j < object . names ( ) . size ( ) ; j ++ ) { if ( JsonType . OBJECT . equals ( object . get ( object . names ( ) . get ( j ) ) . getType ( ) ) ) { removeNulls ( object . get ( object . names ( ) . get ( j ) ) . asObject ( ) ) ; } else { if ( object... | Eliminates null occurrences replacing them with TO_BE_NULL |
39,766 | public void setPreviousElement ( String element , String value ) throws NoSuchFieldException , SecurityException , IllegalArgumentException , IllegalAccessException , InstantiationException , ClassNotFoundException , NoSuchMethodException , InvocationTargetException { Reflections reflections = new Reflections ( "com.st... | Saves the value in the attribute in class extending CommonG . |
39,767 | private boolean isUUID ( String uuid ) { try { UUID . fromString ( uuid ) ; return true ; } catch ( Exception ex ) { return false ; } } | Check if a string is a UUID |
39,768 | private boolean isThisDateValid ( String dateToValidate , String dateFromat ) { if ( dateToValidate == null ) { return false ; } SimpleDateFormat sdf = new SimpleDateFormat ( dateFromat ) ; sdf . setLenient ( false ) ; try { Date date = sdf . parse ( dateToValidate ) ; } catch ( ParseException e ) { e . printStackTrace... | Check is a String is a valid timestamp format |
39,769 | public void resultsMustBeElasticsearch ( DataTable expectedResults ) throws Exception { if ( getElasticsearchResults ( ) != null ) { List < List < String > > expectedResultList = expectedResults . raw ( ) ; assertThat ( expectedResultList . size ( ) - 1 ) . overridingErrorMessage ( "Expected number of columns to be" + ... | Checks the different results of a previous query to Elasticsearch database |
39,770 | public void runLocalCommand ( String command ) throws Exception { String result = "" ; String line ; Process p ; try { p = Runtime . getRuntime ( ) . exec ( new String [ ] { "/bin/sh" , "-c" , command } ) ; p . waitFor ( ) ; } catch ( java . io . IOException e ) { this . commandExitStatus = 1 ; this . commandResult = "... | Runs a command locally |
39,771 | public String removeJSONPathElement ( String jsonString , String expr ) { Configuration conf = Configuration . builder ( ) . jsonProvider ( new GsonJsonProvider ( ) ) . mappingProvider ( new GsonMappingProvider ( ) ) . build ( ) ; DocumentContext context = JsonPath . using ( conf ) . parse ( jsonString ) ; context . de... | Remove a subelement in a JsonPath |
39,772 | public String replaceJSONPathElement ( String jsonString , String key , String value ) { return JsonPath . parse ( jsonString ) . set ( key , value ) . jsonString ( ) ; } | The function searches over the array by certain field value and replaces occurences with the parameter provided . |
39,773 | public JSONObject parseJSONSchema ( JSONObject schema ) throws Exception { JSONObject json = new JSONObject ( ) ; String name = "" ; JSONObject properties = schema ; if ( schema . has ( "properties" ) ) { properties = schema . getJSONObject ( "properties" ) ; } Iterator < ? > keys = properties . keys ( ) ; while ( keys... | Generate deployment json from schema |
39,774 | public boolean matchJsonToSchema ( JSONObject schema , JSONObject json ) throws Exception { SchemaLoader . builder ( ) . useDefaults ( true ) . schemaJson ( schema ) . build ( ) . load ( ) . build ( ) . validate ( json ) ; return true ; } | Check json matches schema |
39,775 | public static SeleniumAssert assertThat ( CommonG commong , List < WebElement > actual ) { return new SeleniumAssert ( commong , actual ) ; } | Checks a selenium list of WebElements . |
39,776 | public SeleniumAssert contains ( CharSequence ... values ) { if ( actual instanceof WebDriver ) { Strings . instance ( ) . assertContains ( info , ( ( WebDriver ) actual ) . getPageSource ( ) , values ) ; } else if ( actual instanceof WebElement ) { Strings . instance ( ) . assertContains ( info , ( ( WebElement ) actu... | Checks if a webDriver or WebElement has values . |
39,777 | public SeleniumAssert isTextField ( Condition < WebElement > cond ) { if ( actual instanceof List ) { Conditions . instance ( ) . equals ( cond ) ; } return this ; } | Checks if a WebElement is a TextField . |
39,778 | @ When ( "^I read info from csv file '(.+?)' with separator '(.+?)'$" ) public void readFromCSV ( String csvFile , String separator ) throws Exception { char sep = ',' ; if ( separator . length ( ) > 1 ) { switch ( separator ) { case "\\t" : sep = '\t' ; break ; default : sep = ',' ; break ; } } else { sep = separator ... | Read csv file and store result in list of maps |
39,779 | @ When ( "^I read file '(.+?)' as '(.+?)' and save it in environment variable '(.+?)' with:$" ) public void readFileToVariable ( String baseData , String type , String envVar , DataTable modifications ) throws Exception { String retrievedData = commonspec . retrieveData ( baseData , type ) ; commonspec . getLogger ( ) ... | Read the file passed as parameter perform the modifications specified and save the result in the environment variable passed as parameter . |
39,780 | @ When ( "^I read file '(.+?)' as '(.+?)' and save it in environment variable '(.+?)'$" ) public void readFileToVariableNoDataTable ( String baseData , String type , String envVar ) throws Exception { String retrievedData = commonspec . retrieveData ( baseData , type ) ; ThreadProperty . set ( envVar , retrievedData ) ... | Read the file passed as parameter and save the result in the environment variable passed as parameter . |
39,781 | public static String getClipboardText ( final Context context ) { final ClipboardManager clipboard = ( ClipboardManager ) context . getSystemService ( Context . CLIPBOARD_SERVICE ) ; final ClipData clipData = clipboard . getPrimaryClip ( ) ; if ( clipData != null && clipData . getItemCount ( ) > 0 ) { final CharSequenc... | Get the current text from the clipboard . |
39,782 | public static void setClipboardText ( final Context context , final String text ) { if ( text != null ) { final ClipboardManager clipboard = ( ClipboardManager ) context . getSystemService ( Context . CLIPBOARD_SERVICE ) ; final ClipData clipData = ClipData . newPlainText ( text , text ) ; clipboard . setPrimaryClip ( ... | Set the clipboard text . |
39,783 | public static void closeKeyboard ( Context context , View field ) { try { InputMethodManager imm = ( InputMethodManager ) context . getSystemService ( Context . INPUT_METHOD_SERVICE ) ; imm . hideSoftInputFromWindow ( field . getWindowToken ( ) , 0 ) ; } catch ( Exception ex ) { Log . e ( "Caffeine" , "Error occurred t... | Go away keyboard nobody likes you . |
39,784 | public static void showKeyboard ( Context context , View field ) { try { field . requestFocus ( ) ; InputMethodManager imm = ( InputMethodManager ) context . getSystemService ( Context . INPUT_METHOD_SERVICE ) ; imm . showSoftInput ( field , InputMethodManager . SHOW_IMPLICIT ) ; } catch ( Exception ex ) { Log . e ( "C... | Show the pop - up keyboard |
39,785 | public static Bitmap viewToImage ( Context context , WebView viewToBeConverted ) { int extraSpace = 2000 ; int height = viewToBeConverted . getContentHeight ( ) + extraSpace ; Bitmap viewBitmap = Bitmap . createBitmap ( viewToBeConverted . getWidth ( ) , height , Bitmap . Config . ARGB_8888 ) ; Canvas canvas = new Canv... | Convert view to an image . Can be used to make animations smoother . |
39,786 | public static void launchWebBrowser ( final Context context , final String url ) { if ( context != null && url != null && ! "" . equals ( url ) ) { final Intent browserIntent = new Intent ( Intent . ACTION_VIEW , Uri . parse ( url ) ) ; if ( browserIntent . resolveActivity ( context . getPackageManager ( ) ) != null ) ... | Start Intent to launch web browser . |
39,787 | public static boolean isAppInstalled ( final Context context , final String packageName ) { try { context . getPackageManager ( ) . getPackageInfo ( packageName , 0 ) ; return true ; } catch ( Exception e ) { return false ; } } | Check if app for the given package name is installed on this device . |
39,788 | public static void launchCameraIntent ( final Activity context , final Uri outputDestination , final int requestCode ) { final Intent intent = new Intent ( MediaStore . ACTION_IMAGE_CAPTURE ) ; intent . putExtra ( MediaStore . EXTRA_OUTPUT , outputDestination ) ; if ( intent . resolveActivity ( context . getPackageMana... | Launch camera on the device using android s ACTION_IMAGE_CAPTURE intent . |
39,789 | public static boolean launchAppForPackage ( final Context context , final String packageName ) { try { final PackageManager packageManager = context . getPackageManager ( ) ; final Intent intent = packageManager . getLaunchIntentForPackage ( packageName ) ; intent . addCategory ( Intent . CATEGORY_LAUNCHER ) ; context ... | Tries to launch the application for a given package name . |
39,790 | public static void launchActivity ( Activity context , Class < ? extends Activity > activity , boolean closeCurrentActivity , Map < String , String > params ) { Intent intent = new Intent ( context , activity ) ; if ( params != null ) { Bundle bundle = new Bundle ( ) ; for ( Entry < String , String > param : params . e... | Launch an Activity . |
39,791 | public static void turnScreenOn ( Activity context ) { try { Window window = context . getWindow ( ) ; window . addFlags ( WindowManager . LayoutParams . FLAG_DISMISS_KEYGUARD ) ; window . addFlags ( WindowManager . LayoutParams . FLAG_SHOW_WHEN_LOCKED ) ; window . addFlags ( WindowManager . LayoutParams . FLAG_TURN_SC... | Force screen to turn on if the phone is asleep . |
39,792 | public final static boolean isValidEmail ( String email ) { if ( email == null ) { return false ; } else { return android . util . Patterns . EMAIL_ADDRESS . matcher ( email ) . matches ( ) ; } } | Uses androids android . util . Patterns . EMAIL_ADDRESS to check if an email address is valid . |
39,793 | public final static boolean isValidURL ( String url ) { if ( url == null ) { return false ; } else { return Patterns . WEB_URL . matcher ( url ) . matches ( ) ; } } | Uses androids android . util . Patterns . WEB_URL to check if an url is valid . |
39,794 | public static Toast quickToast ( Context context , String message , boolean longLength ) { final Toast toast ; if ( longLength ) { toast = Toast . makeText ( context , message , Toast . LENGTH_LONG ) ; } else { toast = Toast . makeText ( context , message , Toast . LENGTH_SHORT ) ; } toast . show ( ) ; return toast ; } | Display a toast with the given message . |
39,795 | public Server onpublish ( Action < Map < String , Object > > action ) { publishActions . add ( action ) ; return this ; } | Adds an action to be called with a message to be published to every node in the cluster . |
39,796 | public static ServerSocketPredicate tag ( String ... tags ) { return socket -> socket . tags ( ) . containsAll ( Arrays . asList ( tags ) ) ; } | Returns a predicate that tests the socket tags against the given tags . |
39,797 | public static void addRoute ( MangooRoute route ) { Objects . requireNonNull ( route , Required . ROUTE . toString ( ) ) ; Preconditions . checkArgument ( routes . size ( ) <= MAX_ROUTES , "Maximum of " + MAX_ROUTES + " routes reached" ) ; routes . add ( route ) ; if ( route instanceof RequestRoute ) { RequestRoute req... | Adds a new route to the router |
39,798 | public static RequestRoute getReverseRoute ( String key ) { Objects . requireNonNull ( key , Required . KEY . toString ( ) ) ; return reverseRoutes . get ( key . toLowerCase ( Locale . ENGLISH ) ) ; } | Retrieves a reverse route by its controller class and controller method |
39,799 | public void addChannel ( WebSocketChannel channel ) { Objects . requireNonNull ( channel , Required . CHANNEL . toString ( ) ) ; final String url = RequestUtils . getWebSocketURL ( channel ) ; Set < WebSocketChannel > channels = getChannels ( url ) ; if ( channels == null ) { channels = new HashSet < > ( ) ; channels .... | Adds a new channel to the manager |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.