Java Code Examples for org.junit.jupiter.api.Assertions#assertTrue()
The following examples show how to use
org.junit.jupiter.api.Assertions#assertTrue() .
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: PerconaAddForeignKeyConstraintChangeTest.java From liquibase-percona with Apache License 2.0 | 6 votes |
@Test public void testSelfReferencingForeignKeyPT3() { PerconaAddForeignKeyConstraintChange change = new PerconaAddForeignKeyConstraintChange(); change.setBaseTableName("person"); change.setBaseColumnNames("parent"); change.setConstraintName("fk_person_parent"); change.setReferencedColumnNames("id"); change.setReferencedTableName("person"); PTOnlineSchemaChangeStatement.perconaToolkitVersion = new PerconaToolkitVersion("3.0.12"); PerconaToolkitVersion version = PTOnlineSchemaChangeStatement.getVersion(); Assertions.assertEquals("3.0.12", version.toString()); Assertions.assertTrue(PTOnlineSchemaChangeStatement.available); setTargetTableName("person"); assertPerconaChange("ADD CONSTRAINT fk_person_parent FOREIGN KEY (parent) REFERENCES _person_new (id)", change.generateStatements(getDatabase())); }
Example 2
Source File: FunctionTest.java From quarkus with Apache License 2.0 | 6 votes |
@Test public void testFunqy() { final HttpRequestMessageMock req = new HttpRequestMessageMock(); req.setUri(URI.create("https://foo.com/funqy")); req.setHttpMethod(HttpMethod.POST); req.setBody("\"Bill\"".getBytes(StandardCharsets.UTF_8)); req.getHeaders().put("Content-Type", "application/json"); // Invoke final HttpResponseMessage ret = new Function().run(req, new ExecutionContext() { @Override public Logger getLogger() { return null; } @Override public String getInvocationId() { return null; } @Override public String getFunctionName() { return null; } }); // Verify Assertions.assertEquals(ret.getStatus(), HttpStatus.OK); Assertions.assertEquals("\"Make it funqy Bill\"", new String((byte[]) ret.getBody(), StandardCharsets.UTF_8)); String contentType = ret.getHeader("Content-Type"); Assertions.assertNotNull(contentType); Assertions.assertTrue(MediaType.valueOf(contentType).isCompatible(MediaType.APPLICATION_JSON_TYPE)); }
Example 3
Source File: TimerDevModeTest.java From camel-quarkus with Apache License 2.0 | 6 votes |
static void assertLogMessage(BufferedReader logFileReader, String msg, long timeout) throws IOException { boolean found = false; final long deadline = System.currentTimeMillis() + timeout; while (System.currentTimeMillis() < deadline) { final String line = logFileReader.readLine(); if (line == null) { try { Thread.sleep(50); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } } else if (line.contains(msg)) { found = true; break; } } Assertions.assertTrue(found, "Could not find '" + msg + "' in " + LOG_FILE); }
Example 4
Source File: SingularitySchedulerTest.java From Singularity with Apache License 2.0 | 6 votes |
@Test public void testJobRescheduledWhenItFinishesDuringDecommission() { initScheduledRequest(); initFirstDeploy(); resourceOffers(); SingularityTask task = launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING); slaveManager.changeState( "slave1", MachineState.STARTING_DECOMMISSION, Optional.<String>empty(), Optional.of("user1") ); cleaner.drainCleanupQueue(); resourceOffers(); cleaner.drainCleanupQueue(); statusUpdate(task, TaskState.TASK_FINISHED); scheduler.drainPendingQueue(); Assertions.assertTrue(!taskManager.getPendingTaskIds().isEmpty()); }
Example 5
Source File: ConfigUtilsCompilerOptionsTests.java From vscode-as3mxml with Apache License 2.0 | 6 votes |
@Test void testWarningsWithBaseOnly() throws IOException { boolean baseValue = false; ObjectMapper mapper = new ObjectMapper(); JsonNode baseConfigData = mapper.readTree( "{" + "\"compilerOptions\": {" + "\"warnings\": " + baseValue + "}" + "}" ); JsonNode configData = mapper.readTree("{}"); JsonNode result = ConfigUtils.mergeConfigs(configData, baseConfigData); Assertions.assertTrue(result.has(TopLevelFields.COMPILER_OPTIONS)); JsonNode compilerOptions = result.get(TopLevelFields.COMPILER_OPTIONS); Assertions.assertTrue(compilerOptions.isObject()); Assertions.assertTrue(compilerOptions.has(CompilerOptions.WARNINGS)); boolean resultValue = compilerOptions.get(CompilerOptions.WARNINGS).asBoolean(); Assertions.assertEquals(baseValue, resultValue); }
Example 6
Source File: TemplateValidationTest.java From doov with Apache License 2.0 | 5 votes |
@Test void test2Params() { GenericModel model = new GenericModel(); IntegerFieldInfo A = model.intField(3, "A"); IntegerFieldInfo B = model.intField(5, "B"); TemplateRule.Rule2<IntegerFieldInfo, IntegerFieldInfo> template = DOOV.template(ParameterTypes.$Integer, ParameterTypes.$Integer).rule(NumericFieldInfo::greaterThan); Assertions.assertTrue(template.bind(B, A).executeOn(model).value()); Assertions.assertFalse(template.bind(A, B).executeOn(model).value()); }
Example 7
Source File: TestMatching.java From javageci with Apache License 2.0 | 5 votes |
@Test void testStringWithNamedPattern() { final var source = new TestSource("public var h = \"kkk\""); try (final var javaLexed = new JavaLexed(source)) { javaLexed.match(list(match("public var h = "), string("Zkk", Pattern.compile("(k{3})")))); final var result = javaLexed.fromIndex(0).result(); Assertions.assertTrue(result.matches); Assertions.assertTrue(javaLexed.regexGroups("Zkk").isPresent()); Assertions.assertEquals(1, javaLexed.regexGroups("Zkk").get().groupCount()); Assertions.assertEquals("kkk", javaLexed.regexGroups("Zkk").get().group(1)); } }
Example 8
Source File: JUnit5MediumTest.java From evosql with Apache License 2.0 | 5 votes |
@Test void generatedTest1() throws SQLException { // Arrange: set up the fixture data runSql("INSERT INTO `table1` (`column1_1`, `column1_2`) VALUES (1, 'String of row 1'), (2, 'String of row 2');", true); runSql("INSERT INTO `products` (`product_name`, `expired`, `expiry_date`) VALUES ('Milk', 0, '2018-03-22 00:00:00'), ('Yogurt', 1, '2018-03-15 00:00:00'), ('Salt', 0, '2025-12-31 23:59:59');", true); // Act: run a selection query on the database ArrayList<HashMap<String, String>> result = runSql(PRODUCTION_QUERY, false); // Assert: verify that the expected number of rows is returned Assertions.assertEquals(1, result.size()); // Assert: verify that the results are correct Assertions.assertTrue(result.contains(makeMap())); }
Example 9
Source File: LinearPatternTest.java From panda with Apache License 2.0 | 5 votes |
@Test void testOptional() { LinearPattern pattern = LinearPattern.compile("&opt:unit second:test"); Assertions.assertTrue(pattern.match(of("test")).isMatched()); Assertions.assertTrue(pattern.match(of("unit test")).isMatched()); Assertions.assertFalse(pattern.match(of("unit")).isMatched()); }
Example 10
Source File: SubscriptionManagerTest.java From spectator with Apache License 2.0 | 5 votes |
@Test public void singleExpressionIgnoreExplicit() throws Exception { ManualClock clock = new ManualClock(); byte[] data = json(sub(1)); HttpClient client = uri -> new HttpRequestBuilder(HttpClient.DEFAULT_LOGGER, uri) { @Override public HttpResponse send() { return ok(data); } }; Map<String, String> config = new HashMap<>(); config.put("atlas.lwc.ignore-publish-step", "true"); SubscriptionManager mgr = new SubscriptionManager(mapper, client, clock, config::get); mgr.refresh(); Assertions.assertTrue(mgr.subscriptions().isEmpty()); }
Example 11
Source File: SparkNameFunctionTest.java From spectator with Apache License 2.0 | 5 votes |
@Test public void JustPatternMatching() { final String pattern_string = "^([^.]+)\\.(driver)\\.((CodeGenerator|DAGScheduler|BlockManager|jvm)\\..*)$"; final String metric = "97278898-4bd4-49c2-9889-aa5f969a7816-0023.driver.jvm.pools.PS-Old-Gen.used"; final Pattern pattern = Pattern.compile(pattern_string); final Matcher m = pattern.matcher(metric); Assertions.assertTrue(m.matches()); Assertions.assertEquals("97278898-4bd4-49c2-9889-aa5f969a7816-0023", m.group(1)); Assertions.assertEquals("driver", m.group(2)); Assertions.assertEquals("jvm.pools.PS-Old-Gen.used", m.group(3)); Assertions.assertEquals("jvm", m.group(4)); }
Example 12
Source File: SingularityExpiringActionsTest.java From Singularity with Apache License 2.0 | 5 votes |
@Test public void testExpiringSkipHealthchecks() { initRequest(); initHCDeploy(); SingularityTask firstTask = startTask(firstDeploy); Assertions.assertTrue(healthchecker.cancelHealthcheck(firstTask.getTaskId().getId())); requestResource.skipHealthchecks( requestId, new SingularitySkipHealthchecksRequest( Optional.of(true), Optional.of(1L), Optional.empty(), Optional.empty() ), singularityUser ); statusUpdate(firstTask, TaskState.TASK_FAILED); SingularityTask secondTask = startTask(firstDeploy); Assertions.assertFalse( healthchecker.cancelHealthcheck(secondTask.getTaskId().getId()) ); statusUpdate(secondTask, TaskState.TASK_FAILED); expiringUserActionPoller.runActionOnPoll(); SingularityTask thirdTask = startTask(firstDeploy); Assertions.assertTrue(healthchecker.cancelHealthcheck(thirdTask.getTaskId().getId())); }
Example 13
Source File: CachingPackageClientTests.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
@Test public void testSearch() throws IOException { CachingPackageClient client = new CachingPackageClient("http://packages.fhir.org"); List<PackageInfo> matches = client.search("core", null, null, false); for (PackageInfo pi : matches) { System.out.println(pi.toString()); } Assertions.assertTrue(matches.size() > 0); }
Example 14
Source File: AddressTest.java From symbol-sdk-java with Apache License 2.0 | 4 votes |
@ParameterizedTest @EnumSource(NetworkType.class) void isValidAddressFromGeneratedPublicKey(NetworkType networkType) { Assertions.assertTrue(Address.isValidPlainAddress(generateAddress(networkType).plain())); Assertions.assertTrue(Address.isValidEncodedAddress(generateAddress(networkType).encoded())); }
Example 15
Source File: ControllerModelTest.java From nalu with Apache License 2.0 | 4 votes |
@Test void match06() { ControllerModel cm = this.getControllerModelForMatchingTest("/[shell01|shell02]/route01", "route01"); Assertions.assertTrue(cm.match("shell01/route01")); }
Example 16
Source File: ControllerModelTest.java From nalu with Apache License 2.0 | 4 votes |
@Test void match26() { ControllerModel cm = this.getControllerModelForMatchingTest("/shell01/route01/route02/:parameter", "route01/route02"); Assertions.assertTrue(cm.match("shell01/route01/route02")); }
Example 17
Source File: CompositeCacheViewTests.java From catnip with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test public void allMatchEmpty() { Assertions.assertTrue(composite().allMatch("some string"::equals)); }
Example 18
Source File: ArrayUtilsTest.java From panda with Apache License 2.0 | 4 votes |
@Test void isEmpty() { Assertions.assertTrue(ArrayUtils.isEmpty(EMPTY_ARRAY)); Assertions.assertFalse(ArrayUtils.isEmpty(ARRAY)); }
Example 19
Source File: SingularitySchedulerTest.java From Singularity with Apache License 2.0 | 4 votes |
private void validateTaskDoesntMoveDuringDecommission() { scheduler.drainPendingQueue(); sms .resourceOffers( Arrays.asList(createOffer(1, 129, 1025, "slave1", "host1", Optional.of("rack1"))) ) .join(); scheduler.drainPendingQueue(); sms .resourceOffers( Arrays.asList(createOffer(1, 129, 1025, "slave2", "host2", Optional.of("rack1"))) ) .join(); Assertions.assertEquals(1, taskManager.getActiveTaskIds().size()); Assertions.assertEquals( "host1", taskManager.getActiveTaskIds().get(0).getSanitizedHost() ); Assertions.assertEquals( StateChangeResult.SUCCESS, slaveManager.changeState( "slave1", MachineState.STARTING_DECOMMISSION, Optional.<String>empty(), Optional.of("user1") ) ); scheduler.checkForDecomissions(); scheduler.drainPendingQueue(); sms .resourceOffers( Arrays.asList(createOffer(1, 129, 1025, "slave2", "host2", Optional.of("rack1"))) ) .join(); cleaner.drainCleanupQueue(); scheduler.drainPendingQueue(); sms .resourceOffers( Arrays.asList(createOffer(1, 129, 1025, "slave2", "host2", Optional.of("rack1"))) ) .join(); cleaner.drainCleanupQueue(); // task should not move! Assertions.assertEquals(1, taskManager.getActiveTaskIds().size()); Assertions.assertEquals( "host1", taskManager.getActiveTaskIds().get(0).getSanitizedHost() ); Assertions.assertTrue(taskManager.getKilledTaskIdRecords().isEmpty()); Assertions.assertTrue(taskManager.getCleanupTaskIds().size() == 1); }
Example 20
Source File: TagFilterTest.java From spectator with Apache License 2.0 | 4 votes |
@Test public void collectFilteredTagValue() { Predicate<Measurement> filter = new TagMeasurementFilter(null, null, "Z"); Assertions.assertTrue(filter.test(measureAXZ)); Assertions.assertFalse(filter.test(measureAXY)); }