test_class.file: core/src/test/java/org/carrot2/attrs/AttrsTest.java
test_class.identifier: AttrsTest
test_class.superclass: extends TestBase
test_case.body: @Test
    public void testFromMapAttrWithInvalidValue() {
      class Clazz extends AttrComposite {
        AttrBoolean attrBoolean =
            attributes.register("attrBoolean", AttrBoolean.builder().defaultValue(null));
        AttrInteger attrInteger =
            attributes.register("attrInteger", AttrInteger.builder().defaultValue(null));
        AttrDouble attrDouble =
            attributes.register("attrDouble", AttrDouble.builder().defaultValue(null));
        AttrString attrString =
            attributes.register("attrString", AttrString.builder().defaultValue(null));
        AttrEnum<EnumClazz> attrEnum =
            attributes.register("attrEnum", AttrEnum.builder(EnumClazz.class).defaultValue(null));
        AttrObject<Clazz> attrObject =
            attributes.register(
                "attrObject", AttrObject.builder(Clazz.class).defaultValue(null, () -> new Clazz()));
        AttrObjectArray<Clazz> attrObjectArray =
            attributes.register(
                "attrObjectArray",
                AttrObjectArray.builder(Clazz.class, () -> new Clazz()).defaultValue(null));
      }
  
      AliasMapper mapper = new AliasMapper();
      mapper.alias("clazz", Clazz.class, () -> new Clazz());
  
      Assertions.assertThatExceptionOfType(IllegalArgumentException.class)
          .isThrownBy(
              () -> {
                Map<String, Object> map = Collections.singletonMap("extraKey", "");
                Attrs.populate(new Clazz(), map, mapper::fromName);
              });
  
      Assertions.assertThatExceptionOfType(IllegalArgumentException.class)
          .isThrownBy(
              () -> {
                Map<String, Object> map =
                    Collections.singletonMap(
                        "attrObject", Collections.singletonMap("extraKey", "invalid-value"));
                Attrs.populate(new Clazz(), map, mapper::fromName);
              });
  
      for (Object value : Arrays.asList(true, false, null)) {
        checkValueLegal(mapper, new Clazz(), "attrBoolean", value);
      }
      for (Object value : Arrays.asList(10, "true", 10d, new Object[0], new ArrayList<>())) {
        checkValueIllegal(mapper, new Clazz(), "attrBoolean", (c) -> c.attrBoolean.get(), value);
      }
  
      for (Object value : Arrays.asList(10, 10f, 10d, null)) {
        checkValueLegal(mapper, new Clazz(), "attrInteger", value);
      }
      for (Object value :
          Arrays.asList(
              true,
              "true",
              10.1f,
              10.1d,
              Long.MAX_VALUE,
              Double.NaN,
              new Object[0],
              new ArrayList<>())) {
        checkValueIllegal(mapper, new Clazz(), "attrInteger", (c) -> c.attrInteger.get(), value);
      }
  
      for (Object value : Arrays.asList(10, 10f, 10d, null, Double.NaN, Double.MAX_VALUE)) {
        checkValueLegal(mapper, new Clazz(), "attrDouble", value);
      }
      for (Object value : Arrays.asList(true, "true", new Object[0], new ArrayList<>())) {
        checkValueIllegal(mapper, new Clazz(), "attrDouble", (c) -> c.attrDouble.get(), value);
      }
  
      for (Object value : Arrays.asList(null, "abc", "")) {
        checkValueLegal(mapper, new Clazz(), "attrString", value);
      }
      for (Object value : Arrays.asList(true, 10, 10d, new Object[0], new ArrayList<>())) {
        checkValueIllegal(mapper, new Clazz(), "attrString", (c) -> c.attrString.get(), value);
      }
  
      for (Object value : Arrays.asList(null, EnumClazz.FOO, EnumClazz.FOO.name())) {
        checkValueLegal(mapper, new Clazz(), "attrEnum", value);
      }
      for (Object value :
          Arrays.asList(true, 10, 10d, "NONVALUE", new Object[0], new ArrayList<>())) {
        checkValueIllegal(mapper, new Clazz(), "attrEnum", (c) -> c.attrEnum.get(), value);
      }
  
      for (Object value : Arrays.asList(null, new HashMap<>())) {
        checkValueLegal(mapper, new Clazz(), "attrObject", value);
      }
      for (Object value :
          Arrays.asList(
              true,
              10,
              10d,
              "NONVALUE",
              Collections.singletonMap("attrInteger", "invalid-value"),
              new Object(),
              new Object[0],
              new ArrayList<>())) {
        checkValueIllegal(mapper, new Clazz(), "attrObject", (c) -> c.attrObject.get(), value);
      }
  
      for (Object value :
          Arrays.asList(
              null,
              new ArrayList<>(),
              new Object[] {Collections.emptyMap(), Collections.singletonMap("attrString", "foo")})) {
        checkValueLegal(mapper, new Clazz(), "attrObjectArray", value);
      }
      for (Object value :
          Arrays.asList(true, 10, 10d, new Object(), new Object[] {"invalid-value"})) {
        checkValueIllegal(
            mapper, new Clazz(), "attrObjectArray", (c) -> c.attrObjectArray.get(), value);
      }
    }
test_case.class_method_signature: AttrsTest.testFromMapAttrWithInvalidValue()
test_case.full_signature: @Test public void testFromMapAttrWithInvalidValue()
test_case.identifier: testFromMapAttrWithInvalidValue
test_case.invocations: register defaultValue builder register defaultValue builder register defaultValue builder register defaultValue builder register defaultValue builder register defaultValue builder register defaultValue builder alias isThrownBy assertThatExceptionOfType singletonMap populate isThrownBy assertThatExceptionOfType singletonMap singletonMap populate asList checkValueLegal asList checkValueIllegal get asList checkValueLegal asList checkValueIllegal get asList checkValueLegal asList checkValueIllegal get asList checkValueLegal asList checkValueIllegal get asList name checkValueLegal asList checkValueIllegal get asList checkValueLegal asList singletonMap checkValueIllegal get asList emptyMap singletonMap checkValueLegal asList checkValueIllegal get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testFromMapAttrWithInvalidValue()
focal_class.declarator: KEY_WRAPPED = "@value"
focal_class.modifier: private static final
focal_class.original_string: private static final String KEY_WRAPPED = "@value";
focal_class.type: String
focal_class.var_name: KEY_WRAPPED
focal_class.declarator: KEY_TYPE = "@type"
focal_class.modifier: static final
focal_class.original_string: static final String KEY_TYPE = "@type";
focal_class.type: String
focal_class.var_name: KEY_TYPE
focal_class.file: core/src/main/java/org/carrot2/attrs/Attrs.java
focal_class.identifier: Attrs
focal_class.class_method_signature: Attrs.toMap(AcceptingVisitor composite)
focal_class.full_signature: public static Map<String, Object> toMap(AcceptingVisitor composite)
focal_class.identifier: toMap
focal_class.modifiers: public static
focal_class.parameters: (AcceptingVisitor composite)
focal_class.return: Map<String, Object>
focal_class.signature: Map<String, Object> toMap(AcceptingVisitor composite)
focal_class.class_method_signature: Attrs.toMap(
        AcceptingVisitor composite, Function<Object, String> classToName)
focal_class.full_signature: public static Map<String, Object> toMap(
        AcceptingVisitor composite, Function<Object, String> classToName)
focal_class.identifier: toMap
focal_class.modifiers: public static
focal_class.parameters: (
        AcceptingVisitor composite, Function<Object, String> classToName)
focal_class.return: Map<String, Object>
focal_class.signature: Map<String, Object> toMap(
        AcceptingVisitor composite, Function<Object, String> classToName)
focal_class.class_method_signature: Attrs.fromMap(
        Class<? extends E> clazz, Map<String, Object> map)
focal_class.full_signature: public static E fromMap(
        Class<? extends E> clazz, Map<String, Object> map)
focal_class.identifier: fromMap
focal_class.modifiers: public static
focal_class.parameters: (
        Class<? extends E> clazz, Map<String, Object> map)
focal_class.return: E
focal_class.signature: E fromMap(
        Class<? extends E> clazz, Map<String, Object> map)
focal_class.class_method_signature: Attrs.fromMap(
        Class<? extends E> clazz, Map<String, Object> map, Function<String, Object> nameToClass)
focal_class.full_signature: public static E fromMap(
        Class<? extends E> clazz, Map<String, Object> map, Function<String, Object> nameToClass)
focal_class.identifier: fromMap
focal_class.modifiers: public static
focal_class.parameters: (
        Class<? extends E> clazz, Map<String, Object> map, Function<String, Object> nameToClass)
