@Test public void overwriteExistingFilter() { int n = 1000; double p = 0.01; String name = "loadExistingTest"; String testString = "simpletest"; String testString2 = "simpletest2"; cleanupRedis(); BloomFilter<String> first = createFilter(name, n, p, true); first.add(testString); System.out.println(first.asString()); BloomFilter<String> loaded = createFilter(name, n, p, true); System.out.println(loaded.asString()); assertFalse(loaded.contains(testString)); assertTrue(loaded.getExpectedElements() == n); assertEquals(first.getSize(), loaded.getSize()); assertEquals(first.getHashes(), loaded.getHashes()); assertEquals(0, Math.round(first.getEstimatedPopulation())); loaded.add(testString2); assertTrue(first.contains(testString2)); cleanupRedis(); }
@Test public void TestTemp() { ArCondicionado ac = new ArCondicionado(); SensorTemp sensorTemp = new SensorTemp(ac); ac.SensorTemperatura(sensorTemp); sensorTemp.setTemp(6); SensorPessoa sensorPessoa = new SensorPessoa(ac); ac.SensorPessoa(sensorPessoa); sensorPessoa.setQtd(6); assertEquals(Math.round(ac.getTemp()), 6, 6); }
/* * The client MUST take care to choose an initial 'rid' that will never be * incremented above 9007199254740991 [21] within the session. * * @param node node to validate */ private void assertSessionCreationRequestIDRange(final Node node) { String ridStr = node.getBody().getAttribute(Attributes.RID); long rid = Long.parseLong(ridStr); BigInteger biRID = BigInteger.valueOf(rid); BigInteger biMax = new BigInteger("9007199254740991"); BigInteger biThreshold = BigInteger.valueOf(Math.round(Math.pow(2.0, 20.0))); assertTrue( "Initial RID leaves fewer than " + biThreshold.toString() + " total requests before max RID limit is hit", biRID.compareTo(biMax.subtract(biThreshold)) <= 0); }
@Test public void testWearAndUnWearBloodPercentEquip() { ScriptManager manager = ScriptManager.getInstance(); User user = UserManager.getInstance().createDefaultUser(); user.setBlood(100); User expectUser = UserManager.getInstance().createDefaultUser(); expectUser.setBlood(100); WeaponPojo weapon = new WeaponPojo(); weapon.setAddBloodPercent(15); user.getBag().removeOtherPropDatas(Bag.BAG_WEAR_COUNT); user.getBag().addOtherPropDatas(weapon.toPropData(30, WeaponColor.WHITE)); user.getBag().wearPropData(Bag.BAG_WEAR_COUNT, PropDataEquipIndex.WEAPON.index()); // default power = 2980 assertEquals(Math.round(expectUser.getBlood() * 1.15), user.getBlood()); user.getBag().wearPropData(PropDataEquipIndex.WEAPON.index(), -1); assertEquals(expectUser.getBlood(), user.getBlood()); }