Пример #1
0
  @Before
  public void init() throws OseeCoreException {
    MockitoAnnotations.initMocks(this);
    txDataManager = new TxDataManager(proxyManager, artifactFactory, relationManager, loader);

    guid = GUID.create();

    when(artifact1.getExistingAttributeTypes()).thenAnswer(answerValue(types));

    when(proxyManager.asInternalArtifact(readable1)).thenReturn(artifact1);
    when(proxyManager.asExternalArtifact(session, artifact1)).thenReturn(readable1);

    when(branch.getUuid()).thenReturn(111L);
    when(provider.getBranch(111L)).thenReturn(branch);

    when(txData.getSession()).thenReturn(session);
    when(txData.getBranch()).thenReturn(branch);
    when(txData.getGraph()).thenReturn(graph);

    r1Guid = GUID.create();
    r2Guid = GUID.create();
    r3Guid = GUID.create();

    when(artifactId1.getGuid()).thenReturn(r1Guid);
    when(artifactId2.getGuid()).thenReturn(r2Guid);
    when(artifactId3.getGuid()).thenReturn(r3Guid);

    when(readable1.getGuid()).thenReturn(r1Guid);
    when(readable2.getGuid()).thenReturn(r2Guid);
    when(readable3.getGuid()).thenReturn(r3Guid);

    when(readable1.getBranch()).thenReturn(branch);
    when(readable2.getBranch()).thenReturn(branch);
    when(readable3.getBranch()).thenReturn(branch);

    when(artifact1.getGuid()).thenReturn(r1Guid);
    when(artifact2.getGuid()).thenReturn(r2Guid);
    when(artifact3.getGuid()).thenReturn(r3Guid);

    when(artifact1.getBranch()).thenReturn(branch);
    when(artifact2.getBranch()).thenReturn(branch);
    when(artifact3.getBranch()).thenReturn(branch);
  }
Пример #2
0
  @Test
  public void testGetForWriteArtifactButIsFromDifferentBranch() throws OseeCoreException {
    when(artifact1.getBranch()).thenReturn(CoreBranches.COMMON);
    when(txData.getWriteable(readable1)).thenReturn(null);

    ResultSet<Artifact> loaded = ResultSets.singleton(artifact2);
    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(data.isUseBackingData()).thenReturn(false);

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

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

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