focal_class.return: E
focal_class.signature: E fromMap(
        Class<? extends E> clazz, Map<String, Object> map, Function<String, Object> nameToClass)
focal_class.class_method_signature: Attrs.extract(
        AcceptingVisitor instance, Function<Object, String> classToName)
focal_class.full_signature: public static Map<String, Object> extract(
        AcceptingVisitor instance, Function<Object, String> classToName)
focal_class.identifier: extract
focal_class.modifiers: public static
focal_class.parameters: (
        AcceptingVisitor instance, Function<Object, String> classToName)
focal_class.return: Map<String, Object>
focal_class.signature: Map<String, Object> extract(
        AcceptingVisitor instance, Function<Object, String> classToName)
focal_class.class_method_signature: Attrs.extract(AcceptingVisitor instance)
focal_class.full_signature: public static Map<String, Object> extract(AcceptingVisitor instance)
focal_class.identifier: extract
focal_class.modifiers: public static
focal_class.parameters: (AcceptingVisitor instance)
focal_class.return: Map<String, Object>
focal_class.signature: Map<String, Object> extract(AcceptingVisitor instance)
focal_class.class_method_signature: Attrs.populate(E instance, Map<String, Object> map)
focal_class.full_signature: public static E populate(E instance, Map<String, Object> map)
focal_class.identifier: populate
focal_class.modifiers: public static
focal_class.parameters: (E instance, Map<String, Object> map)
focal_class.return: E
focal_class.signature: E populate(E instance, Map<String, Object> map)
focal_class.class_method_signature: Attrs.populate(
        E instance, Map<String, Object> map, Function<String, Object> nameToClass)
focal_class.full_signature: public static E populate(
        E instance, Map<String, Object> map, Function<String, Object> nameToClass)
focal_class.identifier: populate
focal_class.modifiers: public static
focal_class.parameters: (
        E instance, Map<String, Object> map, Function<String, Object> nameToClass)
focal_class.return: E
focal_class.signature: E populate(
        E instance, Map<String, Object> map, Function<String, Object> nameToClass)
focal_class.class_method_signature: Attrs.toJson(AcceptingVisitor composite, ClassNameMapper classNameMapper)
focal_class.full_signature: public static String toJson(AcceptingVisitor composite, ClassNameMapper classNameMapper)
focal_class.identifier: toJson
focal_class.modifiers: public static
focal_class.parameters: (AcceptingVisitor composite, ClassNameMapper classNameMapper)
focal_class.return: String
focal_class.signature: String toJson(AcceptingVisitor composite, ClassNameMapper classNameMapper)
focal_class.class_method_signature: Attrs.toJson(AcceptingVisitor composite, Function<Object, String> classToName)
focal_class.full_signature: public static String toJson(AcceptingVisitor composite, Function<Object, String> classToName)
focal_class.identifier: toJson
focal_class.modifiers: public static
focal_class.parameters: (AcceptingVisitor composite, Function<Object, String> classToName)
focal_class.return: String
focal_class.signature: String toJson(AcceptingVisitor composite, Function<Object, String> classToName)
focal_class.class_method_signature: Attrs.safeCast(Object value, String key, Class<T> clazz)
focal_class.full_signature: static T safeCast(Object value, String key, Class<T> clazz)
focal_class.identifier: safeCast
focal_class.modifiers: static
focal_class.parameters: (Object value, String key, Class<T> clazz)
focal_class.return: T
focal_class.signature: T safeCast(Object value, String key, Class<T> clazz)
focal_class.class_method_signature: Attrs.toDebugString(Object value)
focal_class.full_signature: static String toDebugString(Object value)
focal_class.identifier: toDebugString
focal_class.modifiers: static
focal_class.parameters: (Object value)
focal_class.return: String
focal_class.signature: String toDebugString(Object value)
focal_method.body: public static <E extends AcceptingVisitor> E populate(E instance, Map<String, Object> map) {
      return populate(instance, map, AliasMapper.SPI_DEFAULTS::fromName);
    }
focal_method.class_method_signature: Attrs.populate(E instance, Map<String, Object> map)
focal_method.full_signature: public static E populate(E instance, Map<String, Object> map)
focal_method.identifier: populate
focal_method.invocations: populate
focal_method.modifiers: public static
focal_method.parameters: (E instance, Map<String, Object> map)
focal_method.return: E
focal_method.signature: E populate(E instance, Map<String, Object> map)