本文整理汇总了Java中org.assertj.core.util.Arrays类的典型用法代码示例。如果您正苦于以下问题:Java Arrays类的具体用法?Java Arrays怎么用?Java Arrays使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Arrays类属于org.assertj.core.util包,在下文中一共展示了Arrays类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatPrimitiveArray
import org.assertj.core.util.Arrays; //导入依赖的package包/类
protected String formatPrimitiveArray(Object o) {
if (!isArray(o)) return null;
if (!isArrayTypePrimitive(o)) throw Arrays.notAnArrayOfPrimitives(o);
int size = getLength(o);
if (size == 0) return DEFAULT_START + DEFAULT_END;
StringBuilder buffer = new StringBuilder();
buffer.append(DEFAULT_START);
buffer.append(toStringOf(Array.get(o, 0)));
for (int i = 1; i < size; i++) {
buffer.append(ELEMENT_SEPARATOR)
.append(INDENTATION_FOR_SINGLE_LINE);
if (i == maxElementsForPrinting) {
buffer.append(DEFAULT_MAX_ELEMENTS_EXCEEDED);
break;
}
buffer.append(toStringOf(Array.get(o, i)));
}
buffer.append(DEFAULT_END);
return buffer.toString();
}
示例2: shouldPrintVerboseResult
import org.assertj.core.util.Arrays; //导入依赖的package包/类
@Test
public void shouldPrintVerboseResult() {
JacksonEvolutionResultConsumer<Integer> integerJacksonEvolutionResultConsumer = new JacksonEvolutionResultConsumer<Integer>();
ComparisonResult<Integer> integerComparisonResult = new ComparisonResult<Integer>("testEvolution",
ImplementationPreference.EVOLVED,
new ProtoplastValueExecutionResult<Integer>(Arrays.array(1,2), 100, 6),
new EvolvedValueExecutionResult<Integer>(Arrays.array(1,2), 130, 6),
ResultType.OK);
integerJacksonEvolutionResultConsumer.consumeResults(integerComparisonResult, ResultConsumerConfiguration.VERBOSE);
}
示例3: shouldPrintSilentResult
import org.assertj.core.util.Arrays; //导入依赖的package包/类
@Test
public void shouldPrintSilentResult() {
JacksonEvolutionResultConsumer<Integer> integerJacksonEvolutionResultConsumer = new JacksonEvolutionResultConsumer<Integer>();
ComparisonResult<Integer> integerComparisonResult = new ComparisonResult<Integer>("testEvolution",
ImplementationPreference.EVOLVED,
new ProtoplastValueExecutionResult<Integer>(Arrays.array(1,2), 100, 6),
new EvolvedValueExecutionResult<Integer>(Arrays.array(1,2), 130, 6),
ResultType.OK);
integerJacksonEvolutionResultConsumer.consumeResults(integerComparisonResult, ResultConsumerConfiguration.SILENT);
}
示例4: createIntegerOkExceptionsComparisonResult
import org.assertj.core.util.Arrays; //导入依赖的package包/类
private static ComparisonResult<Integer> createIntegerOkExceptionsComparisonResult() {
return new ComparisonResult<Integer>("testEvolution",
ImplementationPreference.EVOLVED,
new ProtoplastExceptionExecutionResult<Integer>(Arrays.array(-1,-2), 100, new Exception("fasd")),
new EvolvedExceptionExecutionResult<Integer>(Arrays.array(-1,-2), 130, new Exception("fdsa")),
ResultType.OK_EXCEPTIONS);
}
示例5: createIntegerValueOkComparisonResult
import org.assertj.core.util.Arrays; //导入依赖的package包/类
private static ComparisonResult<Integer> createIntegerValueOkComparisonResult() {
return new ComparisonResult<Integer>("testEvolution",
ImplementationPreference.EVOLVED,
new ProtoplastValueExecutionResult<Integer>(Arrays.array(-1,-2), 100, -6),
new EvolvedValueExecutionResult<Integer>(Arrays.array(-1,-2), 130, -6),
ResultType.OK);
}
示例6: should_convert_sequence_of_blank_strings_to_empty_string_array
import org.assertj.core.util.Arrays; //导入依赖的package包/类
@Test
public void should_convert_sequence_of_blank_strings_to_empty_string_array() throws Exception {
// given
StateTypeConverter typeConverter = new StateTypeConverter();
String[] arrayOfEmptyStrings = Arrays.array("", "", "", "", "");
// when
String[] convertedStringArray = typeConverter.convert(" , , , , ", String[].class);
// then
assertThat(convertedStringArray).isEqualTo(arrayOfEmptyStrings);
}
示例7: should_convert_single_element_to_one_element_array
import org.assertj.core.util.Arrays; //导入依赖的package包/类
@Test
public void should_convert_single_element_to_one_element_array() throws Exception {
// given
StateTypeConverter typeConverter = new StateTypeConverter();
String[] singleElementArray = Arrays.array("one element");
// when
String[] convertedStringArray = typeConverter.convert("one element", String[].class);
// then
assertThat(convertedStringArray).isEqualTo(singleElementArray);
}
示例8: should_convert_single_element_with_delimiter_to_one_element_array
import org.assertj.core.util.Arrays; //导入依赖的package包/类
@Test
public void should_convert_single_element_with_delimiter_to_one_element_array() throws Exception {
// given
StateTypeConverter typeConverter = new StateTypeConverter();
String[] singleElementArray = Arrays.array("one element");
// when
String[] convertedStringArray = typeConverter.convert("one element,", String[].class);
// then
assertThat(convertedStringArray).isEqualTo(singleElementArray);
}
示例9: should_convert_single_element_with_delimiters_to_one_element_array
import org.assertj.core.util.Arrays; //导入依赖的package包/类
@Test
public void should_convert_single_element_with_delimiters_to_one_element_array() throws Exception {
// given
StateTypeConverter typeConverter = new StateTypeConverter();
String[] singleElementArray = Arrays.array("one element");
// when
String[] convertedStringArray = typeConverter.convert("one element,,,,,,,", String[].class);
// then
assertThat(convertedStringArray).isEqualTo(singleElementArray);
}
示例10: should_convert_blank_to_empty_string_when_appear_in_sequence_with_non_blanks
import org.assertj.core.util.Arrays; //导入依赖的package包/类
@Test
public void should_convert_blank_to_empty_string_when_appear_in_sequence_with_non_blanks() throws Exception {
// given
StateTypeConverter typeConverter = new StateTypeConverter();
String[] expectedArray = Arrays.array("a", "", "test", "", "", "b");
// when
String[] convertedStringArray = typeConverter.convert("a, , test , , , b ", String[].class);
// then
assertThat(convertedStringArray).isEqualTo(expectedArray);
}
示例11: testingCombiningNestedObservables
import org.assertj.core.util.Arrays; //导入依赖的package包/类
@Test
public void testingCombiningNestedObservables() {
Observable<String> observable1 = Observable.from(Arrays.array(1, 2, 3, 4, 5, 6, 7, 8, 9)).map(el -> "a" + el);
Observable<String> observable2 = Observable.from(Arrays.array(10, 20, 30, 40, 50, 60, 70, 80, 90)).map(el -> "a" + el);
Observable<Observable<String>> observableObservable =
Observable.from(new Observable[]{observable1, observable2});
Observable<String> mergedObservable = Observable.merge(observableObservable);
mergedObservable.subscribe(System.out::println);
}
示例12: testingCombiningNestedObservablesWithLatency
import org.assertj.core.util.Arrays; //导入依赖的package包/类
@Test
public void testingCombiningNestedObservablesWithLatency() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(19);
Observable<String> observable1 = Observable.interval(1L, SECONDS).map(el -> "a" + el).take(10);
Observable<String> observable2 = Observable.from(Arrays.array(10L, 20L, 30L, 40L, 50L, 60L, 70L, 80L, 90L)).map(el -> "b" + el);
Observable<Observable<String>> observableObservable =
Observable.from(new Observable[] { observable1, observable2 });
Observable<String> mergedObservable = Observable.merge(observableObservable);
mergedObservable.subscribe((x) -> {
latch.countDown();
System.out.println(x);
});
latch.await();
}
示例13: testYahooFinanceRealtimeTwo
import org.assertj.core.util.Arrays; //导入依赖的package包/类
@Test
public void testYahooFinanceRealtimeTwo() throws Exception {
String body = doRestQuery(realtimeUrl, format("%s+%s", tickerA.getRicAsString(), tickerB.getRicAsString()));
logger.info("and the response body should be parseable as a YahooFinanceRealtime object");
List<YahooFinanceRealtime> yfrs = YahooFinanceRealtime.of(OffsetDateTime.now(), body.split("\\n"),
Arrays.array(tickerA, tickerB));
assertThat(yfrs).hasSize(2);
}
示例14: withJpaServer
import org.assertj.core.util.Arrays; //导入依赖的package包/类
@Test
public void withJpaServer() {
load(
Arrays.array(
EmbeddedDataSourceConfiguration.class,
HibernateJpaAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
FhirAutoConfiguration.class),
"hapi.fhir.version:DSTU3",
"spring.jpa.properties.hibernate.search.default.indexBase:target/lucenefiles",
"spring.jpa.properties.hibernate.search.model_mapping:ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory");
assertThat(this.context.getBeansOfType(DaoConfig.class)).hasSize(1);
assertThat(this.context.getBeansOfType(Dstu3.class)).hasSize(1);
}
示例15: assertIsAssignableFrom
import org.assertj.core.util.Arrays; //导入依赖的package包/类
/**
* Verifies that the actual {@code Class} is assignable from all the {@code others} classes.
*
* @param info contains information about the assertion.
* @param actual the "actual" {@code Class}.
* @param others the others {@code Class} who this actual class must be assignable.
* @throws NullPointerException if one of the {@code others} is {@code null}.
* @throws AssertionError if {@code actual} is {@code null}.
* @throws AssertionError if the actual {@code Class} is not assignable from all of the {@code others} classes.
*/
public void assertIsAssignableFrom(AssertionInfo info, Class<?> actual, Class<?>... others) {
assertNotNull(info, actual);
checkArgument(!Arrays.isNullOrEmpty(others), "Expecting at least one Class to be specified");
Set<Class<?>> expected = newLinkedHashSet(others);
Set<Class<?>> missing = new LinkedHashSet<>();
for (Class<?> other : expected) {
classParameterIsNotNull(other);
if (!actual.isAssignableFrom(other)) missing.add(other);
}
if (!missing.isEmpty()) throw failures.failure(info, shouldBeAssignableFrom(actual, expected, missing));
}