How to use assertNotNull method of org.testng.Assert class

Best Testng code snippet using org.testng.Assert.assertNotNull

Source:TestEntityRESTDelete.java Github

copy

Full Screen

...39import java.util.ArrayList;40import java.util.HashMap;41import java.util.List;42import java.util.Map;43import static org.testng.Assert.assertNotNull;44import static org.testng.AssertJUnit.assertTrue;45import static org.testng.FileAssert.fail;46@Guice(modules = {TestModules.TestOnlyModule.class})47public class TestEntityRESTDelete {48 @Inject49 private AtlasTypeDefStore typeStore;50 @Inject51 private EntityREST entityREST;52 private List<AtlasEntity> dbEntities = new ArrayList<>();53 @BeforeClass54 public void setUp() throws Exception {55 AtlasTypesDef typesDef = TestUtilsV2.defineHiveTypes();56 typeStore.createTypesDef(typesDef);57 }58 @AfterMethod59 public void cleanup() {60 RequestContext.clear();61 }62 private void assertSoftDelete(String guid) throws AtlasBaseException {63 AtlasEntity.AtlasEntityWithExtInfo entity = entityREST.getById(guid, false, false);64 assertTrue(entity != null && entity.getEntity().getStatus() == AtlasEntity.Status.DELETED);65 }66 private void assertHardDelete(String guid) {67 try {68 entityREST.getById(guid, false, false);69 fail("Entity should have been deleted. Exception should have been thrown.");70 } catch (AtlasBaseException e) {71 assertTrue(true);72 }73 }74 private void createEntities() throws Exception {75 dbEntities.clear();76 for (int i = 1; i <= 2; i++) {77 AtlasEntity dbEntity = TestUtilsV2.createDBEntity();78 final EntityMutationResponse response = entityREST.createOrUpdate(new AtlasEntity.AtlasEntitiesWithExtInfo(dbEntity));79 assertNotNull(response);80 List<AtlasEntityHeader> entitiesMutated = response.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE);81 assertNotNull(entitiesMutated);82 Assert.assertEquals(entitiesMutated.size(), 1);83 assertNotNull(entitiesMutated.get(0));84 dbEntity.setGuid(entitiesMutated.get(0).getGuid());85 dbEntities.add(dbEntity);86 }87 }88 @Test89 public void deleteByGuidTestSoft() throws Exception {90 RequestContext.get().setDeleteType(DeleteType.SOFT);91 createEntities();92 EntityMutationResponse response = entityREST.deleteByGuid(dbEntities.get(0).getGuid());93 assertNotNull(response);94 assertNotNull(response.getDeletedEntities());95 assertSoftDelete(dbEntities.get(0).getGuid());96 }97 @Test98 public void deleteByGuidTestHard() throws Exception {99 RequestContext.get().setDeleteType(DeleteType.HARD);100 createEntities();101 EntityMutationResponse response = entityREST.deleteByGuid(dbEntities.get(0).getGuid());102 assertNotNull(response);103 assertNotNull(response.getDeletedEntities());104 assertHardDelete(dbEntities.get(0).getGuid());105 }106 @Test107 public void deleteByGuidsSoft() throws Exception {108 RequestContext.get().setDeleteType(DeleteType.SOFT);109 createEntities();110 List<String> guids = new ArrayList<>();111 guids.add(dbEntities.get(0).getGuid());112 guids.add(dbEntities.get(1).getGuid());113 EntityMutationResponse response = entityREST.deleteByGuids(guids);114 assertNotNull(response);115 assertNotNull(response.getDeletedEntities());116 for (String guid : guids) {117 assertSoftDelete(guid);118 }119 }120 @Test121 public void deleteByGuidsHard() throws Exception {122 RequestContext.get().setDeleteType(DeleteType.HARD);123 createEntities();124 List<String> guids = new ArrayList<>();125 guids.add(dbEntities.get(0).getGuid());126 guids.add(dbEntities.get(1).getGuid());127 EntityMutationResponse response = entityREST.deleteByGuids(guids);128 assertNotNull(response);129 assertNotNull(response.getDeletedEntities());130 for (String guid : guids) {131 assertHardDelete(guid);132 }133 }134 @Test135 public void testUpdateGetDeleteEntityByUniqueAttributeSoft() throws Exception {136 RequestContext.get().setDeleteType(DeleteType.SOFT);137 createEntities();138 entityREST.deleteByUniqueAttribute(TestUtilsV2.DATABASE_TYPE, toHttpServletRequest(TestUtilsV2.NAME,139 (String) dbEntities.get(0).getAttribute(TestUtilsV2.NAME)));140 assertSoftDelete(dbEntities.get(0).getGuid());141 }142 @Test143 public void testUpdateGetDeleteEntityByUniqueAttributeHard() throws Exception {...

Full Screen

Full Screen

Source:FloatingIPTests.java Github

copy

Full Screen

1package org.openstack4j.api.compute;2import static org.testng.Assert.assertEquals;3import static org.testng.Assert.assertFalse;4import static org.testng.Assert.assertNotNull;5import static org.testng.Assert.assertNull;6import static org.testng.Assert.assertTrue;7import java.io.IOException;8import java.lang.reflect.Method;9import java.util.List;10import java.util.UUID;11import org.openstack4j.api.AbstractTest;12import org.openstack4j.core.transport.internal.HttpExecutor;13import org.openstack4j.model.common.ActionResponse;14import org.openstack4j.model.compute.FloatingIP;15import org.testng.annotations.BeforeMethod;16import org.testng.annotations.DataProvider;17import org.testng.annotations.Test;18@Test(suiteName = "Compute")19public class FloatingIPTests extends AbstractTest {20 private static final String JSON_FIPS = "/compute/floatingips.json";21 @SuppressWarnings("unused")22 private String httpExecutorName;23 @DataProvider(name = "floatingIPs")24 public Object[][] createFloatingIPData(Method m) {25 final int SIZE = 10;26 final String BASE_IP = "192.168.0.";27 Object[][] fipsData = new Object[SIZE][];28 for (int i = 0; i < SIZE; i++) {29 fipsData[i] = new String[]{BASE_IP + (i + 1)};30 }31 return fipsData;32 }33 @BeforeMethod34 protected void checkEnvironment(Method method) {35 httpExecutorName = HttpExecutor.create().getExecutorName();36 }37 @Override38 protected Service service() {39 return Service.COMPUTE;40 }41 @SuppressWarnings("unchecked")42 @Test43 public void listFloatingIPs() throws IOException {44 respondWith(JSON_FIPS);45 List<FloatingIP> fips = (List<FloatingIP>) osv3().compute().floatingIps().list();46 assertNotNull(fips);47 assertEquals(fips.size(), 5);48 // Test empty list49 respondWith(200, "{\"floating_ips\": []}");50 List<FloatingIP> fipsEmpty = (List<FloatingIP>) osv3().compute().floatingIps().list();51 assertNotNull(fipsEmpty);52 assertEquals(fipsEmpty.size(), 0);53 }54 @Test(dataProvider = "floatingIPs")55 public void allocateFloatingIP(String ip) throws IOException {56 final String POOL = "floating";57 String jsonResponse = String.format("{\"floating_ip\": {"58 + "\"instance_id\": null, "59 + "\"ip\": \"%s\", "60 + "\"fixed_ip\": null, "61 + "\"id\": \"%s\", "62 + "\"pool\": \"%s\"}}", ip, UUID.randomUUID().toString(), POOL);63 respondWith(200, jsonResponse);64 FloatingIP fip = osv3().compute().floatingIps().allocateIP(POOL);65 assertNotNull(fip);66 assertEquals(fip.getFloatingIpAddress(), ip);67 assertEquals(fip.getPool(), POOL);68 assertNotNull(fip.getId());69 assertNull(fip.getFixedIpAddress());70 assertNull(fip.getInstanceId());71 }72 @Test(dataProvider = "floatingIPs")73 public void deallocateFloatingIP(String ip) {74 // Test deallocate success75 respondWith(202);76 ActionResponse successResponse = osv3().compute().floatingIps().deallocateIP(ip);77 assertNotNull(successResponse);78 assertTrue(successResponse.isSuccess());79 String jsonResponse = String.format("{\"itemNotFound\": {"80 + "\"message\": \"Floating ip not found for id %s\", "81 + "\"code\": 404}}",82 ip);83 // Test deallocate error84 respondWith(404, jsonResponse);85 ActionResponse failureResponse = osv3().compute().floatingIps().deallocateIP(ip);86 assertNotNull(failureResponse);87 assertFalse(failureResponse.isSuccess());88 assertEquals(failureResponse.getCode(), 404);89 }90 91 @Test(dataProvider = "floatingIPs")92 public void removeFloatingIP(String ip) {93 String serverId = "255b83fd-1193-44a8-aba5-9887b347a41d" ;94 // Test remove floatingIP success95 respondWith(202);96 ActionResponse successResponse = osv3().compute().floatingIps().removeFloatingIP(serverId, ip);97 assertNotNull(successResponse);98 assertTrue(successResponse.isSuccess());99 // Test remove floatingIP fail -- Floating ip existed but not bind to server or server instance not existed100 String jsonResponse = String.format("{\"itemNotFound\": {"101 + "\"message\": \"Floating ip %s is not associated with instance %s.\", "102 + "\"code\": 409}}",103 ip, serverId);104 105 respondWith(409, jsonResponse);106 ActionResponse failureResponse = osv3().compute().floatingIps().removeFloatingIP(serverId, ip);107 assertNotNull(failureResponse);108 assertFalse(failureResponse.isSuccess());109 assertEquals(failureResponse.getCode(), 409);110 111 112 // Test remove floatingIP fail -- floatingIP not existed113 String jsonResponse2 = String.format("{\"itemNotFound\": {"114 + "\"message\": \"floating ip not found\", "115 + "\"code\": 404}}");116 respondWith(404, jsonResponse2);117 ActionResponse failureResponse2 = osv3().compute().floatingIps().removeFloatingIP(serverId, ip);118 assertNotNull(failureResponse2);119 assertFalse(failureResponse2.isSuccess());120 assertEquals(failureResponse2.getCode(), 404);121 }122 123 @Test(dataProvider = "floatingIPs")124 public void addFloatingIP( String ip) {125 String serverId = "255b83fd-1193-44a8-aba5-9887b347a41d" ;126 // Test add floatingIP success127 respondWith(202);128 ActionResponse successResponse = osv3().compute().floatingIps().addFloatingIP(serverId, ip);129 assertNotNull(successResponse);130 assertTrue(successResponse.isSuccess());131 132 // Test add floatingIP fail -- server instance not existed133 String jsonResponse = String.format("{\"itemNotFound\": {"134 + "\"message\": \"Instance %s could not be found.\", "135 + "\"code\": 404}}",136 serverId);137 respondWith(404, jsonResponse);138 ActionResponse failureResponse = osv3().compute().floatingIps().addFloatingIP(serverId, ip);139 assertNotNull(failureResponse);140 assertFalse(failureResponse.isSuccess());141 assertEquals(failureResponse.getCode(), 404);142 143 // Test add floatingIP fail -- floatingIP not existed144 String jsonResponse2 = String.format("{\"itemNotFound\": {"145 + "\"message\": \"floating ip not found\", "146 + "\"code\": 404}}");147 148 respondWith(404, jsonResponse2);149 ActionResponse failureResponse2 = osv3().compute().floatingIps().addFloatingIP(serverId, ip);150 assertNotNull(failureResponse2);151 assertFalse(failureResponse2.isSuccess());152 assertEquals(failureResponse2.getCode(), 404);153 }154}...

Full Screen

Full Screen

Source:NodeIdTest.java Github

copy

Full Screen

...21import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint;22import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort;23import static org.testng.Assert.assertEquals;24import static org.testng.Assert.assertFalse;25import static org.testng.Assert.assertNotNull;26import static org.testng.Assert.assertNull;27import static org.testng.Assert.assertThrows;28import static org.testng.Assert.assertTrue;29public class NodeIdTest {30 @Test31 public void testParseLargerThanIntMax() {32 long i = Integer.MAX_VALUE + 1L;33 NodeId nodeId = NodeId.parse("ns=1;i=" + i);34 assertNotNull(nodeId);35 assertEquals(nodeId.getIdentifier(), uint(i));36 }37 @Test38 public void testParseInvalid() {39 assertNull(NodeId.parseOrNull(""));40 assertNull(NodeId.parseOrNull("n"));41 assertNull(NodeId.parseOrNull("ns"));42 assertNull(NodeId.parseOrNull("ns="));43 assertNull(NodeId.parseOrNull("ns=0"));44 assertNull(NodeId.parseOrNull("ns=0;"));45 assertNull(NodeId.parseOrNull("ns=0;s"));46 }47 @Test48 public void testParseInvalidInt() {49 assertThrows(UaRuntimeException.class, () -> NodeId.parse("ns=0;i=" + UInteger.MAX_VALUE + 1));50 assertThrows(UaRuntimeException.class, () -> NodeId.parse("ns=0;i=" + -1));51 }52 @Test53 public void testParseNamespaceIndex() {54 for (int i = 0; i < UShort.MAX_VALUE; i++) {55 NodeId nodeId = NodeId.parseOrNull("ns=" + i + ";i=" + i);56 assertNotNull(nodeId);57 assertEquals(nodeId.getNamespaceIndex(), ushort(i));58 assertEquals(nodeId.getIdentifier(), uint(i));59 }60 }61 @Test62 public void testParseInt() {63 long[] is = new long[]{0, UByte.MAX_VALUE, UShort.MAX_VALUE, UInteger.MAX_VALUE};64 for (long i : is) {65 assertNotNull(NodeId.parseOrNull("i=" + i));66 assertNotNull(NodeId.parseOrNull("ns=0;i=" + i));67 }68 }69 @Test70 public void testParseString() {71 assertNotNull(NodeId.parseOrNull("s="));72 assertNotNull(NodeId.parseOrNull("s=foo"));73 assertNotNull(NodeId.parseOrNull("ns=0;s="));74 assertNotNull(NodeId.parseOrNull("ns=0;s=foo"));75 }76 @Test77 public void testParseGuid() {78 for (int i = 0; i < 100; i++) {79 UUID uuid = UUID.randomUUID();80 {81 NodeId nodeId = NodeId.parseOrNull("g=" + uuid.toString());82 assertNotNull(nodeId);83 assertEquals(nodeId.getIdentifier(), uuid);84 }85 {86 NodeId nodeId = NodeId.parseOrNull("ns=0;g=" + uuid.toString());87 assertNotNull(nodeId);88 assertEquals(nodeId.getIdentifier(), uuid);89 }90 }91 }92 @Test93 public void testParseByteString() {94 Random r = new Random();95 for (int i = 0; i < 100; i++) {96 byte[] bs = new byte[r.nextInt(64) + 1];97 r.nextBytes(bs);98 String bss = DatatypeConverter.printBase64Binary(bs);99 {100 NodeId nodeId = NodeId.parseOrNull("b=" + bss);101 assertNotNull(nodeId);102 assertEquals(nodeId.getIdentifier(), ByteString.of(bs));103 }104 {105 NodeId nodeId = NodeId.parseOrNull("ns=0;b=" + bss);106 assertNotNull(nodeId);107 assertEquals(nodeId.getIdentifier(), ByteString.of(bs));108 }109 }110 }111 @Test112 public void testEqualityWithExpandedNodeId() {113 NodeId nodeId = new NodeId(0, "foo");114 {115 ExpandedNodeId xni = nodeId.expanded();116 assertTrue(nodeId.equalTo(xni));117 }118 {119 ExpandedNodeId xni = new ExpandedNodeId(ushort(0), Namespaces.OPC_UA, "foo");120 assertTrue(nodeId.equalTo(xni));121 }122 {123 ExpandedNodeId xni = new ExpandedNodeId(ushort(1), Namespaces.OPC_UA, "foo");124 assertTrue(nodeId.equalTo(xni));125 }126 {127 ExpandedNodeId xni = new ExpandedNodeId(ushort(0), Namespaces.OPC_UA, "foo", uint(1));128 assertFalse(nodeId.equalTo(xni));129 }130 {131 ExpandedNodeId xni = new ExpandedNodeId(ushort(0), "uri:foo:bar", "foo");132 assertFalse(nodeId.equalTo(xni));133 }134 }135 @Test136 public void testStringWithNewlineCharacters() {137 NodeId nodeId1 = NodeId.parse("s=foo\nbar\nbaz");138 assertNotNull(nodeId1);139 assertNotNull(NodeId.parse(nodeId1.toParseableString()));140 NodeId nodeId2 = NodeId.parse("ns=2;s=foo\n\bar\nbaz");141 assertNotNull(nodeId2);142 assertNotNull(NodeId.parse(nodeId2.toParseableString()));143 }144 @Test145 public void testExpandedWithNamespaceTable() {146 NamespaceTable namespaceTable = new NamespaceTable();147 namespaceTable.addUri("urn:test");148 NodeId nodeId = new NodeId(1, "foo");149 ExpandedNodeId xni = nodeId.expanded(namespaceTable);150 assertEquals(xni.getNamespaceUri(), "urn:test");151 }152}...

Full Screen

Full Screen

Source:RegistrationRepositoryBeanTest.java Github

copy

Full Screen

...19package be.fedict.eid.pkira.blm.model.usermgmt;2021import static org.testng.Assert.assertEquals;22import static org.testng.Assert.assertFalse;23import static org.testng.Assert.assertNotNull;24import static org.testng.Assert.assertSame;25import static org.testng.Assert.assertTrue;26import static org.testng.Assert.fail;2728import java.util.Collection;29import java.util.List;3031import javax.persistence.PersistenceException;3233import org.testng.annotations.BeforeClass;34import org.testng.annotations.Test;3536import be.fedict.eid.pkira.blm.model.DatabaseTest;37import be.fedict.eid.pkira.blm.model.certificatedomain.CertificateDomain;3839/**40 * @author Bram Baeyens41 */42public class RegistrationRepositoryBeanTest extends DatabaseTest {4344 private static final String EMAIL = "rAbc@de.fg";45 private static final String EMAIL_2 = "rAbc@de.fg2";46 47 private RegistrationRepositoryBean registrationRepository;48 private Registration valid;49 private User requester;50 public CertificateDomain certificateDomain;5152 @BeforeClass(dependsOnGroups = "CertificateDomainRepository")53 public void setup() {54 registrationRepository = new RegistrationRepositoryBean();55 registrationRepository.setEntityManager(getEntityManager());5657 requester = loadObject(User.class, TEST_USER_ID);58 certificateDomain = loadObject(CertificateDomain.class, TEST_CERTIFICATE_DOMAIN_ID);59 } 6061 @Test62 public void persist() throws Exception {63 valid = createRegistration(EMAIL, certificateDomain, requester);64 registrationRepository.persist(valid);65 forceCommit();66 assertNotNull(valid.getId()); 67 }68 69 @Test(dependsOnMethods="persist")70 public void testGetRegistrations() {71 User requester2 = getEntityManager().getReference(User.class, requester.getId());72 Collection<Registration> registrations = requester2.getRegistrations();73 assertNotNull(registrations);74 assertEquals(3, registrations.size());75 }7677 @Test(dependsOnMethods = "persist", expectedExceptions = PersistenceException.class)78 public void userCertificateDomainConstraint() throws Exception {79 Registration registration = createRegistration(EMAIL_2, certificateDomain, requester);80 registrationRepository.persist(registration);81 fail("PersistenceException expected.");82 }8384 @Test(dependsOnMethods = "persist")85 public void reject() throws Exception {86 registrationRepository.setDisapproved(valid);87 assertFalse(getEntityManager().contains(valid));88 }8990 @Test(dependsOnMethods = "persist")91 public void confirm() throws Exception {92 registrationRepository.setApproved(valid);93 assertSame(RegistrationStatus.APPROVED, valid.getStatus());94 }9596 @Test(dependsOnMethods = "persist")97 public void findAllNewRegistrations() throws Exception {98 List<Registration> newRegistrations = registrationRepository.findAllNewRegistrations();99 assertTrue(newRegistrations.size() >= 1);100 }101102 @Test(dependsOnMethods = "persist")103 public void findRegistration() throws Exception {104 Registration registration = registrationRepository.findRegistration(certificateDomain, requester);105 assertNotNull(registration);106 }107 108 @Test(dependsOnMethods="persist")109 public void getNumberOfRegistrationsForForUserInStatus() {110 assertTrue(registrationRepository.getNumberOfRegistrationsForForUserInStatus(requester, RegistrationStatus.NEW)>0);111 }112 113 @Test114 public void findApprovedRegistrationsByUser() {115 List<Registration> registrations = registrationRepository.findApprovedRegistrationsByUser(requester);116 117 assertNotNull(registrations);118 assertTrue(registrations.size()==1);119 120 }121122 private Registration createRegistration(String email, CertificateDomain certificateDomain, User requester) {123 Registration registration = new Registration();124 registration.setStatus(RegistrationStatus.NEW);125 registration.setEmail(email);126 registration.setCertificateDomain(certificateDomain);127 registration.setRequester(requester);128 return registration;129 }130}

Full Screen

Full Screen

Source:SimpleTreeTest.java Github

copy

Full Screen

1package org.molgenis.util;2import static org.testng.AssertJUnit.assertEquals;3import static org.testng.AssertJUnit.assertFalse;4import static org.testng.AssertJUnit.assertNotNull;5import static org.testng.AssertJUnit.assertNull;6import static org.testng.AssertJUnit.assertTrue;7import static org.testng.AssertJUnit.fail;8import org.testng.annotations.Test;9public class SimpleTreeTest10{11 @Test12 public void testCreate()13 {14 String name = "test";15 TestTree tree = new TestTree(name, null);16 assertEquals(name, tree.getName());17 assertFalse(tree.hasChildren());18 assertNotNull(tree.getChildren());19 assertTrue(tree.getChildren().isEmpty());20 assertNull(tree.getParent());21 assertEquals(tree, tree.getRoot());22 assertNotNull(tree.getAllChildren());23 assertTrue(tree.getAllChildren().isEmpty());24 assertNotNull(tree.getAllChildren(true));25 assertEquals(1, tree.getAllChildren(true).size());26 assertEquals(tree, tree.getAllChildren(true).get(0));27 assertNull(tree.getChild("xxx"));28 assertNull(tree.getChild(name));29 assertNull(tree.get("xxx"));30 assertNotNull(tree.get(name));31 assertEquals(tree, tree.get(name));32 assertNull(tree.getValue());33 assertNotNull(tree.getPath(","));34 assertEquals(name, tree.getPath(","));35 }36 @Test37 public void testCreateWithParent()38 {39 TestTree parent = new TestTree("parent", null);40 TestTree child = new TestTree("child", parent);41 assertTrue(parent.hasChildren());42 assertEquals(1, parent.getAllChildren().size());43 assertEquals(child, parent.getAllChildren().get(0));44 assertNotNull(child.getParent());45 assertEquals(child.getParent(), parent);46 assertEquals("parent,child", child.getPath(","));47 assertNotNull(child.getRoot());48 assertEquals(parent, child.getRoot());49 }50 @Test51 public void testSetParent()52 {53 TestTree parent = new TestTree("parent", null);54 TestTree child = new TestTree("child", null);55 child.setParent(parent);56 assertTrue(parent.hasChildren());57 assertEquals(1, parent.getAllChildren().size());58 assertEquals(child, parent.getAllChildren().get(0));59 assertNotNull(child.getParent());60 assertEquals(child.getParent(), parent);61 assertEquals("parent,child", child.getPath(","));62 assertNotNull(child.getRoot());63 assertEquals(parent, child.getRoot());64 TestTree duplicate = new TestTree("child", null);65 try66 {67 duplicate.setParent(parent);68 fail("Should have thrown IllegalArgumentException");69 }70 catch (IllegalArgumentException e)71 {72 // Expected73 }74 }75 @Test76 public void testGetChild()77 {78 TestTree parent = new TestTree("test", null);79 TestTree child1 = new TestTree("child1", parent);80 TestTree child2 = new TestTree("child2", parent);81 assertEquals(child1, parent.getChild("child1"));82 assertEquals(child2, parent.getChild("child2"));83 }84 @Test85 public void testSetValue()86 {87 String parentValue = "parentValue";88 String childValue = "childValue";89 TestTree parent = new TestTree("parent", null);90 parent.setValue(parentValue);91 TestTree child = new TestTree("child", null);92 child.setValue(childValue);93 child.setParent(parent);94 assertNotNull(parent.getValue());95 assertNotNull(parentValue, parent.getValue());96 assertNotNull(child.getValue());97 assertNotNull(childValue, child.getValue());98 }99 @Test100 public void testRemove()101 {102 TestTree parent = new TestTree("test", null);103 TestTree child1 = new TestTree("child1", parent);104 TestTree child2 = new TestTree("child2", parent);105 assertNotNull(parent.getAllChildren());106 assertEquals(2, parent.getAllChildren().size());107 child1.remove();108 assertNotNull(parent.getAllChildren());109 assertEquals(1, parent.getAllChildren().size());110 assertEquals(child2, parent.getAllChildren().get(0));111 assertNull(parent.getChild("child1"));112 }113 private static class TestTree extends SimpleTree<TestTree>114 {115 private static final long serialVersionUID = 2697117779184102294L;116 public TestTree(String name, TestTree parent)117 {118 super(name, parent);119 }120 }121}...

Full Screen

Full Screen

Source:GlanceIntegrationTest.java Github

copy

Full Screen

1package org.openstack.client.images;2import static org.testng.Assert.assertEquals;3import static org.testng.Assert.assertNotNull;4import static org.testng.Assert.assertNull;5import java.io.ByteArrayInputStream;6import java.io.InputStream;7import org.openstack.api.images.ImagesResource;8import org.openstack.client.AbstractOpenStackTest;9import org.openstack.model.images.Image;10import org.openstack.model.images.ImageList;11import org.openstack.model.images.glance.GlanceImage;12import org.testng.Assert;13import org.testng.SkipException;14import org.testng.annotations.BeforeClass;15import org.testng.annotations.Test;16public class GlanceIntegrationTest extends AbstractOpenStackTest {17 18 private ImagesResource images;19 20 private Image uploaded;21 22 @BeforeClass23 public void init() {24 if (!glanceEnabled) {25 init("etc/openstack.public.properties");26 images = client.getImagesEndpoint(); 27 } else {28 throw new SkipException("Skipping because glance not present / accessible");29 }30 31 }32 33 @Test34 public void createImage() {35 try {36 Image image = new GlanceImage();37 image.setName(random.randomAlphanumericString(1, 16).trim());38 image.setDiskFormat("raw");39 image.setContainerFormat("bare");40 41 int size = 1024;42 InputStream is = new ByteArrayInputStream(new byte[size]);43 44 uploaded = images.post(is, size, image);45 assertEquals(uploaded.getSize(), Long.valueOf(size));46 assertEquals(uploaded.getName(), image.getName());47 assertNull(uploaded.getDeletedAt());48 assertNotNull(uploaded.getCreatedAt());49 assertNotNull(uploaded.getUpdatedAt());50 assertNotNull(uploaded.getId());51 assertEquals(uploaded.isDeleted(), Boolean.FALSE);52 assertEquals(uploaded.getDiskFormat(), image.getDiskFormat());53 assertEquals(uploaded.getContainerFormat(), image.getContainerFormat());54 assertNotNull(uploaded.getOwner());55 assertEquals(uploaded.getStatus(), "active"); 56 } catch(Exception e) {57 throw new RuntimeException(e.getMessage(), e);58 }59 }60 61 @Test(priority=1)62 public void listImages() {63 ImageList list = images.get();64 Assert.assertNotNull(list);65 }66 67 68 @Test(dependsOnMethods="createImage", priority=2)69 public void showImage() {70 Image image = images.image(uploaded.getId()).head();71 assertImageEquals(image, uploaded);72 }73 74 public void updateImage() {75 76 }77 78 @Test(dependsOnMethods="createImage", priority=3)...

Full Screen

Full Screen

Source:EjemplitoTest.java Github

copy

Full Screen

...48 public void f(Integer n, String s) {49 }50 @Test51 public void multiplicaPorCinco() {52 Assert.assertNotNull(Ejemplito.multiplicaPorCinco(DATA_TEST));53 Assert.assertEquals(Ejemplito.multiplicaPorCinco(DATA_TEST), DATA_TEST*5);54 }55 @Test56 public void multiplicaPorCuatro() {57 Assert.assertNotNull(Ejemplito.multiplicaPorCuatro(DATA_TEST));58 Assert.assertEquals(Ejemplito.multiplicaPorCuatro(DATA_TEST), DATA_TEST*4);59 }60 @Test61 public void multiplicaPorDos() {62 Assert.assertNotNull(Ejemplito.multiplicaPorDos(DATA_TEST));63 Assert.assertEquals(Ejemplito.multiplicaPorDos(DATA_TEST), DATA_TEST*2);64 }65/* @Test(dependsOnMethods={"multiplicaPorDos"})66 @Parameters({"param_test"})67 public void multiplicaPorNueve(int paramTest) {68 Assert.assertNotNull(Ejemplito.multiplicaPorNueve(paramTest));69 Assert.assertEquals(Ejemplito.multiplicaPorNueve(paramTest), paramTest*9);70 }*/71 @Test(dependsOnMethods={"multiplicaPorDos"})72 public void multiplicaPorNueve() {73 Assert.assertNotNull(Ejemplito.multiplicaPorNueve(DATA_TEST));74 Assert.assertEquals(Ejemplito.multiplicaPorNueve(DATA_TEST), DATA_TEST*9);75 }76 //ejecuta el test para tantos elementos como tenga el dataProvider. Soporta Map77 @Test(dataProvider = "provideNumbers")78 public void testProvideData(int number, int expected) {79 Assert.assertEquals(number + 10, expected);80 }81 @DataProvider(name = "provideNumbers")82 public Object[][] provideData() {83 return new Object[][] { 84 { 10, 20 }, 85 { 100, 110 }, 86 { 200, 210 } 87 };...

Full Screen

Full Screen

Source:HerramientaRegistradorTest.java Github

copy

Full Screen

...24 }2526 @org.testng.annotations.Test27 public void testBuscarPacientePorNombre1() {28 assertNotNull(h.buscarPacientePorNombre("legalo"));29 }3031 @org.testng.annotations.Test32 public void testBuscarPacientePorNombre2() {33 assertNotNull(h.buscarPacientePorNombre("nomnbre"));3435 }3637 @org.testng.annotations.Test38 public void testBuscarPacientePorNombre3() {39 assertNotNull(h.buscarPacientePorNombre("nombre2"));4041 }4243 @org.testng.annotations.Test44 public void testBuscarPacientePorNombre4() {45 assertNull(h.buscarPacientePorNombre("paciente"));4647 }48 @org.testng.annotations.Test49 public void testBuscarPacientePorRut1() {50 assertNotNull(h.buscarPacientePorRut(new Rut("152361084")));51 }5253 @org.testng.annotations.Test54 public void testBuscarPacientePorRut2() {55 assertNotNull(h.buscarPacientePorRut(new Rut("188772129")));5657 }5859 @org.testng.annotations.Test60 public void testBuscarPacientePorRut3() {61 assertNotNull(h.buscarPacientePorRut(new Rut("171261805")));6263 }6465 @org.testng.annotations.Test66 public void testBuscarPacientePorRut4() {67 assertNull(h.buscarPacientePorRut(new Rut("67807081")));6869 }7071} ...

Full Screen

Full Screen

assertNotNull

Using AI Code Generation

copy

Full Screen

1import org.testng.Assert;2public class TestNGExample {3 public void testAssertNotNull(){4 String str1 = "TestNG is working fine";5 String str2 = null;6 Assert.assertNotNull(str1);7 Assert.assertNotNull(str2);8 }9}10import org.testng.Assert;11public class TestNGExample {12 public void testAssertEquals(){13 String str1 = "TestNG is working fine";14 String str2 = "TestNG is working fine";15 Assert.assertEquals(str1, str2);16 }17}18import org.testng.Assert;19public class TestNGExample {20 public void testAssertTrue(){21 boolean condition = true;22 Assert.assertTrue(condition);23 }24}25import org.testng.Assert;26public class TestNGExample {27 public void testAssertFalse(){28 boolean condition = false;29 Assert.assertFalse(condition);30 }31}32import org.testng.Assert;33public class TestNGExample {34 public void testAssertSame(){35 String str1 = "TestNG is working fine";36 String str2 = "TestNG is working fine";37 Assert.assertSame(str1, str2);38 }39}40import org.testng.Assert;41public class TestNGExample {42 public void testAssertNotSame(){43 String str1 = "TestNG is working fine";44 String str2 = "TestNG is working fine";45 Assert.assertNotSame(str1, str2);46 }47}48import org.testng.Assert;49public class TestNGExample {50 public void testAssertArrayEquals(){51 String[] expectedArray = {"one", "two", "three"};52 String[] resultArray = {"one", "two", "three"};53 Assert.assertArrayEquals(expectedArray, resultArray);54 }55}56import org.testng.Assert;57public class TestNGExample {58 public void testAssertThrows(){59 Assert.assertThrows(60 () -> {

Full Screen

Full Screen

assertNotNull

Using AI Code Generation

copy

Full Screen

1public void testAssertNotNull() {2 String str1 = "TestNG is working fine";3 String str2 = null;4 assertNotNull(str1);5 assertNotNull(str2);6}7public void testAssertTrue() {8 String str1 = "TestNG is working fine";9 String str2 = null;10 assertTrue(str1 != null);11 assertTrue(str2 == null);12}13public void testAssertEquals() {14 String str1 = "TestNG is working fine";15 String str2 = "TestNG is working fine";16 String str3 = null;17 String str4 = null;18 assertEquals(str1, str2);19 assertEquals(str3, str4);20}21public void testAssertNotEquals() {22 String str1 = "TestNG is working fine";23 String str2 = "TestNG is working fine";24 String str3 = null;25 String str4 = null;26 assertNotEquals(str1, str3);27 assertNotEquals(str2, str4);28}29public void testAssertSame() {30 String str1 = "TestNG is working fine";31 String str2 = "TestNG is working fine";32 String str3 = null;33 String str4 = null;34 assertSame(str1, str2);35 assertSame(str3, str4);36}37public void testAssertNotSame() {38 String str1 = "TestNG is working fine";39 String str2 = "TestNG is working fine";40 String str3 = null;41 String str4 = null;42 assertNotSame(str1, str3);43 assertNotSame(str2, str4);44}45public void testAssertNull()

Full Screen

Full Screen

assertNotNull

Using AI Code Generation

copy

Full Screen

1import org.testng.Assert;2import org.testng.annotations.Test;3public class TestNGTest {4 public void test() {5 Object obj = null;6 Assert.assertNotNull(obj);7 }8}9package com.javabydeveloper.lombok.nullcheck;10import org.testng.Assert;11import org.testng.annotations.Test;12public class TestNGTest {13 public void test() {14 Object obj = null;15 Assert.assertNull(obj);16 }17}18 at org.testng.Assert.fail(Assert.java:94)19 at org.testng.Assert.failNotNull(Assert.java:513)20 at org.testng.Assert.assertNull(Assert.java:499)21 at org.testng.Assert.assertNull(Assert.java:479)22 at com.javabydeveloper.lombok.nullcheck.TestNGTest.test(TestNGTest.java:14)23package com.javabydeveloper.lombok.nullcheck;24import org.testng.Assert;25import org.testng.annotations.Test;26public class TestNGTest {27 public void test() {28 Assert.assertThrows(NullPointerException.class, () -> {29 throw new NullPointerException();30 });31 }32}33package com.javabydeveloper.lombok.nullcheck;34import org.testng.Assert;35import org.testng.annotations.Test;36public class TestNGTest {37 public void test() {38 Assert.assertThrows(NullPointerException.class, IndexOutOfBoundsException.class, () -> {39 throw new IndexOutOfBoundsException();40 });41 }42}43package com.javabydeveloper.lombok.nullcheck;44import org.testng.Assert;45import org.testng.annotations.Test;46public class TestNGTest {47 public void test() {48 Assert.assertThrows(NullPointerException.class, IndexOutOfBoundsException.class

Full Screen

Full Screen

assertNotNull

Using AI Code Generation

copy

Full Screen

1public void testAssertNotNull() {2 String str1 = "test";3 String str2 = null;4 Assert.assertNotNull(str1);5 Assert.assertNotNull(str2);6}7public void testAssertTrue() {8 boolean condition = true;9 Assert.assertTrue(condition);10}11public void testAssertFalse() {12 boolean condition = false;13 Assert.assertFalse(condition);14}15public void testAssertEquals() {16 String str1 = "test";17 String str2 = "test";18 Assert.assertEquals(str1, str2);19}20public void testAssertNotEquals() {21 String str1 = "test";22 String str2 = "test1";23 Assert.assertNotEquals(str1, str2);24}25public void testAssertSame() {26 String str1 = "test";27 String str2 = "test";28 Assert.assertSame(str1, str2);29}30public void testAssertNotSame() {31 String str1 = "test";32 String str2 = new String("test");33 Assert.assertNotSame(str1, str2);34}

Full Screen

Full Screen

TestNG tutorial

TestNG is a Java-based open-source framework for test automation that includes various test types, such as unit testing, functional testing, E2E testing, etc. TestNG is in many ways similar to JUnit and NUnit. But in contrast to its competitors, its extensive features make it a lot more reliable framework. One of the major reasons for its popularity is its ability to structure tests and improve the scripts' readability and maintainability. Another reason can be the important characteristics like the convenience of using multiple annotations, reliance, and priority that make this framework popular among developers and testers for test design. You can refer to the TestNG tutorial to learn why you should choose the TestNG framework.

Chapters

  1. JUnit 5 vs. TestNG: Compare and explore the core differences between JUnit 5 and TestNG from the Selenium WebDriver viewpoint.
  2. Installing TestNG in Eclipse: Start installing the TestNG Plugin and learn how to set up TestNG in Eclipse to begin constructing a framework for your test project.
  3. Create TestNG Project in Eclipse: Get started with creating a TestNG project and write your first TestNG test script.
  4. Automation using TestNG: Dive into how to install TestNG in this Selenium TestNG tutorial, the fundamentals of developing an automation script for Selenium automation testing.
  5. Parallel Test Execution in TestNG: Here are some essential elements of parallel testing with TestNG in this Selenium TestNG tutorial.
  6. Creating TestNG XML File: Here is a step-by-step tutorial on creating a TestNG XML file to learn why and how it is created and discover how to run the TestNG XML file being executed in parallel.
  7. Automation with Selenium, Cucumber & TestNG: Explore for an in-depth tutorial on automation using Selenium, Cucumber, and TestNG, as TestNG offers simpler settings and more features.
  8. JUnit Selenium Tests using TestNG: Start running your regular and parallel tests by looking at how to run test cases in Selenium using JUnit and TestNG without having to rewrite the tests.
  9. Group Test Cases in TestNG: Along with the explanation and demonstration using relevant TestNG group examples, learn how to group test cases in TestNG.
  10. Prioritizing Tests in TestNG: Get started with how to prioritize test cases in TestNG for Selenium automation testing.
  11. Assertions in TestNG: Examine what TestNG assertions are, the various types of TestNG assertions, and situations that relate to Selenium automated testing.
  12. DataProviders in TestNG: Deep dive into learning more about TestNG's DataProvider and how to effectively use it in our test scripts for Selenium test automation.
  13. Parameterization in TestNG: Here are the several parameterization strategies used in TestNG tests and how to apply them in Selenium automation scripts.
  14. TestNG Listeners in Selenium WebDriver: Understand the various TestNG listeners to utilize them effectively for your next plan when working with TestNG and Selenium automation.
  15. TestNG Annotations: Learn more about the execution order and annotation attributes, and refer to the prerequisites required to set up TestNG.
  16. TestNG Reporter Log in Selenium: Find out how to use the TestNG Reporter Log and learn how to eliminate the need for external software with TestNG Reporter Class to boost productivity.
  17. TestNG Reports in Jenkins: Discover how to generate TestNG reports in Jenkins if you want to know how to create, install, and share TestNG reports in Jenkins.

Certification

You can push your abilities to do automated testing using TestNG and advance your career by earning a TestNG certification. Check out our TestNG certification.

YouTube

Watch this complete tutorial to learn how you can leverage the capabilities of the TestNG framework for Selenium automation testing.

Run Testng automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful