org.junit.jupiter.api.Assertions#assertEquals()源码实例Demo

下面列出了org.junit.jupiter.api.Assertions#assertEquals() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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));
}
 
@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());

}
 
源代码3 项目: camel-quarkus   文件: WebSocketJSR356Test.java
@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));
    }
}
 
源代码4 项目: spectator   文件: DefaultTimerTest.java
@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);
}
 
@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());
}
 
@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);
}
 
源代码7 项目: voj   文件: DiscussionThreadMapperTest.java
/**
 * 测试用例: 测试getDiscussionThreadUsingThreadId(long)方法
 * 测试数据: 不存在的讨论帖子唯一标识符
 * 预期结果: 方法正常执行, 未影响数据表中的数据
 */
@Test
public void testDeleteDiscussionThreadUsingNotExistingThreadId() {
	DiscussionThread thread = discussionThreadMapper.getDiscussionThreadUsingThreadId(0);
	Assertions.assertNull(thread);

	int numberOfRowsAffected = discussionThreadMapper.deleteDiscussionThreadUsingThreadId(0);
	Assertions.assertEquals(0, numberOfRowsAffected);
}
 
源代码8 项目: commons-numbers   文件: SmallPrimesTest.java
@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);
}
 
源代码9 项目: vavr-jackson   文件: ParameterizedPojoTest.java
@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());
}
 
@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);
}
 
源代码11 项目: spectator   文件: RegistryTest.java
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);
}
 
源代码12 项目: spectator   文件: DefaultHttpClientTest.java
@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());
}
 
源代码13 项目: symbol-sdk-java   文件: EnumMapperTest.java
@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());
}
 
@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());
}
 
@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);
}
 
源代码16 项目: commons-numbers   文件: ComplexTest.java
@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));
}
 
源代码17 项目: spectator   文件: CompositeRegistryTest.java
@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);
}
 
源代码18 项目: synopsys-detect   文件: PipEnvDetectableTest.java
@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");
}
 
源代码19 项目: symbol-sdk-java   文件: MapperUtilsTest.java
@Test
void shouldMapToNamespaceId() {
    Assertions.assertNull(MapperUtils.toNamespaceId(null));
    Assertions
        .assertEquals(BigInteger.valueOf(1194684), MapperUtils.toNamespaceId("123ABC").getId());
}
 
@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));
}