org.testng.Assert.assertTrue()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(205)

本文整理了Java中org.testng.Assert.assertTrue()方法的一些代码示例,展示了Assert.assertTrue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertTrue()方法的具体详情如下:
包路径:org.testng.Assert
类名称:Assert
方法名:assertTrue

Assert.assertTrue介绍

[英]Asserts that a condition is true. If it isn't, an AssertionError is thrown.
[中]断言某个条件为真。如果不是,则抛出断言错误。

代码示例

代码示例来源:origin: prestodb/presto

@Test
public void testGroupByNanArray()
{
  MaterializedResult actual = computeActual("SELECT a FROM (VALUES (ARRAY[nan(), 2e0, 3e0]), (ARRAY[nan(), 2e0, 3e0])) t(a) GROUP BY a");
  List<MaterializedRow> actualRows = actual.getMaterializedRows();
  assertEquals(actualRows.size(), 1);
  assertTrue(Double.isNaN(((List<Double>) actualRows.get(0).getField(0)).get(0)));
  assertEquals(((List<Double>) actualRows.get(0).getField(0)).get(1), 2.0);
  assertEquals(((List<Double>) actualRows.get(0).getField(0)).get(2), 3.0);
}

代码示例来源:origin: prestodb/presto

@Test
public void testTransactionsTable()
{
  List<MaterializedRow> result = computeActual("SELECT * FROM system.runtime.transactions").getMaterializedRows();
  assertTrue(result.size() >= 1); // At least one row for the current transaction.
}

代码示例来源:origin: prestodb/presto

private static void assertType(List<Type> types, Type expectedType)
{
  assertTrue(types.size() == 1, "Expected one type, but got " + types);
  Type actualType = types.get(0);
  assertEquals(actualType, expectedType);
}

代码示例来源:origin: prestodb/presto

@Test
public void testTableSampleBernoulli()
{
  DescriptiveStatistics stats = new DescriptiveStatistics();
  int total = computeExpected("SELECT orderkey FROM orders", ImmutableList.of(BIGINT)).getMaterializedRows().size();
  for (int i = 0; i < 100; i++) {
    List<MaterializedRow> values = computeActual("SELECT orderkey FROM orders TABLESAMPLE BERNOULLI (50)").getMaterializedRows();
    assertEquals(values.size(), ImmutableSet.copyOf(values).size(), "TABLESAMPLE produced duplicate rows");
    stats.addValue(values.size() * 1.0 / total);
  }
  double mean = stats.getGeometricMean();
  assertTrue(mean > 0.45 && mean < 0.55, format("Expected mean sampling rate to be ~0.5, but was %s", mean));
}

代码示例来源:origin: prestodb/presto

@AfterMethod
public void tearDown(Method method)
{
  assertTrue(Futures.allAsList(futures).isDone(), "Expression test futures are not complete");
  log.info("FINISHED %s in %s verified %s expressions", method.getName(), Duration.nanosSince(start), futures.size());
}

代码示例来源:origin: prestodb/presto

@Test
  public void testIsCompressionCodecSupported()
  {
    assertTrue(S3SelectPushdown.isCompressionCodecSupported(inputFormat, new Path("s3://fakeBucket/fakeObject.gz")));
    assertTrue(S3SelectPushdown.isCompressionCodecSupported(inputFormat, new Path("s3://fakeBucket/fakeObject")));
    assertFalse(S3SelectPushdown.isCompressionCodecSupported(inputFormat, new Path("s3://fakeBucket/fakeObject.lz4")));
    assertFalse(S3SelectPushdown.isCompressionCodecSupported(inputFormat, new Path("s3://fakeBucket/fakeObject.snappy")));
    assertTrue(S3SelectPushdown.isCompressionCodecSupported(inputFormat, new Path("s3://fakeBucket/fakeObject.bz2")));
  }
}

代码示例来源:origin: swagger-api/swagger-core

@Test(description = "it should apply required flag when ApiProperty annotation first")
public void testApiModelPropertyFirstPosition() {
  final Map<String, Schema> models = ModelConverters.getInstance().readAll(ApiFirstRequiredFieldModel.class);
  final Schema model = models.get("aaa");
  final Schema prop = (Schema) model.getProperties().get("bla");
  assertNotNull(prop);
  assertTrue(model.getRequired().contains("bla"));
}

代码示例来源:origin: prestodb/presto

@Test
public void testCastOperatorsExistForCoercions()
{
  Set<Type> types = getStandardPrimitiveTypes();
  for (Type sourceType : types) {
    for (Type resultType : types) {
      if (typeRegistry.canCoerce(sourceType, resultType) && sourceType != UNKNOWN && resultType != UNKNOWN) {
        assertTrue(functionRegistry.canResolveOperator(OperatorType.CAST, resultType, ImmutableList.of(sourceType)),
            format("'%s' -> '%s' coercion exists but there is no cast operator", sourceType, resultType));
      }
    }
  }
}

代码示例来源:origin: prestodb/presto

@Test
public void testGetUpdateCount()
    throws Exception
{
  try (Connection connection = createConnection()) {
    try (Statement statement = connection.createStatement()) {
      assertTrue(statement.execute("SELECT 123 x, 'foo' y"));
      assertEquals(statement.getUpdateCount(), -1);
      assertEquals(statement.getLargeUpdateCount(), -1);
    }
  }
}

代码示例来源:origin: prestodb/presto

