@Test
  public void testNullField() {
    String[] fields = new String[] {"s", "i"};
    PdxLuceneSerializer mapper = new PdxLuceneSerializer();

    PdxInstance pdxInstance = mock(PdxInstance.class);

    when(pdxInstance.hasField("s")).thenReturn(true);
    when(pdxInstance.hasField("i")).thenReturn(true);
    when(pdxInstance.getField("s")).thenReturn("a");
    when(pdxInstance.getField("i")).thenReturn(null);

    Document doc = invokeSerializer(mapper, pdxInstance, fields);

    assertEquals(1, doc.getFields().size());
    assertEquals("a", doc.getField("s").stringValue());
    assertNull(doc.getField("i"));
  }
Unit test of the PdxFieldMapperJUnitTest. Tests that all field types are mapped correctly.
geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/repository/serializer/PdxFieldMapperJUnitTest.java