@Test
  public void testSerializeSystemStreamPartition() throws IOException {
    // case 1: keyBucket not explicitly mentioned
    SystemStreamPartition ssp = new SystemStreamPartition("foo", "bar", new Partition(1));
    String serializedString = this.samzaObjectMapper.writeValueAsString(ssp);

    ObjectMapper objectMapper = new ObjectMapper();

    ObjectNode sspJson = objectMapper.createObjectNode();
    sspJson.put("system", "foo");
    sspJson.put("stream", "bar");
    sspJson.put("partition", 1);

    // use a plain ObjectMapper to read JSON to make comparison easier
    ObjectNode serializedAsJson = (ObjectNode) new ObjectMapper().readTree(serializedString);
    ObjectNode expectedJson = sspJson;

    assertEquals(expectedJson.get("system"), serializedAsJson.get("system"));
    assertEquals(expectedJson.get("stream"), serializedAsJson.get("stream"));
    assertEquals(expectedJson.get("partition"), serializedAsJson.get("partition"));

    //Case 2: with non-null keyBucket
    ssp = new SystemStreamPartition("foo", "bar", new Partition(1), 1);
    serializedString = this.samzaObjectMapper.writeValueAsString(ssp);

    sspJson = objectMapper.createObjectNode();
    sspJson.put("system", "foo");
    sspJson.put("stream", "bar");
    sspJson.put("partition", 1);
    sspJson.put("keyBucket", 1);

    // use a plain ObjectMapper to read JSON to make comparison easier
    serializedAsJson = (ObjectNode) new ObjectMapper().readTree(serializedString);
    expectedJson = sspJson;

    assertEquals(expectedJson.get("system"), serializedAsJson.get("system"));
    assertEquals(expectedJson.get("stream"), serializedAsJson.get("stream"));
    assertEquals(expectedJson.get("partition"), serializedAsJson.get("partition"));
    assertEquals(expectedJson.get("keyBucket"), serializedAsJson.get("keyBucket"));
  }
Given a {@link ContainerModel} JSON with only an "id" field, deserialization should fail.
This verifies that even though {@link ContainerModel} has a getId method, the "id" field is not used, since
"processor-id" is the field that is supposed to be used.
samza-core/src/test/java/org/apache/samza/serializers/model/TestSamzaObjectMapper.java