Search in sources :

Example 11 with TransformWork

use of com.google.copybara.TransformWork in project copybara by google.

the class SequenceTest method testSequence_treeStateMultipleCacheHits.

@Test
public void testSequence_treeStateMultipleCacheHits() throws Exception {
    TransformWork work = cachedTreeStateTransformWork();
    // The first transform uses the pre-existing cache...
    Transformation t1 = new MockTransform("t1").setUseTreeState(true).setExpectCacheHit(true);
    // ...and the second transform does as well
    Transformation t2 = new MockTransform("t2").setUseTreeState(true).setExpectCacheHit(true);
    Transformation t = sequence(t1, t2);
    t.transform(work);
}
Also used : Transformation(com.google.copybara.Transformation) TransformWork(com.google.copybara.TransformWork) Test(org.junit.Test)

Example 12 with TransformWork

use of com.google.copybara.TransformWork in project copybara by google.

the class SequenceTest method testSequence_nestedSequences_allCachesHit.

@Test
public void testSequence_nestedSequences_allCachesHit() throws Exception {
    TransformWork work = cachedTreeStateTransformWork();
    MockTransform t1 = new MockTransform("t1").setUseTreeState(true).setExpectCacheHit(true);
    MockTransform t2 = new MockTransform("t2").setUseTreeState(true).setExpectCacheHit(true);
    MockTransform t3 = new MockTransform("t3").setUseTreeState(true).setExpectCacheHit(true);
    MockTransform t4 = new MockTransform("t4").setUseTreeState(true).setExpectCacheHit(true);
    Transformation t = sequence(sequence(t1, t2), sequence(t3, t4));
    t.transform(work);
    assertThat(t1.wasRun).isTrue();
    assertThat(t2.wasRun).isTrue();
    assertThat(t3.wasRun).isTrue();
    assertThat(t4.wasRun).isTrue();
}
Also used : Transformation(com.google.copybara.Transformation) TransformWork(com.google.copybara.TransformWork) Test(org.junit.Test)

Example 13 with TransformWork

use of com.google.copybara.TransformWork in project copybara by google.

the class SequenceTest method testSequence_nestedSequences_missOnFirstCache.

@Test
public void testSequence_nestedSequences_missOnFirstCache() throws Exception {
    TransformWork work = uncachedTreeStateTransformWork();
    MockTransform t1 = new MockTransform("t1").setUseTreeState(true).setExpectCacheHit(false);
    MockTransform t2 = new MockTransform("t2").setUseTreeState(true).setExpectCacheHit(true);
    MockTransform t3 = new MockTransform("t3").setUseTreeState(true).setExpectCacheHit(true);
    MockTransform t4 = new MockTransform("t4").setUseTreeState(true).setExpectCacheHit(true);
    Transformation t = sequence(sequence(t1, t2), sequence(t3, t4));
    t.transform(work);
    assertThat(t1.wasRun).isTrue();
    assertThat(t2.wasRun).isTrue();
    assertThat(t3.wasRun).isTrue();
    assertThat(t4.wasRun).isTrue();
}
Also used : Transformation(com.google.copybara.Transformation) TransformWork(com.google.copybara.TransformWork) Test(org.junit.Test)

Example 14 with TransformWork

use of com.google.copybara.TransformWork in project copybara by google.

the class SequenceTest method testSequence_ignoreNoop_someChildNoops.

@Test
public void testSequence_ignoreNoop_someChildNoops() throws Exception {
    TransformWork work = uncachedTreeStateTransformWork();
    MockTransform t1 = new MockTransform("t1");
    MockTransform t2 = new MockTransform("t2").setNoop(true);
    MockTransform t3 = new MockTransform("t3");
    Transformation t = sequence(Sequence.NoopBehavior.IGNORE_NOOP, t1, t2, t3);
    TransformationStatus status = t.transform(work);
    assertThat(t1.wasRun).isTrue();
    assertThat(t2.wasRun).isTrue();
    assertThat(t3.wasRun).isTrue();
    assertThat(status.isSuccess()).isTrue();
}
Also used : TransformationStatus(com.google.copybara.TransformationStatus) Transformation(com.google.copybara.Transformation) TransformWork(com.google.copybara.TransformWork) Test(org.junit.Test)

Example 15 with TransformWork

use of com.google.copybara.TransformWork in project copybara by google.

the class SequenceTest method testSequence_ignoreNoop_insideFailIfAnyNoop.

@Test
public void testSequence_ignoreNoop_insideFailIfAnyNoop() throws Exception {
    TransformWork work = uncachedTreeStateTransformWork();
    MockTransform t1 = new MockTransform("t1").setNoop(true);
    Transformation t = sequence(Sequence.NoopBehavior.FAIL_IF_ANY_NOOP, sequence(Sequence.NoopBehavior.IGNORE_NOOP, t1));
    TransformationStatus status = t.transform(work);
    assertThat(t1.wasRun).isTrue();
    assertThat(status.isSuccess()).isTrue();
}
Also used : TransformationStatus(com.google.copybara.TransformationStatus) Transformation(com.google.copybara.Transformation) TransformWork(com.google.copybara.TransformWork) Test(org.junit.Test)

Aggregations

TransformWork (com.google.copybara.TransformWork)41 Test (org.junit.Test)33 Transformation (com.google.copybara.Transformation)23 TransformationStatus (com.google.copybara.TransformationStatus)9 DummyRevision (com.google.copybara.testing.DummyRevision)6 Changes (com.google.copybara.Changes)5 Author (com.google.copybara.authoring.Author)5 ValidationException (com.google.copybara.exception.ValidationException)4 Change (com.google.copybara.Change)3 ProcessedChange (com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange)3 EmptyChangeException (com.google.copybara.exception.EmptyChangeException)2 NonReversibleValidationException (com.google.copybara.exception.NonReversibleValidationException)2 RepoException (com.google.copybara.exception.RepoException)2 TransformWorks.toChange (com.google.copybara.testing.TransformWorks.toChange)2 Strings (com.google.common.base.Strings)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1