示例#1
0
  @Test
  public void testDeleteArtifact() throws OseeCoreException {
    when(artifactFactory.clone(session, artifact1)).thenReturn(artifact2);

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

    txDataManager.deleteArtifact(txData, artifact1);

    verify(artifact2).delete();
    verify(relationManager).unrelateFromAll(session, artifact2);
  }
示例#2
0
  @Test
  public void testGetForWriteDuringWrite() throws OseeCoreException {
    when(txData.add(artifact1)).thenReturn(artifact3);
    when(artifactFactory.clone(session, artifact1)).thenReturn(artifact1);

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

    thrown.expect(OseeArgumentException.class);
    thrown.expectMessage(
        "Another instance of writeable detected - writeable tracking would be inconsistent");
    txDataManager.getForWrite(txData, readable1);
  }
示例#3
0
  @Test
  public void testGetForWriteArtifact() throws OseeCoreException {
    when(txData.getWriteable(artifact1)).thenReturn(null);
    when(artifactFactory.clone(session, artifact1)).thenReturn(artifact2);

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

    Artifact actual = txDataManager.getForWrite(txData, artifact1);

    verify(txData).getWriteable(artifact1);
    verify(artifactFactory).clone(session, artifact1);

    assertEquals(artifact2, actual);
  }
示例#4
0
  @Test
  public void testGetForWriteReadableButIsFromDifferentBranch() throws OseeCoreException {
    when(readable1.getBranch()).thenReturn(CoreBranches.COMMON);
    when(txData.getWriteable(readable1)).thenReturn(null);
    when(proxyManager.asInternalArtifact(readable1)).thenReturn(artifact1);
    when(artifactFactory.clone(session, artifact1)).thenReturn(artifact2);

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

    Artifact actual = txDataManager.getForWrite(txData, readable1);

    verify(txData).getWriteable(readable1);
    verify(proxyManager).asInternalArtifact(readable1);
    verify(artifact1).getBranch();

    assertEquals(artifact2, actual);
  }