.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()))));
/** * Creates a matcher that matches when either of the specified matchers match the examined object. * <p/> * For example: * <pre>assertThat("fan", either(containsString("a")).and(containsString("b")))</pre> */ @Factory public static <LHS> CombinableEitherMatcher<LHS> either(Matcher<? super LHS> matcher) { return new CombinableEitherMatcher<LHS>(matcher); }
.or(Matchers.containsString("BigQuery dataset not found for table"))); tableRows.apply( BigQueryIO.writeTableRows()
assertThat(prevDoc.getSplitDocType(), either(is(SplitDocType.DEFAULT)).or(is(SplitDocType.DEFAULT_NO_BRANCH)));
/** * Checks the result of {@link QueryBuilder#toQuery(QueryShardContext)} given the original {@link QueryBuilder} * and {@link QueryShardContext}. Verifies that named queries and boost are properly handled and delegates to * {@link #doAssertLuceneQuery(AbstractQueryBuilder, Query, SearchContext)} for query specific checks. */ private void assertLuceneQuery(QB queryBuilder, Query query, SearchContext context) throws IOException { if (queryBuilder.queryName() != null) { Query namedQuery = context.getQueryShardContext().copyNamedQueries().get(queryBuilder.queryName()); assertThat(namedQuery, equalTo(query)); } if (query != null) { if (queryBuilder.boost() != AbstractQueryBuilder.DEFAULT_BOOST) { assertThat(query, either(instanceOf(BoostQuery.class)).or(instanceOf(SpanBoostQuery.class))); if (query instanceof SpanBoostQuery) { SpanBoostQuery spanBoostQuery = (SpanBoostQuery) query; assertThat(spanBoostQuery.getBoost(), equalTo(queryBuilder.boost())); query = spanBoostQuery.getQuery(); } else { BoostQuery boostQuery = (BoostQuery) query; assertThat(boostQuery.getBoost(), equalTo(queryBuilder.boost())); query = boostQuery.getQuery(); } } } doAssertLuceneQuery(queryBuilder, query, context); }
/** * Test for the {@link MoveActionNodeTypeRestrictionToAvailabilityTask}. */ @Test public void testMoveActionNodeTypeRestrictionToAvailabilityTask() throws Exception { // GIVEN Node actionNode = NodeUtil.createPath(session.getRootNode(), "/modules/test/apps/myApp/subApps/browser/actions/editItem", NodeTypes.ContentNode.NAME); actionNode.setProperty("class", EditItemActionDefinition.class.getName()); actionNode.setProperty(NODE_TYPE, "mgnl:dummyNode"); session.save(); ContentAppMigrationTask task = new ContentAppMigrationTask("/modules/test"); // WHEN task.execute(installContext); // THEN assertFalse(actionNode.hasProperty(NODE_TYPE)); // nodeType property has been removed from the action node assertTrue(actionNode.hasNode("availability")); // availability and nodeTypes nodes exist assertTrue(actionNode.getNode("availability").hasNode(NODE_TYPES)); Node nodeTypes = actionNode.getNode("availability/nodeTypes"); // It's a pity we have to help the either().or() matcher with generics here; 1.7 doesn't need this. assertThat(nodeTypes, everyProperty(Matchers.<Property> either(propertyName(startsWith("jcr:"))). or(propertyName(startsWith("mgnl:"))). or(propertyValue(equalTo("mgnl:dummyNode"))))); }
@Deployment public void testParallelGatewayBeforeAndInSubProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); List<Task> tasks = taskService.createTaskQuery().list(); assertThat(tasks, hasSize(3)); ActivityInstance instance = runtimeService.getActivityInstance(processInstance.getId()); assertThat(instance.getActivityName(), is("Process1")); ActivityInstance[] childActivityInstances = instance.getChildActivityInstances(); for (ActivityInstance activityInstance : childActivityInstances) { if (activityInstance.getActivityId().equals("SubProcess_1")) { ActivityInstance[] instances = activityInstance.getChildActivityInstances(); for (ActivityInstance activityInstance2 : instances) { assertThat(activityInstance2.getActivityName(), is(either(equalTo("Inner User Task 1")).or(CoreMatchers.<Object>equalTo("Inner User Task 2")))); } } else { assertThat(activityInstance.getActivityName(), is("Outer User Task")); } } }
@Test public void excerptFunction() throws RepositoryException { String statement = "SELECT rep:excerpt() from mgnl:page WHERE contains(., 'article')"; Session session = MgnlContext.getJCRSession("website"); QueryManager manager = session.getWorkspace().getQueryManager(); // excerpt functionality isn't supported in JCR_SQL2 https://issues.apache.org/jira/browse/JCR-3609 Query query = manager.createQuery(statement, Query.SQL); // We need to work with QueryResult#rows anyway, so QueryUtil won't help QueryResult result = query.execute(); @SuppressWarnings("unchecked") final ImmutableList<Row> rows = ImmutableList.<Row> copyOf(result.getRows()); assertThat(rows, everyItem(column("rep:excerpt()", allOf( either(containsString("This is the abstract for the <strong>article</strong> page")).or(containsString("Teaser to an <strong>Article</strong>")), not(containsString("<")), not(containsString(">")), not(containsString(""")), not(regexMatch(UUID_PATTERN)) )))); }
@Test public void testSecure() throws Exception { for (HttpUriRequest request : Arrays.asList( new HttpGet(jetty.getUri().resolve("rest/layers.xml")), new HttpGet(jetty.getUri().resolve("rest/seed/img%20states")), new HttpPost(jetty.getUri().resolve("rest/reload")), new HttpPost(jetty.getUri().resolve("rest/seed/img%20states.xml")), new HttpGet(jetty.getUri().resolve("rest/seed/img%20states.xml")), new HttpGet(jetty.getUri().resolve("rest/seed/ui_form")), new HttpPost(jetty.getUri().resolve("rest/seed/ui_form")), new HttpGet(jetty.getUri().resolve("rest/masstruncate")), new HttpPost(jetty.getUri().resolve("rest/masstruncate")))) { testSecured(request, not(either(equalTo(401)).or(equalTo(405)))); } }
@Test public void testClientIsInstrumentedWithTracer() throws InterruptedException, IOException { OpenSpan parentTrace = Tracer.startSpan(""); Tracer.subscribe(TracerTest.class.getName(), span -> { assertThat(span.getOperation(), either(is("acquireLimiter")).or(is("GET /{param}"))); }); String traceId = Tracer.getTraceId(); service.param("somevalue"); Tracer.unsubscribe(TracerTest.class.getName()); RecordedRequest request = server.takeRequest(); assertThat(request.getHeader(TraceHttpHeaders.TRACE_ID), is(traceId)); assertThat(request.getHeader(TraceHttpHeaders.SPAN_ID), is(not(parentTrace.getSpanId()))); } }
@Factory public static Matcher<AspectRatio> closeToOrInverse(AspectRatio ratio) { return either(closeTo(ratio)).or(closeTo(ratio.inverse())); }
@Test public void shouldMaximizeDamageOutputInCurrentTurn() { assertThat(strategy.nextMove(withMana(8), andHealth(30), fromCards(7, 6, 4, 3, 2)), either(is(isAttackingWithCard(2))).or(is(isAttackingWithCard(6)))); }
/** * Creates a matcher that matches when either of the specified matchers match the examined object. * <p/> * For example: * <pre>assertThat("fan", either(containsString("a")).and(containsString("b")))</pre> */ @Factory public static <LHS> CombinableEitherMatcher<LHS> either(Matcher<? super LHS> matcher) { return new CombinableEitherMatcher<LHS>(matcher); }
/** * Creates a matcher that matches when either of the specified matchers match the examined object. * <p/> * For example: * <pre>assertThat("fan", either(containsString("a")).and(containsString("b")))</pre> */ @Factory public static <LHS> CombinableEitherMatcher<LHS> either(Matcher<? super LHS> matcher) { return new CombinableEitherMatcher<LHS>(matcher); }
/** * Creates a matcher that matches when either of the specified matchers match the examined object. * <p/> * For example: * <pre>assertThat("fan", either(containsString("a")).and(containsString("b")))</pre> */ @Factory public static <LHS> CombinableEitherMatcher<LHS> either(Matcher<? super LHS> matcher) { return new CombinableEitherMatcher<LHS>(matcher); }
/** * Creates a matcher that matches when either of the specified matchers match the examined object. * <p/> * For example: * <pre>assertThat("fan", either(containsString("a")).and(containsString("b")))</pre> */ @Factory public static <LHS> CombinableEitherMatcher<LHS> either(Matcher<? super LHS> matcher) { return new CombinableEitherMatcher<LHS>(matcher); }
/** * Creates a matcher that matches when either of the specified matchers match the examined object. * <p/> * For example: * <pre>assertThat("fan", either(containsString("a")).and(containsString("b")))</pre> */ @Factory public static <LHS> CombinableEitherMatcher<LHS> either(Matcher<? super LHS> matcher) { return new CombinableEitherMatcher<LHS>(matcher); }
/** * Creates a matcher that matches when either of the specified matchers match the examined object. * <p/> * For example: * <pre>assertThat("fan", either(containsString("a")).and(containsString("b")))</pre> */ @Factory public static <LHS> CombinableEitherMatcher<LHS> either(Matcher<? super LHS> matcher) { return new CombinableEitherMatcher<LHS>(matcher); }
/** * Creates a matcher that matches when either of the specified matchers match the examined object. * <p/> * For example: * <pre>assertThat("fan", either(containsString("a")).and(containsString("b")))</pre> */ @Factory public static <LHS> CombinableEitherMatcher<LHS> either(Matcher<? super LHS> matcher) { return new CombinableEitherMatcher<LHS>(matcher); }