static Serializer createSerializer(Fury fury, Class<?> cls) {
    for (Tuple2<Class<?>, Function> factory : unmodifiableFactories()) {
      if (factory.f0 == cls) {
        return createSerializer(fury, factory);
      }
    }
    throw new IllegalArgumentException("Unsupported type " + cls);
  }
@SuppressWarnings("unchecked")
  @Test
  public void testWrite() throws Exception {
    Fury fury = Fury.builder().withLanguage(Language.JAVA).requireClassRegistration(false).build();
    MemoryBuffer buffer = MemoryUtils.buffer(32);
    Object[] values =
        new Object[] {
          Collections.unmodifiableCollection(Collections.singletonList("abc")),
          Collections.unmodifiableCollection(Arrays.asList("abc", "def")),
          Collections.unmodifiableList(Arrays.asList("abc", "def")),
          Collections.unmodifiableList(new LinkedList<>(Arrays.asList("abc", "def"))),
          Collections.unmodifiableSet(new HashSet<>(Arrays.asList("abc", "def"))),
          Collections.unmodifiableSortedSet(new TreeSet<>(Arrays.asList("abc", "def"))),
          Collections.unmodifiableMap(ImmutableMap.of("k1", "v1")),
          Collections.unmodifiableSortedMap(new TreeMap<>(ImmutableMap.of("k1", "v1")))
        };
    for (Object value : values) {
      buffer.writerIndex(0);
      buffer.readerIndex(0);
      Serializer serializer = createSerializer(fury, value.getClass());
      serializer.write(buffer, value);
      Object newObj = serializer.read(buffer);
      assertEquals(newObj.getClass(), value.getClass());
      long sourceCollectionFieldOffset =
          Collection.class.isAssignableFrom(value.getClass())
              ? SOURCE_COLLECTION_FIELD_OFFSET
              : SOURCE_MAP_FIELD_OFFSET;
      Object innerValue = Platform.getObject(value, sourceCollectionFieldOffset);
      Object newValue = Platform.getObject(newObj, sourceCollectionFieldOffset);
      assertEquals(innerValue, newValue);

      newObj = serDe(fury, value);
      innerValue = Platform.getObject(value, sourceCollectionFieldOffset);
      newValue = Platform.getObject(newObj, sourceCollectionFieldOffset);
      assertEquals(innerValue, newValue);
      assertTrue(
          fury.getClassResolver()
              .getSerializerClass(value.getClass())
              .getName()
              .contains("Unmodifiable"));
    }
  }