APISonar


org.junit.Assert.assertThrows

> org > junit > Assert > assertThrows
org APIs junit APIs Assert APIs assertThrows APIs

Example 1
public void testMissingSubschema() {
    String subSchema = "fake_schema";
    String tableName = "fake_table";
    when(mockSchemaPlus.getSubSchema(subSchema)).thenReturn(null);

    Assert.assertThrows(
        IllegalStateException.class,
        () -> {
          TableResolution.resolveCalciteTable(
              mockSchemaPlus, ImmutableList.of(subSchema, tableName));
        });
  }
Example 2
public void upgrade_toANonExistentVersion_fails() {
    int oldVersion = 1;
    int nonExistentVersion = 1000;
    SchemaManager schemaManager = new SchemaManager(RuntimeEnvironment.application, oldVersion);

    Assert.assertThrows(
        IllegalArgumentException.class,
        () ->
            schemaManager.onUpgrade(
                schemaManager.getWritableDatabase(), oldVersion, nonExistentVersion));
  }