Logo Search packages:      
Sourcecode: pcalendar version File versions  Download package

void net::sf::linuxorg::pcal::engine::EngineTest::testGetDayInfoWithOvulations (  ) [inline]

Test method for net.sf.linuxorg.pcal.engine.Engine#getDayInfo(java.util.Date). Check the ovulation records functionality

Definition at line 288 of file EngineTest.java.

References net::sf::linuxorg::pcal::PCalDayInfo::day_num, net::sf::linuxorg::pcal::PCalDayInfo::estimate, and net::sf::linuxorg::pcal::engine::Engine::getDayInfo().

                                                 {
            PCalDayInfo dayInfo; 
                  
            // set the ovulation for the past period
            calendar.set(2007, 9, 14);
            Date ovulationDate = calendar.getTime();

            engine.addOvulationDate(ovulationDate);
            
            // ovulation itself
            dayInfo = engine.getDayInfo(ovulationDate);
            assertEquals(dayInfo.day_num, 13);
            assertTrue(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.estimate);
            assertTrue(dayInfo.ovulation);
            

            // next day after ovulation
            calendar.set(2007, 9, 15);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 14);
            assertFalse(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.estimate);
            assertFalse(dayInfo.ovulation);

            // 3 days before ovulation
            calendar.set(2007, 9, 11);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 10);
            assertTrue(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.estimate);
            assertFalse(dayInfo.ovulation);

            // the first fertile day
            calendar.set(2007, 9, 9);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 8);
            assertTrue(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.estimate);
            assertFalse(dayInfo.ovulation);

            // the last non-fertile day
            calendar.set(2007, 9, 8);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 7);
            assertFalse(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.estimate);
            assertFalse(dayInfo.ovulation);


            // test the ovulation prediction staff
            calendar.set(2008, 0, 22);
            ovulationDate = calendar.getTime();
            engine.addOvulationDate(ovulationDate);

            dayInfo = engine.getDayInfo(ovulationDate);
            assertEquals(dayInfo.day_num, 13);
            assertTrue(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.estimate);
            assertTrue(dayInfo.ovulation);

            // next day after ovulation
            calendar.set(2008, 0, 23);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 14);
            assertFalse(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertTrue(dayInfo.estimate);
            assertFalse(dayInfo.ovulation);

            // last day of the cycle
            calendar.set(2008, 1, 2);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 24);
            assertFalse(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertTrue(dayInfo.estimate);
            assertFalse(dayInfo.ovulation);

            // first day of the next cycle
            calendar.set(2008, 1, 3);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 0);
            assertFalse(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertTrue(dayInfo.badFeel);
            assertTrue(dayInfo.estimate);
            assertFalse(dayInfo.ovulation);


            // 3 days before ovulation
            calendar.set(2008, 0, 19);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 10);
            assertTrue(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.estimate);
            assertFalse(dayInfo.ovulation);

            // the first fertile day
            calendar.set(2008, 0, 17);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 8);
            assertTrue(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.estimate);
            assertFalse(dayInfo.ovulation);

            // the last non-fertile day
            calendar.set(2008, 0, 16);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 7);
            assertFalse(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.estimate);
            assertFalse(dayInfo.ovulation);

            // test the empty dataset case
            engine.newFile();

            // test day 1 combinations
            // recorded day 0
            calendar.set(2007, 9, 26);
            ovulationDate = calendar.getTime();
            engine.addOvulationDate(ovulationDate);
            dayInfo = engine.getDayInfo(ovulationDate);
            assertEquals(dayInfo.day_num, -1);
            assertTrue(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.estimate);
            assertTrue(dayInfo.ovulation);

            // ovulation within a regular cycle
            calendar.set(2007, 9, 6);
            Date mensDate = calendar.getTime();
            engine.addStartDate(mensDate);
            dayInfo = engine.getDayInfo(ovulationDate);
            assertEquals(dayInfo.day_num, 20);
            assertTrue(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.estimate);
            assertTrue(dayInfo.ovulation);

            // ovulation beyond a regular cycle
            engine.removeDateRecord(mensDate);
            calendar.set(2007, 7, 6);
            engine.addStartDate(calendar.getTime());
            dayInfo = engine.getDayInfo(ovulationDate);
            assertEquals(dayInfo.day_num, -1);
            assertTrue(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.estimate);
            assertTrue(dayInfo.ovulation);

      }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index