/** * Evaluates to true if ANY of the passed in matchers evaluate to true. * @param matchers the matchers */ @SafeVarargs public final void anyOf(Matcher<? super T>... matchers) { verifyUsingMatcher(CoreMatchers.anyOf(matchers)); }
private static List<QueuedCommand> getQueuedCommands(final Object... args) { assertThat(args.length % 2, equalTo(0)); final List<QueuedCommand> queuedCommandList = new ArrayList<>(); for (int i = 0; i < args.length; i += 2) { assertThat(args[i], instanceOf(CommandId.class)); assertThat(args[i + 1], anyOf(is(nullValue()), instanceOf(Command.class))); queuedCommandList.add( new QueuedCommand((CommandId) args[i], (Command) args[i + 1])); } return queuedCommandList; }
private static ConsumerRecords<CommandId, Command> buildRecords(final Object... args) { assertThat(args.length % 2, equalTo(0)); final List<ConsumerRecord<CommandId, Command>> records = new ArrayList<>(); for (int i = 0; i < args.length; i += 2) { assertThat(args[i], instanceOf(CommandId.class)); assertThat(args[i + 1], anyOf(is(nullValue()), instanceOf(Command.class))); records.add( new ConsumerRecord<>(COMMAND_TOPIC, 0, 0, (CommandId) args[i], (Command) args[i + 1])); } return new ConsumerRecords<>(Collections.singletonMap(COMMAND_TOPIC_PARTITION, records)); } }
@Test public void getPrefix() { assertThat("Always returns \"xmlns\" for \"http://www.w3.org/2000/xmlns/\"", context.getPrefix(XMLConstants.XMLNS_ATTRIBUTE_NS_URI), is(XMLConstants.XMLNS_ATTRIBUTE)); assertThat("Always returns \"xml\" for \"http://www.w3.org/XML/1998/namespace\"", context.getPrefix(XMLConstants.XML_NS_URI), is(XMLConstants.XML_NS_PREFIX)); assertThat("Returns null for an unbound namespace URI", context.getPrefix(unboundNamespaceUri), is(nullValue())); context.bindNamespaceUri("prefix1", namespaceUri); context.bindNamespaceUri("prefix2", namespaceUri); assertThat("Returns a prefix for a bound namespace URI", context.getPrefix(namespaceUri), anyOf(is("prefix1"), is("prefix2"))); }
@Test public void test_getColumnClassName_forFLOAT_isFloat() throws SQLException { assertThat( rowMetadata.getColumnClassName( ordReqFLOAT ), anyOf( equalTo( Float.class.getName() ), equalTo( Double.class.getName() ) ) ); }
@Test public void withAsyncBeanWithExecutorQualifiedByName() throws ExecutionException, InterruptedException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(AsyncWithExecutorQualifiedByNameConfig.class); ctx.refresh(); AsyncBeanWithExecutorQualifiedByName asyncBean = ctx.getBean(AsyncBeanWithExecutorQualifiedByName.class); Future<Thread> workerThread0 = asyncBean.work0(); assertThat(workerThread0.get().getName(), not(anyOf(startsWith("e1-"), startsWith("otherExecutor-")))); Future<Thread> workerThread = asyncBean.work(); assertThat(workerThread.get().getName(), startsWith("e1-")); Future<Thread> workerThread2 = asyncBean.work2(); assertThat(workerThread2.get().getName(), startsWith("otherExecutor-")); Future<Thread> workerThread3 = asyncBean.work3(); assertThat(workerThread3.get().getName(), startsWith("otherExecutor-")); ctx.close(); }
@Test public void test_getSchemaName_forViewGetsName() throws SQLException { assertThat( rowMetadata.getSchemaName( ordOptBOOLEAN ), anyOf( equalTo( DFS_TMP_SCHEMA ), equalTo( "" ) ) ); }
@Test public void test_getCatalogName_getsCatalogName() throws SQLException { assertThat( rowMetadata.getCatalogName( ordOptBOOLEAN ), anyOf( equalTo( "DRILL" ), equalTo( "" ) ) ); }
@Test public void test_getTableName_forViewGetsName() throws SQLException { assertThat( rowMetadata.getTableName( ordOptBOOLEAN ), anyOf( equalTo( VIEW_NAME ), equalTo( "" ) ) ); }
@Test( expected = InvalidParameterSqlException.class ) public void testSetNetworkTimeoutRejectsBadTimeoutValue() throws SQLException { try { connection.setNetworkTimeout( executor, -1 ); } catch ( InvalidParameterSqlException e ) { // Check exception for some mention of parameter name or semantics: assertThat( e.getMessage(), anyOf( containsString( "milliseconds" ), containsString( "timeout" ), containsString( "Timeout" ) ) ); throw e; } }
@Test( expected = InvalidParameterSqlException.class ) public void testSetNetworkTimeoutRejectsBadExecutorValue() throws SQLException { try { connection.setNetworkTimeout( null, 1 ); } catch ( InvalidParameterSqlException e ) { // Check exception for some mention of parameter name or semantics: assertThat( e.getMessage(), anyOf( containsString( "executor" ), containsString( "Executor" ) ) ); throw e; } }
private void testCreateStreamAsSelect(String selectQuery, final Schema resultSchema, final Map<String, GenericRow> expectedResults) { if (!selectQuery.endsWith(";")) { selectQuery += ";"; } final String queryString = "CREATE STREAM " + streamName + " AS " + selectQuery; /* Start Stream Query */ assertRunCommand( queryString, anyOf( equalTo(new TestResult("Stream created and running")), equalTo(new TestResult("Parsing statement")), equalTo(new TestResult("Executing statement")))); /* Assert Results */ final Map<String, GenericRow> results = topicConsumer .readResults(streamName, resultSchema, expectedResults.size(), new StringDeserializer()); dropStream(streamName); assertThat(results, equalTo(expectedResults)); }
@Test public void testIteration() { assertTrue(_nbhs.isEmpty()); assertTrue(_nbhs.add("k1")); assertTrue(_nbhs.add("k2")); StringBuilder buf = new StringBuilder(); for (String val : _nbhs) { buf.append(val); } assertThat("found all vals", buf.toString(), anyOf(is("k1k2"), is("k2k1"))); assertThat("toString works", _nbhs.toString(), anyOf(is("[k1, k2]"), is("[k2, k1]"))); _nbhs.clear(); }
@Test public void testIteration() { assertTrue(_nbsi.isEmpty()); assertTrue(_nbsi.add(1)); assertTrue(_nbsi.add(2)); StringBuilder buf = new StringBuilder(); for (Integer val : _nbsi) { buf.append(val); } assertThat("found all vals", buf.toString(), anyOf(is("12"), is("21"))); assertThat("toString works", _nbsi.toString(), anyOf(is("[1, 2]"), is("[2, 1]"))); _nbsi.clear(); }
@Test( expected = SQLConversionOverflowException.class ) public void test_getByte_on_DOUBLE_thatOverflows_rejectsIt() throws InvalidAccessException { final SqlAccessor uut = new TypeConvertingSqlAccessor( new DoubleStubAccessor( -130 ) ); try { uut.getByte( 0 ); } catch ( Throwable e ) { assertThat( e.getMessage(), containsString( "-130" ) ); assertThat( e.getMessage(), containsString( "getByte" ) ); assertThat( e.getMessage(), allOf( containsString( "double" ), anyOf( containsString( "DOUBLE PRECISION" ), containsString( "FLOAT(" ) ) ) ); throw e; } }
@Test public void repro() { ConfigurableApplicationContext parent = new GenericApplicationContext(); parent.refresh(); AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext(); child.setParent(parent); child.refresh(); ConfigurableEnvironment env = child.getBean(ConfigurableEnvironment.class); assertThat("unknown env", env, anyOf( sameInstance(parent.getEnvironment()), sameInstance(child.getEnvironment()))); assertThat("expected child ctx env", env, sameInstance(child.getEnvironment())); child.close(); parent.close(); }
@Test(expected = SQLException.class) public void testExecuteThrowsRight1() throws Exception { final Statement statement = connection.createStatement(); try { statement.execute("SELECT one case of syntax error"); } catch (SQLException e) { assertThat("Null getCause(); missing expected wrapped exception", e.getCause(), notNullValue()); assertThat("Unexpectedly wrapped another SQLException", e.getCause(), not(instanceOf(SQLException.class))); assertThat("getCause() not UserRemoteException as expected", e.getCause(), instanceOf(UserRemoteException.class)); assertThat("No expected current \"SYSTEM ERROR\"/eventual \"PARSE ERROR\"", e.getMessage(), anyOf(startsWith("SYSTEM ERROR"), startsWith("PARSE ERROR"))); throw e; } }
@Test(expected = SQLException.class) public void testExecuteUpdateThrowsRight2() throws Exception { final Statement statement = connection.createStatement(); try { statement.executeUpdate("naughty, naughty query 3"); } catch (SQLException e) { assertThat("Null getCause(); missing expected wrapped exception", e.getCause(), notNullValue()); assertThat("Unexpectedly wrapped another SQLException", e.getCause(), not(instanceOf(SQLException.class))); assertThat("getCause() not UserRemoteException as expected", e.getCause(), instanceOf(UserRemoteException.class)); assertThat("No expected current \"SYSTEM ERROR\"/eventual \"PARSE ERROR\"", e.getMessage(), anyOf(startsWith("SYSTEM ERROR"), startsWith("PARSE ERROR"))); throw e; } }
assertEquals(new TimeWindow(0, 13), windowSet.addWindow(new TimeWindow(0, 13), mergeFunction)); assertTrue(mergeFunction.hasMerged()); assertThat(mergeFunction.mergedStateWindows(), anyOf( containsInAnyOrder(new TimeWindow(0, 3), new TimeWindow(5, 8)), containsInAnyOrder(new TimeWindow(0, 3), new TimeWindow(10, 13)), containsInAnyOrder(new TimeWindow(5, 8), new TimeWindow(10, 13)))); assertThat(windowSet.getStateWindow(new TimeWindow(0, 13)), anyOf(is(new TimeWindow(1, 3)), is(new TimeWindow(5, 8)), is(new TimeWindow(10, 13))));