package org.mutabilitydetector.casestudies.jodatime;

import static org.mutabilitydetector.unittesting.AllowedReason.provided;
import static org.mutabilitydetector.unittesting.MutabilityAssert.assertImmutable;
import static org.mutabilitydetector.unittesting.MutabilityAssert.assertInstancesOf;
import static org.mutabilitydetector.unittesting.matchers.MutabilityMatchers.areImmutable;

import org.joda.time.Chronology;
import org.joda.time.DateTimeZone;
import org.joda.time.Days;
import org.joda.time.Hours;
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
import org.joda.time.LocalTime;
import org.joda.time.Minutes;
import org.joda.time.Months;
import org.joda.time.Partial;
import org.joda.time.Period;
import org.joda.time.TimeOfDay;
import org.joda.time.Weeks;
import org.joda.time.YearMonthDay;
import org.joda.time.Years;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.PeriodFormatter;
import org.junit.Test;

@SuppressWarnings("deprecation") 
public class TestJodaTime {
    @Test
    public void testorg_joda_time_LocalDateTime() {
        assertInstancesOf(LocalDateTime.class, areImmutable(),provided(Chronology.class).isAlsoImmutable());
    }

    @Test
    public void testorg_joda_time_LocalTime() {
    	assertInstancesOf(LocalTime.class, areImmutable(),provided(Chronology.class).isAlsoImmutable());
    }

    @Test
    public void testorg_joda_time_format_DateTimeFormatter() {
        assertImmutable(DateTimeFormatter.class);
    }

    @Test
    public void testorg_joda_time_format_PeriodFormatter() {
        assertImmutable(PeriodFormatter.class);
    }

    @Test
    public void testorg_joda_time_Seconds() {
        assertImmutable(org.joda.time.Seconds.class);
    }

    @Test
    public void testorg_joda_time_DateMidnight() {
        assertImmutable(org.joda.time.DateMidnight.class);
    }

    @Test
    public void testorg_joda_time_DateTime() {
        assertImmutable(org.joda.time.DateTime.class);
    }

    @Test
    public void testorg_joda_time_Duration() {
        assertImmutable(org.joda.time.Duration.class);
    }

    @Test
    public void testorg_joda_time_LocalDate() {
    	assertInstancesOf(LocalDate.class, areImmutable(),provided(Chronology.class).isAlsoImmutable());
    }

    @Test
    public void testorg_joda_time_DateTimeZone() {
        assertImmutable(DateTimeZone.class);
    }

    @Test
    public void testorg_joda_time_Months() {
        assertImmutable(Months.class);
    }

    @Test
    public void testorg_joda_time_Years() {
        assertImmutable(Years.class);
    }

    @Test
    public void testorg_joda_time_YearMonthDay() {
        assertImmutable(YearMonthDay.class);
    }

    @Test
    public void testorg_joda_time_TimeOfDay() {
        assertImmutable(TimeOfDay.class);
    }

    @Test
    public void testorg_joda_time_Days() {
        assertImmutable(Days.class);
    }

    @Test
    public void testorg_joda_time_Weeks() {
        assertImmutable(Weeks.class);
    }

    @Test
    public void testorg_joda_time_Hours() {
        assertImmutable(Hours.class);
    }

    @Test
    public void testorg_joda_time_Period() {
        assertImmutable(Period.class);
    }

    @Test
    public void testorg_joda_time_Partial() {
        assertInstancesOf(Partial.class, areImmutable(),provided(Chronology.class).isAlsoImmutable());
    }

    @Test
    public void testorg_joda_time_Minutes() {
        assertImmutable(Minutes.class);
    }

}

@@ -376,24 +376,50 @@
 Immutable;%0A%0A
+import java.util.Locale;%0A%0A
 import org.j
@@ -747,16 +747,49 @@
 Period;%0A
+import org.joda.time.PeriodType;%0A
 import o
@@ -987,32 +987,75 @@
 eriodFormatter;%0A
+import org.joda.time.format.PeriodPrinter;%0A
 import org.junit
@@ -1546,35 +1546,34 @@
 ) %7B%0A    
-    
+%09
 assertI
-mmutable
+nstancesOf
 (DateTim
@@ -1584,33 +1584,192 @@
 matter.class
-);%0A    %7D%0A
+, areImmutable(), provided(Locale.class).isAlsoImmutable());%0A    %7D%0A%0A    @Test%0A    public void testjava_util_Locale() %7B%0A        assertImmutable(Locale.class);%0A    %7D%0A    
 %0A    @Test%0A 
@@ -1836,49 +1836,248 @@
     
-    
+%09
 assertI
-mmutable(PeriodFormatter.class
+nstancesOf(PeriodFormatter.class, areImmutable(), provided(PeriodPrinter.class).isAlsoImmutable());%0A    %7D%0A    %0A    @Test%0A    public void testorg_joda_time_format_PeriodType() %7B%0A    %09assertInstancesOf(PeriodType.class, areImmutable()
 );%0A 

Update the test of JodaTime.