@Test public void testComplex() throws Exception { testedTable.put("testkey", "testvalue"); Assert.assertEquals(testedTable.get("testkey"), "testvalue"); testedTable.put("testkey", "testvalue2"); Assert.assertEquals(testedTable.remove("testkey"), "testvalue2"); Assert.assertNull(testedTable.get("abcd")); Assert.assertNull(testedTable.remove("abcd")); }
@Test public void testJoin9() { Stamp bExact = StampFactory.exact(getType(B.class)); Stamp dExact = StampFactory.exact(getType(D.class)); Stamp join = join(bExact, dExact); Assert.assertTrue(StampTool.isPointerAlwaysNull(join)); Assert.assertNull(StampTool.typeOrNull(join)); Assert.assertNull(StampTool.typeOrNull(join)); }
public void testToArray() { StripedObjectIDSet stripedObjectIdSet = new StripedObjectIDSet(16); for (int i = 0; i < 100; i++) { Assert.assertTrue(stripedObjectIdSet.add(new ObjectID(i))); } ObjectID[] o1 = new ObjectID[] {}; o1 = stripedObjectIdSet.toArray(o1); Assert.assertEquals(100, o1.length); long prev = -1; for (int i = 0; i < 100; i++) { Assert.assertTrue(o1[i].toLong() > prev); prev = o1[i].toLong(); } o1 = new ObjectID[101]; o1 = stripedObjectIdSet.toArray(o1); Assert.assertEquals(101, o1.length); prev = -1; for (int i = 0; i < 100; i++) { Assert.assertTrue(o1[i].toLong() > prev); prev = o1[i].toLong(); } Assert.assertNull(o1[100]); }
@Test public void testDivideByZero() { a = 20; b = 0; Integer result = calculator.divide(a, b); Assert.assertNull(result); }
/* I Tried to make a test to prove that a SingletonDBConnection instance can not be created by calling the constructor directly, because it's private. The problem is that the class won't compile if it tries to call the constructor SingletonDBConnection(), so I skipped the test */ @Ignore("Couldn't figure out how to make it work yet") @Test public void singletonCreatesObjectOnlyThrough_getInstance() { SingletonDBConnection testSingle4 = null; // testSingle4 = new SingletonDBConnection(); Assert.assertNull("Should be NULL", testSingle4); }
@Test public void testRollback() throws Exception { testedTable.put("abc1", "1"); testedTable.remove("abc1"); testedTable.put("abc1", "2"); Assert.assertEquals(testedTable.rollback(), 1); Assert.assertNull(testedTable.get("abc1")); }
public void assertNull(Object p) { try { Assert.assertNull(p); } catch (Error e) { lastTestFailed = true; throw e; } }
@Test public void testJoin5() { Stamp dExact = StampFactory.exact(getType(D.class)); Stamp c = StampFactory.declared(getType(C.class)); Stamp join = join(c, dExact); Assert.assertTrue(StampTool.isPointerAlwaysNull(join)); Assert.assertNull(StampTool.typeOrNull(join)); Assert.assertFalse(StampTool.isExactType(join)); }
@Test public void testJoin7() { Stamp aExact = StampFactory.exact(getType(A.class)); Stamp e = StampFactory.declared(getType(E.class)); Stamp join = join(aExact, e); Assert.assertTrue(StampTool.isPointerAlwaysNull(join)); Assert.assertNull(StampTool.typeOrNull(join)); Assert.assertFalse(StampTool.isExactType(join)); }
@Test public void testCommit() throws Exception { testedTable.put("abcd1", "1"); testedTable.put("abcd2", "2"); Assert.assertEquals(testedTable.commit(), 2); Assert.assertEquals(testedTable.get("abcd1"), "1"); testedTable.remove("abcd1"); testedTable.remove("abcd2"); Assert.assertEquals(testedTable.commit(), 2); Assert.assertNull(testedTable.get("abcd2")); }
@Test public void testBuscarPorLetras() { Local local = new Local("Administrador"); Integer idlocal = localDao.insertar(local); Sala sala = new Sala("Premium", "Miraflores", 50, "Moderna", idlocal); Integer idsala = salaDao.insertar(sala); ArmadoSala armadosala = new ArmadoSala(idsala, 12); Integer id = armadosalaDao.insertar(armadosala); armadosala = armadosalaDao.buscar(-8); Assert.assertNull(armadosala); }
@Ignore @Test public void testNullEmitting() throws Exception { // FIXME this is no longer allowed NbpObservable<Boolean> nullNbpObservable = NbpBehaviorSubject.createDefault((Boolean) null); NbpObservable<Boolean> nonNullNbpObservable = NbpBehaviorSubject.createDefault(true); NbpObservable<Boolean> combined = combineLatest( nullNbpObservable, nonNullNbpObservable, new BiFunction<Boolean, Boolean, Boolean>() { @Override public Boolean apply(Boolean bool1, Boolean bool2) { return bool1 == null ? null : bool2; } }); combined.subscribe(aBoolean -> Assert.assertNull(aBoolean)); }
@Test public void testUser() { newEnv .getAccountDao() .persistUser( new BasicUser( "joachimhs", "Account name", "Admin", null, null, null, null, null, null)); newEnv .getAccountDao() .persistUser( new BasicUser( "joachimhs", "Account name Two", "Admin", null, null, null, null, null, null)); newEnv .getAccountDao() .persistUser( new BasicUser( "brandnewuser", "Account name", "Admin", null, null, null, null, null, null)); User userOne = newEnv.getAccountDao().getUser("joachimhs", "Account Name"); User userTwo = newEnv.getAccountDao().getUser("joachimhs", "Account Name Two"); User userThree = newEnv.getAccountDao().getUser("brandnewuser", "Account Name"); User userNull = newEnv.getAccountDao().getUser("brandnewuser", "Account Name Two"); Assert.assertNotNull(userOne); Assert.assertEquals("joachimhs", userOne.getUserName()); Assert.assertEquals("Account Name", userOne.getAccountName()); Assert.assertEquals("Admin", userOne.getUserRole()); Assert.assertNotNull(userTwo); Assert.assertEquals("joachimhs", userTwo.getUserName()); Assert.assertEquals("Account Name Two", userTwo.getAccountName()); Assert.assertEquals("Admin", userTwo.getUserRole()); Assert.assertNotNull(userThree); Assert.assertEquals("brandnewuser", userThree.getUserName()); Assert.assertEquals("Account Name", userThree.getAccountName()); Assert.assertEquals("User", userThree.getUserRole()); Assert.assertNull(userNull); }
@Test public void testEmailGroup() throws InterruptedException { newEnv .getSmtpDao() .persistEmailRecipientGroup( new BasicEmailRecipientGroup( "Email Group Name", "Account Name", "localhost", "username", "password", true, 579, Arrays.asList("*****@*****.**", "*****@*****.**"))); EmailRecipientGroup emailGroupOne = newEnv.getSmtpDao().getEmailRecipientGroup("Email Group Name", "Account Name"); Assert.assertNotNull(emailGroupOne); Assert.assertEquals("Email Group Name", emailGroupOne.getEmailRecipientGroupName()); Assert.assertEquals("Account Name", emailGroupOne.getAccountName()); Assert.assertEquals("localhost", emailGroupOne.getSmtpServerhost()); Assert.assertEquals("username", emailGroupOne.getSmtpUsername()); Assert.assertEquals("password", emailGroupOne.getSmtpPassword()); Assert.assertTrue(emailGroupOne.isUseSSL()); Assert.assertEquals(new Integer(579), emailGroupOne.getPort()); Assert.assertNotNull(emailGroupOne.getEmailRecipientList()); Assert.assertEquals(2, emailGroupOne.getEmailRecipientList().size()); Assert.assertEquals("*****@*****.**", emailGroupOne.getEmailRecipientList().get(0)); Assert.assertEquals("*****@*****.**", emailGroupOne.getEmailRecipientList().get(1)); // newEnv.getSmtpDao().deleteEmailRecipientGroup(emailGroupOne); newEnv.getSmtpDao().deleteEmailRecipientGroup("Email Group Name", "Account Name"); Thread.sleep(550); EmailRecipientGroup deletedGroup = newEnv.getSmtpDao().getEmailRecipientGroup("Email Group Name", "Account Name"); Assert.assertNull(deletedGroup); }
@Test public void testTreeMenu() throws InterruptedException { newEnv .getTreeMenuDao() .persistTreeMenu( new BasicStatistics("EurekaJAgent:Memory:Heap:Used %", "Account Name", "Y")); Statistics statOne = newEnv.getTreeMenuDao().getTreeMenu("EurekaJAgent:Memory:Heap:Used %", "Account Name"); Assert.assertNotNull(statOne); Assert.assertEquals("EurekaJAgent:Memory:Heap:Used %", statOne.getGuiPath()); Assert.assertEquals("Account Name", statOne.getAccountName()); Assert.assertEquals("Y", statOne.getNodeLive()); newEnv.getTreeMenuDao().deleteTreeMenu("EurekaJAgent:Memory:Heap:Used %", "Account Name"); Thread.sleep(550); Statistics deletedStatOne = newEnv.getTreeMenuDao().getTreeMenu("EurekaJAgent:Memory:Heap:Used %", "Account Name"); Assert.assertNull(deletedStatOne); }
@Test public void testSquareRootWithNegativeNumber() { a = -26665; Double result = calculator.squareRoot(a); Assert.assertNull(result); }
@Test public void store_get_delete() throws Exception { JdbcContentPersistenceService tested = getTested(); // case - get from noexisting table Assert.assertNull(tested.get("a-1", "tt")); String sysContentType = "testtype_1"; Map<String, Object> content = null; // case - store into nonexisting table, nonexisting id tested.store("aaa-1", sysContentType, content); assertRowCount(tested, sysContentType, 1); Assert.assertNull(tested.get("aaa-1", sysContentType)); // case - get nonexisting id from existing table Assert.assertNull(tested.get("a-1", sysContentType)); // case - test persistence after commit assertRowCount(tested, sysContentType, 1); Assert.assertNull(tested.get("aaa-1", sysContentType)); // case - store into existing table, nonexisting id content = new HashMap<String, Object>(); content.put("testkey", "testvalue"); tested.store("aaa-2", sysContentType, content); assertRowCount(tested, sysContentType, 2); Assert.assertNull(tested.get("aaa-1", sysContentType)); TestUtils.assertJsonContent( "{\"testkey\" : \"testvalue\"}", tested.get("aaa-2", sysContentType)); // case - store into existing table, existing id so update, sys_updated is Date instance content.put(ContentObjectFields.SYS_UPDATED, new Date(65463749865l)); tested.store("aaa-1", sysContentType, content); assertRowCount(tested, sysContentType, 2); TestUtils.assertJsonContent( "{\"testkey\" : \"testvalue\", \"sys_updated\":\"1972-01-28T16:22:29.865Z\"}", tested.get("aaa-1", sysContentType)); assertTableContent( tested, sysContentType, "aaa-1", SearchUtils.getISODateFormat().parse("1972-01-28T16:22:29.865+0000")); // case - store into existing table, existing id so update, sys_updated is ISO String instance content.put(ContentObjectFields.SYS_UPDATED, "1973-01-28T17:22:29.865+0100"); tested.store("aaa-2", sysContentType, content); assertRowCount(tested, sysContentType, 2); TestUtils.assertJsonContent( "{\"testkey\" : \"testvalue\", \"sys_updated\":\"1973-01-28T17:22:29.865+0100\"}", tested.get("aaa-2", sysContentType)); assertTableContent( tested, sysContentType, "aaa-2", SearchUtils.getISODateFormat().parse("1973-01-28T17:22:29.865+0100")); // case - store into existing table, existing id so update, sys_updated is invalid String // instance but no // exception and table is correctly filled content.put(ContentObjectFields.SYS_UPDATED, "sdfasdf"); tested.store("aaa-2", sysContentType, content); assertRowCount(tested, sysContentType, 2); TestUtils.assertJsonContent( "{\"testkey\" : \"testvalue\", \"sys_updated\":\"sdfasdf\"}", tested.get("aaa-2", sysContentType)); assertTableContent(tested, sysContentType, "aaa-2", null); // case - delete from nonexisting table tested.delete("aaa", "jj"); // case - delete from existing table, nonexisting id tested.delete("a-1", sysContentType); assertRowCount(tested, sysContentType, 2); // case - delete existing id tested.delete("aaa-1", sysContentType); assertRowCount(tested, sysContentType, 1); Assert.assertNull(tested.get("aaa-1", sysContentType)); Assert.assertNotNull(tested.get("aaa-2", sysContentType)); }
@Test public void gettingRemovedTable() { provider.createTable("testRemove"); provider.removeTable("testRemove"); Assert.assertNull("should be null", provider.getTable("testRemove")); }
@Test public void gettingNonExistingTableShouldFail() { Assert.assertNull("should be null", provider.getTable("testNonExist")); }