Refine search
/** * A shortcut to the frequently used <code>not(equalTo(x))</code>. * For example: * <pre>assertThat(cheese, is(not(smelly)))</pre> * instead of: * <pre>assertThat(cheese, is(not(equalTo(smelly))))</pre> * * @param value * the value that any examined object should <b>not</b> equal */ public static <T> Matcher<T> not(T value) { return not(equalTo(value)); } }
/** * Creates a matcher that wraps an existing matcher, but inverts the logic by which * it will match. * <p/> * For example: * <pre>assertThat(cheese, is(not(equalTo(smelly))))</pre> * * @param matcher * the matcher whose sense should be inverted */ @Factory public static <T> Matcher<T> not(Matcher<T> matcher) { return new IsNot<T>(matcher); }
@Test public void shouldComputeHashCodeForOnePrimitive() { assertThat(HashCode.compute(1), is(not(0))); assertThat(HashCode.compute((long) 8), is(not(0))); assertThat(HashCode.compute((short) 3), is(not(0))); assertThat(HashCode.compute(1.0f), is(not(0))); assertThat(HashCode.compute(1.0d), is(not(0))); assertThat(HashCode.compute(true), is(not(0))); }
@Test public void testRecoveryInteractiveMode() throws Exception { // Arrange File logfile = new File(new File(mySnapDir, "version-2"), "log.42"); TxnLogToolkit lt = new TxnLogToolkit(true, false, logfile.toString(), false); // Act lt.dump(new Scanner("y\n")); // Assert String output = outContent.toString(); assertThat(output, containsString("CRC ERROR")); // Should be able to dump the recovered logfile with no CRC error outContent.reset(); logfile = new File(new File(mySnapDir, "version-2"), "log.42.fixed"); lt = new TxnLogToolkit(false, false, logfile.toString(), true); lt.dump(null); output = outContent.toString(); assertThat(output, not(containsString("CRC ERROR"))); } }
@Test public void testSimpleQuery() { final String simpleQuery = "SELECT col0, col2, col3 FROM test1 WHERE col0 > 100;"; final PreparedStatement statement = KSQL_PARSER.buildAst(simpleQuery, metaStore).get(0); assertThat(statement.getStatementText(), is(simpleQuery)); Assert.assertTrue("testSimpleQuery fails", statement.getStatement() instanceof Query); final Query query = (Query) statement.getStatement(); Assert.assertTrue("testSimpleQuery fails", query.getQueryBody() instanceof QuerySpecification); final QuerySpecification querySpecification = (QuerySpecification)query.getQueryBody(); Assert.assertTrue("testSimpleQuery fails", querySpecification.getSelect().getSelectItems().size() == 3); assertThat(querySpecification.getFrom(), not(nullValue())); Assert.assertTrue("testSimpleQuery fails", querySpecification.getWhere().isPresent()); Assert.assertTrue("testSimpleQuery fails", querySpecification.getWhere().get() instanceof ComparisonExpression); final ComparisonExpression comparisonExpression = (ComparisonExpression)querySpecification.getWhere().get(); Assert.assertTrue("testSimpleQuery fails", comparisonExpression.getType().getValue().equalsIgnoreCase(">")); }
@Test public void updateSubClassProperty() { doInJPA( this::entityManagerFactory, entityManager -> { Customer customer = entityManager.find( Customer.class, customerId ); assertThat( customer.getCreatedAt(), is( not( nullValue() ) ) ); assertThat( customer.getModifiedAt(), is( not( nullValue() ) ) ); assertModifiedAtWasNotUpdated( customer ); customer.setEmail( "xyz@" ); } ); doInJPA( this::entityManagerFactory, entityManager -> { Customer customer = entityManager.find( Customer.class, customerId ); assertThat( customer.getCreatedAt(), is( not( nullValue() ) ) ); assertThat( customer.getModifiedAt(), is( not( nullValue() ) ) ); assertModifiedAtWasUpdated( customer ); } ); }
/** * Two StorageDescriptorKey objects with null storage descriptors should be * equal iff the base location is equal. */ @Test public void testCompareNullSd() { assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", null), is(new MetaStoreServerUtils.StorageDescriptorKey("a", null))); // Different locations produce different objects assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", null), IsNot.not(equalTo(new MetaStoreServerUtils.StorageDescriptorKey("b", null)))); }
@Test public void testInsertInto() { final String insertIntoString = "INSERT INTO test2 SELECT col0, col2, col3 FROM test1 WHERE col0 > " + "100;"; final Statement statement = KSQL_PARSER.buildAst(insertIntoString, metaStore).get(0) .getStatement(); final StatementRewriter statementRewriter = new StatementRewriter(); final Statement rewrittenStatement = (Statement) statementRewriter.process(statement, null); assertThat(rewrittenStatement, instanceOf(InsertInto.class)); final InsertInto insertInto = (InsertInto) rewrittenStatement; assertThat(insertInto.getTarget().toString(), equalTo("TEST2")); final Query query = insertInto.getQuery(); assertThat(query.getQueryBody(), instanceOf(QuerySpecification.class)); final QuerySpecification querySpecification = (QuerySpecification)query.getQueryBody(); assertThat(querySpecification.getSelect().getSelectItems().size(), equalTo(3)); assertThat(querySpecification.getFrom(), not(nullValue())); assertThat(querySpecification.getWhere().isPresent(), equalTo(true)); assertThat(querySpecification.getWhere().get(), instanceOf(ComparisonExpression.class)); final ComparisonExpression comparisonExpression = (ComparisonExpression)querySpecification.getWhere().get(); assertThat(comparisonExpression.getType().getValue(), equalTo(">")); }
/** * A shortcut to the frequently used <code>not(nullValue())</code>. * <p/> * For example: * <pre>assertThat(cheese, is(notNullValue()))</pre> * instead of: * <pre>assertThat(cheese, is(not(nullValue())))</pre> * */ @Factory public static Matcher<Object> notNullValue() { return not(nullValue()); }
/** * A shortcut to the frequently used <code>not(equalTo(x))</code>. * <p/> * For example: * <pre>assertThat(cheese, is(not(smelly)))</pre> * instead of: * <pre>assertThat(cheese, is(not(equalTo(smelly))))</pre> * * @param value * the value that any examined object should <b>not</b> equal */ @Factory public static <T> Matcher<T> not(T value) { return not(equalTo(value)); } }
assertTrue(mergeFunction.hasMerged()); assertEquals(new TimeWindow(5, 13), mergeFunction.mergeTarget()); assertThat(mergeFunction.stateWindow(), anyOf(is(new TimeWindow(5, 8)), is(new TimeWindow(10, 13)))); assertThat(mergeFunction.mergeSources(), containsInAnyOrder(new TimeWindow(5, 8), new TimeWindow(10, 13))); assertThat(mergeFunction.mergedStateWindows(), anyOf( containsInAnyOrder(new TimeWindow(10, 13)), containsInAnyOrder(new TimeWindow(5, 8)))); assertThat(mergeFunction.mergedStateWindows(), not(hasItem(mergeFunction.mergeTarget()))); assertFalse(mergeFunction.hasMerged()); assertThat(windowSet.getStateWindow(new TimeWindow(5, 13)), anyOf(is(new TimeWindow(5, 8)), is(new TimeWindow(10, 13)))); containsInAnyOrder(new TimeWindow(5, 8)), containsInAnyOrder(new TimeWindow(10, 13)))); assertThat(mergeFunction.mergedStateWindows(), not(hasItem(mergeFunction.mergeTarget()))); assertThat(windowSet.getStateWindow(new TimeWindow(0, 13)), anyOf(is(new TimeWindow(0, 3)), is(new TimeWindow(5, 8)), is(new TimeWindow(10, 13))));
@Test public void verifyExampleInClassLevelJavadoc() throws Exception { Assume.group(TestGroup.PERFORMANCE); WebClient webClient = new WebClient(); MockMvc mockMvc = MockMvcBuilders.standaloneSetup().build(); MockMvcWebConnection mockConnection = new MockMvcWebConnection(mockMvc, webClient); WebRequestMatcher cdnMatcher = new UrlRegexRequestMatcher(".*?//code.jquery.com/.*"); WebConnection httpConnection = new HttpWebConnection(webClient); webClient.setWebConnection( new DelegatingWebConnection(mockConnection, new DelegateWebConnection(cdnMatcher, httpConnection))); Page page = webClient.getPage("http://code.jquery.com/jquery-1.11.0.min.js"); assertThat(page.getWebResponse().getStatusCode(), equalTo(200)); assertThat(page.getWebResponse().getContentAsString(), not(isEmptyString())); }
/** * Creates a matcher that wraps an existing matcher, but inverts the logic by which * it will match. * <p/> * For example: * <pre>assertThat(cheese, is(not(equalTo(smelly))))</pre> * * @param matcher * the matcher whose sense should be inverted */ public static <T> org.hamcrest.Matcher<T> not(org.hamcrest.Matcher<T> matcher) { return org.hamcrest.core.IsNot.<T>not(matcher); }
@Test public void secureMessageCannotBeDecodedWithNeitherSenderNorRecipientPrivateKey() { // Act: final byte[] input = new byte[] { 12, 46, 7, 43, 22, 15 }; final SecureMessage message = createRoundTrippedMessage(input, false, false); // Assert: Assert.assertThat(message.canDecode(), IsEqual.equalTo(false)); Assert.assertThat(message.getDecodedPayload(), IsNull.nullValue()); Assert.assertThat(message.getEncodedPayload(), IsNot.not(IsEqual.equalTo(input))); }
/** * Creates a matcher that wraps an existing matcher, but inverts the logic by which * it will match. * For example: * <pre>assertThat(cheese, is(not(equalTo(smelly))))</pre> * * @param matcher * the matcher whose sense should be inverted */ public static <T> Matcher<T> not(Matcher<T> matcher) { return new IsNot<T>(matcher); }
@Test public void testRecoveryFixBrokenFile() throws Exception { // Arrange File logfile = new File(new File(mySnapDir, "version-2"), "log.42"); TxnLogToolkit lt = new TxnLogToolkit(true, false, logfile.toString(), true); // Act lt.dump(null); // Assert String output = outContent.toString(); assertThat(output, containsString("CRC FIXED")); // Should be able to dump the recovered logfile with no CRC error outContent.reset(); logfile = new File(new File(mySnapDir, "version-2"), "log.42.fixed"); lt = new TxnLogToolkit(false, false, logfile.toString(), true); lt.dump(null); output = outContent.toString(); assertThat(output, not(containsString("CRC ERROR"))); }