/** * @return A matcher matching any collection in which every element matches elementMatcher * @deprecated Please use {@link CoreMatchers#everyItem(Matcher)} instead. */ @Deprecated public static <T> Matcher<Iterable<T>> everyItem(final Matcher<T> elementMatcher) { return CoreMatchers.everyItem(elementMatcher); }
/** * @return A matcher matching any collection in which every element matches elementMatcher * @deprecated Please use {@link CoreMatchers#everyItem(Matcher)} instead. */ @Deprecated public static <T> Matcher<Iterable<T>> everyItem(final Matcher<T> elementMatcher) { return CoreMatchers.everyItem(elementMatcher); }
/** * If called with one or more null elements in <code>objects</code>, the test will halt and be ignored. */ public static void assumeNotNull(Object... objects) { assumeThat(asList(objects), everyItem(notNullValue())); }
/** * If called with a {@code null} array or one or more {@code null} elements in {@code objects}, * the test will halt and be ignored. */ public static void assumeNotNull(Object... objects) { assumeThat(objects, notNullValue()); assumeThat(asList(objects), everyItem(notNullValue())); }
public void every(Matcher<T> elementMatcher) { verifyUsingMatcher(CoreMatchers.everyItem(elementMatcher)); }
.map(msgId -> msgId.offset()) .collect(Collectors.toList()); assertThat("Expected the emitted messages to be retries of the failed tuples from the first batch, plus the first failed tuple from the second batch", thirdRunOffsets, everyItem(either(isIn(firstRunOffsets)).or(is(secondRunMessageIds.getAllValues().get(0).offset()))));
public static void assertLoop(Predicate<Object> condition, Object... conditionParams) { try { Awaitility.with() .pollInterval(1, TimeUnit.MILLISECONDS) .atMost(Testing.TEST_TIMEOUT_MS, TimeUnit.MILLISECONDS) .untilAsserted(() -> assertThat(Arrays.asList(conditionParams), everyItem(matchesPredicate(condition)))); } catch (ConditionTimeoutException e) { throw new AssertionError(e.getMessage()); } }
@Test public void errorHops() throws Exception { TransMeta meta = new TransMeta(); meta.setFilename( "fileName" ); StepMeta from = new StepMeta( "step1", stepMetaInterface ); meta.addStep( from ); StepMeta to = new StepMeta( "step2", stepMetaInterface ); meta.addStep( to ); meta.addTransHop( new TransHopMeta( from, to ) ); StepMeta error = new StepMeta( "errorHandler", stepMetaInterface ); meta.addStep( error ); TransHopMeta errorHop = new TransHopMeta( from, error ); errorHop.setErrorHop( true ); meta.addTransHop( errorHop ); Transformation trans = TransMetaConverter.convert( meta ); Map<String, List<Hop>> hops = trans.getHops().stream().collect( Collectors.groupingBy( Hop::getType ) ); List<Hop> normalHops = hops.get( Hop.TYPE_NORMAL ); assertThat( normalHops.size(), is( 1 ) ); assertThat( normalHops.get( 0 ).getTo().getId(), is( "step2" ) ); List<Hop> errorHops = hops.get( Hop.TYPE_ERROR ); assertThat( errorHops.size(), is( 1 ) ); assertThat( errorHops.get( 0 ).getTo().getId(), is( "errorHandler" ) ); assertThat( hops.values().stream() .flatMap( List::stream ) .map( Hop::getFrom ).map( Operation::getId ) .collect( Collectors.toList() ), everyItem( equalTo( "step1" ) ) ); }
@Test public void transWithHops() { TransMeta meta = new TransMeta(); meta.setFilename( "fileName" ); StepMeta from = new StepMeta( "step1", stepMetaInterface ); meta.addStep( from ); StepMeta to = new StepMeta( "step2", stepMetaInterface ); meta.addStep( to ); meta.addTransHop( new TransHopMeta( from, to ) ); Transformation trans = TransMetaConverter.convert( meta ); assertThat( trans.getId(), is( meta.getFilename() ) ); assertThat( trans.getOperations().size(), is( 2 ) ); assertThat( trans.getHops().size(), is( 1 ) ); assertThat( trans.getHops().get( 0 ).getFrom().getId(), is( from.getName() ) ); assertThat( trans.getHops().get( 0 ).getTo().getId(), is( to.getName() ) ); assertThat( trans.getHops().stream().map( Hop::getType ).collect( Collectors.toList() ), everyItem( is( Hop.TYPE_NORMAL ) ) ); }
/** * @return A matcher matching any collection in which every element matches elementMatcher * @deprecated Please use {@link CoreMatchers#everyItem(Matcher)} instead. */ @Deprecated public static <T> Matcher<Iterable<T>> everyItem(final Matcher<T> elementMatcher) { return CoreMatchers.everyItem(elementMatcher); }
/** * If called with one or more null elements in <code>objects</code>, the test will halt and be ignored. */ public static void assumeNotNull(Object... objects) { assumeThat(asList(objects), everyItem(notNullValue())); }
@Test public void waitOptionsShouldBuildProperly() { final Map<String, Object> actualOpts = new WaitOptions() .withDuration(ofSeconds(1)) .build(); final Map<String, Object> expectedOpts = new HashMap<>(); expectedOpts.put("ms", 1000L); assertThat(actualOpts.entrySet(), everyItem(isIn(expectedOpts.entrySet()))); assertThat(expectedOpts.entrySet(), everyItem(isIn(actualOpts.entrySet()))); } }
@Test public void tapOptionsShouldBuildProperly() { final Map<String, Object> actualOpts = tapOptions() .withPosition(point(new Point(0, 0))) .withTapsCount(2) .build(); final Map<String, Object> expectedOpts = new HashMap<>(); expectedOpts.put("x", 0); expectedOpts.put("y", 0); expectedOpts.put("count", 2); assertThat(actualOpts.entrySet(), everyItem(isIn(expectedOpts.entrySet()))); assertThat(expectedOpts.entrySet(), everyItem(isIn(actualOpts.entrySet()))); }
@Test public void longPressOptionsShouldBuildProperly() { final Map<String, Object> actualOpts = longPressOptions() .withElement(element(DUMMY_ELEMENT).withCoordinates(0, 0)) .withDuration(ofMillis(1)) .build(); final Map<String, Object> expectedOpts = new HashMap<>(); expectedOpts.put("element", ((RemoteWebElement) DUMMY_ELEMENT).getId()); expectedOpts.put("x", 0); expectedOpts.put("y", 0); expectedOpts.put("duration", 1L); assertThat(actualOpts.entrySet(), everyItem(isIn(expectedOpts.entrySet()))); assertThat(expectedOpts.entrySet(), everyItem(isIn(actualOpts.entrySet()))); }
/** * @return A matcher matching any collection in which every element matches elementMatcher * @deprecated Please use {@link CoreMatchers#everyItem(Matcher)} instead. */ @Deprecated public static <T> Matcher<Iterable<T>> everyItem(final Matcher<T> elementMatcher) { return CoreMatchers.everyItem(elementMatcher); }
/** * @return A matcher matching any collection in which every element matches elementMatcher * @deprecated Please use {@link CoreMatchers#everyItem(Matcher)} instead. */ @Deprecated public static <T> Matcher<Iterable<T>> everyItem(final Matcher<T> elementMatcher) { return CoreMatchers.everyItem(elementMatcher); }
/** * If called with one or more null elements in <code>objects</code>, the test will halt and be ignored. */ public static void assumeNotNull(Object... objects) { assumeThat(asList(objects), everyItem(notNullValue())); }
/** * If called with one or more null elements in <code>objects</code>, the test will halt and be ignored. */ public static void assumeNotNull(Object... objects) { assumeThat(asList(objects), everyItem(notNullValue())); }
@Test void objectShouldMatch() { assertThatJson("{\"test\":[{\"value\":1},{\"value\":2},{\"value\":3}]}").node("test").matches(everyItem(jsonPartMatches("value", lessThanOrEqualTo(valueOf(4))))); }
@Test public void testAsIterable() { final Request<?, ?> request = new TransactionPurgeRequest(TRANSACTION_IDENTIFIER, 0L, probe.ref()); final Consumer<Response<?, ?>> callback = createConsumerMock(); final long now = Ticker.systemTicker().read(); final int sentMessages = getMaxInFlightMessages() + 1; for (int i = 0; i < sentMessages; i++) { queue.enqueueOrForward(new ConnectionEntry(request, callback, now), now); } final Collection<ConnectionEntry> entries = queue.drain(); Assert.assertEquals(sentMessages, entries.size()); Assert.assertThat(entries, everyItem(entryWithRequest(request))); }