Java Code Examples for io.vertx.test.core.TestUtils#randomLong()
The following examples show how to use
io.vertx.test.core.TestUtils#randomLong() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OptionsTest.java From vertx-unit with Apache License 2.0 | 6 votes |
@org.junit.Test public void testTestOptions() { TestOptions options = new TestOptions(); assertEquals(TestOptions.DEFAULT_TIMEOUT, options.getTimeout()); assertEquals(TestOptions.DEFAULT_USE_EVENT_LOOP, options.isUseEventLoop()); assertEquals(Collections.<ReportOptions>emptyList(), options.getReporters()); long timeout = TestUtils.randomLong(); Boolean useEventLoop = randomBoolean(); assertSame(options, options.setTimeout(timeout)); assertSame(options, options.setUseEventLoop(useEventLoop)); assertEquals(timeout, options.getTimeout()); assertEquals(useEventLoop, options.isUseEventLoop()); List<ReportOptions> reporters = new ArrayList<>(); ReportOptions reporter1 = new ReportOptions(); reporters.add(reporter1); assertSame(options, options.setReporters(reporters)); assertEquals(reporters, options.getReporters()); ReportOptions reporter2 = new ReportOptions(); assertSame(options, options.addReporter(reporter2)); assertEquals(reporters, options.getReporters()); assertEquals(2, reporters.size()); assertEquals(Arrays.asList(reporter1, reporter2), reporters); }
Example 2
Source File: OptionsTest.java From vertx-unit with Apache License 2.0 | 6 votes |
@org.junit.Test public void testCopyOptions() { TestOptions options = new TestOptions(); long timeout = TestUtils.randomLong(); Boolean useEventLoop = randomBoolean(); String to = TestUtils.randomAlphaString(10); String at = TestUtils.randomAlphaString(10); String format = TestUtils.randomAlphaString(10); ReportOptions reporter = new ReportOptions().setTo(to).setFormat(format); options.setUseEventLoop(useEventLoop).setTimeout(timeout).addReporter(reporter); TestOptions copy = new TestOptions(options); options.setTimeout(TestUtils.randomLong()); options.setUseEventLoop(randomBoolean()); reporter.setTo(TestUtils.randomAlphaString(10)); reporter.setFormat(TestUtils.randomAlphaString(10)); options.getReporters().clear(); assertEquals(timeout, copy.getTimeout()); assertEquals(useEventLoop, copy.isUseEventLoop()); assertEquals(1, copy.getReporters().size()); assertEquals(to, copy.getReporters().get(0).getTo()); assertEquals(format, copy.getReporters().get(0).getFormat()); }
Example 3
Source File: OptionsTest.java From vertx-unit with Apache License 2.0 | 6 votes |
@org.junit.Test public void testJsonOptions() { JsonObject json = new JsonObject(); long timeout = TestUtils.randomLong(); Boolean useEventLoop = randomBoolean(); String to = TestUtils.randomAlphaString(10); String at = TestUtils.randomAlphaString(10); String format = TestUtils.randomAlphaString(10); json.put("timeout", timeout); if (useEventLoop != null) { json.put("useEventLoop", useEventLoop); } json.put("reporters", new JsonArray(). add(new JsonObject(). put("to", to). put("at", at). put("format", format))); TestOptions options = new TestOptions(json); assertEquals(timeout, options.getTimeout()); assertEquals(useEventLoop, options.isUseEventLoop()); assertEquals(1, options.getReporters().size()); assertEquals(to, options.getReporters().get(0).getTo()); assertEquals(format, options.getReporters().get(0).getFormat()); }
Example 4
Source File: MongoClientBulkWriteResultTest.java From vertx-mongo-client with Apache License 2.0 | 6 votes |
@Test public void testMongoClientBulkWriteStatuses() { long randomMatched = TestUtils.randomLong(); long randomModified = TestUtils.randomLong(); long randomInserted = TestUtils.randomLong(); long randomDeleted = TestUtils.randomLong(); List<JsonObject> upserts = randomUpsertIds(); MongoClientBulkWriteResult mongoClientBulkWriteResult = new MongoClientBulkWriteResult(randomInserted, randomMatched, randomDeleted, randomModified, upserts); assertEquals(randomMatched, mongoClientBulkWriteResult.getMatchedCount()); assertEquals(randomModified, mongoClientBulkWriteResult.getModifiedCount()); assertEquals(randomInserted, mongoClientBulkWriteResult.getInsertedCount()); assertEquals(randomDeleted, mongoClientBulkWriteResult.getDeletedCount()); assertEquals(upserts, mongoClientBulkWriteResult.getUpserts()); }
Example 5
Source File: MongoClientBulkWriteResultTest.java From vertx-mongo-client with Apache License 2.0 | 6 votes |
@Test public void testCopyMongoClientBulkWriteResult() { MongoClientBulkWriteResult mongoClientBulkWriteResultOrigin = new MongoClientBulkWriteResult(TestUtils.randomLong(), TestUtils.randomLong(), TestUtils.randomLong(), TestUtils.randomLong(), randomUpsertIds()); MongoClientBulkWriteResult mongoClientBulkWriteResultCopy = new MongoClientBulkWriteResult( mongoClientBulkWriteResultOrigin); assertEquals(mongoClientBulkWriteResultCopy.getMatchedCount(), mongoClientBulkWriteResultOrigin.getMatchedCount()); assertEquals(mongoClientBulkWriteResultCopy.getModifiedCount(), mongoClientBulkWriteResultOrigin.getModifiedCount()); assertEquals(mongoClientBulkWriteResultCopy.getInsertedCount(), mongoClientBulkWriteResultOrigin.getInsertedCount()); assertEquals(mongoClientBulkWriteResultCopy.getDeletedCount(), mongoClientBulkWriteResultOrigin.getDeletedCount()); assertEquals(mongoClientBulkWriteResultCopy.getUpserts(), mongoClientBulkWriteResultOrigin.getUpserts()); }
Example 6
Source File: MongoClientDeleteResultTest.java From vertx-mongo-client with Apache License 2.0 | 5 votes |
@Test public void testMongoClientDeleteResultWithRemovedCountSpecified() { long randomRemoved = TestUtils.randomLong(); MongoClientDeleteResult mongoClientDeleteResult = new MongoClientDeleteResult(randomRemoved); assertEquals(randomRemoved, mongoClientDeleteResult.getRemovedCount()); }
Example 7
Source File: MongoClientDeleteResultTest.java From vertx-mongo-client with Apache License 2.0 | 5 votes |
@Test public void testCopyMongoClientDeleteResult() { MongoClientDeleteResult origin = new MongoClientDeleteResult(TestUtils.randomLong()); MongoClientDeleteResult copy = new MongoClientDeleteResult(origin); assertEquals(origin.getRemovedCount(), copy.getRemovedCount()); }
Example 8
Source File: MongoClientDeleteResultTest.java From vertx-mongo-client with Apache License 2.0 | 5 votes |
private void logicallyEqual() { long randomRemoved = TestUtils.randomLong(); MongoClientDeleteResult mongoClientDeleteResult1 = new MongoClientDeleteResult(randomRemoved); MongoClientDeleteResult mongoClientDeleteResult2 = new MongoClientDeleteResult(randomRemoved); assertTrue(mongoClientDeleteResult1.equals(mongoClientDeleteResult2)); assertTrue(mongoClientDeleteResult2.equals(mongoClientDeleteResult1)); }
Example 9
Source File: AggregateOptionsTest.java From vertx-mongo-client with Apache License 2.0 | 5 votes |
@Test public void testOptions() { AggregateOptions options = new AggregateOptions(); long maxTime = TestUtils.randomLong(); assertEquals(options, options.setMaxTime(maxTime)); assertEquals(maxTime, options.getMaxTime()); }
Example 10
Source File: AggregateOptionsTest.java From vertx-mongo-client with Apache License 2.0 | 5 votes |
@Test public void testOptionsJson() { JsonObject json = new JsonObject(); long maxAwaitTime = TestUtils.randomLong(); json.put("maxAwaitTime", maxAwaitTime); long maxTime = TestUtils.randomLong(); json.put("maxTime", maxTime); AggregateOptions options = new AggregateOptions(json); assertEquals(maxTime, options.getMaxTime()); }
Example 11
Source File: MongoClientBulkWriteResultTest.java From vertx-mongo-client with Apache License 2.0 | 5 votes |
private void logicallyEqual() { long randomMatched = TestUtils.randomLong(); long randomModified = TestUtils.randomLong(); long randomInserted = TestUtils.randomLong(); long randomDeleted = TestUtils.randomLong(); List<JsonObject> upserts = randomUpsertIds(); MongoClientBulkWriteResult mongoClientBulkWriteResult1 = new MongoClientBulkWriteResult(randomInserted, randomMatched, randomDeleted, randomModified, upserts); MongoClientBulkWriteResult mongoClientBulkWriteResult2 = new MongoClientBulkWriteResult(randomInserted, randomMatched, randomDeleted, randomModified, upserts); assertTrue(mongoClientBulkWriteResult1.equals(mongoClientBulkWriteResult2)); assertTrue(mongoClientBulkWriteResult2.equals(mongoClientBulkWriteResult1)); }
Example 12
Source File: MongoClientUpdateResultTest.java From vertx-mongo-client with Apache License 2.0 | 5 votes |
@Test public void testMongoClientUpdateResultStatuses() { long randomMatched = TestUtils.randomLong(); JsonObject randomUpsertedId = randomUpsertId(); long randomModified = TestUtils.randomLong(); MongoClientUpdateResult mongoClientUpdateResult = new MongoClientUpdateResult(randomMatched, randomUpsertedId, randomModified); assertEquals(randomMatched, mongoClientUpdateResult.getDocMatched()); assertEquals(randomUpsertedId, mongoClientUpdateResult.getDocUpsertedId()); assertEquals(randomModified, mongoClientUpdateResult.getDocModified()); }
Example 13
Source File: MongoClientUpdateResultTest.java From vertx-mongo-client with Apache License 2.0 | 5 votes |
@Test public void testCopyMongoClientUpdateResult() { MongoClientUpdateResult mongoClientUpdateResultOrigin = new MongoClientUpdateResult(TestUtils.randomLong(), randomUpsertId(), TestUtils.randomLong()); MongoClientUpdateResult mongoClientUpdateResultCopy = new MongoClientUpdateResult(mongoClientUpdateResultOrigin); assertEquals(mongoClientUpdateResultOrigin.getDocMatched(), mongoClientUpdateResultCopy.getDocMatched()); assertEquals(mongoClientUpdateResultOrigin.getDocUpsertedId(), mongoClientUpdateResultCopy.getDocUpsertedId()); assertEquals(mongoClientUpdateResultOrigin.getDocModified(), mongoClientUpdateResultCopy.getDocModified()); }
Example 14
Source File: MongoClientUpdateResultTest.java From vertx-mongo-client with Apache License 2.0 | 5 votes |
private void logicallyEqual() { long randomMatched = TestUtils.randomLong(); JsonObject randomUpsertedId = randomUpsertId(); long randomModified = TestUtils.randomLong(); MongoClientUpdateResult mongoClientUpdateResult1 = new MongoClientUpdateResult(randomMatched, randomUpsertedId, randomModified); MongoClientUpdateResult mongoClientUpdateResult2 = new MongoClientUpdateResult(randomMatched, randomUpsertedId, randomModified); assertTrue(mongoClientUpdateResult1.equals(mongoClientUpdateResult2)); assertTrue(mongoClientUpdateResult2.equals(mongoClientUpdateResult1)); }