# devopsgym / testgen__fasterxml__jackson-databind-3716 - taskset: [devopsgym](https://harnessreport.com/tasks/devopsgym.md) - difficulty: hard - category: test-generation - language: - runnable from the site: no - agent timeout: 3000s ## Results by harness _none yet_ ## Instruction ``` The following text contains a user issue (in <issue/> brackets) posted at a repository. Further, you are provided with file contents of several files in the repository that contain relevant code (in <code> brackets). It may be necessary to use code from third party dependencies or files not contained in the attached documents however. Your task is to identify the issue and implement a test case that verifies a proposed solution to this issue. More details at the end of this text. <issue> **Describe the bug** When an interface type is being used for an attribute and an enum implements this interface, resulting serialization and deserialization behavior is incorrect. **Version information** 2.14.1 **To Reproduce** If you have a way to reproduce this with: ```java // POJO public class Animal { private LivingBeingType type; private String name; // getters and setters } @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) @JsonSubTypes({@JsonSubTypes.Type(value = AnimalType.class)}) public interface LivingBeingType { } public enum AnimalType implements LivingBeingType { FOURLEGGED, TWOLEGGED } public static void main(String[] args) throws JsonProcessingException { ObjectMapper objectMapper = new ObjectMapper(); // Serialization Animal animal = new Animal(); animal.setName("Horse"); animal.setType(AnimalType.FOURLEGGED); System.out.println("***Serialization***"); System.out.println(objectMapper.writeValueAsString(animal)); // Deserialization String json = "{\"type\":\"FOURLEGGED\",\"name\":\"Horse\"}"; System.out.println("***Deserialization***"); System.out.println(objectMapper.readValue(json, Animal.class)); } ``` ***Output :*** ``` ***Serialization*** {"type":["com.smilep.jackson.AnimalType","FOURLEGGED"],"name":"Horse"} ***Deserialization*** Exception in thread "main" com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve subtype of [simple type, class com.smilep.jackson.LivingBeingType]: Unexpected input at [Source: (String)"{"type":"FOURLEGGED","name":"Horse"}"; line: 1, column: 9] (through reference chain: com.smilep.jackson.Animal["type"]) at com.fasterxml.jackson.databind.exc.InvalidTypeIdException.from(InvalidTypeIdException.java:43) at com.fasterxml.jackson.databind.DeserializationContext.missingTypeIdException(DeserializationContext.java:2088) at com.fasterxml.jackson.databind.DeserializationContext.handleMissingTypeId(DeserializationContext.java:1601) at com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._handleMissingTypeId(TypeDeserializerBase.java:307) at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedUsingDefaultImpl(AsPropertyTypeDeserializer.java:185) at com.fasterxml.jackson.databind.jsontype.impl.AsDeductionTypeDeserializer.deserializeTypedFromObject(AsDeductionTypeDeserializer.java:110) at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:263) at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:138) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:314) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177) at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4730) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3677) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3645) at com.smilep.jackson.JacksonMain.main(JacksonMain.java:20) Process finished with exit code 1 ``` **Expected behavior** Serialization should produce `{"type":"FOURLEGGED","name":"Horse"}` Deserialization should produce `Animal` instance with `type` having value of `AnimalType.FOURLEGGED` instance. </issue> Please generate test cases that check whether an implemented solution resolves the issue of the user (at the top, within <issue/> brackets). You may apply changes to several files. Apply as much reasoning as you please and see necessary. Make sure to implement only test cases and don't try to fix the issue itself. You are not allowed to read git history. ``` --- Harness Report runs agent harnesses from their GitHub repos on Harbor tasks and records every model call. Every page is also `.md` and `.json`; index: https://harnessreport.com/llms.txt · MCP: https://harnessreport.com/mcp