public void mergeRuntimeUpdate(
      List<TimelineEvent> pendingTimeline, Map<String, Artifact> pendingArtifacts) {
    if (timeline.addAll(pendingTimeline)) {
      synced = false;
    }
    if (pendingArtifacts != null && !pendingArtifacts.isEmpty()) {
      for (Map.Entry<String, Artifact> entry : pendingArtifacts.entrySet()) {
        String key = entry.getKey();
        if (!entry.getValue().equals(artifacts.get(key))) {
          if (artifacts.containsKey(key)
              && artifacts.get(key).getType() == Artifact.Type.DEFAULT
              && entry.getValue().getType() == Artifact.Type.DEFAULT) {
            artifacts.get(key).asDefault().getData().putAll(entry.getValue().asDefault().getData());
          } else {
            artifacts.put(entry.getKey(), entry.getValue());
          }
          synced = false;
        }
      }
    }
    if (!synced) {
      runtimeState.setModifyTime(System.currentTimeMillis());
    }
  }
@Test
  public void testMergeDefaultArtifact() throws Exception {
    StepRuntimeSummary summary =
        loadObject(
            "fixtures/execution/sample-step-runtime-summary-1.json", StepRuntimeSummary.class);
    DefaultArtifact artifact = summary.getArtifacts().get("artifact1").asDefault();
    assertEquals(1L, artifact.getValue());
    assertEquals("bar", artifact.getField("foo"));
    Map<String, Artifact> artifacts = new LinkedHashMap<>();
    DefaultArtifact artifact1 = new DefaultArtifact();
    artifact1.setValue(12L);
    artifact1.add("value", 123L);
    artifact1.add("bar", true);
    artifact1.add("baz", 123L);
    artifacts.put("artifact1", artifact1);
    assertTrue(summary.isSynced());
    summary.mergeRuntimeUpdate(null, artifacts);
    assertFalse(summary.isSynced());
    String ser1 = MAPPER.writeValueAsString(summary);
    StepRuntimeSummary actual = MAPPER.readValue(ser1, StepRuntimeSummary.class);
    String ser2 = MAPPER.writeValueAsString(actual);
    assertEquals(summary, actual);
    assertEquals(ser1, ser2);
    artifact1 = summary.getArtifacts().get("artifact1").asDefault();
    assertEquals(123L, artifact1.getValue());
    assertEquals(123L, artifact1.getField("value"));
    assertEquals("bar", artifact1.getField("foo"));
    assertEquals(true, artifact1.getField("bar"));
    assertEquals(123L, artifact1.getField("baz"));
  }