Search in sources :

Example 21 with OptionalLong

use of java.util.OptionalLong in project jdk8u_jdk by JetBrains.

the class BasicLong method testEmptyOrElseThrowNull.

@Test(expectedExceptions = NullPointerException.class)
public void testEmptyOrElseThrowNull() throws Throwable {
    OptionalLong empty = OptionalLong.empty();
    long got = empty.orElseThrow(null);
}
Also used : OptionalLong(java.util.OptionalLong) Test(org.testng.annotations.Test)

Example 22 with OptionalLong

use of java.util.OptionalLong in project jdk8u_jdk by JetBrains.

the class BasicLong method testEmptyOrElseGetNull.

@Test(expectedExceptions = NullPointerException.class)
public void testEmptyOrElseGetNull() {
    OptionalLong empty = OptionalLong.empty();
    long got = empty.orElseGet(null);
}
Also used : OptionalLong(java.util.OptionalLong) Test(org.testng.annotations.Test)

Example 23 with OptionalLong

use of java.util.OptionalLong in project jdk8u_jdk by JetBrains.

the class BasicLong method testEmpty.

@Test(groups = "unit")
public void testEmpty() {
    OptionalLong empty = OptionalLong.empty();
    OptionalLong present = OptionalLong.of(1);
    // empty
    assertTrue(empty.equals(empty));
    assertTrue(empty.equals(OptionalLong.empty()));
    assertTrue(!empty.equals(present));
    assertTrue(0 == empty.hashCode());
    assertTrue(!empty.toString().isEmpty());
    assertTrue(!empty.isPresent());
    empty.ifPresent(v -> {
        fail();
    });
    assertEquals(2, empty.orElse(2));
    assertEquals(2, empty.orElseGet(() -> 2));
}
Also used : OptionalLong(java.util.OptionalLong) Test(org.testng.annotations.Test)

Aggregations

OptionalLong (java.util.OptionalLong)23 Test (org.testng.annotations.Test)7 OptionalInt (java.util.OptionalInt)5 MetadataDao (com.facebook.presto.raptor.metadata.MetadataDao)3 Type (com.facebook.presto.spi.type.Type)3 List (java.util.List)3 ColumnInfo (com.facebook.presto.raptor.metadata.ColumnInfo)2 ShardManager (com.facebook.presto.raptor.metadata.ShardManager)2 Table (com.facebook.presto.raptor.metadata.Table)2 TableColumn (com.facebook.presto.raptor.metadata.TableColumn)2 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)2 PrestoException (com.facebook.presto.spi.PrestoException)2 Objects.requireNonNull (java.util.Objects.requireNonNull)2 TreeMap (java.util.TreeMap)2 UUID (java.util.UUID)2 Inject (javax.inject.Inject)2 JSONException (com.alibaba.fastjson.JSONException)1 ErrorCode (com.eightkdata.mongowp.ErrorCode)1 Status (com.eightkdata.mongowp.Status)1 BsonDocument (com.eightkdata.mongowp.bson.BsonDocument)1