org.junit.jupiter.api.DisplayName Java Examples
The following examples show how to use
org.junit.jupiter.api.DisplayName.
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: TestSolution2OptionalConditionalFetching.java From java-katas with MIT License | 6 votes |
@Test @DisplayName("return a value either from non-empty Optional or from a Supplier") @Tag("PASSING") @Order(3) public void orElseGetSupplierValue() { String defaultOptional = "supplied"; Optional<String> anOptional = Optional.empty(); /* * DONE: * Replace the below to use an orElseGet(?) - instead of - the or(?) * and the need to use get() * Check API: java.util.Optional.ofNullable(?) */ String nonNullString = anOptional.orElseGet(() -> defaultOptional); assertTrue(nonNullString instanceof String, "The nonNullString should be an instance of String"); assertEquals(nonNullString, "supplied", "The nonNullString should have a value of \"supplied\""); }
Example #2
Source File: MongoDbUpdateTest.java From mongo-kafka with Apache License 2.0 | 6 votes |
@Test @DisplayName( "when valid doc change cdc event containing internal oplog fields then correct UpdateOneModel") public void testValidSinkDocumentWithInternalOploagFieldForUpdate() { BsonDocument keyDoc = BsonDocument.parse("{id: '1234'}"); BsonDocument valueDoc = new BsonDocument("op", new BsonString("u")) .append("patch", new BsonString(UPDATE_DOC_WITH_OPLOG_INTERNALS.toJson())); WriteModel<BsonDocument> result = UPDATE.perform(new SinkDocument(keyDoc, valueDoc)); assertTrue( result instanceof UpdateOneModel, () -> "result expected to be of type UpdateOneModel"); UpdateOneModel<BsonDocument> writeModel = (UpdateOneModel<BsonDocument>) result; assertEquals( UPDATE_DOC, writeModel.getUpdate(), () -> "update doc not matching what is expected"); assertTrue( writeModel.getFilter() instanceof BsonDocument, () -> "filter expected to be of type BsonDocument"); assertEquals(FILTER_DOC, writeModel.getFilter()); }
Example #3
Source File: IdStrategyTest.java From mongo-kafka with Apache License 2.0 | 6 votes |
@Test @DisplayName("test PartialKeyStrategy with Allow List") void testPartialKeyStrategyAllowList() { BsonDocument keyDoc = BsonDocument.parse("{keyPart1: 123, keyPart2: 'ABC', keyPart3: true}"); BsonDocument expected = BsonDocument.parse("{keyPart1: 123}"); MongoSinkTopicConfig cfg = createTopicConfig( format( "{'%s': '%s', '%s': 'keyPart1'}", DOCUMENT_ID_STRATEGY_PARTIAL_KEY_PROJECTION_TYPE_CONFIG, ALLOWLIST, DOCUMENT_ID_STRATEGY_PARTIAL_KEY_PROJECTION_LIST_CONFIG)); IdStrategy ids = new PartialKeyStrategy(); ids.configure(cfg); SinkDocument sd = new SinkDocument(keyDoc, null); BsonValue id = ids.generateId(sd, null); assertAll( "id checks", () -> assertTrue(id instanceof BsonDocument), () -> assertEquals(expected, id.asDocument())); assertEquals(new BsonDocument(), ids.generateId(new SinkDocument(null, null), null)); }
Example #4
Source File: BinarySerialiserTests.java From chart-fx with Apache License 2.0 | 6 votes |
@DisplayName("test getGenericArrayAsBoxedPrimitive(...) helper method") @ParameterizedTest(name = "IoBuffer class - {0}") @ValueSource(classes = { FastByteBuffer.class, ByteBuffer.class }) public void testgetGenericArrayAsBoxedPrimitiveHelper(final Class<? extends IoBuffer> bufferClass) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { assertNotNull(bufferClass, "bufferClass being not null"); assertNotNull(bufferClass.getConstructor(int.class), "Constructor(Integer) present"); final IoBuffer buffer = bufferClass.getConstructor(int.class).newInstance(2 * BUFFER_SIZE); // a bit larger buffer since we test more cases at once putGenericTestArrays(buffer); buffer.reset(); // test conversion to double array assertThrows(IllegalArgumentException.class, () -> BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.OTHER)); assertArrayEquals(new Boolean[] { true, false, true }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.BOOL)); assertArrayEquals(new Byte[] { (byte) 1.0, (byte) 0.0, (byte) 2.0 }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.BYTE)); assertArrayEquals(new Character[] { (char) 1.0, (char) 0.0, (char) 2.0 }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.CHAR)); assertArrayEquals(new Short[] { (short) 1.0, (short) 0.0, (short) 2.0 }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.SHORT)); assertArrayEquals(new Integer[] { (int) 1.0, (int) 0.0, (int) 2.0 }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.INT)); assertArrayEquals(new Long[] { (long) 1.0, (long) 0.0, (long) 2.0 }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.LONG)); assertArrayEquals(new Float[] { 1.0f, 0.0f, 2.0f }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.FLOAT)); assertArrayEquals(new Double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.DOUBLE)); assertArrayEquals(new String[] { "1.0", "0.0", "2.0" }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.STRING)); }
Example #5
Source File: IirFilterTests.java From chart-fx with Apache License 2.0 | 6 votes |
@DisplayName("Butterworth - High-Pass") @ParameterizedTest(name = "{displayName}: filter-order: {0}, algorithm: {1}") @CsvSource({ "2, 0", "3, 0", "4, 0", "2, 1", "3, 1", "4, 1", "2, 2", "3, 2", "4, 2" }) public void testButterworthHighPass(final int filterOrder, final int algorithmVariant) { final Butterworth iirHighPass = new Butterworth(); switch (algorithmVariant) { case 1: iirHighPass.highPass(filterOrder, 1.0, F_CUT_HIGH, DirectFormAbstract.DIRECT_FORM_I); break; case 2: iirHighPass.highPass(filterOrder, 1.0, F_CUT_HIGH, DirectFormAbstract.DIRECT_FORM_II); break; case 0: default: iirHighPass.highPass(filterOrder, 1.0, F_CUT_HIGH); break; } final DataSet magHighPass = filterAndGetMagnitudeSpectrum(iirHighPass, demoDataSet); assertThat("high-pass cut-off", magHighPass.getValue(DIM_X, F_CUT_HIGH), lessThan(-3.0 + EPSILON_DB)); assertThat("high-pass rejection", magHighPass.getValue(DIM_X, 0.1 * F_CUT_HIGH), lessThan(-3.0 + EPSILON_DB - 20 * filterOrder)); assertThat("high-pass pass-band ripple", getRange(magHighPass, (int) (N_SAMPLES_FFT * 0.95), N_SAMPLES_FFT), lessThan(EPSILON_DB)); }
Example #6
Source File: SinkDocumentTest.java From mongo-kafka with Apache License 2.0 | 6 votes |
@Test @DisplayName("test SinkDocument clone with missing key / value") void testCloneNoKeyValue() { SinkDocument orig = new SinkDocument(null, null); assertAll( "orig key/value docs NOT present", () -> assertFalse(orig.getKeyDoc().isPresent()), () -> assertFalse(orig.getValueDoc().isPresent())); SinkDocument clone = orig.clone(); assertAll( "clone key/value docs NOT present", () -> assertFalse(clone.getKeyDoc().isPresent()), () -> assertFalse(clone.getValueDoc().isPresent())); }
Example #7
Source File: TestKata1OptionalCreationAndFetchingValues.java From java-katas with MIT License | 6 votes |
@Test @DisplayName("create an Optional from a variable") @Tag("TODO") @Order(2) public void createOptionalFromValue() { Integer anInteger = 10; /* * TODO: * Replace the "null" to create an Optional for anInteger. * Check API: java.util.Optional.of(?) */ Optional<Integer> optionalForInteger = null; assertTrue(optionalForInteger instanceof Optional, "The optionalEmptyString should be an instance of Optional"); assertFalse(optionalForInteger.isEmpty(), "The optionalForInteger should not be empty"); }
Example #8
Source File: BinarySerialiserTests.java From chart-fx with Apache License 2.0 | 6 votes |
@DisplayName("test getDoubleArray([boolean[], byte[], ..., String[]) helper method") @ParameterizedTest(name = "IoBuffer class - {0}") @ValueSource(classes = { FastByteBuffer.class, ByteBuffer.class }) public void testGetDoubleArrayHelper(final Class<? extends IoBuffer> bufferClass) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { assertNotNull(bufferClass, "bufferClass being not null"); assertNotNull(bufferClass.getConstructor(int.class), "Constructor(Integer) present"); final IoBuffer buffer = bufferClass.getConstructor(int.class).newInstance(2 * BUFFER_SIZE); // a bit larger buffer since we test more cases at once putGenericTestArrays(buffer); buffer.reset(); // test conversion to double array assertThrows(IllegalArgumentException.class, () -> BinarySerialiser.getDoubleArray(buffer, DataType.OTHER)); assertArrayEquals(new double[] { 1.0, 0.0, 1.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.BOOL_ARRAY)); assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.BYTE_ARRAY)); assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.CHAR_ARRAY)); assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.SHORT_ARRAY)); assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.INT_ARRAY)); assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.LONG_ARRAY)); assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.FLOAT_ARRAY)); assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.DOUBLE_ARRAY)); assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.STRING_ARRAY)); }
Example #9
Source File: RdbmsDeleteTest.java From mongo-kafka with Apache License 2.0 | 6 votes |
@Test @DisplayName("when valid cdc event with single field PK then correct DeleteOneModel") void testValidSinkDocumentSingleFieldPK() { BsonDocument filterDoc = BsonDocument.parse("{_id: {id: 1004}}"); BsonDocument keyDoc = BsonDocument.parse("{id: 1004}"); BsonDocument valueDoc = BsonDocument.parse("{op: 'd'}"); WriteModel<BsonDocument> result = RDBMS_DELETE.perform(new SinkDocument(keyDoc, valueDoc)); assertTrue(result instanceof DeleteOneModel, "result expected to be of type DeleteOneModel"); DeleteOneModel<BsonDocument> writeModel = (DeleteOneModel<BsonDocument>) result; assertTrue( writeModel.getFilter() instanceof BsonDocument, "filter expected to be of type BsonDocument"); assertEquals(filterDoc, writeModel.getFilter()); }
Example #10
Source File: WriteModelStrategyTest.java From mongo-kafka with Apache License 2.0 | 6 votes |
@Test @DisplayName( "when sink document is valid for DeleteOneDefaultStrategy then correct DeleteOneModel") void testDeleteOneDefaultStrategyWitValidSinkDocument() { BsonDocument keyDoc = BsonDocument.parse("{id: 1234}"); WriteModel<BsonDocument> result = DELETE_ONE_DEFAULT_STRATEGY.createWriteModel(new SinkDocument(keyDoc, null)); assertTrue(result instanceof DeleteOneModel, "result expected to be of type DeleteOneModel"); DeleteOneModel<BsonDocument> writeModel = (DeleteOneModel<BsonDocument>) result; assertTrue( writeModel.getFilter() instanceof BsonDocument, "filter expected to be of type BsonDocument"); assertEquals(FILTER_DOC_DELETE_DEFAULT, writeModel.getFilter()); }
Example #11
Source File: AWSXRayTracerTests.java From java-xray-tracer with Apache License 2.0 | 5 votes |
@Test @DisplayName("store a reference to the current span") void storeReference() { final Scope scope = tracer .buildSpan("simple-span") .startActive(true); assertNotNull(tracer.activeSpan()); assertNotNull(tracer.scopeManager().active().span()); assertEquals(tracer.activeSpan(), scope.span()); assertEquals(tracer.scopeManager().active().span(), scope.span()); scope.close(); }
Example #12
Source File: MongoDbHandlerTest.java From mongo-kafka with Apache License 2.0 | 5 votes |
@Test @DisplayName("when value doc contains unmapped operation type then DataException") void testUnmappedCdcOperationType() { SinkDocument cdcEvent = new SinkDocument( new BsonDocument("_id", new BsonInt32(1234)), new BsonDocument("op", new BsonString("c")) .append("after", new BsonString("{_id:1234,foo:\"blah\"}"))); assertThrows(DataException.class, () -> HANDLER_EMPTY_MAPPING.handle(cdcEvent)); }
Example #13
Source File: AuthUserRoleBindDaoTest.java From sureness with Apache License 2.0 | 5 votes |
@DisplayName("删除数据Bind应成功") @Test @Transactional public void shouldSuccessWhenDeleteBind() { AuthUserRoleBindDO userRoleBind = AuthUserRoleBindDO.builder() .userId(123L).roleId(232L).build(); userRoleBind = userRoleBindDao.save(userRoleBind); userRoleBindDao.delete(userRoleBind); Assertions.assertThat(userRoleBindDao.findById(userRoleBind.getId()).isPresent()).isFalse(); }
Example #14
Source File: Base64BinaryTypeTest.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
@Test @DisplayName("Valid Base64 String creates non-null instance with non-null values.") public void testValid() { String v = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ="; Base64BinaryType b64 = new Base64BinaryType(v); Assertions.assertNotNull(b64); Assertions.assertNotNull(b64.getValue()); Assertions.assertEquals(v, b64.asStringValue()); }
Example #15
Source File: MongoSourceConnectorTest.java From mongo-kafka with Apache License 2.0 | 5 votes |
@Test @DisplayName("Ensure source loads data from MongoClient with copy existing data") void testSourceLoadsDataFromMongoClientWithCopyExisting() { assumeTrue(isGreaterThanThreeDotSix()); Properties sourceProperties = new Properties(); sourceProperties.put(MongoSourceConfig.COPY_EXISTING_CONFIG, "true"); addSourceConnector(sourceProperties); MongoDatabase db1 = getDatabaseWithPostfix(); MongoDatabase db2 = getDatabaseWithPostfix(); MongoDatabase db3 = getDatabaseWithPostfix(); MongoCollection<Document> coll1 = db1.getCollection("coll"); MongoCollection<Document> coll2 = db2.getCollection("coll"); MongoCollection<Document> coll3 = db3.getCollection("coll"); MongoCollection<Document> coll4 = db1.getCollection("db1Coll2"); insertMany(rangeClosed(1, 50), coll1, coll2); assertAll( () -> assertProduced(createInserts(1, 50), coll1), () -> assertProduced(createInserts(1, 50), coll2), () -> assertProduced(emptyList(), coll3)); db1.drop(); insertMany(rangeClosed(51, 60), coll2, coll4); insertMany(rangeClosed(1, 70), coll3); assertAll( () -> assertProduced( concat(createInserts(1, 50), singletonList(createDropCollection())), coll1), () -> assertProduced(createInserts(1, 60), coll2), () -> assertProduced(createInserts(1, 70), coll3), () -> assertProduced(createInserts(51, 60), coll4)); }
Example #16
Source File: IntegerValueProducerTest.java From JsonTemplate with Apache License 2.0 | 5 votes |
@Test @DisplayName("generate a integer string with max parameter") void testProduceWithParamMax() { Map<String, String> mapParam = new HashMap<>(); int max = 80; mapParam.put("max", Integer.toString(max)); String producedValue = producer.produce(mapParam).compactString(); int parsedInt = Integer.parseInt(producedValue); assertThat(parsedInt, lessThanOrEqualTo(max)); }
Example #17
Source File: AWSXRaySpanTests.java From java-xray-tracer with Apache License 2.0 | 5 votes |
@Test @DisplayName("set IS_SAMPLED tag on underlying Entity") void tagSampled() { final AWSXRaySpan span = mockSpan("test-tag-is-sampled"); assertTrue(span.getEntity() instanceof Segment); span.setTag(AWSXRayTags.IS_SAMPLED.getKey(), false); assertFalse(((Segment) span.getEntity()).isSampled()); span.setTag(AWSXRayTags.IS_SAMPLED.getKey(), true); assertTrue(((Segment) span.getEntity()).isSampled()); }
Example #18
Source File: MongoDbHandlerTest.java From mongo-kafka with Apache License 2.0 | 5 votes |
@Test @DisplayName("when value doc contains operation type other than string then DataException") void testInvalidCdcOperationType() { SinkDocument cdcEvent = new SinkDocument( new BsonDocument("id", new BsonInt32(1234)), new BsonDocument("op", new BsonInt32('c'))); assertThrows(DataException.class, () -> HANDLER_DEFAULT_MAPPING.handle(cdcEvent)); }
Example #19
Source File: EntityIdTest.java From hedera-mirror-node with Apache License 2.0 | 5 votes |
@DisplayName("Convert String to EntityId") @Test void ofStringPositive() { EntityTypeEnum type = EntityTypeEnum.ACCOUNT; assertThat(EntityId.of("0.0.1", type)).isEqualTo(EntityId.of(0, 0, 1, type)); assertThat(EntityId.of("0.0.0", type)).isNull(); }
Example #20
Source File: ValidatorGuiTest.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
@Test @DisplayName("Page boots correctly, and displays index.html") public void UI_contains_correct_heading() throws IOException { ValidatorGui.start(new CliContext(), null, false); WebDriverManager.chromedriver().setup(); ChromeOptions options = new ChromeOptions(); options.addArguments("--headless"); options.addArguments("--disable-gpu"); WebDriver driver = new ChromeDriver(options); driver.get("http://localhost:" + ValidatorGui.getPort() + "/home"); Assertions.assertTrue(driver.getPageSource().contains(HTML_TITLE_TAG)); driver.quit(); ValidatorGui.stop(); }
Example #21
Source File: IirFilterTests.java From chart-fx with Apache License 2.0 | 5 votes |
@DisplayName("ChebyshevII - Band-Pass") @ParameterizedTest(name = "{displayName}: filter-order: {0}, algorithm: {1}") @CsvSource({ "2, 0", "3, 0", "4, 0", "2, 1", "3, 1", "4, 1", "2, 2", "3, 2", "4, 2" }) public void testChebyshevIILBandPass(final int filterOrder, final int algorithmVariant) { final ChebyshevII iirBandPass = new ChebyshevII(); switch (algorithmVariant) { case 1: iirBandPass.bandPass(filterOrder, 1.0, F_BAND_CENTRE, F_BAND_WIDTH, ALLOWED_OUT_OF_BAND_RIPPLE_DB, DirectFormAbstract.DIRECT_FORM_I); break; case 2: iirBandPass.bandPass(filterOrder, 1.0, F_BAND_CENTRE, F_BAND_WIDTH, ALLOWED_OUT_OF_BAND_RIPPLE_DB, DirectFormAbstract.DIRECT_FORM_II); break; case 0: default: iirBandPass.bandPass(filterOrder, 1.0, F_BAND_CENTRE, F_BAND_WIDTH, ALLOWED_OUT_OF_BAND_RIPPLE_DB); break; } final DataSet magBandPass = filterAndGetMagnitudeSpectrum(iirBandPass, demoDataSet); assertThat("band-pass cut-off (low)", magBandPass.getValue(DIM_X, F_BAND_START), lessThan(ALLOWED_OUT_OF_BAND_RIPPLE_DB + EPSILON_DB)); assertThat("band-pass cut-off (high)", magBandPass.getValue(DIM_X, F_BAND_STOP), lessThan(ALLOWED_OUT_OF_BAND_RIPPLE_DB + EPSILON_DB)); assertThat("band-pass rejection (low)", magBandPass.getValue(DIM_X, 0.1 * F_BAND_START), lessThan(ALLOWED_OUT_OF_BAND_RIPPLE_DB + EPSILON_DB)); assertThat("band-pass rejection (high)", magBandPass.getValue(DIM_X, 10 * F_BAND_STOP), lessThan(ALLOWED_OUT_OF_BAND_RIPPLE_DB + EPSILON_DB)); final double rangePassBand = getRange(magBandPass, magBandPass.getIndex(DIM_X, (F_BAND_CENTRE - 0.1 * F_BAND_WIDTH)), magBandPass.getIndex(DIM_X, (F_BAND_CENTRE + 0.1 * F_BAND_WIDTH))); assertThat("band-pass pass-band ripple", rangePassBand, lessThan(ALLOWED_IN_BAND_RIPPLE_DB + EPSILON_DB)); }
Example #22
Source File: MongoSinkTaskTest.java From mongo-kafka with Apache License 2.0 | 5 votes |
@Test @DisplayName("test with default config and no sink records") void testBuildWriteModelDefaultConfigSinkRecordsAbsent() { List<? extends WriteModel> writeModelList = new MongoSinkTask().buildWriteModel(createTopicConfig(), emptyList()); assertNotNull(writeModelList, "WriteModel list was null"); assertEquals(emptyList(), writeModelList, "WriteModel list mismatch"); }
Example #23
Source File: GITMergeUnitTest.java From MergeProcessor with Apache License 2.0 | 5 votes |
@DisplayName("Tests compareTo() using 2 equal GITMergeUnits with different file names") @Test public void testCompareToWithEqualMergeUnitButDifferentFileNames() { final LocalDateTime date = LocalDateTime.now(); final GITMergeUnit unit1 = new GITMergeUnit(DEFAULT_TEST_HOST, DEFAULT_REPOSITORY, date, DEFAULT_COMMIT_ID, DEFAULT_BRANCH_SOURCE, DEFAULT_BRANCH_TARGET, DEFAULT_FILE_NAME, new ArrayList<>(0), new JUnitConfiguration()); final GITMergeUnit unit = new GITMergeUnit(DEFAULT_TEST_HOST, DEFAULT_REPOSITORY, date, DEFAULT_COMMIT_ID, DEFAULT_BRANCH_SOURCE, DEFAULT_BRANCH_TARGET, "theFile1", new ArrayList<>(0), new JUnitConfiguration()); assertEquals(0, unit.compareTo(unit1)); assertNotEquals(unit.getFileName(), unit1.getFileName()); }
Example #24
Source File: GITMergeUnitTest.java From MergeProcessor with Apache License 2.0 | 5 votes |
@DisplayName("Tests compareTo() using 2 GITMergeUnits with different target branch") @Test public void testCompareToWithDifferentTargetBranch() { final LocalDateTime date = LocalDateTime.now(); final GITMergeUnit unit = new GITMergeUnit(DEFAULT_TEST_HOST, DEFAULT_REPOSITORY, date, DEFAULT_COMMIT_ID, DEFAULT_BRANCH_SOURCE, DEFAULT_BRANCH_TARGET, DEFAULT_FILE_NAME, new ArrayList<>(0), new JUnitConfiguration()); final GITMergeUnit unit1 = new GITMergeUnit(DEFAULT_TEST_HOST, DEFAULT_REPOSITORY, date, "67890", DEFAULT_BRANCH_SOURCE, "remotes/origin/V1.1", "theFile1", new ArrayList<>(0), new JUnitConfiguration()); assertNotEquals(0, unit.equals(unit1)); }
Example #25
Source File: SinkFieldConverterTest.java From mongo-kafka with Apache License 2.0 | 5 votes |
@TestFactory @DisplayName("tests for int16 field conversions") List<DynamicTest> testInt16FieldConverter() { SinkFieldConverter converter = new Int16FieldConverter(); List<DynamicTest> tests = new ArrayList<>(); asList(Short.MIN_VALUE, (short) 0, Short.MAX_VALUE) .forEach( el -> tests.add( dynamicTest( "conversion with " + converter.getClass().getSimpleName() + " for " + el, () -> assertEquals( (short) el, ((BsonInt32) converter.toBson(el)).getValue())))); tests.add( dynamicTest( "optional type conversions", () -> { Schema valueOptionalDefault = SchemaBuilder.int16().optional().defaultValue((short) 0); assertAll( "checks", () -> assertThrows( DataException.class, () -> converter.toBson(null, Schema.INT16_SCHEMA)), () -> assertEquals( new BsonNull(), converter.toBson(null, Schema.OPTIONAL_INT16_SCHEMA)), () -> assertEquals( ((short) valueOptionalDefault.defaultValue()), ((BsonInt32) converter.toBson(null, valueOptionalDefault)).getValue())); })); return tests; }
Example #26
Source File: AWSXRaySpanTests.java From java-xray-tracer with Apache License 2.0 | 5 votes |
@Test @DisplayName("tag metadata with nested key") void tagMetadataNestedKey() { final AWSXRaySpan span = mockSpan("test-tag-metadata-nested-key"); span.setTag("metadata.default.nested.is_test", true); span.setTag("metadata.default.nested.counter", 42); span.setTag("metadata.default.nested.service", "backend"); @SuppressWarnings("unchecked") final Map<String, Object> targetMap = (Map<String, Object>) span.getEntity().getMetadata().get(AWSXRayMetadataNamespaces.DEFAULT).get("nested"); assertEquals(true, targetMap.get("is_test")); assertEquals(42, targetMap.get("counter")); assertEquals("backend", targetMap.get("service")); }
Example #27
Source File: IirFilterTests.java From chart-fx with Apache License 2.0 | 5 votes |
@DisplayName("Bessel - Band-Pass") @ParameterizedTest(name = "{displayName}: filter-order: {0}, algorithm: {1}") @CsvSource({ "2, 0", "3, 0", "4, 0", "2, 1", "3, 1", "4, 1", "2, 2", "3, 2", "4, 2" }) public void testBesselBandPass(final int filterOrder, final int algorithmVariant) { final Bessel iirBandPass = new Bessel(); switch (algorithmVariant) { case 1: iirBandPass.bandPass(filterOrder, 1.0, F_BAND_CENTRE, F_BAND_WIDTH, DirectFormAbstract.DIRECT_FORM_I); break; case 2: iirBandPass.bandPass(filterOrder, 1.0, F_BAND_CENTRE, F_BAND_WIDTH, DirectFormAbstract.DIRECT_FORM_II); break; case 0: default: iirBandPass.bandPass(filterOrder, 1.0, F_BAND_CENTRE, F_BAND_WIDTH); break; } final DataSet magBandPass = filterAndGetMagnitudeSpectrum(iirBandPass, demoDataSet); assertThat("band-pass cut-off (low)", magBandPass.getValue(DIM_X, F_BAND_START), lessThan(EPSILON_DB)); assertThat("band-pass cut-off (high)", magBandPass.getValue(DIM_X, F_BAND_STOP), lessThan(EPSILON_DB)); assertThat("band-pass rejection (low)", magBandPass.getValue(DIM_X, 0.1 * F_BAND_START), lessThan(3.0 + EPSILON_DB - 10 * filterOrder)); assertThat("band-pass rejection (high)", magBandPass.getValue(DIM_X, 10 * F_BAND_STOP), lessThan(3.0 + EPSILON_DB - 10 * filterOrder)); final double rangePassBand = getRange(magBandPass, magBandPass.getIndex(DIM_X, (F_BAND_CENTRE - 0.1 * F_BAND_WIDTH)), magBandPass.getIndex(DIM_X, (F_BAND_CENTRE + 0.1 * F_BAND_WIDTH))); assertThat("band-pass pass-band ripple", rangePassBand, lessThan(10 * EPSILON_DB)); }
Example #28
Source File: MongoSinkConfigTest.java From mongo-kafka with Apache License 2.0 | 5 votes |
@Test @DisplayName("build config doc (no test)") // CHECKSTYLE:OFF void doc() { System.out.println(MongoSinkConfig.CONFIG.toRst()); System.out.println(MarkdownFormatter.toMarkdown(MongoSinkConfig.CONFIG)); assertTrue(true); }
Example #29
Source File: AuthRoleResourceBindDaoTest.java From sureness with Apache License 2.0 | 5 votes |
@DisplayName("删除数据Bind应成功") @Test @Transactional public void shouldSuccessWhenDeleteBind() { AuthRoleResourceBindDO roleResourceBind = AuthRoleResourceBindDO.builder() .roleId(123L).resourceId(234L).build(); roleResourceBind = roleResourceBindDao.save(roleResourceBind); roleResourceBindDao.delete(roleResourceBind); Assertions.assertThat(roleResourceBindDao.findById(roleResourceBind.getId()).isPresent()).isFalse(); }
Example #30
Source File: RdbmsHandlerTest.java From mongo-kafka with Apache License 2.0 | 5 votes |
@Test @DisplayName("when value doc contains unmapped operation type then DataException") void testUnmappedCdcOperationType() { SinkDocument cdcEvent = new SinkDocument( BsonDocument.parse("{id: 1234}"), BsonDocument.parse("{op: 'c', after: {id: 1234, foo: 'bar'}}")); assertThrows(DataException.class, () -> RDBMS_HANDLER_EMPTY_MAPPING.handle(cdcEvent)); }