@Test(expected = NullPointerException.class) public void testEmptyGet() { Optional.empty().get(); }
@Test(expected = NullPointerException.class) public void testEmptyGet() { Optional.empty().get(); }
@Test(expected = NullPointerException.class) public void testAbsentGet() { Optional.absent().get(); }
@Test(expected = NullPointerException.class) public void testAbsentGet() { Optional.absent().get(); }
@Test(expected = NullPointerException.class) public void testAbsentGet() { Optional.absent().get(); }
@Test(expected = NullPointerException.class) public void testEmptyGet() { Optional.empty().get(); }
rdd.repartitionAndSortWithinPartitions(partitioner); assertTrue(repartitioned.partitioner().isPresent()); assertEquals(repartitioned.partitioner().get(), partitioner); List<List<Tuple2<Integer, Integer>>> partitions = repartitioned.glom().collect(); assertEquals(partitions.get(0),
rdd.repartitionAndSortWithinPartitions(partitioner); assertTrue(repartitioned.partitioner().isPresent()); assertEquals(repartitioned.partitioner().get(), partitioner); List<List<Tuple2<Integer, Integer>>> partitions = repartitioned.glom().collect(); assertEquals(partitions.get(0),
@Test public void testOf() { Assert.assertTrue(Optional.of(1).isPresent()); Assert.assertNotNull(Optional.of(1).orNull()); Assert.assertEquals(Integer.valueOf(1), Optional.of(1).get()); Assert.assertEquals(Integer.valueOf(1), Optional.of(1).or(2)); Assert.assertEquals(Integer.valueOf(1), Optional.of(1).orElse(2)); }
@Test public void testOf() { Assert.assertTrue(Optional.of(1).isPresent()); Assert.assertNotNull(Optional.of(1).orNull()); Assert.assertEquals(Integer.valueOf(1), Optional.of(1).get()); Assert.assertEquals(Integer.valueOf(1), Optional.of(1).or(2)); Assert.assertEquals(Integer.valueOf(1), Optional.of(1).orElse(2)); }
@Test public void testOf() { Assert.assertTrue(Optional.of(1).isPresent()); Assert.assertNotNull(Optional.of(1).orNull()); Assert.assertEquals(Integer.valueOf(1), Optional.of(1).get()); Assert.assertEquals(Integer.valueOf(1), Optional.of(1).or(2)); Assert.assertEquals(Integer.valueOf(1), Optional.of(1).orElse(2)); }
@Test public void checkpointAndRestore() { JavaRDD<Integer> rdd = sc.parallelize(Arrays.asList(1, 2, 3, 4, 5)); sc.setCheckpointDir(tempDir.getAbsolutePath()); assertFalse(rdd.isCheckpointed()); rdd.checkpoint(); rdd.count(); // Forces the DAG to cause a checkpoint assertTrue(rdd.isCheckpointed()); assertTrue(rdd.getCheckpointFile().isPresent()); JavaRDD<Integer> recovered = sc.checkpointFile(rdd.getCheckpointFile().get()); assertEquals(Arrays.asList(1, 2, 3, 4, 5), recovered.collect()); }
@Test public void checkpointAndRestore() { JavaRDD<Integer> rdd = sc.parallelize(Arrays.asList(1, 2, 3, 4, 5)); sc.setCheckpointDir(tempDir.getAbsolutePath()); assertFalse(rdd.isCheckpointed()); rdd.checkpoint(); rdd.count(); // Forces the DAG to cause a checkpoint assertTrue(rdd.isCheckpointed()); assertTrue(rdd.getCheckpointFile().isPresent()); JavaRDD<Integer> recovered = sc.checkpointFile(rdd.getCheckpointFile().get()); assertEquals(Arrays.asList(1, 2, 3, 4, 5), recovered.collect()); }
@Test public void checkpointAndRestore() { JavaRDD<Integer> rdd = sc.parallelize(Arrays.asList(1, 2, 3, 4, 5)); sc.setCheckpointDir(tempDir.getAbsolutePath()); assertFalse(rdd.isCheckpointed()); rdd.checkpoint(); rdd.count(); // Forces the DAG to cause a checkpoint assertTrue(rdd.isCheckpointed()); assertTrue(rdd.getCheckpointFile().isPresent()); JavaRDD<Integer> recovered = sc.checkpointFile(rdd.getCheckpointFile().get()); assertEquals(Arrays.asList(1, 2, 3, 4, 5), recovered.collect()); }
@Test public void testOfNullable() { Assert.assertTrue(Optional.ofNullable(1).isPresent()); Assert.assertNotNull(Optional.ofNullable(1).orNull()); Assert.assertEquals(Integer.valueOf(1), Optional.ofNullable(1).get()); Assert.assertEquals(Integer.valueOf(1), Optional.ofNullable(1).or(2)); Assert.assertEquals(Integer.valueOf(1), Optional.ofNullable(1).orElse(2)); Assert.assertFalse(Optional.ofNullable(null).isPresent()); Assert.assertNull(Optional.ofNullable(null).orNull()); Assert.assertEquals(Integer.valueOf(2), Optional.<Integer>ofNullable(null).or(2)); Assert.assertEquals(Integer.valueOf(2), Optional.<Integer>ofNullable(null).orElse(2)); }
@Test public void testOfNullable() { Assert.assertTrue(Optional.ofNullable(1).isPresent()); Assert.assertNotNull(Optional.ofNullable(1).orNull()); Assert.assertEquals(Integer.valueOf(1), Optional.ofNullable(1).get()); Assert.assertEquals(Integer.valueOf(1), Optional.ofNullable(1).or(2)); Assert.assertEquals(Integer.valueOf(1), Optional.ofNullable(1).orElse(2)); Assert.assertFalse(Optional.ofNullable(null).isPresent()); Assert.assertNull(Optional.ofNullable(null).orNull()); Assert.assertEquals(Integer.valueOf(2), Optional.<Integer>ofNullable(null).or(2)); Assert.assertEquals(Integer.valueOf(2), Optional.<Integer>ofNullable(null).orElse(2)); }
@Test public void testFromNullable() { Assert.assertTrue(Optional.fromNullable(1).isPresent()); Assert.assertNotNull(Optional.fromNullable(1).orNull()); Assert.assertEquals(Integer.valueOf(1), Optional.fromNullable(1).get()); Assert.assertEquals(Integer.valueOf(1), Optional.fromNullable(1).or(2)); Assert.assertEquals(Integer.valueOf(1), Optional.fromNullable(1).orElse(2)); Assert.assertFalse(Optional.fromNullable(null).isPresent()); Assert.assertNull(Optional.fromNullable(null).orNull()); Assert.assertEquals(Integer.valueOf(2), Optional.<Integer>fromNullable(null).or(2)); Assert.assertEquals(Integer.valueOf(2), Optional.<Integer>fromNullable(null).orElse(2)); }
@Test public void testFromNullable() { Assert.assertTrue(Optional.fromNullable(1).isPresent()); Assert.assertNotNull(Optional.fromNullable(1).orNull()); Assert.assertEquals(Integer.valueOf(1), Optional.fromNullable(1).get()); Assert.assertEquals(Integer.valueOf(1), Optional.fromNullable(1).or(2)); Assert.assertEquals(Integer.valueOf(1), Optional.fromNullable(1).orElse(2)); Assert.assertFalse(Optional.fromNullable(null).isPresent()); Assert.assertNull(Optional.fromNullable(null).orNull()); Assert.assertEquals(Integer.valueOf(2), Optional.<Integer>fromNullable(null).or(2)); Assert.assertEquals(Integer.valueOf(2), Optional.<Integer>fromNullable(null).orElse(2)); }
@Test public void testFromNullable() { Assert.assertTrue(Optional.fromNullable(1).isPresent()); Assert.assertNotNull(Optional.fromNullable(1).orNull()); Assert.assertEquals(Integer.valueOf(1), Optional.fromNullable(1).get()); Assert.assertEquals(Integer.valueOf(1), Optional.fromNullable(1).or(2)); Assert.assertEquals(Integer.valueOf(1), Optional.fromNullable(1).orElse(2)); Assert.assertFalse(Optional.fromNullable(null).isPresent()); Assert.assertNull(Optional.fromNullable(null).orNull()); Assert.assertEquals(Integer.valueOf(2), Optional.<Integer>fromNullable(null).or(2)); Assert.assertEquals(Integer.valueOf(2), Optional.<Integer>fromNullable(null).orElse(2)); }
@Test public void testOfNullable() { Assert.assertTrue(Optional.ofNullable(1).isPresent()); Assert.assertNotNull(Optional.ofNullable(1).orNull()); Assert.assertEquals(Integer.valueOf(1), Optional.ofNullable(1).get()); Assert.assertEquals(Integer.valueOf(1), Optional.ofNullable(1).or(2)); Assert.assertEquals(Integer.valueOf(1), Optional.ofNullable(1).orElse(2)); Assert.assertFalse(Optional.ofNullable(null).isPresent()); Assert.assertNull(Optional.ofNullable(null).orNull()); Assert.assertEquals(Integer.valueOf(2), Optional.<Integer>ofNullable(null).or(2)); Assert.assertEquals(Integer.valueOf(2), Optional.<Integer>ofNullable(null).orElse(2)); }