Ejemplo n.º 1
0
  @Test
  public void testIntroduceArtifact() throws OseeCoreException {
    when(txData.isCommitInProgress()).thenReturn(false);
    when(txData.getTxState()).thenReturn(TxState.NEW_TX);
    when(txData.getBranch()).thenReturn(branch);

    ResultSet<Artifact> loaded = ResultSets.singleton(artifact1);
    when(loader.loadArtifacts(eq(session), eq(COMMON), anyCollectionOf(ArtifactId.class)))
        .thenReturn(loaded);
    when(artifactFactory.introduceArtifact(session, artifact1, artifact1, branch))
        .thenReturn(artifact2);
    when(proxyManager.asExternalArtifact(session, artifact2)).thenReturn(readable2);
    when(artifact1.getGraph()).thenReturn(graph);
    when(graph.getAdjacencies(artifact1)).thenReturn(adjacencies);

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

    ArtifactReadable actual = txDataManager.introduceArtifact(txData, COMMON, readable1, readable2);

    verify(artifactFactory).introduceArtifact(session, artifact1, artifact1, branch);
    verify(proxyManager).asExternalArtifact(session, artifact1);
    assertEquals(readable1, actual);
  }