Search in sources :

Example 6 with Transformation

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

the class SequenceTest method testSequence_treeStateCacheInvalidation.

@Test
public void testSequence_treeStateCacheInvalidation() throws Exception {
    TransformWork work = cachedTreeStateTransformWork();
    // The first transform does not use/notify the TreeState...
    Transformation t1 = new MockTransform("t1").setUseTreeState(false);
    // ...so the second transform should not have a cache available
    Transformation t2 = new MockTransform("t2").setUseTreeState(true).setExpectCacheHit(false);
    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 7 with Transformation

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

the class SequenceTest method testSequence_nestedSequences_missOnThirdCache.

@Test
public void testSequence_nestedSequences_missOnThirdCache() throws Exception {
    TransformWork work = cachedTreeStateTransformWork();
    MockTransform t1 = new MockTransform("t1").setUseTreeState(true).setExpectCacheHit(true);
    MockTransform t2 = new MockTransform("t2").setUseTreeState(false);
    MockTransform t3 = new MockTransform("t3").setUseTreeState(true).setExpectCacheHit(false);
    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 8 with Transformation

use of com.google.copybara.Transformation 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 9 with Transformation

use of com.google.copybara.Transformation 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 10 with Transformation

use of com.google.copybara.Transformation 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)

Aggregations

Transformation (com.google.copybara.Transformation)42 Test (org.junit.Test)38 TransformWork (com.google.copybara.TransformWork)23 TransformationStatus (com.google.copybara.TransformationStatus)12 Author (com.google.copybara.authoring.Author)3 DummyRevision (com.google.copybara.testing.DummyRevision)3 Changes (com.google.copybara.Changes)2 Sequence (com.google.copybara.transform.Sequence)2 Transformations.toTransformation (com.google.copybara.transform.Transformations.toTransformation)2 NonReversibleValidationException (com.google.copybara.exception.NonReversibleValidationException)1 ValidationException (com.google.copybara.exception.ValidationException)1 FileSubjects.assertThatPath (com.google.copybara.testing.FileSubjects.assertThatPath)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1