package com.fasterxml.jackson.failing;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Assert;
import org.junit.Test;

/**
 */
public class TestPolymorphicDeserialization extends BaseMapTest
{
  @Test
  public void testName() throws Exception
  {
    ObjectMapper mapper = objectMapper();

    Assert.assertEquals("A", mapper.readValue("{\"type\": \"a\"}", SomeInterface.class).get());
    Assert.assertEquals("A", mapper.readValue("{}", SomeInterface.class).get());
    Assert.assertEquals("B", mapper.readValue("{\"type\": \"b\"}", SomeInterface.class).get());
    Assert.assertEquals("A", mapper.readValue("{\"type\": \"c\"}", SomeInterface.class).get());

    Assert.assertEquals("A", mapper.readValue("{\"type\": \"a\"}", ClassA.class).get());
    Assert.assertEquals("B", mapper.readValue("{\"type\": \"b\"}", ClassB.class).get());
    Assert.assertEquals("C", mapper.readValue("{\"type\": \"c\"}", ClassC.class).get());
  }

  @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = ClassA.class)
  @JsonSubTypes({
          @JsonSubTypes.Type(name = "a", value = ClassA.class),
          @JsonSubTypes.Type(name = "b", value = ClassB.class)
  })
  public static interface SomeInterface
  {
    public String get();
  }

  public static class ClassA implements SomeInterface
  {
    @Override
    public String get()
    {
      return "A";
    }
  }

  public static class ClassB implements SomeInterface
  {
    @Override
    public String get()
    {
      return "B";
    }
  }

  public static class ClassC implements SomeInterface
  {
    @Override
    public String get()
    {
      return "C";
    }
  }

}

@@ -303,84 +303,967 @@
 *%0A *
-/%0Apublic class TestPolymorphicDeserialization extends BaseMapTest%0A%7B%0A  @Test%0A
+ Reproduction of %5Bhttps://github.com/FasterXML/jackson-databind/issues/283%5D,%0A * contributed by Eric T.%0A */%0Apublic class TestPolymorphicDeserialization extends BaseMapTest%0A%7B%0A    @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = %22type%22, defaultImpl = ClassA.class)%0A    @JsonSubTypes(%7B%0A            @JsonSubTypes.Type(name = %22a%22, value = ClassA.class),%0A            @JsonSubTypes.Type(name = %22b%22, value = ClassB.class)%0A    %7D)%0A    public static interface SomeInterface%0A    %7B%0A      public String get();%0A    %7D%0A%0A    public static class ClassA implements SomeInterface%0A    %7B%0A      @Override%0A      public String get()%0A      %7B%0A        return %22A%22;%0A      %7D%0A    %7D%0A%0A    public static class ClassB implements SomeInterface%0A    %7B%0A      @Override%0A      public String get()%0A      %7B%0A        return %22B%22;%0A      %7D%0A    %7D%0A%0A    public static class ClassC implements SomeInterface%0A    %7B%0A      @Override%0A      public String get()%0A      %7B%0A        return %22C%22;%0A      %7D%0A    %7D%0A%0A    @Test%0A  
   pu
@@ -1302,18 +1302,22 @@
 ption%0A  
-%7B%0A
+  %7B%0A  
     Obje
@@ -1347,32 +1347,34 @@
 tMapper();%0A%0A    
+  
 Assert.assertEqu
@@ -1445,32 +1445,34 @@
 ss).get());%0A    
+  
 Assert.assertEqu
@@ -1524,32 +1524,34 @@
 .class).get());%0A
+  
     Assert.asser
@@ -1626,32 +1626,34 @@
 ss).get());%0A    
+  
 Assert.assertEqu
@@ -1729,24 +1729,26 @@
 et());%0A%0A    
+  
 Assert.asser
@@ -1812,32 +1812,34 @@
 .class).get());%0A
+  
     Assert.asser
@@ -1911,24 +1911,26 @@
 get());%0A    
+  
 Assert.asser
@@ -2008,717 +2008,10 @@
 ;%0A  
-%7D%0A%0A  @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = %22type%22, defaultImpl = ClassA.class)%0A  @JsonSubTypes(%7B%0A          @JsonSubTypes.Type(name = %22a%22, value = ClassA.class),%0A          @JsonSubTypes.Type(name = %22b%22, value = ClassB.class)%0A  %7D)%0A  public static interface SomeInterface%0A  %7B%0A    public String get();%0A  %7D%0A%0A  public static class ClassA implements SomeInterface%0A  %7B%0A    @Override%0A    public String get()%0A    %7B%0A      return %22A%22;%0A    %7D%0A  %7D%0A%0A  public static class ClassB implements SomeInterface%0A  %7B%0A    @Override%0A    public String get()%0A    %7B%0A      return %22B%22;%0A    %7D%0A  %7D%0A%0A  public static class ClassC implements SomeInterface%0A  %7B%0A    @Override%0A    public String get()%0A    %7B%0A      return %22C%22;%0A    %7D%0A  %7D%0A
+  %7D
 %0A%7D%0A

Add a notes wrt #283