@Test
public void testStatsExtraction()
    throws Exception
{
  try (PrestoResultSet rs = (PrestoResultSet) statement.executeQuery("SELECT 123 x, 456 x")) {
    assertNotNull(rs.getStats());
    assertTrue(rs.next());
    assertNotNull(rs.getStats());
    assertFalse(rs.next());
    assertNotNull(rs.getStats());
  }
}

代码示例来源:origin: prestodb/presto

private static void assertOutputBuffers(OutputBuffers outputBuffers)
  {
    assertNotNull(outputBuffers);
    assertTrue(outputBuffers.getVersion() > 0);
    assertTrue(outputBuffers.isNoMoreBufferIds());
    Map<OutputBufferId, Integer> buffers = outputBuffers.getBuffers();
    assertEquals(buffers.size(), 4);
    for (int partition = 0; partition < 4; partition++) {
      assertEquals(buffers.get(new OutputBufferId(partition)), Integer.valueOf(partition));
    }
  }
}

代码示例来源:origin: prestodb/presto

private void checkRepresentation(String expression, int expectedSqlType, ResultAssertion assertion)
    throws Exception
{
  try (ResultSet rs = statement.executeQuery("SELECT " + expression)) {
    ResultSetMetaData metadata = rs.getMetaData();
    assertEquals(metadata.getColumnCount(), 1);
    assertEquals(metadata.getColumnType(1), expectedSqlType);
    assertTrue(rs.next());
    assertion.accept(rs, 1);
    assertFalse(rs.next());
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
void verifyBeanInitialized() {
  assertInTransaction(false);
  assertTrue(beanInitialized,
      "This test instance should have been initialized due to InitializingBean semantics.");
}

代码示例来源:origin: prestodb/presto

private static void assertWarnings(SQLWarning warning, Set<WarningEntry> currentWarnings)
{
  assertNotNull(warning);
  int previousSize = currentWarnings.size();
  addWarnings(currentWarnings, warning);
  assertTrue(currentWarnings.size() >= previousSize);
}

代码示例来源:origin: prestodb/presto

@Test
public void testGroupByNanRow()
{
  MaterializedResult actual = computeActual("SELECT a, b, c FROM (VALUES ROW(nan(), 1, 2), ROW(nan(), 1, 2)) t(a, b, c) GROUP BY 1, 2, 3");
  List<MaterializedRow> actualRows = actual.getMaterializedRows();
  assertEquals(actualRows.size(), 1);
  assertTrue(Double.isNaN((Double) actualRows.get(0).getField(0)));
  assertEquals(actualRows.get(0).getField(1), 1);
  assertEquals(actualRows.get(0).getField(2), 2);
}

代码示例来源:origin: prestodb/presto

@Test
public void testValuesWithNonTrivialType()
{
  MaterializedResult actual = computeActual("VALUES (0E0/0E0, 1E0/0E0, -1E0/0E0)");
  List<MaterializedRow> rows = actual.getMaterializedRows();
  assertEquals(rows.size(), 1);
  MaterializedRow row = rows.get(0);
  assertTrue(((Double) row.getField(0)).isNaN());
  assertEquals(row.getField(1), Double.POSITIVE_INFINITY);
  assertEquals(row.getField(2), Double.NEGATIVE_INFINITY);
}

代码示例来源:origin: prestodb/presto

private static void assertRecordCursor(List<Type> types, Iterator<?>[] valuesByField, RecordCursor cursor)
{
  while (cursor.advanceNextPosition()) {
    for (int field = 0; field < types.size(); field++) {
      assertTrue(valuesByField[field].hasNext());
      Object expected = valuesByField[field].next();
      Object actual = getActualCursorValue(cursor, types.get(field), field);
      assertEquals(actual, expected);
    }
  }
}

代码示例来源:origin: prestodb/presto

@Test
public void tableIsCreatedAfterCommits()
{
  assertNoTables();
  SchemaTableName schemaTableName = new SchemaTableName("default", "temp_table");
  ConnectorOutputTableHandle table = metadata.beginCreateTable(
      SESSION,
      new ConnectorTableMetadata(schemaTableName, ImmutableList.of(), ImmutableMap.of()),
      Optional.empty());
  metadata.finishCreateTable(SESSION, table, ImmutableList.of(), ImmutableList.of());
  List<SchemaTableName> tables = metadata.listTables(SESSION, Optional.empty());
  assertTrue(tables.size() == 1, "Expected only one table");
  assertTrue(tables.get(0).getTableName().equals("temp_table"), "Expected table with name 'temp_table'");
}

代码示例来源:origin: prestodb/presto

@Test
public void testBloomFilterPredicateValuesNonExisting()
{
  BloomFilter bloomFilter = new BloomFilter(TEST_VALUES.size() * 10, 0.01);
  for (Map.Entry<Object, Type> testValue : TEST_VALUES.entrySet()) {
    boolean matched = checkInBloomFilter(bloomFilter, testValue.getKey(), testValue.getValue());
    assertFalse(matched, "type " + testValue.getKey().getClass());
  }
  // test unsupported type: can be supported by ORC but is not implemented yet
  assertTrue(checkInBloomFilter(bloomFilter, new Date(), DATE), "unsupported type DATE should always return true");
}

代码示例来源:origin: swagger-api/swagger-core

@Test
public void shouldDeserializeArrayPropertyUniqueItems() throws Exception {
  String path = "json-schema-validation/array.json";
  ArraySchema property = (ArraySchema) TestUtils.deserializeJsonFileFromClasspath(path, Schema.class);
  assertNotNull(property.getUniqueItems());
  assertTrue(property.getUniqueItems());
}

相关文章