package moontime.examples;

import java.util.Calendar;
import java.util.EnumSet;
import java.util.List;

import moontime.MoonEvent;
import moontime.MoonEventType;
import moontime.alg.MoonToolPhaseAlgorithm;
import moontime.rise.LuminaryDayTimesCalculator;
import moontime.rise.LuminaryDayTimesCalculator.DayTimes;
import moontime.rise.MoonTimesCalculator;
import moontime.rise.SunTimesCalculator;
import moontime.testsupport.TestConstants;

import org.junit.Test;

public class ShowCase {

    private Calendar _now = Calendar.getInstance();
    
    @Test
    public void testNextMoonEvents() throws Exception {
        System.out.println("next moon events:");
        MoonToolPhaseAlgorithm phaseAlgorithm = new MoonToolPhaseAlgorithm();
        List<MoonEvent> nextMoonEvents = phaseAlgorithm.getNextMoonEvents(_now, 3, EnumSet.of(MoonEventType.FULL_MOON,MoonEventType.NEW_MOON));
        for (MoonEvent moonEvent : nextMoonEvents) {
            System.out.println("\t:"+moonEvent);
        }
    }
    
    @Test
    public void testSunMoonRise() throws Exception {
         LuminaryDayTimesCalculator moon = new MoonTimesCalculator(TestConstants.LEIPZIG_LONGITUDE, TestConstants.LEIPZIG_LATITUDE);
         DayTimes moonDayTimes = moon.calculateDayTimes(_now);
         System.out.println("\nmoonrise ("+moonDayTimes.getDay().getTime()+"):");
         System.out.println("\t"+moonDayTimes);
         
         LuminaryDayTimesCalculator sun = new SunTimesCalculator(TestConstants.LEIPZIG_LONGITUDE, TestConstants.LEIPZIG_LATITUDE);
         DayTimes sunDayTimes = sun.calculateDayTimes(_now);
         System.out.println("\nsunrise ("+sunDayTimes.getDay().getTime()+"):");
         System.out.println("\t"+sunDayTimes);
    }
}

@@ -1,8 +1,620 @@
+/**%0A * Copyright 2011 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A
 package 
@@ -1042,24 +1042,73 @@
 Constants;%0A%0A
+import org.junit.After;%0Aimport org.junit.Before;%0A
 import org.j
@@ -1196,20 +1196,90 @@
 ance();%0A
+%0A
     
+@After%0A    public void after() %7B%0A        System.out.println();%0A    %7D%0A
 %0A    @Te
@@ -1582,16 +1582,17 @@
 LL_MOON,
+ 
 MoonEven
@@ -1700,11 +1700,12 @@
 (%22%5Ct
-:%22+
+%22 + 
 moon
@@ -1728,21 +1728,17 @@
 %7D%0A    %7D%0A
-    
 %0A
+
     @Tes
@@ -1763,19 +1763,16 @@
 test
-Sun
 MoonRise
 () t
@@ -1767,16 +1767,19 @@
 MoonRise
+Set
 () throw
@@ -1788,25 +1788,24 @@
 Exception %7B%0A
- 
         Lumi
@@ -1924,33 +1924,32 @@
 ITUDE);%0A        
- 
 DayTimes moonDay
@@ -1986,33 +1986,32 @@
 (_now);%0A        
- 
 System.out.print
@@ -2014,18 +2014,16 @@
 rintln(%22
-%5Cn
 moonrise
@@ -2025,17 +2025,19 @@
 nrise (%22
-+
+ + 
 moonDayT
@@ -2051,33 +2051,35 @@
 tDay().getTime()
-+
+ + 
 %22):%22);%0A         
@@ -2069,33 +2069,32 @@
  %22):%22);%0A        
- 
 System.out.print
@@ -2100,17 +2100,19 @@
 tln(%22%5Ct%22
-+
+ + 
 moonDayT
@@ -2126,15 +2126,73 @@
     
+%7D%0A%0A
     
- %0A 
+@Test%0A    public void testSunRiseSet() throws Exception %7B%0A
     
@@ -2321,25 +2321,24 @@
 E);%0A        
- 
 DayTimes sun
@@ -2377,33 +2377,32 @@
 (_now);%0A        
- 
 System.out.print
@@ -2409,10 +2409,8 @@
 ln(%22
-%5Cn
 sunr
@@ -2415,17 +2415,19 @@
 nrise (%22
-+
+ + 
 sunDayTi
@@ -2452,17 +2452,18 @@
 me()
-+
+ + 
 %22):%22);%0A
- 
     
@@ -2489,17 +2489,19 @@
 tln(%22%5Ct%22
-+
+ + 
 sunDayTi

improve ShowCase