Java Code Examples for org.junit.jupiter.api.Assertions#assertEquals()
The following examples show how to use
org.junit.jupiter.api.Assertions#assertEquals() .
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: WebSocketJSR356Test.java From camel-quarkus with Apache License 2.0 | 6 votes |
@Test public void testWebsocketChat() throws Exception { LinkedBlockingDeque<String> message = new LinkedBlockingDeque<>(); Endpoint endpoint = new Endpoint() { @Override public void onOpen(Session session, EndpointConfig endpointConfig) { session.addMessageHandler(new MessageHandler.Whole<String>() { @Override public void onMessage(String s) { message.add(s); } }); session.getAsyncRemote().sendText("Camel Quarkus WebSocket"); } }; ClientEndpointConfig config = ClientEndpointConfig.Builder.create().build(); try (Session session = ContainerProvider.getWebSocketContainer().connectToServer(endpoint, config, uri)) { Assertions.assertEquals("Hello Camel Quarkus WebSocket", message.poll(5, TimeUnit.SECONDS)); } }
Example 2
Source File: TransactionMapperVertxTest.java From symbol-sdk-java with Apache License 2.0 | 6 votes |
@Test void shouldCreateAggregateAddressAliasTransaction() { TransactionInfoDTO aggregateTransferTransactionDTO = TestHelperVertx .loadTransactionInfoDTO("aggregateAddressAliasTransaction.json"); Transaction aggregateTransferTransaction = map(aggregateTransferTransactionDTO); validateAggregateTransaction((AggregateTransaction) aggregateTransferTransaction, aggregateTransferTransactionDTO); AddressAliasTransaction transaction = (AddressAliasTransaction) ((AggregateTransaction) aggregateTransferTransaction) .getInnerTransactions().get(0); Assertions.assertEquals("SDT4THYNVUQK2GM6XXYTWHZXSPE3AUA2GTDPM2Q", transaction.getAddress().plain()); Assertions.assertEquals(AliasAction.LINK, transaction.getAliasAction()); Assertions.assertEquals(new BigInteger("307262000798378"), transaction.getNamespaceId().getId()); }
Example 3
Source File: DefaultTimerTest.java From spectator with Apache License 2.0 | 6 votes |
@Test public void testRecordRunnableException() throws Exception { Timer t = new DefaultTimer(clock, NoopId.INSTANCE); clock.setMonotonicTime(100L); boolean seen = false; try { t.record(() -> { clock.setMonotonicTime(500L); throw new RuntimeException("foo"); }); } catch (Exception e) { seen = true; } Assertions.assertTrue(seen); Assertions.assertEquals(t.count(), 1L); Assertions.assertEquals(t.totalTime(), 400L); }
Example 4
Source File: NetworkRepositoryOkHttpImplTest.java From symbol-sdk-java with Apache License 2.0 | 6 votes |
@Test void getTransactionFees() throws Exception { TransactionFeesDTO dto = new TransactionFeesDTO(); dto.setAverageFeeMultiplier(1L); dto.setMedianFeeMultiplier(2L); dto.setLowestFeeMultiplier(3L); dto.setHighestFeeMultiplier(4L); mockRemoteCall(dto); TransactionFees info = repository.getTransactionFees().toFuture().get(); Assertions.assertNotNull(info); Assertions.assertEquals(dto.getAverageFeeMultiplier(), info.getAverageFeeMultiplier()); Assertions.assertEquals(dto.getMedianFeeMultiplier(), info.getMedianFeeMultiplier()); Assertions.assertEquals(dto.getLowestFeeMultiplier(), info.getLowestFeeMultiplier()); Assertions.assertEquals(dto.getHighestFeeMultiplier(), info.getHighestFeeMultiplier()); }
Example 5
Source File: MosaicAddressRestrictionIntegrationTest.java From symbol-sdk-java with Apache License 2.0 | 6 votes |
private void assertMosaicAddressRestriction( Address address, MosaicAddressRestrictionTransaction transaction, MosaicAddressRestriction restriction) { BigInteger restrictionKey = transaction.getRestrictionKey(); BigInteger newRestrictionValue = transaction .getNewRestrictionValue(); Assertions.assertEquals(Collections.singleton(restrictionKey), restriction.getRestrictions().keySet()); Assertions.assertEquals(address, restriction.getTargetAddress()); Assertions.assertEquals(1, restriction.getRestrictions().size()); Assertions .assertEquals(newRestrictionValue, restriction.getRestrictions().get(restrictionKey)); Assertions.assertEquals(transaction.getNewRestrictionValue(), restriction.getRestrictions().get(restrictionKey)); }
Example 6
Source File: SmallPrimesTest.java From commons-numbers with Apache License 2.0 | 5 votes |
@Test void boundedTrialDivision_twoDifferentFactors() { final List<Integer> factors = new ArrayList<Integer>(); final int result = SmallPrimes.boundedTrialDivision(LARGE_PRIME[0] * LARGE_PRIME[1], Integer.MAX_VALUE, factors); Assertions.assertEquals(LARGE_PRIME[1], result); Assertions.assertEquals(Arrays.asList(LARGE_PRIME[0], LARGE_PRIME[1]), factors); }
Example 7
Source File: ParameterizedPojoTest.java From vavr-jackson with Apache License 2.0 | 5 votes |
@Test void testVectorOfTuple() throws Exception { String src00 = "A"; String src01 = "B"; Tuple2<String, String> src0 = Tuple.of(src00, src01); Vector<Tuple2<String, String>> src = Vector.of(src0); String json = MAPPER.writeValueAsString(new ParameterizedVectorPojo<>(src)); Assertions.assertEquals(json, "{\"value\":[[\"A\",\"B\"]]}"); ParameterizedVectorPojo<io.vavr.Tuple2<java.lang.String, java.lang.String>> restored = MAPPER.readValue(json, new TypeReference<ParameterizedVectorPojo<io.vavr.Tuple2<java.lang.String, java.lang.String>>>(){}); Assertions.assertEquals(src, restored.getValue()); }
Example 8
Source File: PreferSameRackWeightingBalancedTest.java From Baragon with Apache License 2.0 | 5 votes |
@Test public void testSimpleCase1B() { List<String> results = new ArrayList<>(); final BaragonAgentMetadata agentMetadata = generateBaragonAgentMetadata("us-east-1b"); for (String availabilityZone : AVAILABILITY_ZONES) { final UpstreamInfo currentUpstream = new UpstreamInfo("testhost:8080", Optional.absent(), Optional.of(availabilityZone)); final PreferSameRackWeightingHelper helper = new PreferSameRackWeightingHelper(CONFIGURATION, agentMetadata); CharSequence result = helper.preferSameRackWeighting(UPSTREAMS, currentUpstream, null); results.add(result.toString()); } Assertions.assertEquals(Arrays.asList("weight=2", "weight=2", "weight=16", "backup", "backup"), results); }
Example 9
Source File: RegistryTest.java From spectator with Apache License 2.0 | 5 votes |
private void assertLongTaskTimer(Registry r, Id id, long timestamp, int activeTasks, double duration) { PolledMeter.update(r); Gauge g = r.gauge(id.withTag(Statistic.activeTasks)); Assertions.assertEquals(timestamp, g.measure().iterator().next().timestamp()); Assertions.assertEquals(activeTasks, g.value(), 1.0e-12); g = r.gauge(id.withTag(Statistic.duration)); Assertions.assertEquals(timestamp, g.measure().iterator().next().timestamp()); Assertions.assertEquals(duration, g.value(), 1.0e-12); }
Example 10
Source File: ConfigUtilsAirOptionsTests.java From vscode-as3mxml with Apache License 2.0 | 5 votes |
@Test void testOutputPlatformMerge() throws IOException { String baseValue = "bin/Base.air"; String newValue = "bin/New.air"; ObjectMapper mapper = new ObjectMapper(); JsonNode baseConfigData = mapper.readTree( "{" + "\"airOptions\": {" + "\"android\": {" + "\"output\": \"" + baseValue + "\"" + "}" + "}" + "}" ); JsonNode configData = mapper.readTree( "{" + "\"airOptions\": {" + "\"android\": {" + "\"output\": \"" + newValue + "\"" + "}" + "}" + "}" ); JsonNode result = ConfigUtils.mergeConfigs(configData, baseConfigData); Assertions.assertTrue(result.has(TopLevelFields.AIR_OPTIONS)); JsonNode airOptions = result.get(TopLevelFields.AIR_OPTIONS); Assertions.assertTrue(airOptions.isObject()); Assertions.assertTrue(airOptions.has(AIRPlatform.ANDROID)); JsonNode android = airOptions.get(AIRPlatform.ANDROID); Assertions.assertTrue(android.isObject()); Assertions.assertTrue(android.has(AIROptions.OUTPUT)); String resultValue = android.get(AIROptions.OUTPUT).asText(); Assertions.assertEquals(newValue, resultValue); }
Example 11
Source File: DefaultHttpClientTest.java From spectator with Apache License 2.0 | 5 votes |
@Test public void ok() throws IOException { HttpResponse res = HttpClient.DEFAULT .get(uri("/ok")) .addHeader("X-Status", "200") .addHeader("X-Length", "-1") .send(); Assertions.assertEquals(200, res.status()); }
Example 12
Source File: EnumMapperTest.java From symbol-sdk-java with Apache License 2.0 | 5 votes |
@ParameterizedTest @EnumSource(NodeIdentityEqualityStrategy.class) void validNodeIdentityEqualityStrategyEnum(NodeIdentityEqualityStrategy enumValue) { assertNotNull(io.nem.symbol.sdk.model.network.NodeIdentityEqualityStrategy.rawValueOf(enumValue.getValue())); Assertions.assertEquals(NodeIdentityEqualityStrategy.fromValue(enumValue.getValue()).getValue(), enumValue.getValue()); }
Example 13
Source File: OperationsHelperTest.java From multiapps-controller with Apache License 2.0 | 5 votes |
@Test public void testAddErrorTypeWhenOperationIsInErrorStateContentError() { Operation mockedOperation = createMockedOperation(PROCESS_ID, ProcessType.DEPLOY, Operation.State.ERROR); HistoricOperationEvent mockedHistoricOperationEvent = createMockedHistoricOperationEvent(HistoricOperationEvent.EventType.FAILED_BY_CONTENT_ERROR); List<HistoricOperationEvent> historicOperationEvents = Collections.singletonList(mockedHistoricOperationEvent); Mockito.when(processHelper.getHistoricOperationEventByProcessId(mockedOperation.getProcessId())) .thenReturn(historicOperationEvents); Operation operation = operationsHelper.addErrorType(mockedOperation); Assertions.assertEquals(ErrorType.CONTENT, operation.getErrorType()); }
Example 14
Source File: ClientSupportGuiceyTest.java From dropwizard-guicey with MIT License | 5 votes |
@Test void testLimitedClient(ClientSupport client) { Assertions.assertEquals(200, client.target("http://localhost:8080/dummy/") .request().buildGet().invoke().getStatus()); // web methods obviously doesnt work Assertions.assertThrows(NullPointerException.class, client::basePathMain); }
Example 15
Source File: ComplexTest.java From commons-numbers with Apache License 2.0 | 5 votes |
@Test void testPolarConstructor() { final double r = 98765; final double theta = 0.12345; final Complex z = Complex.ofPolar(r, theta); final Complex y = Complex.ofCis(theta); Assertions.assertEquals(r * y.getReal(), z.getReal()); Assertions.assertEquals(r * y.getImaginary(), z.getImaginary()); // Edge cases // Non-finite theta Assertions.assertEquals(NAN, Complex.ofPolar(1, -inf)); Assertions.assertEquals(NAN, Complex.ofPolar(1, inf)); Assertions.assertEquals(NAN, Complex.ofPolar(1, nan)); // Infinite rho is invalid when theta is NaN // i.e. do not create an infinite complex such as (inf, nan) Assertions.assertEquals(NAN, Complex.ofPolar(inf, nan)); // negative or NaN rho Assertions.assertEquals(NAN, Complex.ofPolar(-inf, 1)); Assertions.assertEquals(NAN, Complex.ofPolar(-0.0, 1)); Assertions.assertEquals(NAN, Complex.ofPolar(nan, 1)); // Construction from infinity has values left to double arithmetic. // Test the examples from the javadoc Assertions.assertEquals(NAN, Complex.ofPolar(-0.0, 0.0)); Assertions.assertEquals(Complex.ofCartesian(0.0, 0.0), Complex.ofPolar(0.0, 0.0)); Assertions.assertEquals(Complex.ofCartesian(1.0, 0.0), Complex.ofPolar(1.0, 0.0)); Assertions.assertEquals(Complex.ofCartesian(-1.0, Math.sin(pi)), Complex.ofPolar(1.0, pi)); Assertions.assertEquals(Complex.ofCartesian(-inf, inf), Complex.ofPolar(inf, pi)); Assertions.assertEquals(Complex.ofCartesian(inf, nan), Complex.ofPolar(inf, 0.0)); Assertions.assertEquals(Complex.ofCartesian(inf, -inf), Complex.ofPolar(inf, -pi / 4)); Assertions.assertEquals(Complex.ofCartesian(-inf, -inf), Complex.ofPolar(inf, 5 * pi / 4)); }
Example 16
Source File: CompositeRegistryTest.java From spectator with Apache License 2.0 | 5 votes |
@Test public void testCounterBadTypeAccessNoThrow() { Registry r = newRegistry(5, false); r.counter(r.createId("foo")).count(); Counter c = r.counter("foo"); DistributionSummary ds = r.distributionSummary(r.createId("foo")); ds.record(42); Assertions.assertEquals(ds.count(), 0L); }
Example 17
Source File: PipEnvDetectableTest.java From synopsys-detect with Apache License 2.0 | 5 votes |
@Override public void assertExtraction(@NotNull final Extraction extraction) { Assertions.assertEquals("simple", extraction.getProjectName()); Assertions.assertEquals("1", extraction.getProjectVersion()); Assertions.assertEquals(1, extraction.getCodeLocations().size()); final DependencyGraph dependencyGraph = extraction.getCodeLocations().get(0).getDependencyGraph(); final NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, dependencyGraph); graphAssert.hasNoDependency("simple", "1"); graphAssert.hasRootDependency("with-dashes", "2.0"); graphAssert.hasRootDependency("dots.and-dashes", "3.1.2"); graphAssert.hasParentChildRelationship("with-dashes", "2.0", "dots.and-dashes", "3.1.2"); }
Example 18
Source File: DiscussionThreadMapperTest.java From voj with GNU General Public License v3.0 | 5 votes |
/** * 测试用例: 测试getDiscussionThreadUsingThreadId(long)方法 * 测试数据: 不存在的讨论帖子唯一标识符 * 预期结果: 方法正常执行, 未影响数据表中的数据 */ @Test public void testDeleteDiscussionThreadUsingNotExistingThreadId() { DiscussionThread thread = discussionThreadMapper.getDiscussionThreadUsingThreadId(0); Assertions.assertNull(thread); int numberOfRowsAffected = discussionThreadMapper.deleteDiscussionThreadUsingThreadId(0); Assertions.assertEquals(0, numberOfRowsAffected); }
Example 19
Source File: MapperUtilsTest.java From symbol-sdk-java with Apache License 2.0 | 4 votes |
@Test void shouldMapToNamespaceId() { Assertions.assertNull(MapperUtils.toNamespaceId(null)); Assertions .assertEquals(BigInteger.valueOf(1194684), MapperUtils.toNamespaceId("123ABC").getId()); }
Example 20
Source File: PropertyGetLogicDefaultMockTest.java From canon-sdk-java with MIT License | 3 votes |
@Test void getPropertyDataForInt16Array() { final short[] expectedResult = new short[]{1, 2, 5, 9}; final EdsPropertyID propertyID = EdsPropertyID.kEdsPropID_ISOSpeed; final long inParam = 0L; final int inPropertySize = 4; propertyInfo = new PropertyInfo(EdsDataType.kEdsDataType_Int16_Array, inPropertySize); // mocks when(CanonFactory.propertyLogic().getPropertyTypeAndSize(fakeBaseRef, propertyID, inParam)).thenReturn(propertyInfo); returnNoErrorForEdsGetPropertyData(propertyID, inParam, inPropertySize); // mock actual result when(mockMemory.getShortArray(0, (int) (inPropertySize / 2))).thenReturn(expectedResult); final short[] result = propertyGetLogicDefaultExtended.getPropertyData(fakeBaseRef, propertyID); Assertions.assertEquals(expectedResult, result); verify(CanonFactory.propertyLogic()).getPropertyTypeAndSize(fakeBaseRef, propertyID, inParam); verify(CanonFactory.edsdkLibrary()).EdsGetPropertyData(eq(fakeBaseRef), eq(new NativeLong(propertyID.value())), eq(new NativeLong(inParam)), eq(new NativeLong(inPropertySize)), eq(mockMemory)); }