Ejemplo n.º 1
0
  @Test
  public void testSetRelations() throws OseeCoreException {
    when(txData.getWriteable(readable1)).thenReturn(artifact1);
    when(txData.getWriteable(readable2)).thenReturn(artifact2);
    when(txData.getWriteable(readable3)).thenReturn(artifact3);
    when(txData.getGraph()).thenReturn(graph);

    ArtifactData data = Mockito.mock(ArtifactData.class);
    when(artifact1.getOrcsData()).thenReturn(data);
    when(artifact2.getOrcsData()).thenReturn(data);
    when(artifact3.getOrcsData()).thenReturn(data);
    when(data.isUseBackingData()).thenReturn(false);

    ResultSet<Artifact> related = ResultSets.singleton(artifact3);
    when(relationManager.<Artifact>getRelated(session, DEFAULT_HIERARCHY, artifact1, SIDE_A))
        .thenReturn(related);
    when(txData.getWriteable(artifact3)).thenReturn(artifact3);

    txDataManager.setRelations(txData, readable1, DEFAULT_HIERARCHY, Arrays.asList(readable2));

    verify(relationManager).relate(session, artifact1, DEFAULT_HIERARCHY, artifact2);
    verify(relationManager).unrelate(session, artifact1, DEFAULT_HIERARCHY, artifact3);
  }