How to access and increase 'rx2.buffer-size' in RxJava 2? - rx-java2

In http://reactivex.io/RxJava/javadoc/io/reactivex/Observable it is stated:
The Observable's operators, by default, run with a buffer size of 128 elements (see Flowable.bufferSize(), that can be overridden globally via the system parameter rx2.buffer-size.
My question is, how can I access and set rx2.buffer-size? If I do:
import io.reactivex.Completable;
import io.reactivex.Flowable;
import io.reactivex.Observable;
import io.reactivex.Scheduler;
import io.reactivex.Single;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.subjects.BehaviorSubject;
import io.reactivex.subjects.PublishSubject;
import io.reactivex.subjects.Subject;
import io.reactivex.*;
...followed by:
Integer bufferSize = rx2.buffer-size;
I am informed by Studio that:
Unused import statement (for import io.reactivex.*;)
Cannot resolve symbol 'rx2'
Cannot resolve symbol 'size'
How can I override the system parameter rx2.buffer-size?
My project is using
io.reactivex.rxjava2/rxandroid/2.0.1
io.reactivex.rxjava2/rxjava/2.1.11

Try :
Integer bufferSize = Integer.parseInt(System.getProperty("rx2.buffer-size"))
To set a new value :
System.setProperty("rx2.buffer-size", 2048)

Related

Is there a way to create a "Verify Element Text is Not" keyword?

