コード例 #1
0
ファイル: TxDataManagerTest.java プロジェクト: pkdevboxy/osee
  @Test
  public void testGetForWriteMultiples() throws OseeCoreException {
    List<? extends ArtifactId> ids = Arrays.asList(artifactId1, artifactId2, artifactId3);

    when(txData.getWriteable(artifactId2)).thenReturn(artifact2);

    List<Artifact> artifacts = Arrays.asList(artifact1, artifact3);
    ResultSet<Artifact> loaded = ResultSets.newResultSet(artifacts);
    when(loader.loadArtifacts(eq(session), eq(graph), anyCollectionOf(ArtifactId.class)))
        .thenReturn(loaded);

    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);

    Iterable<Artifact> actual = txDataManager.getForWrite(txData, ids);

    verify(loader).loadArtifacts(eq(session), eq(graph), idCaptor.capture());
    Iterator<ArtifactId> iterator1 = idCaptor.getValue().iterator();
    assertEquals(artifactId1, iterator1.next());
    assertEquals(artifactId3, iterator1.next());

    Iterator<Artifact> iterator2 = actual.iterator();
    assertEquals(artifact1, iterator2.next());
    assertEquals(artifact2, iterator2.next());
    assertEquals(artifact3, iterator2.next());
  }
コード例 #2
0
ファイル: TxDataManagerTest.java プロジェクト: pkdevboxy/osee
  @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
ファイル: TxDataManagerTest.java プロジェクト: pkdevboxy/osee
  @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
ファイル: TxDataManagerTest.java プロジェクト: pkdevboxy/osee
  @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);
  }
コード例 #5
0
ファイル: TxDataManagerTest.java プロジェクト: pkdevboxy/osee
  @Test
  public void testGetForWriteId() throws OseeCoreException {
    when(txData.getWriteable(artifactId1)).thenReturn(null);

    ResultSet<Artifact> loaded = ResultSets.singleton(artifact1);
    when(loader.loadArtifacts(eq(session), eq(graph), anyCollectionOf(ArtifactId.class)))
        .thenReturn(loaded);

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

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

    verify(txData).getWriteable(artifactId1);
    verify(loader).loadArtifacts(eq(session), eq(graph), idCaptor.capture());

    assertEquals(artifactId1, idCaptor.getValue().iterator().next());
    assertEquals(artifact1, actual);
  }