// Path: src/test/java/com/hubspot/jackson/datatype/protobuf/util/ObjectMapperHelper.java
// public static ObjectMapper camelCase() {
//   return DEFAULT;
// }
// 
// Path: src/test/java/com/hubspot/jackson/datatype/protobuf/util/TestExtensionRegistry.java
// public class TestExtensionRegistry {
// 
//   public static ExtensionRegistry getInstance() {
//     ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance();
//     Iterable<FieldDescriptor> extensionDescriptors = Iterables.concat(
//         AllExtensions.getDescriptor().getExtensions(),
//         RepeatedExtensions.getDescriptor().getExtensions()
//     );
// 
//     for (FieldDescriptor extension : extensionDescriptors) {
//       if (extension.getJavaType() == JavaType.MESSAGE) {
//         extensionRegistry.add(extension, Nested.getDefaultInstance());
//       } else {
//         extensionRegistry.add(extension);
//       }
//     }
// 
//     return extensionRegistry;
//   }
// }


import static com.hubspot.jackson.datatype.protobuf.util.ObjectMapperHelper.camelCase;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import org.junit.BeforeClass;
import org.junit.Test;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.CaseFormat;
import com.google.common.base.Enums;
import com.google.protobuf.Descriptors.Descriptor;
import com.google.protobuf.Descriptors.FieldDescriptor;
import com.google.protobuf.ExtensionRegistry;
import com.google.protobuf.ExtensionRegistry.ExtensionInfo;
import com.hubspot.jackson.datatype.protobuf.util.TestExtensionRegistry;
import com.hubspot.jackson.datatype.protobuf.util.TestProtobuf.AllFields;
        assertThat(node.get(field).isArray());
      } else {
        assertThat(node.get(field).isNull());
      }
    }
  }

  @Test
  public void itOnlyWritesArrayExtensionFieldsWhenSerializationIncludeIsNotAlways() {
    AllFields message = AllFields.getDefaultInstance();

    for (Include inclusion : EnumSet.complementOf(EXCLUDED_VALUES)) {
      JsonNode node = mapper(inclusion, EXTENSION_REGISTRY).valueToTree(message);

      for (String field : allExtensionFields) {
        if (arrayExtensionFields.contains(field)) {
          assertThat(node.has(field)).isTrue();
          assertThat(node.get(field).isArray());
        } else {
          assertThat(node.has(field)).isFalse();
        }
      }
    }
  }

  private static String translate(String fieldName) {
    return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, fieldName);
  }

  private static ObjectMapper mapper(Include inclusion) {
// Path: src/test/java/com/hubspot/jackson/datatype/protobuf/util/ObjectMapperHelper.java
// public static ObjectMapper camelCase() {
//   return DEFAULT;
// }
// 
// Path: src/test/java/com/hubspot/jackson/datatype/protobuf/util/TestExtensionRegistry.java
// public class TestExtensionRegistry {
// 
//   public static ExtensionRegistry getInstance() {
//     ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance();
//     Iterable<FieldDescriptor> extensionDescriptors = Iterables.concat(
//         AllExtensions.getDescriptor().getExtensions(),
//         RepeatedExtensions.getDescriptor().getExtensions()
//     );
// 
//     for (FieldDescriptor extension : extensionDescriptors) {
//       if (extension.getJavaType() == JavaType.MESSAGE) {
//         extensionRegistry.add(extension, Nested.getDefaultInstance());
//       } else {
//         extensionRegistry.add(extension);
//       }
//     }
// 
//     return extensionRegistry;
//   }
// }


// Path: src/test/java/com/hubspot/jackson/datatype/protobuf/JsonInclusionTest.java
import static com.hubspot.jackson.datatype.protobuf.util.ObjectMapperHelper.camelCase;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import org.junit.BeforeClass;
import org.junit.Test;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.CaseFormat;
import com.google.common.base.Enums;
import com.google.protobuf.Descriptors.Descriptor;
import com.google.protobuf.Descriptors.FieldDescriptor;
import com.google.protobuf.ExtensionRegistry;
import com.google.protobuf.ExtensionRegistry.ExtensionInfo;
import com.hubspot.jackson.datatype.protobuf.util.TestExtensionRegistry;
import com.hubspot.jackson.datatype.protobuf.util.TestProtobuf.AllFields;

        assertThat(node.get(field).isArray());
      } else {
        assertThat(node.get(field).isNull());
      }
    }
  }

  @Test
  public void itOnlyWritesArrayExtensionFieldsWhenSerializationIncludeIsNotAlways() {
    AllFields message = AllFields.getDefaultInstance();

    for (Include inclusion : EnumSet.complementOf(EXCLUDED_VALUES)) {
      JsonNode node = mapper(inclusion, EXTENSION_REGISTRY).valueToTree(message);

      for (String field : allExtensionFields) {
        if (arrayExtensionFields.contains(field)) {
          assertThat(node.has(field)).isTrue();
          assertThat(node.get(field).isArray());
        } else {
          assertThat(node.has(field)).isFalse();
        }
      }
    }
  }

  private static String translate(String fieldName) {
    return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, fieldName);
  }

  private static ObjectMapper mapper(Include inclusion) {
    return camelCase().copy().setSerializationInclusion(inclusion);