下面列出了org.junit.jupiter.api.Assertions#assertNotNull() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test
public void shouldParsePrintedConvertObject() {
Car car = new Car("Renault", "Scenic", 2005, OptionalInt.empty());
String json = jsonHelper.print(car);
Assertions.assertNotNull(json);
Assertions.assertTrue(json.contains("Renault"));
Assertions.assertFalse(json.contains("millage"));
Object genericType = jsonHelper.parse(json);
Car convertedType = jsonHelper.convert(genericType, Car.class);
Assertions.assertEquals(car, convertedType);
Assertions.assertEquals(BigInteger.valueOf(2005), convertedType.getYear());
}
@Test
public void shouldParsePrintedObject() {
Car car = new Car("Renault", "Scenic", 2005, OptionalInt.of(100));
String json = jsonHelper.print(car);
Assertions.assertNotNull(json);
Assertions.assertTrue(json.contains("Renault"));
Assertions.assertTrue(json.contains("\"millage\":100"));
Car parsedCar = jsonHelper.parse(json, Car.class);
Assertions.assertEquals(car, parsedCar);
Assertions.assertEquals(BigInteger.valueOf(2005), parsedCar.getYear());
Assertions.assertEquals(100, parsedCar.getMillage().getAsInt());
}
@Test
public void greeterGrpc() {
CKClassResult a = report.get("com.hry.spring.grpc.simple.GreeterGrpc");
Assertions.assertNotNull(a);
CKClassResult b = report.get("com.hry.spring.grpc.simple.GreeterGrpc$GreeterImplBase");
Assertions.assertNotNull(b);
Assertions.assertEquals(2, b.getNumberOfMethods());
CKClassResult c = report.get("com.hry.spring.grpc.simple.GreeterGrpc$GreeterBlockingStub");
Assertions.assertNotNull(c);
}
@Test
void getPictureStyleCaption() {
final String expectedResult = "value";
mockGetProperty(fakeImage, EdsPropertyID.kEdsPropID_PictureStyleCaption, expectedResult);
final String result = spyPropertyGetShortcutLogic.getPictureStyleCaption(fakeImage);
Assertions.assertNotNull(result);
Assertions.assertEquals(expectedResult, result);
}
@Disabled("Only run manually")
@Test
void testShootWithShortcut() throws InterruptedException, ExecutionException {
cameraObjectEventLogic().registerCameraObjectEvent(cameraRef);
final CameraObjectListener cameraObjectListener = event -> {
log.warn("Got event: {}", event);
};
cameraObjectEventLogic().addCameraObjectListener(cameraRef, cameraObjectListener);
final CompletableFuture<List<File>> future = CompletableFuture.supplyAsync(() -> {
try {
return shootLogic().shoot(cameraRef);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
getEvents();
getEvents();
getEvents();
getEvents();
final List<File> files = future.get();
log.info("Files: {}", files);
Assertions.assertNotNull(files);
Assertions.assertTrue(files.size() > 0);
}
@Test
void test5() {
final EdsFrameDesc eds1 = new EdsFrameDesc();
final List<String> fieldOrder = eds1.getFieldOrder();
Assertions.assertNotNull(fieldOrder);
Assertions.assertFalse(fieldOrder.isEmpty());
final EdsFrameDesc eds2 = new EdsFrameDesc(new Pointer(0));
final EdsFrameDesc eds3 = new EdsFrameDesc(new NativeLong(0), new NativeLong(0),
new NativeLong(0), new EdsRect(), new NativeLong(0));
new EdsFrameDesc.ByReference();
new EdsFrameDesc.ByValue();
}
@Test
public void test1() {
final ConnectionFactory connectionFactory = new DriverManagerConnectionFactory("jdbc:some:connect:string","userName","password");
final PoolableConnectionFactory pcf =
new PoolableConnectionFactory(connectionFactory, null);
pcf.setDefaultReadOnly(Boolean.FALSE);
pcf.setDefaultAutoCommit(Boolean.TRUE);
final GenericObjectPool<PoolableConnection> connectionPool =
new GenericObjectPool<>(pcf);
pcf.setPool(connectionPool);
final DataSource ds = new PoolingDataSource<>(connectionPool);
Assertions.assertNotNull(ds);
}
@RegistryServiceTest
public void testSmoke(Supplier<RegistryService> supplier) {
RegistryService service = supplier.get();
service.deleteAllGlobalRules();
Assertions.assertNotNull(service.toString());
Assertions.assertEquals(service.hashCode(), service.hashCode());
Assertions.assertEquals(service, service);
}
/**
* 测试用例: 测试createDiscussionReply(DiscussionReply)方法.
* 测试数据: 合法数据集
* 预期结果: 数据插入操作成功完成
*/
@Test
public void testCreateDiscussionReplyNormally() {
long threadId = 1;
User creator = userMapper.getUserUsingUid(1000);
Assertions.assertNotNull(creator);
DiscussionReply discussionReply = new DiscussionReply(threadId, creator, "Content", "{}");
int numberOfRowsAffected = discussionReplyMapper.createDiscussionReply(discussionReply);
Assertions.assertEquals(1, numberOfRowsAffected);
}
@Test
public void test() {
TestProxyService service = this.testProxyService.getInstance();
System.out.println(service);
System.out.println(this.testProxyService);
Assertions.assertNotNull(service);
}
@Test
void getAEModeSelectDesc() {
final List<EdsAEModeSelect> result = spyPropertyDescShortcutLogic.getAEModeSelectDesc(fakeCamera);
Assertions.assertNotNull(result);
verify(propertyDescLogic).getPropertyDesc(fakeCamera, EdsPropertyID.kEdsPropID_AEModeSelect);
}
@Test
public void when_alfrescoMvcDispatcherServletConfigOptionsWithSuffix_expect_suffixHandledAndOk() throws Exception {
DispatcherServlet dispatcherServlet = dispatcherWebscript.getDispatcherServlet().getWebApplicationContext()
.getBean(DispatcherServlet.class);
Assertions.assertNotNull(dispatcherServlet);
MockHttpServletResponse res = mockWebscript.withControllerMapping("/test/withsufix.test").execute();
Assertions.assertEquals(HttpStatus.OK.value(), res.getStatus());
String contentAsString = res.getContentAsString();
Assertions.assertEquals("withsufix.test", contentAsString);
System.out.println();
}
@Test
public void test_listPointLog4Page() {
ListPointLogParam param = new ListPointLogParam();
param.setUid(super.getUid()).setOrderNo("abcd123").setSk("abewfgewgewgewgewg")
.setType(super.getPointType());
ListResponse<PointLogDto> res = this.pointLogDs.listPointLog4Page(param);
Assertions.assertNotNull(res);
}
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void addAndRemoveTransactionRestriction(RepositoryType type) {
AccountOperationRestrictionFlags restrictionFlags = AccountOperationRestrictionFlags.BLOCK_OUTGOING_TRANSACTION_TYPE;
TransactionType transactionType = TransactionType.SECRET_PROOF;
Account testAccount = getTestAccount();
Assertions.assertNotNull(get(getRepositoryFactory(type).createAccountRepository()
.getAccountInfo(testAccount.getAddress())));
if (hasRestriction(type, testAccount, restrictionFlags, transactionType)) {
System.out.println("Removing existing transaction restriction!");
sendAccountRestrictionTransaction(type, transactionType, false, restrictionFlags);
Assertions
.assertFalse(hasRestriction(type, testAccount, restrictionFlags, transactionType));
}
System.out.println("Adding transaction restriction");
sendAccountRestrictionTransaction(type, transactionType, true, restrictionFlags);
Assertions.assertTrue(hasRestriction(type, testAccount, restrictionFlags, transactionType));
System.out.println("Removing transaction restriction");
sendAccountRestrictionTransaction(type, transactionType, false, restrictionFlags);
Assertions
.assertFalse(hasRestriction(type, testAccount, restrictionFlags, transactionType));
}
@Test
void getArtist() {
final String expectedResult = "value";
mockGetProperty(fakeCamera, EdsPropertyID.kEdsPropID_Artist, expectedResult);
final String result = spyPropertyGetShortcutLogic.getArtist(fakeCamera);
Assertions.assertNotNull(result);
Assertions.assertEquals(expectedResult, result);
}
@Test
public void testSubscriptions() {
MinecraftRecipeService service = new MinecraftRecipeService(plugin);
AtomicReference<RecipeSnapshot> reference = new AtomicReference<>();
Assertions.assertThrows(IllegalArgumentException.class, () -> service.subscribe(null));
service.subscribe(reference::set);
service.refresh();
// The callback was executed
Assertions.assertNotNull(reference.get());
}
@Test
void unusedBeanWhoseProducerMarkedAsUnemoveableShouldBeAccessible() {
Assertions.assertNotNull(Arc.container().instance(ProducerOfUnusedUnremovableBean.Bean.class).get());
}
@Test
public void shouldGetBlockByHeight() throws Exception {
Address address = Address.generateRandom(networkType);
BlockInfoDTO dto = new BlockInfoDTO();
BlockMetaDTO metaDTO = new BlockMetaDTO();
metaDTO.setHash("someHash");
metaDTO.setNumTransactions(10);
metaDTO.setGenerationHash("generationHash");
metaDTO.setNumStatements(20);
metaDTO.setStateHashSubCacheMerkleRoots(Arrays.asList("string1", "string2"));
metaDTO.setTotalFee(BigInteger.valueOf(8L));
dto.setMeta(metaDTO);
BlockDTO blockDto = new BlockDTO();
blockDto.setType(16716);
blockDto.setSize(10L);
blockDto.setVersion(3);
blockDto.setSignerPublicKey("B630EFDDFADCC4A2077AB8F1EC846B08FEE2D2972EACF95BBAC6BFAC3D31834C");
blockDto.setBeneficiaryAddress(address.encoded());
blockDto.setHeight(BigInteger.valueOf(9L));
blockDto.setNetwork(NetworkTypeEnum.NUMBER_144);
dto.setBlock(blockDto);
mockRemoteCall(dto);
BigInteger height = BigInteger.valueOf(10L);
BlockInfo info = repository.getBlockByHeight(height).toFuture().get();
Assertions.assertNotNull(info);
Assertions.assertEquals(blockDto.getBeneficiaryAddress(), info.getBeneficiaryAddress().encoded());
Assertions.assertEquals(blockDto.getSignerPublicKey(), info.getSignerPublicAccount().getPublicKey().toHex());
Assertions.assertEquals(16716, info.getType());
Assertions.assertEquals(10, info.getSize());
Assertions.assertEquals(3, info.getVersion().intValue());
Assertions.assertEquals(NetworkType.MIJIN_TEST, info.getNetworkType());
Assertions.assertEquals(BigInteger.valueOf(9L), info.getHeight());
Assertions.assertEquals(metaDTO.getHash(), info.getHash());
Assertions.assertEquals(metaDTO.getNumTransactions(), info.getNumTransactions());
Assertions.assertEquals(metaDTO.getGenerationHash(), info.getGenerationHash());
Assertions.assertEquals(metaDTO.getNumStatements(), info.getNumStatements().get());
Assertions.assertEquals(metaDTO.getStateHashSubCacheMerkleRoots(), info.getSubCacheMerkleRoots());
Assertions.assertEquals(metaDTO.getTotalFee(), info.getTotalFee());
Assertions.assertEquals(blockDto.getHeight(), info.getHeight());
Assertions.assertEquals(address, info.getBeneficiaryAddress());
Assertions.assertEquals(10L, info.getSize());
}
@Test
public void fullNameEvenWhenTypesAreNotAvailable() {
CKClassResult a = report.get("bind.BindingFail1");
Assertions.assertNotNull(a);
}
/**
* Helper method to validate a KafkaBroker instance.
* @param broker The KafkaBroker instance under test.
* @param expectedBrokerId The expected brokerId.
*/
private void validateKafkaBroker(final KafkaBroker broker, final int expectedBrokerId) {
Assertions.assertNotNull(broker);
Assertions.assertEquals(expectedBrokerId, broker.getBrokerId());
}