Search in sources :

Example 26 with Transformation

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

the class SequenceTest method testSequence_failIfAnyNoop_insideIgnoreNoop.

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

Example 27 with Transformation

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

the class SequenceTest method testSequence_noopIfAnyNoop_insideIgnoreNoop.

@Test
public void testSequence_noopIfAnyNoop_insideIgnoreNoop() throws Exception {
    TransformWork work = uncachedTreeStateTransformWork();
    MockTransform t1 = new MockTransform("t1").setNoop(true);
    Transformation t = sequence(Sequence.NoopBehavior.IGNORE_NOOP, sequence(Sequence.NoopBehavior.NOOP_IF_ANY_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)

Example 28 with Transformation

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

the class SequenceTest method testSequence_noopIfAnyNoop_noChildNoops.

@Test
public void testSequence_noopIfAnyNoop_noChildNoops() throws Exception {
    TransformWork work = uncachedTreeStateTransformWork();
    MockTransform t1 = new MockTransform("t1");
    MockTransform t2 = new MockTransform("t2");
    Transformation t = sequence(Sequence.NoopBehavior.NOOP_IF_ANY_NOOP, t1, t2);
    TransformationStatus status = t.transform(work);
    assertThat(t1.wasRun).isTrue();
    assertThat(t2.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 29 with Transformation

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

the class SequenceTest method testSequence_failIfAnyNoop_causesFailure.

@Test
public void testSequence_failIfAnyNoop_causesFailure() throws Exception {
    TransformWork work = uncachedTreeStateTransformWork();
    MockTransform t1 = new MockTransform("t1").setNoop(true);
    Transformation t = sequence(Sequence.NoopBehavior.FAIL_IF_ANY_NOOP, t1);
    assertThrows(VoidOperationException.class, () -> t.transform(work));
    assertThat(t1.wasRun).isTrue();
}
Also used : Transformation(com.google.copybara.Transformation) TransformWork(com.google.copybara.TransformWork) Test(org.junit.Test)

Example 30 with Transformation

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

the class SequenceTest method testSequence_treeStateBeginsUncached.

/**
 * A Sequence should automatically validate the cache in between each child Transformation that it
 * runs.
 */
@Test
public void testSequence_treeStateBeginsUncached() throws Exception {
    TransformWork work = uncachedTreeStateTransformWork();
    // No cache for the first transform to use...
    Transformation t1 = new MockTransform("t1").setUseTreeState(true).setExpectCacheHit(false);
    // ...but it should have created one for the second transform
    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)

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