I need to verify an element had been randomized from a fixed starting state. I already have a test step that verifies the fixed state is working that uses "Verify Element Text" is "inserttexthere".
So I need a way to verify that the text is not "inserttexthere" after I click the randomizing button.
Is there anyway to do this that wouldn't require too much programming knowledge? (I use katalon studio because I have limited tech knowledge)
or is there an if else statement I can use that would pass the step only if the text is different?
Background and other methods I do know of or tried:
I can create another verify text command and just accept it as an intended to fail step. However that's harder to be aware of, especially if the text doesnt change because the test step will pass and I have to remember thats bad.
The other commands that are available only cover if the element no longer has text or if the element is no longer visible/clickable. There is nothing that lets me verify an attribute as "!=" or "NOT"
This is how you need to create a custom keyword in Katalon: Click
Code:
class help_keyword_elemtnotPresent {
#Keyword
def isElemetNotPresent() {
WebUI.verifyElementNotPresent(findTestObject(‘someobject’, timeout, FailureHandling.OPTIONAL)
}
for : if/else
More example
Here's a short beginners' practical tutorial:
Create a keyword in Keywords (1) (right-click, new keyword).
Create a package (2) (right-click, new package) called examplePackage.
Create a new class called ExampleClass inside that package:
public class ExampleClass {
#Keyword
public static verifyElementTextIsNot(String text1, String text2){
assert text1 != text2
}
}
Example test case showing how you can call the above keyword (Keyword is Katalon's name for method):
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import examplePackage.ExampleClass
String someText = "It is a rainy day"
String someOtherText = "It is a sunny day"
ExampleClass.verifyElementTextIsNot(someText, someOtherText)

Flutter tests keeps asking for packages already imported

I am trying to run a baseline test on Flutter before I get started developing tests and already it's failing asking for packages that are already included:
Compiler message:
src/resources/news_api_provider_test.dart:17:5: Error: 'expect' is imported from both 'package:flutter_test/src/widget_tester.dart' and 'package:test_api/src/frontend/expect.dart'. expect(sum, 4);
^^^^^^
src/resources/news_api_provider_test.dart:12:3: Error: 'test' is imported from both 'package:flutter_test/src/test_compat.dart' and 'package:test_api/test_api.dart'. test('FetchTopIds returns a list of ids', () {
^^^^^^
I have all these packages:
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_test/src/test_compat.dart';
import 'package:flutter_test/widget_tester.dart';
import 'package:test_api/test_api.dart';
import 'package:test_api/src/frontend/expect.dart':
void main() {
test('FetchTopIds returns a list of ids', () {
// Setup a test case
final sum = 1 + 3;
// expectation
expect(sum, 4);
});
}
What gives here? I don't see anything in the flutter.io documentation to clarify what is going on.
So import 'package:test/test.dart'; has been replaced with import 'package:test_api/test_api.dart';, but it has not made it to their documentation yet.
After replacing that and commenting out my news_api_provider.dart import like so:
// import 'package:news/src/resources/news_api_provider.dart';
import 'dart:convert';
import 'package:test_api/test_api.dart';
import 'package:test_api/src/frontend/expect.dart';
import 'package:http/http.dart';
import 'package:http/testing.dart';
I got the baseline test passing.
Can you try using either one of
import 'package:flutter_test/widget_tester.dart';
or
import 'package:flutter_test/expect.dart';
And similarly try to use either one of
import 'package:flutter_test/src/test_compat.dart';
or
import 'package:flutter_test/src/test_api.dart';
Let's see if this fixes the compilation error.

How to order imports with tslint's import-ordering rule

On my project tslint's "import-ordering" rule is used
import CopyLensModal from './CopyLensModal';
import FetchStatus from '../../../../../state/generic/models/FetchStatus';
import FlexRow from '../../../../generic/components/FlexRow';
import Geofilter from '../../../../../state/geofilter/models/Geofilter';
import Input from '../../../../generic/components/Input';
import * as React from 'react';
import * as salert from 'sweetalert';
import { func } from '../../../../../types/func';
import { Iterable } from 'immutable';
import { Button } from 'react-bootstrap';
tslint is not happy with this order and crashes with error
[2, 1]: Import sources within a group must be alphabetized.
[4, 1]: Import sources within a group must be alphabetized.
This page didn't help that much, I've tried to place imports in many different ways but without luck. Which order will be correct?
I agree that it's confusing. The problem is that the source string comparisons include the ../.. portions of the module names, so to appease the rule, you would need to sort them like this:
import FetchStatus from '../../../../../state/generic/models/FetchStatus';
import Geofilter from '../../../../../state/geofilter/models/Geofilter';
import FlexRow from '../../../../generic/components/FlexRow';
import Input from '../../../../generic/components/Input';
import CopyLensModal from './CopyLensModal';
The rule has two parts and can be configured to enforce orderings of the import names and sources separately. To enforce only the ordering of names only, you could use a configuration like this:
"ordered-imports": [true, {
"import-sources-order": "any",
"named-imports-order": "case-insensitive"
}]
That would raise an error for imports like this:
import { A, C, B } from 'some-module';
but wouldn't enforce ordering for the module paths, etc.
This error also happens if there is not empty new line added as separation between groups of imports.
import * as fs from 'fs';
import * as os from 'os';
import * as bar from './bar';
import * as foo from './foo';
Also notice if the error says like this:
***(5,1): Import sources within a group must be alphabetized.***
This means in the specified file go to line #5 and press enter to add a new empty line there as separator.
I did that and this resolved my problem. For more reference about this issue review this page
In file tslint.json add
"rules": {
"ordered-imports": [false],
"object-literal-sort-keys": [false]
}
For example, then file tslint.json will look like this
{
"extends": [
"tslint:recommended",
"tslint-react",
"tslint-config-prettier"
],
"linterOptions": {
"exclude": [
"config/**/*.js",
"node_modules/**/*.ts",
"coverage/lcov-report/*.js"
]
},
"rules": {
"ordered-imports": [false],
"object-literal-sort-keys": [false]
}
}

Cython read large binary file using class definition

My code tries to read a binary file using a Structure class:
import os
import mmap
from ctypes import Structure, c_uint
class StructFile(Structure):
_pack_ = 1
_fields_ = [('Xmin', c_uint),('Ymax', c_uint)]
fd = os.open(filePath, os.O_RDWR | os.O_BINARY)
mmap_file = mmap.mmap(fd, length=ln, access=mmap.ACCESS_WRITE, offset=0)
d_arrayFile = StructFile * numItems
data = d_arrayFile.from_buffer(mmap_file)
for i in data:
print i.Xmin, i.Ymax
It works correctly, but I would like to speed it up using a cython class. The problem is when I use cdef class StructFile(Structure): the compilation says: "'Structure' is not a type name".
How could I do in order to cython recognise 'Structure' as a type name like 'int', 'object', etc.? Or any other solution to optimise the code (not using struct.unpack).
Thanks!

Call a template expression from another in XTend

i have a question about calling template expression methods from another template expression.
The example below didn't work, ie. it doesn't expand and 'prints' the code on the spot it was called. How can I modify this code to print the result of ResourceGenerator().generate(resource) on the spot where it is called? Note that ResourceGenerator().generate(resource) is in itself a template expression.
class ServerGenerator extends RESTServiceGenerator {
def generate(Server it) '''
package nl.sytematic.projects.RESTServiceServlet;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
#Path("«it.baseURI»")
public class «it.name» {
«it.resources.forEach[ resource |new ResourceGenerator().generate(resource)]»
}
'''
}
Hope I am clear in my question. An example would be great! (Again: ResourceGenerator().generate returns a CharSequence).
forEach always returns null and is just about doing side-effects. What you want is a map and a join.
it.resources.map(resource |new ResourceGenerator().generate(resource)).join
But there's an even better way:
«FOR resource : resources»
«new ResourceGenerator().generate(resource)»
«ENDFOR»
I suggest to hold and reuse a single instance of ResourceGenerator as a field (do you use dependency injection?) or make ResourceGenerator::generate static.