/*
 *    Copyright (c) 2008-2011 Graham Allan
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */
package org.mutabilitydetector.benchmarks.visibility;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.mutabilitydetector.TestUtil.runChecker;
import static org.mutabilitydetector.unittesting.MutabilityMatchers.areEffectivelyImmutable;
import static org.mutabilitydetector.unittesting.MutabilityMatchers.areImmutable;

import org.junit.Test;
import org.mutabilitydetector.benchmarks.ImmutableExample;
import org.mutabilitydetector.benchmarks.visibility.HasNonFinalField;
import org.mutabilitydetector.checkers.AsmMutabilityChecker;
import org.mutabilitydetector.checkers.NonFinalFieldChecker;

public class NonFinalFieldsCheckerTest {

    
    private final AsmMutabilityChecker checker = new NonFinalFieldChecker();


    @Test
    public void remainsImmutableWhenFieldIsFinal() throws Exception {
        assertThat(runChecker(checker, ImmutableExample.class), areImmutable());
    }
    
    
    @Test
    public void isEffectivelyImmutableWhenTheFieldIsNotDeclaredFinal() throws Exception {
        assertThat(runChecker(checker, HasNonFinalField.class), areEffectivelyImmutable());
    }
}

@@ -1091,34 +1091,59 @@
 rks.
-visibility.HasNonFinalFiel
+settermethod.ImmutableUsingPrivateFieldSettingMetho
 d;%0Ai
@@ -1765,10 +1765,230 @@
 ;%0A    %7D%0A
+    %0A    @Test%0A    public void isMutableForNonFinalFieldsSetOnlyInConstructor() throws Exception %7B%0A        assertThat(runChecker(checker, ImmutableUsingPrivateFieldSettingMethod.class), areEffectivelyImmutable());%0A    %7D%0A
 %7D%0A

Add tests that confirm that non-final fields still render something as effectively immutable, regardless of private setter methods called only from the constructor.