@Test public void testEmptyPollingMethod() { BinaryLocatorSupplier supplier = new BinaryLocatorSupplier(data, DEFAULT_MASS_TYPE, DEFAULT_MASS_ARGS); for (int i = 0; i < (int) (DEFAULT_MASS_ARGS[2] - DEFAULT_MASS_ARGS[1] + 1); i++) { Assert.assertFalse(supplier.empty()); supplier.popLocator(); } Assert.assertTrue(supplier.empty()); }
@Test public void testMeanScaledSuppliesCorrectCount() { BinaryLocatorSupplier supplier = new BinaryLocatorSupplier(data, DEFAULT_MASS_TYPE, DEFAULT_MASS_ARGS); int count = 0; while (!supplier.empty()) { count++; supplier.popLocator(); } Assert.assertEquals((int) (DEFAULT_MASS_ARGS[2] - DEFAULT_MASS_ARGS[1] + 1), count); }
@Test public void testMeanScaledSuppliesValidLocators() { BinaryLocatorSupplier supplier = new BinaryLocatorSupplier(data, DEFAULT_MASS_TYPE, DEFAULT_MASS_ARGS); while (!supplier.empty()) { Locator locator = supplier.popLocator(); locator.initialize(); BrightBodyList[] bodies = locator.locate(); Assert.assertEquals(bodies.length, data.length); // checks length of the locators Assert.assertNotEquals(bodies[0].size(), 0); // tests that there is at least one body found Assert.assertNotEquals( bodies[data.length / 2].size(), 0); // tests that there is at least one body found Assert.assertNotEquals( bodies[data.length - 1].size(), 0); // tests that there is at least one body found Assert.assertTrue( bodies[data.length / 2].get(0).body.length > 5); // test that the first bright body is larger than 5 Assert.assertTrue( bodies[data.length / 2].get(0).body.length < 1000); // test that the first bright body is smaller than 1000 Assert.assertTrue(bodies[data.length / 2].get(0).area > 10); Assert.assertTrue(bodies[data.length / 2].get(0).area < Integer.MAX_VALUE); } }