package com.fasterxml.jackson.databind.introspect;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.databind.ObjectMapper;

/* Tests mostly for [JACKSON-754]: ability to create "annotation bundles"
 */
public class TestAnnotionBundles extends com.fasterxml.jackson.databind.BaseMapTest
{
    @Retention(RetentionPolicy.RUNTIME)
    @JacksonAnnotationsInside
    @JsonIgnore
    private @interface MyIgnoral { }

    @Retention(RetentionPolicy.RUNTIME)
    @JacksonAnnotationsInside
    @JsonProperty("foobar")
    private @interface MyRename { }

    protected final static class Bean {
        @MyIgnoral
        public String getIgnored() { return "foo"; }
 
        @MyRename
        public int renamed = 13;
    }

    @Retention(RetentionPolicy.RUNTIME)
    @JsonAutoDetect(fieldVisibility=Visibility.NONE,
            getterVisibility=Visibility.NONE, isGetterVisibility=Visibility.NONE)
    @JacksonAnnotationsInside
    public @interface JsonAutoDetectOff {}

    @JsonAutoDetectOff
    public class NoAutoDetect {
      public int getA() { return 13; }
      
      @JsonProperty
      public int getB() { return 5; }
    }
    
    /*
    /**********************************************************
    /* Test methods
    /**********************************************************
     */

    private final ObjectMapper MAPPER = new ObjectMapper();
    
    public void testBundledIgnore() throws Exception
    {
        assertEquals("{\"foobar\":13}", MAPPER.writeValueAsString(new Bean()));
    }

    public void testVisibilityBundle() throws Exception
    {
        assertEquals("{\"b\":5}", MAPPER.writeValueAsString(new NoAutoDetect()));
    }
    
}

@@ -1298,24 +1298,241 @@
  5; %7D%0A    %7D%0A
+%0A    @Retention(RetentionPolicy.RUNTIME)%0A    @JacksonAnnotationsInside%0A    @JsonProperty(%22_id%22)%0A    public @interface Bundle92 %7B%7D%0A%0A    public class Bean92 %7B%0A        @Bundle92%0A        protected String id = %22abc%22;%0A    %7D
     %0A    /*%0A
@@ -2054,10 +2054,153 @@
  %7D%0A    %0A
+    public void testIssue92() throws Exception%0A    %7B%0A        assertEquals(%22%7B%5C%22_id%5C%22:%5C%22abc%5C%22%7D%22, MAPPER.writeValueAsString(new Bean92()));%0A    %7D%0A
 %7D%0A

add a unit test for [Issue#92] (can not reproduce)