public synchronized void addRelationship(final Relationship relationship, final ShallowTraceBuilder from,
      final ShallowTraceBuilder to) {
    if (_relationships.size() < _maxTraceBuildersPerTrace) {
      TraceRelationship rel = new TraceRelationship(from, to, relationship);
      _relationships.add(rel);
    }
  }
@Test
  public void testAddRelationship() {
    final ShallowTraceBuilder trace1 =
        new ShallowTraceBuilder(IdGenerator.getNextId()).setName("task1").setResultType(ResultType.UNFINISHED);
    final ShallowTraceBuilder trace2 =
        new ShallowTraceBuilder(IdGenerator.getNextId()).setName("task2").setResultType(ResultType.UNFINISHED);
    final TraceBuilder builder = new TraceBuilder(1024, "test", 0L);
    builder.addRelationship(Relationship.SUCCESSOR_OF, trace1, trace2);
    Trace trace = builder.build();
    assertEquals(trace1.build(), trace.getTraceMap().get(trace1.getNativeId()));
    assertEquals(trace2.build(), trace.getTraceMap().get(trace2.getNativeId()));
    assertEquals(1, trace.getRelationships().size());
    assertTrue(trace.getRelationships()
        .contains(new TraceRelationship(trace1, trace2, Relationship.SUCCESSOR_OF)));
  }